Re: locking of referenced table during constraint construction - Mailing list pgsql-hackers

From Stephan Szabo
Subject Re: locking of referenced table during constraint construction
Date
Msg-id 20020904144259.B60532-100000@megazone23.bigpanda.com
Whole thread Raw
In response to locking of referenced table during constraint construction  (Scott Shattuck <ss@technicalpursuit.com>)
Responses Re: locking of referenced table during constraint
List pgsql-hackers
On 4 Sep 2002, Scott Shattuck wrote:

> Under what conditions would the following statement cause the USERS
> table to lock out selects?
>
>
> alter table my_coupons
>   add constraint FK_mc_user_id
>   FOREIGN KEY (mc_frn_user_id)
>   REFERENCES users(user_ID);

If I'm reading code correctly, an exclusive lock
on the pk table is grabbed which will block selects
as well. You're effectively altering both tables
(you need to add triggers to both tables) and
both get locked.




pgsql-hackers by date:

Previous
From: Scott Shattuck
Date:
Subject: locking of referenced table during constraint construction
Next
From: Olivier PRENANT
Date:
Subject: Re: Bug in Makefile.shlib