Re: BUG #14684: pg_dump omits columns in inherited tables / psql -d shows deleted columns

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: buschmann(at)nidsa(dot)net
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #14684: pg_dump omits columns in inherited tables / psql -d shows deleted columns
Date: 2017-06-02 15:29:12
Message-ID: 21638.1496417352@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

buschmann(at)nidsa(dot)net writes:
> It seems that the catalogs are screwed up when adding /deleting columns
> inderectly for inherited tables. This was tested under PG 9.6.3 and 10beta1
> under Windows x64.

I could not reproduce any such misbehavior from the details you gave.
Perhaps you could provide a self-contained example? (Ie, starting
from scratch, create and alter some tables to arrive at a bogus state.)

Note that it's not necessarily wrong for a column deleted from the parent
to still exist in a child; if the child had a local definition to start
with then it would still have one afterwards. For example,

create table p (f1 int, f2 int, f3 int);
create table c (f2 int) inherits (p);
-- you'll get some bleat about merging f2 with the inherited column
alter table p drop column f2;
alter table p drop column f3;
-- c will now have f1 (inherited) and f2 (local), but not f3

But I can't think of a case where we should allow a column to exist
in a parent but not a child.

You might find it useful to examine pg_attribute.attislocal (does
column have a "local" definition?) and pg_attribute.attinhcount
(number of times column is inherited from parent table(s)) for the
seemingly-misbehaving columns.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Ray Warren 2017-06-02 15:39:30 Re: BUG #14683: *** glibc detected *** SELECT: double free or corruption
Previous Message Tom Lane 2017-06-02 15:09:35 Re: BUG #14683: *** glibc detected *** SELECT: double free or corruption