From 84d56c6bd37b06cb4b7d8f1d0772de84763b66fa Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 30 Jun 2026 15:04:23 +0200 Subject: [PATCH] Update GROUP BY ALL comments about window functions When GROUP BY ALL was added in commit ef38a4d9756, the SQL standard was silent on what to do with window functions. This has now been fixed in the SQL standard. Update the documentation and code comments about that. The PostgreSQL implementation was already doing the right thing. --- doc/src/sgml/ref/select.sgml | 3 ++- src/backend/parser/parse_clause.c | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/doc/src/sgml/ref/select.sgml b/doc/src/sgml/ref/select.sgml index 09b6ce809bb..3b60316ac31 100644 --- a/doc/src/sgml/ref/select.sgml +++ b/doc/src/sgml/ref/select.sgml @@ -862,7 +862,8 @@ <literal>GROUP BY</literal> Clause grouping_elements provided is equivalent to writing GROUP BY with the numbers of all SELECT output columns that do not - contain either an aggregate function or a window function. + contain either an aggregate function or a window function referring to the + same query level. diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c index 5fe5257b019..f08e7d4c4d1 100644 --- a/src/backend/parser/parse_clause.c +++ b/src/backend/parser/parse_clause.c @@ -2813,9 +2813,7 @@ transformGroupClause(ParseState *pstate, List *grouplist, bool groupByAll, /* * Likewise, TLEs containing window functions are not okay to add - * to GROUP BY. At this writing, the SQL standard is silent on - * what to do with them, but by analogy to aggregates we'll just - * skip them. + * to GROUP BY, and the SQL standard directs us to skip them. */ if (pstate->p_hasWindowFuncs && contain_windowfuncs((Node *) tle->expr)) -- 2.55.0