BUG #5389: Column order on dump/reload broken from defined setof function

From: "Timothy Seever" <tim(dot)seever(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #5389: Column order on dump/reload broken from defined setof function
Date: 2010-03-25 20:23:38
Message-ID: 201003252023.o2PKNcj9028361@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 5389
Logged by: Timothy Seever
Email address: tim(dot)seever(at)gmail(dot)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

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Timothy Seever 2010-03-25 20:30:20 BUG #5390: pg_dump does not check/include additional schema dependencies when writing schema/search path
Previous Message ALCALDIA DE INFANTE ALCALDIA DE INFANTE 2010-03-25 18:15:40 Fwd: [BUGS] Question about installation in 2003 server