Re: JumbleQuery ma treat different GROUP BY expr as the same

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Richard Guo <guofenglinux(at)gmail(dot)com>
Subject: Re: JumbleQuery ma treat different GROUP BY expr as the same
Date: 2026-01-13 07:09:46
Message-ID: aWXvug98FbHvp22H@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Attachment Content-Type Size
v2-0001-Fix-query-jumbling-computations-with-GROUP-BY-cla.patch text/x-diff 6.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2026-01-13 07:13:08 Re: [[BUG] pg_stat_statements crashes with var and non-var expressions in IN clause
Previous Message VASUKI M 2026-01-13 07:01:30 Re: [PATCH] tests: verify renamed index functionality in alter_table