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

Foreign Key woes -- 7.2 and ~7.3

From: "Rod Taylor" <rbt(at)zort(dot)ca>
To: <pgsql-bugs(at)postgresql(dot)org>,"Hackers List" <pgsql-hackers(at)postgresql(dot)org>
Subject: Foreign Key woes -- 7.2 and ~7.3
Date: 2002-04-16 16:10:56
Message-ID: 0bbf01c1e561$4b1c0340$8001a8c0@jester (view raw, whole thread or download thread mbox)
Lists: pgsql-bugspgsql-hackers
b=# create table stuff (stuff_id serial unique);
NOTICE:  CREATE TABLE will create implicit sequence
'stuff_stuff_id_seq' for SERIAL column 'stuff.stuff_id'
NOTICE:  CREATE TABLE / UNIQUE will create implicit index
'stuff_stuff_id_key' for table 'stuff'
b=# create table stuff2 (stuff_id int4 references stuff on update
cascade on delete cascade);
NOTICE:  CREATE TABLE will create implicit trigger(s) for FOREIGN KEY
ERROR:  PRIMARY KEY for referenced table "stuff" not found

You'll notice there isn't a primary key at all -- which shouldn't be
an issue as there is still the unique.

Not the brightest thing to do, but surely the primary key shouldn't be
enforced to exist before a plain old unique.

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.
Rod Taylor

Your eyes are weary from staring at the CRT. You feel sleepy. Notice
how restful it is to watch the cursor blink. Close your eyes. The
opinions stated above are yours. You cannot imagine why you ever felt


pgsql-hackers by date

Next:From: Bruce MomjianDate: 2002-04-16 16:54:13
Subject: Re: ANSI Compliant Inserts
Previous:From: Neil ConwayDate: 2002-04-16 16:04:37
Subject: Re: [SQL] 16 parameter limit

pgsql-bugs by date

Next:From: Stephan SzaboDate: 2002-04-16 17:18:52
Subject: Re: [HACKERS] Foreign Key woes -- 7.2 and ~7.3
Previous:From: Michal SchwarzDate: 2002-04-16 15:31:03
Subject: Case sensitivity in psql/pg_dump

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