Re: locking of referenced table during constraint construction

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Scott Shattuck <ss(at)technicalpursuit(dot)com>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: locking of referenced table during constraint construction
Date: 2002-09-04 21:51:30
Message-ID: 20020904144259.B60532-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sean Chittenden 2002-09-04 21:53:18 Schemas not available for pl/pgsql %TYPE....
Previous Message Tom Lane 2002-09-04 21:14:13 Re: Bug in Makefile.shlib