Skip to content

Bad copy paste #630

Description

@kuznetsovvvv

case ConstraintRelationId:
{
HeapTuple conTup;
Form_pg_constraint con;
conTup = SearchSysCache1(CONSTROID,
ObjectIdGetDatum(object->objectId));
if (!HeapTupleIsValid(conTup))
{
if (!missing_ok)
elog(ERROR, "cache lookup failed for constraint %u",
object->objectId);
break;
}
con = (Form_pg_constraint) GETSTRUCT(conTup);
if (OidIsValid(con->conrelid))
{
appendStringInfo(&buffer, "%s on ",
quote_identifier(NameStr(con->conname)));
getRelationIdentity(&buffer, con->conrelid, objname,
false);
if (objname)
*objname = lappend(*objname, pstrdup(NameStr(con->conname)));
}
else
{
ObjectAddress domain;
Assert(OidIsValid(con->contypid));
domain.classId = TypeRelationId;
domain.objectId = con->contypid;
domain.objectSubId = 0;
appendStringInfo(&buffer, "%s on %s",
quote_identifier(NameStr(con->conname)),
getObjectIdentityParts(&domain, objname,
objargs, false));
if (objname)
*objargs = lappend(*objargs, pstrdup(NameStr(con->conname)));
}

I saw the wrong logic in your code in the line 4951.
The logic is broken, and the if(objname) condition has not been modified. It should be if (objargs), as the condition checks objname, which was already checked in the previous case if OidIsValid(...) is incorrect. Now, the second parameter, objargs, should be checked.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions