From: | Chris Rohlfs <seeken(at)gmail(dot)com> |
---|---|
To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Sort Order inconsistent when using Grouping Sets Rollup |
Date: | 2022-11-22 05:06:47 |
Message-ID: | CAL48EtKDHCKnOkLdSgOmgBZBcahU2zpBqyzeET_ZM74uNZBFHg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The attached file will create a table and run 2 queries, the first of which
is not honoring the requested sort order. I expect the Nulls first.
I have found this problem in Postgres 12.7 (pop os) and 14.6 (mac
Postgres.app)
Incorrect:
select "last_name", "first_name", count("actor_id")
from actor
where (( "actor_id" >= 1 ) and ( "last_name" = 'GUINESS' ) *and (
"first_name" = 'PENELOPE' )*)
group by rollup( 1, 2 )
order by 1 asc nulls first, 2 asc nulls first;
last_name | first_name | count
-----------+------------+-------
GUINESS | PENELOPE | 1
GUINESS | | 1
| | 1
Expected:
select "last_name", "first_name", count("actor_id")
from actor
where (( "actor_id" >= 1 ) and ( "last_name" = 'GUINESS' ))
group by rollup( 1, 2 )
order by 1 asc nulls first, 2 asc nulls first;
last_name | first_name | count
-----------+------------+-------
| | 1
GUINESS | | 1
GUINESS | PENELOPE | 1
(3 rows)
The only difference between the two queries is the "first_name" filter
added to the second.
Thank you!
Chris
Attachment | Content-Type | Size |
---|---|---|
bug.sql | application/sql | 1.1 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | sebastian.patino-lang | 2022-11-22 06:34:21 | Re: BUG #17691: Unexpected behaviour using ts_headline() |
Previous Message | Amit Kapila | 2022-11-22 03:36:22 | Re: WAL segments removed from primary despite the fact that logical replication slot needs it. |