|
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.
PolarDB-for-PostgreSQL/src/backend/catalog/objectaddress.c
Lines 4912 to 4953 in accf02e
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.