Re: 7.2.1: pg_dump of UNIONed VIEWs broken - Mailing list pgsql-bugs

From Tom Lane
Subject Re: 7.2.1: pg_dump of UNIONed VIEWs broken
Date
Msg-id 14926.1019487365@sss.pgh.pa.us
Whole thread Raw
In response to 7.2.1: pg_dump of UNIONed VIEWs broken  (Ian Morgan <imorgan@webcon.net>)
Responses Re: 7.2.1: pg_dump of UNIONed VIEWs broken  (Ian Morgan <imorgan@webcon.net>)
List pgsql-bugs
Ian Morgan <imorgan@webcon.net> writes:
> The SQL for CREATE VIEW as output by pg_dump generates an error, because the
> appropriate nesting of SELECTs with parentheses is missing:

Hmm.  You shouldn't *need* parentheses in most cases ...

> CREATE VIEW "agents" as (
>         (
>         SELECT DISTINCT
>                 employees.contact_id
>         FROM
>                 employees
>         ORDER BY
>                 employees.contact_id
>         )
> UNION
>         (
>         SELECT DISTINCT
>                 contractors.contact_id
>         FROM
>                 contractors
>         ORDER BY
>                 contractors.contact_id
>         )
> );

although I suppose this is a counterexample.  Would it help any to point
out that ORDER BY inside an arm of a UNION is a complete waste of
cycles?  That's probably why it didn't occur to anyone to test this.

BTW, the SELECT DISTINCTs are also a waste of cycles, since UNION will
do that anyway.

            regards, tom lane

pgsql-bugs by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: Bug #638: Buggy select statment with numeric
Next
From: Tom Lane
Date:
Subject: Re: Bug #638: Buggy select statment with numeric