pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Noah Misch <noah@leadboat.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Bruce Momjian <bruce@momjian.us>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: majid@apsalar.com
Cc: PostgreSQL-development <pgsql-hackers@postgreSQL.org>
Subject: Re: [BUGS] Re: BUG #9555: pg_dump for tables with inheritance recreates the table with the wrong order of columns
Date: Wed, 27 Aug 2014 21:40:30 -0400
Message-ID: <20140828014030.GA777962@tornado.leadboat.com> (raw)
In-Reply-To: <31422.1409153093@sss.pgh.pa.us>
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>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

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



view thread (21+ messages)  latest in thread

Message-ID: <20140828014030.GA777962@tornado.leadboat.com>
Permalink:  ../20140828014030.GA777962@tornado.leadboat.com/
Also on:    postgresql.org/message-id/20140828014030.GA777962@tornado.leadboat.com

 · 

reply

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: noah@leadboat.com, tgl@sss.pgh.pa.us, bruce@momjian.us, alvherre@2ndquadrant.com, majid@apsalar.com, pgsql-hackers@postgreSQL.org
  Subject: Re: [BUGS] Re: BUG #9555: pg_dump for tables with inheritance recreates the table with the wrong order of columns
  In-Reply-To: <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> <20140828014030.GA777962@tornado.leadboat.com>

* 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