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 1v2AmA-0012e4-Qx for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Sep 2025 15:54:27 +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 1v2Am8-003THB-OC for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Sep 2025 15:54:25 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1v2Am7-003TH3-Tx for pgsql-hackers@lists.postgresql.org; Fri, 26 Sep 2025 15:54:25 +0000 Received: from fhigh-b2-smtp.messagingengine.com ([202.12.124.153]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1v2Am5-0003Pp-3B for pgsql-hackers@postgresql.org; Fri, 26 Sep 2025 15:54:23 +0000 Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfhigh.stl.internal (Postfix) with ESMTP id 3C2547A0160; Fri, 26 Sep 2025 11:54:21 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Fri, 26 Sep 2025 11:54:21 -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=1758902061; x=1758988461; bh=rGb4fcPAhrERJ8tyP6sDlBym67J0WivU AvnVhO1G2+o=; b=GEKb6TgYbxZS67XNi3QGp+GyRbo72OHIGw/oTLvnkSaZ5FOF CkXqTShBjCqhT3Lxoj+03JOTejxWdkmolc+ch0z+bTEen6GL6kU1pP6EZP07K+Q0 oCfcM5AT7L9qF2kR1Ccs5bTmuMQjj4BIRVMU39IRu8qjuIvDbjOSwEagbobQ74hF 6sgG9n6PeipCWZ0V5uO2mX5mjRBrRibBrsINqlAU/6QOKMgN4B+ZcVI8BeDsbLUX z5t+gQnzmspzCmiMzppmIOa3XNLtdts6e5NoBhl0To3mLbT+zlFaTze0u1cjRHib LmDDHCubItKUPyXNCr/a46UWLwjek1xRu+LZzA== 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=1758902061; x= 1758988461; bh=rGb4fcPAhrERJ8tyP6sDlBym67J0WivUAvnVhO1G2+o=; b=K o+wTfH7AWxaKYH4lMm6NOFdO4n57VJVwo91G41/GL0L+i6zqk4IOEJQBi4KQqVoM PlTdSsB5hkjTJDj2zC+T8HGfogOQmOw13Qld8e+eGtsx9tvUJBemxujgbGtoHM8N XWvrSXpZiuT6eqZpQaXxogWJDxkAMv0a6xPL9vMj6Zp/UMVQ/dL3u1PVIm0z5YBX usjD6LwS96y/ZChMQyvACdsNayyWIATAMUrIMCfP7Xp9KWBfOkuiXHKd2jm2bGPa cTTYtqyr8zDPBz17Ws+6OppcdkrG7JMhsr3w97jsYq8uVJ1HNvcBlPfZ0NtagqzL 4V+KL6yeL5IRdCQnwlGrQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdeileejkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefkffggfgfuvfevfhfhjggtgfesthejredttddvjeenucfhrhhomheprfgvthgvrhcu gfhishgvnhhtrhgruhhtuceophgvthgvrhesvghishgvnhhtrhgruhhtrdhorhhgqeenuc ggtffrrghtthgvrhhnpefgjedthfekfedtuefgieelheetleejgefhueeltdfhueetvdff udekfeejhfegheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehpvghtvghrsegvihhsvghnthhrrghuthdrohhrghdpnhgspghrtghpthhtohep hedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepthhglhesshhsshdrphhghhdrph grrdhushdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehpohhsthhgrhgvshhq lhdrohhrghdprhgtphhtthhopegurghvihgurdhgrdhjohhhnhhsthhonhesghhmrghilh drtghomhdprhgtphhtthhopegurghvihgusehpghhguhhruhdrnhgvthdprhgtphhtthho pehpohhsthhgrhgvshesjhgvlhhtvghfrdhnlh X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 26 Sep 2025 11:54:19 -0400 (EDT) Message-ID: <3d01eb20-d587-4dec-9261-0c92240ce546@eisentraut.org> Date: Fri, 26 Sep 2025 17:54:18 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] GROUP BY ALL To: Tom Lane Cc: pgsql-hackers , "David G. Johnston" , David Christensen , Jelte Fennema-Nio References: <931747.1721687375@sss.pgh.pa.us> <634aca95-6db5-4beb-b18d-67e65582817f@eisentraut.org> <4054709.1758895915@sss.pgh.pa.us> Content-Language: en-US From: Peter Eisentraut In-Reply-To: <4054709.1758895915@sss.pgh.pa.us> 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 26.09.25 16:11, Tom Lane wrote: > Peter Eisentraut writes: >> 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; > >> (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.) > > I thought I understood this definition, up till your last > comment. What's invalid about that expanded query? > > regression=# create table t1 (a int, b int); > CREATE TABLE > regression=# SELECT a, SUM(b)+a FROM t1 GROUP BY a; > a | ?column? > ---+---------- > (0 rows) This was a sloppy example. Here is a better one: create table t1 (a int, b int, c int); select a, sum(b)+c from t1 group by all; This is equivalent to select a, sum(b)+c from t1 group by a; which would be rejected as ERROR: column "t1.c" must appear in the GROUP BY clause or be used in an aggregate function