From: Daniel Gustafsson <daniel@yesql.se>
To: Chao Li <li.evan.chao@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Subject: Re: Fix GROUP BY ALL handling of ORDER BY operator semantics
Date: Mon, 13 Jul 2026 22:10:22 +0200
Message-ID: <A0B7C417-5710-47B3-8FA2-C0DDA518DA07@yesql.se> (raw)
In-Reply-To: <5243308F-8E5C-45AA-828C-FAD96C4F34DA@gmail.com>
References: <5243308F-8E5C-45AA-828C-FAD96C4F34DA@gmail.com>
> On 29 Jun 2026, at 09:20, Chao Li <li.evan.chao@gmail.com> wrote:
> The fix mostly refactors the existing logic so the GROUP BY ALL path also handles the ORDER BY sort clause. See the attached patch for details.
Thanks for the report and the patch, I am going to study it a bit more but I
have a few small comments on the patch.
+/*
+ * Add a targetlist entry to the GROUP BY list, copying matching ORDER BY
+ * operator information if available.
+ */
This comment is a bit light for such an important routine. The foreach has a
really great comment, I think we should move some (most?) of it to the function
comment.
- *flatresult = lappend(*flatresult, grpc);
+ grouplist = lappend(grouplist, grpc);
found = true;
break;
Now that we are in an external function, we could just return grouplist here
instead of breaking with a flag. The code outside the foreach can then call
addTargetToGroupList directly since we know that if we reach thus far there was
no match.
--
Daniel Gustafsson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: daniel@yesql.se, li.evan.chao@gmail.com, tgl@sss.pgh.pa.us
Subject: Re: Fix GROUP BY ALL handling of ORDER BY operator semantics
In-Reply-To: <A0B7C417-5710-47B3-8FA2-C0DDA518DA07@yesql.se>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox