Re: pg_dump fails for views with UNION and SELECT DISTINCT

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Sam O'Connor" <sam(at)panviva(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: pg_dump fails for views with UNION and SELECT DISTINCT
Date: 2002-06-14 22:42:39
Message-ID: 9677.1024094559@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Sam O'Connor" <sam(at)panviva(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2002-06-15 19:31:36 Re: PgLargeObject bug
Previous Message Lamar Owen 2002-06-14 15:31:29 Re: Bug #692: corrupt rpms