Re: issue about information_schema REFERENTIAL_CONSTRAINTS - Mailing list pgsql-bugs

From Tom Lane
Subject Re: issue about information_schema REFERENTIAL_CONSTRAINTS
Date
Msg-id 2683.1283266019@sss.pgh.pa.us
Whole thread Raw
In response to issue about information_schema REFERENTIAL_CONSTRAINTS  (Fabien COELHO <coelho@cri.ensmp.fr>)
Responses Re: issue about information_schema REFERENTIAL_CONSTRAINTS  (Fabien COELHO <coelho@cri.ensmp.fr>)
Re: issue about information_schema REFERENTIAL_CONSTRAINTS  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-bugs
Fabien COELHO <coelho@cri.ensmp.fr> writes:
> The REFERENTIAL_CONSTRAINTS table in the information_schema references a
> constaint through its database/schema/name, but this information is not
> unique, so it may identify several constraints, thus the information
> derived may not be consistent.

Postgres does not enforce that constraints have unique names within a
schema.  The SQL spec does say that they should be unique per-schema,
and the information_schema views are designed on that assumption.

If you use spec-compliant names for your constraints, you won't have a
problem.  If you don't, well, the information_schema views will be of
limited use to you.

> Suggestion: constraint names could be systematically prefixed with their
> corresponding table so that they are indeed unique,

We are not going to try to enforce uniqueness.  This has been debated
before, and most people like the current behavior just fine, or at least
better than the alternatives.

            regards, tom lane

pgsql-bugs by date:

Previous
From: Fabien COELHO
Date:
Subject: issue about information_schema REFERENTIAL_CONSTRAINTS
Next
From: Bruce Momjian
Date:
Subject: Re: BUG #5631: psql dumps core during command editing