Re: BUG #19805: Wrong results: self-join elimination drops an ORDER BY sort key with GROUPING SETS / CUBE / ROLLUP

From: Tender Wang <tndrwang(at)gmail(dot)com>
To: 303677365(at)qq(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19805: Wrong results: self-join elimination drops an ORDER BY sort key with GROUPING SETS / CUBE / ROLLUP
Date: 2026-10-30 07:27:36
Message-ID: CAHewXNnG-vM+kCSb60Toqyipj7nN0Q=zUo-8r90yAKrz+YX4VQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)org> 于2026年10月30日周五 15:11写道:
>
> The following bug has been logged on the website:
> SET enable_self_join_elimination = on; -- default
> SELECT s1.a, s2.a FROM m2 s1 JOIN m2 s2 ON s1.a = s2.a
> GROUP BY CUBE (s1.a, s2.a) ORDER BY 1, 2;
>
> SET enable_self_join_elimination = off;
> SELECT s1.a, s2.a FROM m2 s1 JOIN m2 s2 ON s1.a = s2.a
> GROUP BY CUBE (s1.a, s2.a) ORDER BY 1, 2;
> SQL
>
> Actual output (N = NULL):
>
> SJE on : (1,N) (1,1) (2,2) (2,N) (N,N) (N,1) (N,2)
> SJE off: (1,1) (1,N) (2,2) (2,N) (N,1) (N,2) (N,N)

Hi,

This appears to be the same SJE/GROUPING SETS issue already reported
in BUG #19800 [1]

Could you check whether your test case exposes a different underlying issue?
If so, please explain how it differs in this thread. Otherwise, please
keep additional test cases in the existing thread.

For future reports, please check for existing reports of the same
issue before opening a new thread.

[1] https://www.postgresql.org/message-id/19800-2f4fc7fcfb9a17a1%40postgresql.org

--
Thanks,
Tender Wang

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message 飞鱼 2026-10-30 07:54:36 Re: BUG #19805: Wrong results: self-join elimination drops an ORDER BY sort key with GROUPING SETS / CUBE / ROLLUP
Previous Message Richard Guo 2026-10-30 07:24:55 Re: Wrong results: hashed SubPlan referenced twice after OR-qual extraction reuses a stale hash table (13 to 19beta4)