Re: BUG #17071: ORDER BY gets ignored when result set has only one row, but another one gets added by rollup() - Mailing list pgsql-bugs

From Tobias Wendorff
Subject Re: BUG #17071: ORDER BY gets ignored when result set has only one row, but another one gets added by rollup()
Date
Msg-id 6574e1c6-fcb6-62fb-9de4-c9005feac87d@tu-dortmund.de
Whole thread Raw
In response to Re: BUG #17071: ORDER BY gets ignored when result set has only one row, but another one gets added by rollup()  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BUG #17071: ORDER BY gets ignored when result set has only one row, but another one gets added by rollup()  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
Dear Tom,

On 23/06/2021 21:20 Tom Lane wrote:
 > Hm, that's certainly a bug, but so far as I can tell it's specific
 > to the case of a constant value being used as the GROUP BY/ORDER BY
 > target.
 > Which doesn't seem very likely to be interesting in practice.
 > Do you have a non-toy example where things go wrong?

I'm a little bit surprised by your message. It is actually common to
make an example reproducible, but as small as possible. Please check
out the "KISS principle". It is therefore pretty unprofessional that
you devalue it as a "toy example".

Even this shorter example would have effectively shown the error:
SELECT 1 GROUP BY rollup(1) ORDER BY 1 NULLS FIRST;

To take some of the wind out of your criticism: Of course there is
a use case for the case. The whole thing stems from a complex query
and kept a colleague busy for a long time today because it led
tocompletely illogical results in some cases.

 > So I'm wondering if this was reduced from a more realistic example
 > that we might be able to fix in some other way.

To keep a long discussion short: you classify it as a wontfix.
Since I've already supplied a workaround (using a subquery or CTE),
let's close it.

Thanks,
Tobias



pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #17071: ORDER BY gets ignored when result set has only one row, but another one gets added by rollup()
Next
From: Tom Lane
Date:
Subject: Re: BUG #17071: ORDER BY gets ignored when result set has only one row, but another one gets added by rollup()