Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YzuVk-0006QC-Fn for pgsql-bugs@arkaria.postgresql.org; Tue, 02 Jun 2015 22:18:16 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YzuVj-0002KP-Rb for pgsql-bugs@arkaria.postgresql.org; Tue, 02 Jun 2015 22:18:15 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YzuVi-0002KI-Sq for pgsql-bugs@postgresql.org; Tue, 02 Jun 2015 22:18:15 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1YzuVg-0005Rj-4v for pgsql-bugs@postgresql.org; Tue, 02 Jun 2015 22:18:13 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id t52MIApA007170; Tue, 2 Jun 2015 18:18:10 -0400 From: Tom Lane To: Keith Fiske cc: "pgsql-bugs@postgresql.org" Subject: Re: Dropping columns with inheritance not working as documented In-reply-to: References: Comments: In-reply-to Keith Fiske message dated "Tue, 02 Jun 2015 17:52:05 -0400" Date: Tue, 02 Jun 2015 18:18:10 -0400 Message-ID: <7169.1433283490@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Keith Fiske 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