Skip site navigation (1) Skip section navigation (2)

Re: Bug with view definitions?

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Dennis Bjorklund <db(at)zigo(dot)dhs(dot)org>
Cc: Justin Clift <jc(at)telstra(dot)net>,PostgreSQL Hackers Mailing List <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Bug with view definitions?
Date: 2004-07-01 16:30:53
Message-ID: 20040701163053.GB1438@wolff.to (view raw or flat)
Thread:
Lists: pgsql-hackers
On Thu, Jul 01, 2004 at 15:19:32 +0200,
  Dennis Bjorklund <db(at)zigo(dot)dhs(dot)org> wrote:
> 
> Looking again at the doc and the example I now know why it can't parse 
> it. The example when simplified is:
> 
> SELECT *
>   FROM (select 1 ORDER BY 1
>         UNION ALL
>         select 2) AS x;
> 
> and it does not parse since the there is an ORDER BY in the first query. 
> If we look at the doc page then the UNION comes before the ORDER BY, so it 
> is in fact an invalid query (I've not checke the standard, just the select 
> doc page).
> 
> If you put a () around the first (inner) select it all works. But why 
> is the order by there at all? The order of the rows from the UNION ALL can 
> (in theory) be random anyway, right?

If DISTINCT ON or LIMIT was used in inner select, then the ORDER BY would
be relevant; so you can't just blindly remove ORDER BY when it is part of
a union.

In response to

Responses

pgsql-hackers by date

Next:From: Dennis BjorklundDate: 2004-07-01 16:32:30
Subject: Re: Bug with view definitions?
Previous:From: Justin CliftDate: 2004-07-01 15:04:55
Subject: Re: Bug with view definitions?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group