diff options
Diffstat (limited to 'src/backend/catalog/pg_constraint.c')
-rw-r--r-- | src/backend/catalog/pg_constraint.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/backend/catalog/pg_constraint.c b/src/backend/catalog/pg_constraint.c index f2209c82103..5fd9822c6ed 100644 --- a/src/backend/catalog/pg_constraint.c +++ b/src/backend/catalog/pg_constraint.c @@ -752,6 +752,25 @@ AlterConstraintNamespaces(Oid ownerId, Oid oldNspId, } /* + * get_constraint_relation_oids + * Find the IDs of the relations to which a constraint refers. + */ +void +get_constraint_relation_oids(Oid constraint_oid, Oid *conrelid, Oid *confrelid) +{ + HeapTuple tup; + Form_pg_constraint con; + + tup = SearchSysCache1(CONSTROID, ObjectIdGetDatum(constraint_oid)); + if (!HeapTupleIsValid(tup)) /* should not happen */ + elog(ERROR, "cache lookup failed for constraint %u", constraint_oid); + con = (Form_pg_constraint) GETSTRUCT(tup); + *conrelid = con->conrelid; + *confrelid = con->confrelid; + ReleaseSysCache(tup); +} + +/* * get_relation_constraint_oid * Find a constraint on the specified relation with the specified name. * Returns constraint's OID. |