Re: Foreign key reference counting strategy? - Mailing list pgsql-sql

From Tom Lane
Subject Re: Foreign key reference counting strategy?
Date
Msg-id 13667.1160871610@sss.pgh.pa.us
Whole thread Raw
In response to Re: Foreign key reference counting strategy?  (Michael Fuhr <mike@fuhr.org>)
Responses Re: Foreign key reference counting strategy?  (Michael Fuhr <mike@fuhr.org>)
List pgsql-sql
Michael Fuhr <mike@fuhr.org> writes:
> On Sat, Oct 14, 2006 at 07:58:06PM -0400, Tom Lane wrote:
>> No, I don't think so, because the DELETE will already be holding
>> exclusive lock on the doomed PK row, which any would-be inserters of
>> matching FK rows will be blocked on.  AFAICS the DELETE should go
>> through and then the inserters will fail.

> Unless the inserters got there first.  I just tested both ways; if
> the insert acquires the lock first then the delete fails, but if the
> delete acquires the lock first then the insert fails.

Well, if the inserters get a lock on the PK row before the DELETE does,
then of course.  I was just disputing the assertion that doing IF EXISTS
in an after trigger would add a new way for the DELETE to fail.  At that
point, any uncommitted inserts must be blocked waiting for the delete.
        regards, tom lane


pgsql-sql by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: Foreign key reference counting strategy?
Next
From: Michael Fuhr
Date:
Subject: Re: Foreign key reference counting strategy?