[BUGS] Meaning of pg_constraint.conindid for foreign keys - Mailing list pgsql-bugs

From Roy Brokvam
Subject [BUGS] Meaning of pg_constraint.conindid for foreign keys
Date
Msg-id CADhin7Xj7FFp3N+d_J=4ya8iqo+hnoyX23vYEA35guMDDuGzbg@mail.gmail.com
Whole thread Raw
Responses Re: [BUGS] Meaning of pg_constraint.conindid for foreign keys
Re: [BUGS] Meaning of pg_constraint.conindid for foreign keys
List pgsql-bugs
Trying to write a query to find unindexed foreign keys referencing a table, I tried to do this:

SELECT *
FROM pg_constraint
WHERE contype = 'f'
AND confrelid = <the oid of the referenced table>
AND conindid = 0

To my surprise, the query did not return any rows, even though I knew there existed indexless foreign keys referencing my table. After investigating further, saw that conindid contained the oid of the referenced table's primary key, not the oid of the index "implementing" the foreign key.

I'm running PostgreSQL 9.5 running on Ubuntu linux 3.19.0-49-generic.

Before posting this as a bug, I wanted to check here whether my understanding of conind for foreign keys is correct. The documentation for conindid (https://www.postgresql.org/docs/9.5/static/catalog-pg-constraint.html) says

conindidoidpg_class.oidThe index supporting this constraint, if it's a unique, primary key, foreign key, or exclusion constraint; else 0

Regards,
Roy Brokvam

pgsql-bugs by date:

Previous
From: Andrew Gierth
Date:
Subject: Re: [BUGS] BUG #14632: Plus and minus operators inconsistency with leap years and year intervals.
Next
From: Andrew Gierth
Date:
Subject: Re: [BUGS] Meaning of pg_constraint.conindid for foreign keys