Re: JumbleQuery ma treat different GROUP BY expr as the same
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: jian he <jian.universality@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, PostgreSQL-development <pgsql-hackers@postgresql.org>, Richard Guo <guofenglinux@gmail.com>
Date: 2026-01-13T07:09:46Z
Lists: pgsql-hackers
Attachments
- v2-0001-Fix-query-jumbling-computations-with-GROUP-BY-cla.patch (text/x-diff) patch v2-0001
On Mon, Jan 12, 2026 at 04:20:44PM +0800, jian he wrote: > While working on it, I guess I found another bug, below JumbleQuery will return > the same result: > > SELECT FROM (VALUES (1::INT, 2::INT)) AS t(a, b) ORDER BY a, b; > SELECT a FROM (VALUES (1::INT, 2::INT)) AS t(a, b) ORDER BY a, b; > SELECT a, b FROM (VALUES (1::INT, 2::INT)) AS t(a, b) ORDER BY a, b; > > so I think TargetEntry.resjunk should not be marked as query_jumble_ignore. Not sure how to feel about this one, as a primary node. 3db72ebcbe20 has put a query_jumble_ignore to TargetEntry.resjunk which was simply a consistent move with the pre-v15 branches because these columns have always been ignored. I have never heard complaints about that in the field with PGSS, TBH. The original choice comes from this thread, back in 2012 when this was still integrated into PGSS: https://www.postgresql.org/message-id/CAEYLb_WGeFCT7MfJ8FXf-CR6BSE6Lbn%2BO1VX3%2BOGrc4Bscn4%3DA%40mail.gmail.com Anyway, let's not mix apples and oranges for now. The GROUP BY issue is a bug worth fixing on its own. What you are pointing out with resjunk is the original behavior we have been relying on. If we finish by changing it, this should not and cannot be backpatched. I have expanded a bit the tests, with a couple of extra patterns, giving the attached. The behavior is the same as the pre-v17 branches. -- Michael
Commits
-
Fix query jumbling with GROUP BY clauses
- 9c3caad02640 18.2 landed
- e217dc7484e5 19 (unreleased) landed