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

Re: Foreign key reference counting strategy?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: PostgreSQL SQL List <pgsql-sql(at)postgresql(dot)org>, Joost Kraaijeveld <J(dot)Kraaijeveld(at)Askesis(dot)nl>
Subject: Re: Foreign key reference counting strategy?
Date: 2006-10-15 00:20:10
Message-ID: 13667.1160871610@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-sql
Michael Fuhr <mike(at)fuhr(dot)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

In response to

Responses

pgsql-sql by date

Next:From: Michael FuhrDate: 2006-10-15 01:07:26
Subject: Re: Foreign key reference counting strategy?
Previous:From: Michael FuhrDate: 2006-10-15 00:11:26
Subject: Re: Foreign key reference counting strategy?

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