Skip site navigation (1) Skip section navigation (2)

Re: bug with constraint dependencies? or bug with

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
Cc: Gregory Stark <gsstark(at)mit(dot)edu>,pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: bug with constraint dependencies? or bug with
Date: 2003-08-28 18:43:09
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> writes:
> On 28 Aug 2003, Gregory Stark wrote:
>> It seems when you create a new table with the "references" syntax the
>> constraint is created with a dependency specifically on a "primary key"
>> constraint on the target table.
>> However when you alter a table to add a foreign key constraint the constraint
>> is added with a dependency on any unique index on the column -- not
>> necessarily a primary key constraint.

> Well, it shouldn't be limited to a primary key constraint (you must be
> able to reference a non-primary key unique constraint).

AFAICT the difference is not whether you create the FK constraint during
table creation or add it later (in fact, the same code is executed
either way).  The difference in Greg's example is that he said
"REFERENCES test" in one case and "REFERENCES test(a)" in the other.
The first syntax is specifically a dependency on the primary key, the
second is not.

I suppose we could tweak the code to prefer a primary key when there are
multiple matching indexes, but I don't see the point.  Having multiple
identical indexes is silly anyway.

			regards, tom lane

In response to


pgsql-hackers by date

Next:From: Greg StarkDate: 2003-08-28 18:45:22
Subject: Re: New array functions
Previous:From: Mendola GaetanoDate: 2003-08-28 18:36:07
Subject: Re: Code review

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group