BUG #5389: Column order on dump/reload broken from defined setof function - Mailing list pgsql-bugs

From Timothy Seever
Subject BUG #5389: Column order on dump/reload broken from defined setof function
Date
Msg-id 201003252023.o2PKNcj9028361@wwwmaster.postgresql.org
Whole thread Raw
Responses Re: BUG #5389: Column order on dump/reload broken from defined setof function  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: BUG #5389: Column order on dump/reload broken from defined setof function  (Dimitri Fontaine <dfontaine@hi-media.com>)
List pgsql-bugs
The following bug has been logged online:

Bug reference:      5389
Logged by:          Timothy Seever
Email address:      tim.seever@gmail.com
PostgreSQL version: 8.3.5, others
Operating system:   Linux
Description:        Column order on dump/reload broken from defined setof
function
Details:

Adding a column to an inherited table in-place works as expected with the
combined table/etc.  However on dump/reload the physical order changes, so
any? predefined select from a setof function pulling from the combined table
will result in a mismatch.

For example:
  table a:
     col1  text

  table b:
     col2  date

  table c: (inherits a&b)

ALTER table a add column col3 int;

table c now has col3 on the end physically

On dump/restore, it's reordered to the correct place based on the inherited
table... which is fine, except in the following:

--Yes, the following is pointless as is, but with arguments less so
CREATE FUNCTION testfunc() RETURNS setof tablec AS $BODY$ SELECT * FROM
tablec; $BODY$ LANGUAGE 'sql' STABLE;

CREATE VIEW xyz AS select * FROM testfunc() c(col1, col2, col3) where
col2='2010-01-01'::date;

pg_dump dumps the view with the existing label/column order, so upon restore
it's misaligned since it will now be col1, col3, col2 in table c

I'm not sure if there's some additional syntax causing it, but that's
basically what appears to be happening

pgsql-bugs by date:

Previous
From: "Timothy Seever"
Date:
Subject: BUG #5390: pg_dump does not check/include additional schema dependencies when writing schema/search path
Next
From: "bortdagos"
Date:
Subject: BUG #5388: bortdagos