Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XMohg-0006ig-Hw for pgsql-hackers@arkaria.postgresql.org; Thu, 28 Aug 2014 01:40:44 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XMohg-0004Yg-0V for pgsql-hackers@arkaria.postgresql.org; Thu, 28 Aug 2014 01:40:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XMohd-0004Vv-QY for pgsql-hackers@postgresql.org; Thu, 28 Aug 2014 01:40:41 +0000 Received: from mail-pa0-f52.google.com ([209.85.220.52]) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1XMohZ-0007Nl-6c for pgsql-hackers@postgresql.org; Thu, 28 Aug 2014 01:40:40 +0000 Received: by mail-pa0-f52.google.com with SMTP id eu11so369311pac.39 for ; Wed, 27 Aug 2014 18:40:33 -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=TXqIoVfiI53vd/qrmbyPSAHHeFjCqR3yj2K9Elb0+j8=; b=OUyaTBlbucatruCRMNow5ryt9HucRp1rAbQB2cRe4fJa1Ifv4b8Pxf0n1fwlOweF2X zwtxQONPry0d5cWmDmc1LYQrQPgbUkOSNqx8m8xQm1VuBroVAUXpCAvKoxQDqAaTVTSe sOCQ81oIbT18fg2CjWF1VEGu2LPKIi8S4rbQ/3wNDwERvt8lGANaTZhgZ7sFPLvvjCCj 98VCv9q7x8PqbIruBP8I9M+gBdP9k64zlww6rpb2zrxBdqYpFj8wCA03Xg0ldO410piM BiAWgnFgBZ36GytSEAiXtl4V9hApHVOOPdagxIg7gy3o7Igh4JlE3IozFM2pFfANdjce JkVA== X-Gm-Message-State: ALoCoQk9wZVCeB6vLx+icf+dTr5EcwGJS5yxpfug/WRGTtGsVu5h8iBLuO6SVScw3SES4RBJW8hF X-Received: by 10.67.22.37 with SMTP id hp5mr1012773pad.150.1409190033797; Wed, 27 Aug 2014 18:40:33 -0700 (PDT) Received: from tornado.leadboat.com (c-174-62-109-97.hsd1.ca.comcast.net. [174.62.109.97]) by mx.google.com with ESMTPSA id na4sm2701566pdb.96.2014.08.27.18.40.32 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 27 Aug 2014 18:40:33 -0700 (PDT) Date: Wed, 27 Aug 2014 21:40:30 -0400 From: Noah Misch To: Tom Lane Cc: Bruce Momjian , Alvaro Herrera , majid@apsalar.com, PostgreSQL-development Subject: Re: [BUGS] Re: BUG #9555: pg_dump for tables with inheritance recreates the table with the wrong order of columns Message-ID: <20140828014030.GA777962@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> <20140317231212.GA3854149@tornado.leadboat.com> <20140827144053.GL14956@momjian.us> <31422.1409153093@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <31422.1409153093@sss.pgh.pa.us> 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-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On Wed, Aug 27, 2014 at 11:24:53AM -0400, Tom Lane wrote: > On Wed, Aug 27, 2014 at 10:40:53AM -0400, Bruce Momjian wrote: > > I looked at this issue from March and I think we need to do something. > > In summary, the problem is that tables using inheritance can be dumped > > and reloaded with columns in a different order from the original > > cluster. > > Yeah ... this has been a well-understood issue for a dozen years, and > pg_dump goes to considerable trouble to get it right. pg_dump goes to trouble to preserve attislocal but not to preserve inherited column order. Hence this thread about pg_dump getting column order wrong. > > I think we have several options: > > > > 1. document this behavior > > That one. +1; certainly reasonable as a first step. > > 2. have ALTER TABLE INHERIT issue a warning about future reordering That warning would summarize as "WARNING: this object is now subject to a known bug". -0; I'm not strongly opposed, but it's not our norm. > > 3. use the pg_dump binary-upgrade code when such cases happen +1. We have the convention that, while --binary-upgrade can inject catalog hacks, regular pg_dump uses standard, documented DDL. I like that convention on general aesthetic grounds and for its benefit to non-superusers. Let's introduce the DDL needed to fix this bug while preserving that convention, namely DDL to toggle attislocal. > > My crude approach for #3 would be for pg_dump to loop over the columns > > and, where pg_attribute.attinhcount == 0, check to see if there is a > > matching column name in any inherited table. That doesn't look right. attinhcount is essentially a cache; it shall equal the number of parents having a matching column. The approach we use in binary upgrade mode ought to suffice. > > Will such tables load fine > > because pg_dump binary-upgrade mode doesn't do any data loading? We're now talking about changes to pg_dump's normal (non-binary-upgrade) mode, right? pg_dump always gives COPY a column list, so I don't expect trouble on the data load side of things. Thanks, nm -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers