Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WPgho-0006Mi-8O for pgsql-bugs@arkaria.postgresql.org; Mon, 17 Mar 2014 23:12:28 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WPghn-0006UQ-Dd for pgsql-bugs@arkaria.postgresql.org; Mon, 17 Mar 2014 23:12:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WPghm-0006U9-CN for pgsql-bugs@postgresql.org; Mon, 17 Mar 2014 23:12:26 +0000 Received: from mail-qc0-f169.google.com ([209.85.216.169]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WPghc-0004aL-Nj for pgsql-bugs@postgresql.org; Mon, 17 Mar 2014 23:12:25 +0000 Received: by mail-qc0-f169.google.com with SMTP id i17so6916351qcy.14 for ; Mon, 17 Mar 2014 16:12:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=7Q9i+3et26HnCxSlvxQBha9B/m9HQ9w1toTICFvjpGE=; b=AsmPf3Uz5DqIZ6zB60MgSmIo5CbXHN+k34flPvCerpHidVMywg7d0NaML8X7n/UtX8 DaYwhaSW2wO93a6a9Z1OkYG0XESyP9GQOLwpQzTtpljnfccLssmuXLMSzSVnyPu4eH9n dkuCXtw573MdlZkrwS8a5ZJ73x1NAVqmi7UoBIxDnjRsPw+h8CZxyqjdjLmOlD7Op4cz xPn42JGhETFb+2rBVSkHhoGrCwY3kWY8NXfZ4V5y8cQCtq1e/mrjzgwJWAASW7TWtt4n uL0fz12urckZvuTfR0AZ88T/8ajPzkFRiOrn1Wr7ms0hn/kDBdGML9l15N141mCFfMRm RzVA== X-Gm-Message-State: ALoCoQlH7afReIjaPZGlMzfBnTZjQpUQXQ069B8lHQB7l3QEzji8TySuNs03ucaNH6cz0mqlkZ8c X-Received: by 10.140.49.100 with SMTP id p91mr15552037qga.52.1395097934356; Mon, 17 Mar 2014 16:12:14 -0700 (PDT) Received: from tornado.leadboat.com (c-107-4-219-91.hsd1.va.comcast.net. [107.4.219.91]) by mx.google.com with ESMTPSA id d30sm23348231qga.9.2014.03.17.16.12.13 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 17 Mar 2014 16:12:13 -0700 (PDT) Date: Mon, 17 Mar 2014 19:12:12 -0400 From: Noah Misch To: Alvaro Herrera Cc: Tom Lane , majid@apsalar.com, pgsql-bugs@postgresql.org Subject: Re: BUG #9555: pg_dump for tables with inheritance recreates the table with the wrong order of columns Message-ID: <20140317231212.GA3854149@tornado.leadboat.com> References: <20140313043900.398.17129@wrigleys.postgresql.org> <20140313134739.GD4744@eldon.alvh.no-ip.org> <15349.1394720340@sss.pgh.pa.us> <20140314153304.GA6899@eldon.alvh.no-ip.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140314153304.GA6899@eldon.alvh.no-ip.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -2.6 (--) 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 On Fri, Mar 14, 2014 at 12:33:04PM -0300, Alvaro Herrera wrote: > Tom Lane wrote: > > Alvaro Herrera writes: > > > majid@apsalar.com wrote: > > >> Reproduction case: > > >> > > >> create table A(a int, b int, c int); > > >> create table B(a int, c int); > > >> alter table A inherit B; > > > > > I wonder if the real fix here is to have ALTER / INHERIT error out of > > > the columns in B are not a prefix of those in A. > > > > Years ago, we sweated quite a lot of blood to make these cases work. > > I'm not thrilled about throwing away all that effort because one person > > doesn't like the behavior. Agreed. That also makes the current pg_dump behavior a bug. Column order matters; pg_dump is failing to recreate a semantically-equivalent database. > Hm, well in that case it makes sense to consider the original > suggestion: if the columns in the parent are not a prefix of those of > the child, use ALTER INHERIT after creating both tables rather than > CREATE TABLE INHERITS. > > It'd be a lot of new code in pg_dump though. I am not volunteering ... "pg_dump --binary-upgrade" already gets this right. Perhaps it won't take too much code to make dumpTableSchema() reuse that one part of its binary-upgrade approach whenever the columns of B are not a prefix of those in A. nm -- Noah Misch EnterpriseDB http://www.enterprisedb.com -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs