From: Tom Lane <tgl@sss.pgh.pa.us>
To: Keith Fiske <keith@omniti.com>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: Dropping columns with inheritance not working as documented
Date: Tue, 02 Jun 2015 18:18:10 -0400
Message-ID: <7169.1433283490@sss.pgh.pa.us> (raw)
In-Reply-To: <CAG1_KcAmEYNRxbU5vJL3pWkXAsmtgZONZpf7F7ikXscd--TRvg@mail.gmail.com>
References: <CAG1_KcAmEYNRxbU5vJL3pWkXAsmtgZONZpf7F7ikXscd--TRvg@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Keith Fiske <keith@omniti.com> writes:
> According to the documentation, dropping a column should be propagated down
> to all children. This only seems to happen for columns that are added AFTER
> a child table is inherited. There's no way to tell when a column was added
> to an inheritance set, so this could be very confusing for someone down the
> line that wasn't there when a table was set up.
I think you might be misreading the docs. DROP COLUMN only propagates to
columns that have no independent reason to exist in the child. For
instance, given
create table p (f1 int);
these two commands have different results:
create table c () inherits (p);
create table c (f1 int) inherits (p);
In the second case, c.f1 has two reasons to exist: it was declared locally
to c, and it was inherited from p. Dropping p's f1 would remove only one
of those reasons to exist, so c.f1 would still be there.
If you do something like
create table c (f1 int);
alter table c inherit p;
that's treated as the second case. This is a debatable call but that's
the way we decided it should work back when these commands were
implemented.
FYI, the pg_attribute columns attislocal and attinhcount track the state
necessary to implement this behavior.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, keith@omniti.com
Subject: Re: Dropping columns with inheritance not working as documented
In-Reply-To: <7169.1433283490@sss.pgh.pa.us>
References: <CAG1_KcAmEYNRxbU5vJL3pWkXAsmtgZONZpf7F7ikXscd--TRvg@mail.gmail.com> <7169.1433283490@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox