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

Foreign key column reference ordering and information_schema

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Foreign key column reference ordering and information_schema
Date: 2006-05-17 14:19:45
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
Now that I've got a little time again...

Per the report from Clark C Evans a while back and associated discussion,
it seems like recent versions of the SQL spec changed the rules for
foreign key column references such that the columns of the referenced
unique constraint must be named in order (this is somewhat silly since
unique(a,b) really should imply unique(b,a) but...). The
information_schema definition seems to require this in order for one to
use the information to find out the column references.

I don't think we can switch to the newer definition directly since that
will break dumps, but we could provide a variable which controls whether
we allow the set allowed by SQL92 (not necessarily ordered) with the
default being true for compatibility.

But, that still doesn't give us a path to being able to change the
default, or for that matter making it safe to use information_schema
(since it would still be possible to change the value, make a constraint
and change it back). One way to do this would be to accept the SQL92 form
and treat it as if the command had given it in the ordered form, in other
words, given
 create table pk(a int, b int, unique(a,b));
 create table fk(c int, d int, foreign key(d,c) references (b,a));
the constraint is stored as if it were given foreign key(c,d)

Does anyone have objections to either or both parts of this, and for the
first, does anyone have a good idea of a name for the variable that would
control this?


pgsql-hackers by date

Next:From: Tom LaneDate: 2006-05-17 14:25:01
Subject: Re: Compression and on-disk sorting
Previous:From: Cristiano DuarteDate: 2006-05-17 14:19:01
Subject: Re: [BUGS] BUG #2429: Explain does not report object's schema

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