Missing pg_depend entries for constraints created by extensions (deptype 'e') - Mailing list pgsql-hackers

From Joel Jacobson
Subject Missing pg_depend entries for constraints created by extensions (deptype 'e')
Date
Msg-id c59f4393-bcdf-4336-8309-d9de7cf14209@app.fastmail.com
Whole thread Raw
List pgsql-hackers
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
Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [PING] fallocate() causes btrfs to never compress postgresql files
Next
From: Tom Lane
Date:
Subject: Re: tighten generic_option_name, or store more carefully in catalog?