From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
---|---|
To: | Ian Barwick <barwick(at)gmail(dot)com> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: 8.4b1: Query returning results in different order to 8.3 |
Date: | 2009-04-18 18:44:19 |
Message-ID: | 49EA1F83.1000802@dunslane.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Ian Barwick wrote:
>
>
> Workaround / solution to produce consistent results is to move the
> "ORDER BY 1" to the main SELECT clause:
>
> SELECT 1 AS id , 2 AS tmpl_id
> WHERE FALSE
> UNION
> SELECT * FROM
> (SELECT 2 AS id, 96 AS tmpl_id
> UNION
> SELECT 3 AS id, 101 AS tmpl_id
> ) tmpl
> WHERE tmpl_id IS NOT NULL
> ORDER BY 1
>
> (The full version of this query in its original form is in production
> on 8.2 and 8.3 versions and I am confident it has always produced
> consistent results. It is used to select the appropriate template for
> pages on a website and someone would have noticed long before now if
> it was serving up the wrong template).
>
> Note I'm not sure whether this is a bug, or whether the assumption
> made for the original query (that the row order returned by the
> subquery would be carried over to the main part of the query) is
> incorrect but just happened to work as expected pre-8.4.
>
>
>
I don't believe it's a bug - the assumption is one you're not entitled
to make. Your "workaround" is the correct solution, ISTM.
cheers
andrew
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2009-04-18 21:22:46 | Re: 8.4b1: Query returning results in different order to 8.3 |
Previous Message | Heikki Linnakangas | 2009-04-18 17:11:06 | Re: 8.4b1: Query returning results in different order to 8.3 |