Re: BUG #9555: pg_dump for tables with inheritance recreates the table with the wrong order of columns

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: majid(at)apsalar(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #9555: pg_dump for tables with inheritance recreates the table with the wrong order of columns
Date: 2014-03-13 13:47:37
Message-ID: 14563.1394718457@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

majid(at)apsalar(dot)com writes:
> create table A(a int, b int, c int);
> create table B(a int, c int);
> alter table A inherit B;

> pg_dump (whether in default or -Fc mode) generates [ A with a,c,b ]

This is not a bug, but expected and desired behavior. The parent's column
order is considered canonical, and child tables are made to append their
columns to that. Perhaps in your use-case that's not how you'd like to
think about it, but if we were to change this we'd doubtless break things
for other people.

Possibly you could use pg_upgrade, which I believe does preserve physical
column order in such cases.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Alvaro Herrera 2014-03-13 13:47:39 Re: BUG #9555: pg_dump for tables with inheritance recreates the table with the wrong order of columns
Previous Message Heikki Linnakangas 2014-03-13 13:45:30 Re: BUG #9557: Row not visible after receiving notification

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2014-03-13 13:47:39 Re: BUG #9555: pg_dump for tables with inheritance recreates the table with the wrong order of columns
Previous Message Greg Stark 2014-03-13 13:47:03 Re: jsonb and nested hstore