Re: BUG #4244: ALTER TABLE ... NO INHERIT problem - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #4244: ALTER TABLE ... NO INHERIT problem
Date
Msg-id 19666.1213709303@sss.pgh.pa.us
Whole thread Raw
In response to BUG #4244: ALTER TABLE ... NO INHERIT problem  ("Tatsuhito Kasahara" <kasahara.tatsuhito@oss.ntt.co.jp>)
List pgsql-bugs
"Tatsuhito Kasahara" <kasahara.tatsuhito@oss.ntt.co.jp> writes:
> The comment in tablecmds.c says "AccessShareLock is probably enough".
> But it actually needs more strong lock mode ?

> ATExecDropInherit(Relation rel, RangeVar *parent)
>     /*
>      * AccessShareLock on the parent is probably enough, seeing that DROP
>      * TABLE doesn't lock parent tables at all.  We need some lock since we'll
>      * be inspecting the parent's schema.
>      */
>     parent_rel = heap_openrv(parent, AccessShareLock);

Well, as the comment points out, things are just as bad if you do
"DROP TABLE c1_tbl" instead of ALTER NO INHERIT.

I'm not sure there is a lot we can do about this.  Taking a lock
on the parent table that is strong enough to block a SELECT would
just convert the problem into a deadlock (since a SELECT on the
parent will lock parent before child).  Hardly seems like an
improvement.

            regards, tom lane

pgsql-bugs by date:

Previous
From: "Tatsuhito Kasahara"
Date:
Subject: BUG #4244: ALTER TABLE ... NO INHERIT problem
Next
From: Andrew Sullivan
Date:
Subject: Re: BUG #4243: Idle in transaction