summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2025-09-27 14:29:41 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2025-09-27 14:29:41 -0400
commit7504d2be9eb45207b48476919e4539d93c389d86 (patch)
treec77fccbb2f67d5d5b70f1ce782549b3e5fe2fa00
parent59c2f03d1ece7b9b215751a508b3a84728419246 (diff)
Fix missed copying of groupDistinct in transformPLAssignStmt.
Because we failed to do this, DISTINCT in GROUP BY DISTINCT would be ignored in PL/pgSQL assignment statements. It's not surprising that no one noticed, since such statements will throw an error if the query produces more than one row. That eliminates most scenarios where advanced forms of GROUP BY could be useful, and indeed makes it hard even to find a simple test case. Nonetheless it's wrong. This is directly the fault of be45be9c3 which added the groupDistinct field, but I think much of the blame has to fall on c9d529848, in which I incautiously supposed that we'd manage to keep two copies of a big chunk of parse-analysis logic in sync. As a follow-up, I plan to refactor so that there's only one copy. But that seems useful only in master, so let's use this one-line fix for the back branches. Author: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/31027.1758919078@sss.pgh.pa.us Backpatch-through: 14
-rw-r--r--src/backend/parser/analyze.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c
index b9763ea1714..70c6295ccd1 100644
--- a/src/backend/parser/analyze.c
+++ b/src/backend/parser/analyze.c
@@ -2935,6 +2935,7 @@ transformPLAssignStmt(ParseState *pstate, PLAssignStmt *stmt)
qry->sortClause,
EXPR_KIND_GROUP_BY,
false /* allow SQL92 rules */ );
+ qry->groupDistinct = sstmt->groupDistinct;
if (sstmt->distinctClause == NIL)
{