Re: pg_dump produces invalid SQL for "group by cast(null as numeric)"

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Martin Pitt <martin(at)piware(dot)de>
Cc: PostgreSQL Bugs <pgsql-bugs(at)postgresql(dot)org>, ubuntubug(at)acrasis(dot)net
Subject: Re: pg_dump produces invalid SQL for "group by cast(null as numeric)"
Date: 2008-03-06 21:29:51
Message-ID: 200803062129.m26LTpD20981@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


FYI, this was fixed in 8.3.0; not sure you got the report of the fix.

---------------------------------------------------------------------------

Martin Pitt wrote:
-- Start of PGP signed section.
> Hi PostgreSQL developers,
>
> in [1], a user reported a failure of pg_dump:
>
> -------- snip ----------
> 1. Create an empty database.
>
> 2. Connect to the database and create these views:
>
> create view foo as select 3;
> create view bar as select count(*) from foo group by cast(null as numeric);
>
> 3. pg_dump the database to a text file. The file contains
>
> 'CREATE VIEW bar AS
> SELECT count(*) AS count FROM foo GROUP BY 2;'
>
> 4. Drop view bar from the database.
>
> 5. Run the CREATE VIEW bar..; statement from the text file.
>
> 6. The statement fails with
>
> 'ERROR: GROUP BY position 2 is not in select list'
> -------- snip ----------
>
> I verified that this is still an issue on 8.3 CVS head.
>
> However, I admit that I'm not sure why "group by cast(null as
> numeric)" is useful. However, it actually works in the DB and fails in
> pg_dump, so either it is valid and should be handled by pg_dump, or it
> is invalid and should not be accepted in the first place.
>
> Thank you!
>
> Martin
>
> [1] https://bugs.launchpad.net/bugs/177382
>
> --
> Martin Pitt http://www.piware.de
> Ubuntu Developer http://www.ubuntu.com
> Debian Developer http://www.debian.org
-- End of PGP section, PGP failed!

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://postgres.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2008-03-06 21:32:20 Re: BUG #3833: Index remains when table is dropped
Previous Message Alex Hunsaker 2008-03-06 20:40:02 Re: [PATCHES] BUG #3973: pg_dump using inherited tables do not always restore