Dear PostgreSQL developers,
I stumbled upon an obscure bug (or undesirable feature:-) in the schema
metadata accessible through the information_schema, and possibly
pg_catalog as well. As it was mixed in a bug in some in my code, it was
hard for me to identify it.
The issue is that when one does (in pg 8.3.5)
ALTER TABLE foo ADD CONSTRAINT xxx UNIQUE ON (...);
this results in a constraint *and* an index, but when one does only the
CREATE UNIQUE INDEX foo(...);
then the index is created but there is no constraint. So what?
The consequence arises downhill when one declares a foreign key which uses
this index as a target. The FK constraint is accepted, but as the metadata
contents does not include the constraint, you cannot find the relevant
informations by joining the various information_schema relations.
I was just looking for this information, how unlucky of me:-)
See the attached file for an example. Comment out the index creation and
uncomment the unique constraint to see the difference in the metadata
(information_schema, and possibly underlying pg_catalog).
ITSM that the fix is that a 'CREATE UNIQUE INDEX...' shoud also add the
Also, there is a minor bug in the documentation, which was the another
source of my troubles:
is tagged as "NOT IMPLEMENTED", but it looks like it is implemented.
Description: text/plain (1.0 KB)
pgsql-hackers by date
|Next:||From: Tom Lane||Date: 2008-11-25 20:06:33|
|Subject: Re: pg metadata and doc bug |
|Previous:||From: Tom Lane||Date: 2008-11-25 19:42:15|
|Subject: Re: Exporting PGINTERVALSTYLE prevents access to older server versions |