Hi hackers,
Foreign key constraints created during CREATE EXTENSION
lack a pg_depend entry with deptype='e'.
Looking at the code, I found that CreateConstraintEntry() in
src/backend/catalog/pg_constraint.c does not call
recordDependencyOnCurrentExtension(), unlike most other CREATE functions.
This seems to affect all constraint types created through CreateConstraintEntry.
I stumbled upon this issue when trying to query all database objects
belonging to an extension using:
SELECT * FROM pg_depend WHERE deptype = 'e' AND refobjid = <ext_oid> AND refclassid = 'pg_extension'::regclass
Is this omission intentional? I couldn't find any documentation or code
comments explaining why constraints should not be extension members.
Currently, it seems impossible to distinguish between:
- Constraints created by CREATE EXTENSION
- Constraints added manually to extension tables after extension creation
Would it make sense to add recordDependencyOnCurrentExtension() to
CreateConstraintEntry()? Or is there a specific reason why constraints
should be handled differently from other extension objects?
/Joel