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

Re: [HACKERS] Foreign Key woes -- 7.2 and ~7.3

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
Cc: Rod Taylor <rbt(at)zort(dot)ca>, pgsql-bugs(at)postgresql(dot)org,Hackers List <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] Foreign Key woes -- 7.2 and ~7.3
Date: 2002-04-16 23:19:30
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugspgsql-hackers
Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> writes:
> On Tue, 16 Apr 2002, Rod Taylor wrote:
>> You'll notice there isn't a primary key at all -- which shouldn't be
>> an issue as there is still the unique.

> If you're not specifying the columns in the references constraint, it
> means specifically referencing the primary key of the table.  If there
> is no primary key, it's an error ("If the <referenced table and columns>
> does not specify a <reference column list>, then the table descriptor
> of the referenced table shall include a unique constraint that specifies

Not sure if Rod got the point here, but: you *can* reference a column
that's only UNIQUE and not PRIMARY KEY.  You just have to name it
explicitly, eg.

regression=# create table stuff2 (stuff_id int4 references stuff(stuff_id)
regression(# on update cascade on delete cascade);
NOTICE:  CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)

This is all per-spec, AFAIK.

>> If thats the case, then unique indecies need to be blocked until there
>> is a primary key, or the first one should be automatically marked as
>> the primary key.

That would be contrary to spec, and I see no need for it...

			regards, tom lane

In response to


pgsql-hackers by date

Next:From: Bruce MomjianDate: 2002-04-16 23:21:50
Subject: Re: regexp character class locale awareness patch
Previous:From: Richard TuckerDate: 2002-04-16 23:14:28
Subject: Re: Firebird 1.0 released

pgsql-bugs by date

Next:From: Tom LaneDate: 2002-04-16 23:27:06
Subject: Re: replace_vars_with_subplan_refs
Previous:From: Geoffrey RitcheyDate: 2002-04-16 22:47:37
Subject: Unknown Response Type [some random character]

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