Re: Bug in MergeAttributesIntoExisting() function. - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Bug in MergeAttributesIntoExisting() function.
Date
Msg-id 11257.1451919231@sss.pgh.pa.us
Whole thread Raw
In response to Bug in MergeAttributesIntoExisting() function.  (amul sul <sul_amul@yahoo.co.in>)
Responses Re: Bug in MergeAttributesIntoExisting() function.
List pgsql-hackers
amul sul <sul_amul@yahoo.co.in> writes:
> In inheritance, child column's pg_attribute.attislocal flag not getting updated, if it is inherited using ALTER TABLE
<child>INHERIT <parent>.
 

I think this patch is wrong and you have broken the intended behavior.
It's a bit hard to tell though because your example is confused.

> CREATE TABLE p1 (a int , b int, c int, d int);

> CREATE TABLE c1 () inherits (p1);CREATE TABLE c2 (a int , b int, c int, d int);

> --Drop parent's column
> ALTER TABLE p1 DROP COLUMN b;
> ALTER TABLE p1 DROP COLUMN c;
> ALTER TABLE p1 DROP COLUMN d;

> postgres=# \d p1
>       Table "public.p1"
>  Column |  Type   | Modifiers 
> --------+---------+-----------
>  a      | integer | 
> Number of child tables: 2 (Use \d+ to list them.)

Say what?  At this point only c1 is a child of p1.  I assume you've
left something out, either an ALTER INHERIT or an INHERITS clause
in CREATE TABLE c2.

Either way, however, the way you declared c2, it has an independent
local definition of all four columns, and so they should not go away
even if the parent's columns go away.  This is exactly the purpose
that attislocal was created to serve, and your patch destroys it.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Bug in MergeAttributesIntoExisting() function.
Next
From: Robert Haas
Date:
Subject: Re: [PATCH] Refactoring of LWLock tranches