Re: BUG #1335: Wrong sort result in union queries - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #1335: Wrong sort result in union queries
Date
Msg-id 8560.1101916469@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #1335: Wrong sort result in union queries  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
List pgsql-bugs
Stephan Szabo <sszabo@megazone.bigpanda.com> writes:
> Union isn't a tool which gives you that ability. Union All is closer, but
> still doesn't guarantee an order.

The current implementation of UNION ALL will in fact act that way (just
append the individual query results together), but if for some reason we
decide to change it later, we'll be within the spec to do so.  (I can't
imagine a reason to change it though...)

> This one is also okay. The order by in one wing does not control the
> output of the union. I believe supporting it is an extension in any case
> (at least SQL92 seems to make it illegal)

Yes.  SQL92 believes strongly that row order is not significant, except
at the top level output of a query with ORDER BY ...

            regards, tom lane

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #1332: wrong results from age function
Next
From: Tom Lane
Date:
Subject: Re: BUG #1332: wrong results from age function