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

Re: foreign key constraints referencing inherited relations - WIP

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Matt Newell <newellm(at)blur(dot)com>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: foreign key constraints referencing inherited relations - WIP
Date: 2005-11-10 23:44:19
Message-ID: 12952.1131666259@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
Matt Newell <newellm(at)blur(dot)com> writes:
> When removing the ONLY clause on the foreign key checks, I also had to remove
> the FOR SHARE OF x part.  This was in the following functions: RI_FKey_check,
> ri_Check_Pk_Match, RI_FKey_noaction_del, RI_FKey_noaction_upd, 
> RI_FKey_restrict_del. I don't really understand the significance of this.

It means you broke it for concurrent-update cases; there's no interlock
preventing someone from dropping the PK row after you look at it
and before you commit the referencing row.

> Inherited relations don't share primary key indexes, so there is the 
> possibility of duplicates.

Which means the whole thing doesn't work, really.  Without a uniqueness
constraint across the set of PK rows, the semantics of FK constraints
are not well-defined.  The multi-table-unique-constraint problem has to
be solved before we can even think much about multi-table FKs :-(

Without having read the patch in detail, I'm guessing that what you've
done might allow the referencing side of an FK constraint to be
inherited (since all this takes is copying down the triggers to the
child tables), but the referenced side still has to be a single table.

			regards, tom lane

In response to

pgsql-hackers by date

Next:From: Bruno Wolff IIIDate: 2005-11-11 05:56:09
Subject: Re: Comments from a Firebird user via Borland
Previous:From: Tom LaneDate: 2005-11-10 23:30:01
Subject: Re: 8.0 -> 8.1 dump duplicate key problem?

pgsql-patches by date

Next:From: Hiroshi SaitoDate: 2005-11-11 01:55:53
Subject: problem in MS-VC6 environment.
Previous:From: Matt NewellDate: 2005-11-10 21:45:00
Subject: foreign key constraints referencing inherited relations - WIP

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