0001-Update-GROUP-BY-ALL-comments-about-window-functions.patch

text/plain

Filename: 0001-Update-GROUP-BY-ALL-comments-about-window-functions.patch
Type: text/plain
Part: 0
Message: Re: [PATCH] GROUP BY ALL

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch 0001
Subject: Update GROUP BY ALL comments about window functions
File+
doc/src/sgml/ref/select.sgml 2 1
src/backend/parser/parse_clause.c 1 3
From 84d56c6bd37b06cb4b7d8f1d0772de84763b66fa Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
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 @@ <title><literal>GROUP BY</literal> Clause</title>
     <replaceable class="parameter">grouping_elements</replaceable>
     provided is equivalent to writing <literal>GROUP BY</literal> with the
     numbers of all <command>SELECT</command> 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.
    </para>
 
    <para>
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