Re: Partitioning/inherited tables vs FKs - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Partitioning/inherited tables vs FKs
Date
Msg-id AANLkTinkbEikDBhP28QryQp_rHgtbJ3rPIT82DemcxpE@mail.gmail.com
Whole thread Raw
In response to Re: Partitioning/inherited tables vs FKs  (Dmitry Fefelov <fozzy@ac-sw.com>)
Responses Re: Partitioning/inherited tables vs FKs
SHARE locks vs. DELETE in SERIALIZABLE mode (Was: Partitioning/inherited tables vs FKs)
List pgsql-hackers
On Tue, May 11, 2010 at 2:16 AM, Dmitry Fefelov <fozzy@ac-sw.com> wrote:
>> The referential integrity triggers contain some extra magic that isn't
>> easily simulatable in userland, and that is necessary to make the
>> foreign key constraints airtight.  We've discussed this previously but
>> I don't remember which thread it was or the details of when things
>> blow up.  I think it's something like this: the parent has a tuple
>> that is not referenced by any child.  Transaction 1 begins, deletes
>> the parent tuple (checking that it has no children), and pauses.
>> Transaction 2 begins, adds a child tuple that references the parent
>> tuple (checking that the parent exists, which it does), and commits.
>> Transaction 1 commits.
>
> Will SELECT ... FOR SHARE not help?

Try it, with the example above.  I think you'll find that it doesn't.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company


pgsql-hackers by date:

Previous
From: Mike Fowler
Date:
Subject: Re: Adding xpath_exists function
Next
From: Marko Tiikkaja
Date:
Subject: Re: Partitioning/inherited tables vs FKs