Re: BUG #18662: ORDER BY after GROUPING SETS does not order correctly for certain WHERE condition - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #18662: ORDER BY after GROUPING SETS does not order correctly for certain WHERE condition
Date
Msg-id 657102.1729177393@sss.pgh.pa.us
Whole thread Raw
In response to BUG #18662: ORDER BY after GROUPING SETS does not order correctly for certain WHERE condition  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> I'm seeing inconsistent results for an ORDER BY in combination with GROUPING
> SETS.

Yup.  Your example actually works correctly as of HEAD (v18-to-be):

regression=# select * from (values (1, 1), (1, 2), (2,1), (2,2)) as t (a,b)
where a=1
group by grouping sets ((b),(a,b))
order by a, b;
 a | b
---+---
 1 | 1
 1 | 2
   | 1
   | 2
(4 rows)

but I'm afraid there's zero chance of back-patching the fix,
as it's far too invasive (and under-tested, for now) for that.

> This might be the same bug as
> https://www.postgresql.org/message-id/CAL48EtKDHCKnOkLdSgOmgBZBcahU2zpBqyzeET_ZM74uNZBFHg@mail.gmail.com

Indeed.  Richard Guo recently completed the fix I alluded to in that
thread:

https://git.postgresql.org/gitweb/?p=postgresql.git&a=commitdiff&h=247dea89f
https://git.postgresql.org/gitweb/?p=postgresql.git&a=commitdiff&h=f5050f795

            regards, tom lane



pgsql-bugs by date:

Previous
From: Erik Wienhold
Date:
Subject: Re: BUG #18660: information_schema.columns.ordinal_position has gaps when primary key columns are dropped
Next
From: Tom Lane
Date:
Subject: Re: BUG #18657: Using JSON_OBJECTAGG with volatile function leads to segfault