Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1v22TD-00FjNu-SP for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Sep 2025 07:02:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1v22TC-008WPD-HH for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Sep 2025 07:02:18 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1v22TB-008WP5-NL for pgsql-hackers@lists.postgresql.org; Fri, 26 Sep 2025 07:02:18 +0000 Received: from fout-b5-smtp.messagingengine.com ([202.12.124.148]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1v22T7-000AQM-31 for pgsql-hackers@postgresql.org; Fri, 26 Sep 2025 07:02:17 +0000 Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfout.stl.internal (Postfix) with ESMTP id 6DC0A1D0008E; Fri, 26 Sep 2025 03:02:11 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Fri, 26 Sep 2025 03:02:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eisentraut.org; h=cc:cc:content-transfer-encoding:content-type:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=fm1; t=1758870131; x=1758956531; bh=Aav2kVfQUe0k+JLJEcZsCCWh/5iGtk3u FicYM8c+Tu4=; b=VqZEkepD5NCg+TUJZWZBuNSveGq1mrQbkADNcpuOadOskY9p z70S2iGcllByr6QaOUSQ0WlqPI1H5cS/oHopDVW+0I2ARyhvFHVdZZ6lQtx5vLUF Wz7/MUrCXJdMXTTlqanCcWSiwkm1oQt31Q+LV0hOu9fkuqeA9ZMcCrRSAsje/9Jk Pm9EkrljxEz5a362I95ZtdMRw2izhgqUYggb/tSnDIn+7WHY3SK1E1xN56ZD4E87 7KBl+JZ/fq1DV/nellqb3ayHpnUtu+eYMVAx+VM+t3WWyuKHh/hCxqzgngZpJoBX zZmeWPA5VCI/iSJwGETvE0PmNh9P2LcR+AMeEw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1758870131; x= 1758956531; bh=Aav2kVfQUe0k+JLJEcZsCCWh/5iGtk3uFicYM8c+Tu4=; b=X Xo1uGftFPKWB2B4k7TCs1hLNY/yDLHTYmOoLXATc5J6ZOsMOYwFyVEtvdEW7TlOL RSzCWvUe+A9ZY638XuJ/fxQEJAVbCaK4IHt5aFf/C1gZtEpFHgActxgszEQITQG8 4KB0srdMV6aQBjS17XzRsBtlE5RuWCXat+XJS5ntuYQYkOju6EOasvWzNqO3BCND M/8OmF+zqMxhNxGPP2s6tIJeTFlpCiDucjv6M0/Xsje4Rb1YBLa/J+Ie1ya2XHqt moKNVOF1O2Rzc+SEJuOV4bkTGGftkauY37vB9gC+sSeKCymVgthhOsIMDlqnvRvz L9dIJOFtCIJTN0jY4h7bw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdeikeejvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenogfuuh hsphgvtghtffhomhgrihhnucdlgeelmdenucfjughrpefkffggfgfuvfevfhfhjggtgfes thejredttddvjeenucfhrhhomheprfgvthgvrhcugfhishgvnhhtrhgruhhtuceophgvth gvrhesvghishgvnhhtrhgruhhtrdhorhhgqeenucggtffrrghtthgvrhhnpeffkeefieek keehveeuheekjedvfeetieeghffhudejgeegfefgffetkefhgfffjeenucffohhmrghinh epughutghkuggsrdhorhhgpdgurghtrggsrhhitghkshdrtghomhdpshhnohiffhhlrghk vgdrtghomhdpfihorhguphhrvghsshdrtghomhenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpehpvghtvghrsegvihhsvghnthhrrghuthdrohhr ghdpnhgspghrtghpthhtohephedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepph hgshhqlhdqhhgrtghkvghrshesphhoshhtghhrvghsqhhlrdhorhhgpdhrtghpthhtohep thhglhesshhsshdrphhghhdrphgrrdhushdprhgtphhtthhopegurghvihgurdhgrdhjoh hhnhhsthhonhesghhmrghilhdrtghomhdprhgtphhtthhopegurghvihgusehpghhguhhr uhdrnhgvthdprhgtphhtthhopehpohhsthhgrhgvshesjhgvlhhtvghfrdhnlh X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 26 Sep 2025 03:02:09 -0400 (EDT) Message-ID: <634aca95-6db5-4beb-b18d-67e65582817f@eisentraut.org> Date: Fri, 26 Sep 2025 09:02:08 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] GROUP BY ALL To: pgsql-hackers Cc: Tom Lane , "David G. Johnston" , David Christensen , Jelte Fennema-Nio References: <931747.1721687375@sss.pgh.pa.us> Content-Language: en-US From: Peter Eisentraut In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 17.08.25 19:12, Jelte Fennema-Nio wrote: > On Tue, 23 Jul 2024 at 22:02, Peter Eisentraut wrote: >> Looks like the main existing implementations take it to mean all entries >> in the SELECT list that are not aggregate functions. >> >> https://duckdb.org/docs/sql/query_syntax/groupby.html#group-by-all >> https://docs.databricks.com/en/sql/language-manual/sql-ref-syntax-qry-select-groupby.html#parameters >> https://docs.snowflake.com/en/sql-reference/constructs/group-by#parameters > > Oracle added support for GROUP BY ALL too now: > https://danischnider.wordpress.com/2025/08/05/oracle-23-9-supports-group-by-all/ The proposal for GROUP BY ALL was accepted into the SQL standard draft yesterday. So maybe someone wants to take this up again. The initially proposed patch appears to have the right idea overall. But it does not handle more complex cases like SELECT a, SUM(b)+a FROM t1 GROUP BY ALL; correctly. The piece of code that does if (!IsA(n->expr,Aggref)) should be generalized to check for aggregates not only at the top level. (For explanation: GROUP BY ALL expands to all select list entries that do not contain aggregates. So the above would expand to SELECT a, SUM(b)+a FROM t1 GROUP BY a; which should then be rejected based on the existing rules.)