Re: Bug in MergeAttributesIntoExisting() function.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: amul sul <sul_amul(at)yahoo(dot)co(dot)in>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Bug in MergeAttributesIntoExisting() function.
Date: 2016-01-04 14:53:51
Message-ID: 11257.1451919231@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

amul sul <sul_amul(at)yahoo(dot)co(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2016-01-04 14:58:28 Re: [PATCH] Refactoring of LWLock tranches
Previous Message Robert Haas 2016-01-04 14:47:59 Re: Bug in MergeAttributesIntoExisting() function.