Lists: | pgsql-bugs |
---|
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 |
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
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Timothy Seever" <tim(dot)seever(at)gmail(dot)com> |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #5389: Column order on dump/reload broken from defined setof function |
Date: | 2010-03-25 21:04:43 |
Message-ID: | 24267.1269551083@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
"Timothy Seever" <tim(dot)seever(at)gmail(dot)com> writes:
> 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.
Yup. This is not pg_dump's fault, and there's no way for pg_dump to fix
it for you. Sorry, but you'll need to correct the queries yourself.
regards, tom lane
From: | Dimitri Fontaine <dfontaine(at)hi-media(dot)com> |
---|---|
To: | "Timothy Seever" <tim(dot)seever(at)gmail(dot)com> |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #5389: Column order on dump/reload broken from defined setof function |
Date: | 2010-03-26 11:00:48 |
Message-ID: | 87tys39wkf.fsf@hi-media-techno.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
"Timothy Seever" <tim(dot)seever(at)gmail(dot)com> writes:
> CREATE FUNCTION testfunc() RETURNS setof tablec AS $BODY$ SELECT * FROM
> tablec; $BODY$ LANGUAGE 'sql' STABLE;
Common wisdom saith to never ever use "SELECT *" in your code. You just
found out a reason why.
Regards,
--
dim
From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | Dimitri Fontaine <dfontaine(at)hi-media(dot)com> |
Cc: | Timothy Seever <tim(dot)seever(at)gmail(dot)com>, pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #5389: Column order on dump/reload broken from defined setof function |
Date: | 2010-03-29 00:20:17 |
Message-ID: | 603c8f071003281720x414628dav62f8823605fdd899@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
On Fri, Mar 26, 2010 at 7:00 AM, Dimitri Fontaine
<dfontaine(at)hi-media(dot)com> wrote:
> "Timothy Seever" <tim(dot)seever(at)gmail(dot)com> writes:
>> CREATE FUNCTION testfunc() RETURNS setof tablec AS $BODY$ SELECT * FROM
>> tablec; $BODY$ LANGUAGE 'sql' STABLE;
>
> Common wisdom saith to never ever use "SELECT *" in your code. You just
> found out a reason why.
Still pretty annoying though.
...Robert