Skip to content

Commit 7504d2b

Browse files
committed
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 be45be9 which added the groupDistinct field, but I think much of the blame has to fall on c9d5298, 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 <[email protected]> Discussion: https://postgr.es/m/[email protected] Backpatch-through: 14
1 parent 59c2f03 commit 7504d2b

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/backend/parser/analyze.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2935,6 +2935,7 @@ transformPLAssignStmt(ParseState *pstate, PLAssignStmt *stmt)
29352935
qry->sortClause,
29362936
EXPR_KIND_GROUP_BY,
29372937
false /* allow SQL92 rules */ );
2938+
qry->groupDistinct = sstmt->groupDistinct;
29382939

29392940
if (sstmt->distinctClause == NIL)
29402941
{

0 commit comments

Comments
 (0)