Re: pg_dump fails for views with UNION and SELECT DISTINCT - Mailing list pgsql-bugs

From Tom Lane
Subject Re: pg_dump fails for views with UNION and SELECT DISTINCT
Date
Msg-id 9677.1024094559@sss.pgh.pa.us
Whole thread Raw
In response to pg_dump fails for views with UNION and SELECT DISTINCT  (Sam O'Connor <sam@panviva.com>)
List pgsql-bugs
"Sam O'Connor" <sam@panviva.com> writes:
> If I create a view like this:
> CREATE VIEW v AS
> SELECT i FROM a
> UNION
> SELECT DISTINCT i FROM b

> It functions as expected but it causes pg_dump to produce
> bad output. "ORDER BY b.i" is added to the view definition.

This appears to be fixed already in current sources --- the problem
is the lack of parentheses around the arms of the UNION.  There's
a difference between
    SELECT foo UNION SELECT bar ORDER BY baz;
and
    SELECT foo UNION (SELECT bar ORDER BY baz);
and the rule dumper was not being careful about it :-(

I'll see about backpatching this change for 7.2.2.

            regards, tom lane

pgsql-bugs by date:

Previous
From: Sam O'Connor
Date:
Subject: pg_dump fails for views with UNION and SELECT DISTINCT
Next
From: Bruce Momjian
Date:
Subject: Re: PgLargeObject bug