Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1a1Ghs-00057o-Ka for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Nov 2015 16:44:40 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1a1Ghr-0000bD-V2 for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Nov 2015 16:44:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1a1GhF-0008LN-Py for pgsql-bugs@postgresql.org; Tue, 24 Nov 2015 16:44:01 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1a1Gh8-0000qU-GF for pgsql-bugs@postgresql.org; Tue, 24 Nov 2015 16:44:01 +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 tAOGhm7q021634; Tue, 24 Nov 2015 11:43:49 -0500 From: Tom Lane To: pinker cc: pgsql-bugs@postgresql.org Subject: Re: pg_dump - wrong order with inheritance In-reply-to: <1448379287033-5874925.post@n5.nabble.com> References: <1448281678687-5874794.post@n5.nabble.com> <1655.1448289868@sss.pgh.pa.us> <1448379287033-5874925.post@n5.nabble.com> Comments: In-reply-to pinker message dated "Tue, 24 Nov 2015 08:34:47 -0700" Date: Tue, 24 Nov 2015 11:43:48 -0500 Message-ID: <21633.1448383428@sss.pgh.pa.us> X-Pg-Spam-Score: -2.5 (--) 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 pinker writes: > i've just prepared test case and did some debugging. It turned out that the > issue isn't dump order but wrong ddl generated by pg_dump. > CREATE TABLE a00 > ( > id INTEGER NOT NULL, > name TEXT NOT NULL, > CONSTRAINT a00_pkey PRIMARY KEY (id) > ) > WITH ( > OIDS =FALSE > ); > CREATE TABLE a03 > ( > id INTEGER NOT NULL, > name TEXT NOT NULL, > CONSTRAINT a03_pkey PRIMARY KEY (id) > ) > WITH ( > OIDS =FALSE > ); > ALTER TABLE a03 > INHERIT a00; > ALTER TABLE a03 > ALTER COLUMN name DROP NOT NULL; Ah. This is not pg_dump's fault, because actually what you've got here is a logically inconsistent database: at this point, it's possible to select from a00 and see some rows with null name values, which should not be possible given the declared NOT NULL constraint on a00.name. This is a known limitation of the backend. It should refuse to let you DROP NOT NULL in a case where the NOT NULL is an inherited constraint, as it is here. It would not let you drop a CHECK constraint in an equivalent situation; but the NOT NULL support is older/more primitive and currently doesn't do enough bookkeeping to realize that a03's NOT NULL constraint is inherited from a parent table. Fixing that is on our to-do list, but it hasn't been very high priority. 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