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 1v2Ake-0012Rf-Ap for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Sep 2025 15:52:52 +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 1v2Akc-003QmZ-9r for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Sep 2025 15:52:50 +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 1v2Akc-003QmR-0n for pgsql-hackers@lists.postgresql.org; Fri, 26 Sep 2025 15:52:50 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v2Aka-000FW1-24 for pgsql-hackers@postgresql.org; Fri, 26 Sep 2025 15:52:50 +0000 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-b28e1b87aa7so314105166b.3 for ; Fri, 26 Sep 2025 08:52:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pgguru-net.20230601.gappssmtp.com; s=20230601; t=1758901967; x=1759506767; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=LL9cfGnZ578PaxvzcypinUNrFd3XW1PU+fG6Ami7FWM=; b=YN30YukRwSS/Kwob5MBYsYjdNIlAIvuM6hIHd/z9XPTuXRhq54BWbNlj+SmqRilZd+ gNWqPl8Cq+dxK9bosg98MPYkCmleO9355wLhHowzTLVL5A1p6X8Plo9EeeGtt+ysbyqi n03Hr5YoGXQ/HynPFhBDGSb9HIDh297e/uTlIyZX8tmdbGa5/udn/6t8aKNciGx7YTEL RuFC1jFDh+9k++pEJul27NRr95r069V+EkckD0ov6h1843G0a0CFJFsqwyeRNL22CXrl e2EbEo1qYrk+5HxJn+xH9kUG91p+J1oPXjXxyf5gWWlPFtYKFxaNsQpXTC8RDe7Hvgk4 P2ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758901967; x=1759506767; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LL9cfGnZ578PaxvzcypinUNrFd3XW1PU+fG6Ami7FWM=; b=M1U2pxxvpcCSUffKKTXWck8herI4+UgI8bivjDev6KtkSKYOvZ9rRuyw/6yZ0FYZpj WAmONIzSdVlsqohqirtm1mTUPGBTRppVfa+gX7ROirce0lj9BjtKxid1XE61HAUbndEu A/ZeKv53BAg4RlbECLo6frfsJ+mo6RQJoPw81FgJrqg5RMs967fW9M5a06Q98BFxqopI zxpqWiTmemEaSRHSwgb/DuDvi+Kat1vJpXyXSsKrFIYSOilUI+N/1FhRdLrMYIxxE7xX De9ctvmyswWy06wa/f5FzjAxx3nWtZhdi1KztDBN54xxvsLw2I0n//IXb32P+f6RpEaH tr2w== X-Forwarded-Encrypted: i=1; AJvYcCUkhgTIGXwVGO4FKIC+C/VCsQt7NSTLBdUIHmdKZGUwd0ImnuhycMe+u8pKpuTvBHAs4M5uJO8gZs+2otNf@postgresql.org X-Gm-Message-State: AOJu0Yyy3Rqytb2R9ImKp53T4S7QTzhE7U0rVdHhZfnXSpTTCrW0ovfT ei5/SEysX4PxbDkkeiZwdSNaQEHNZBIk6EUx8697o6znqoO0r6vTzFCmShf963t3oAwV+QLFvTD XQCzA0cGJl+krqWsvBuswVpvTbA7gNf55U192LFXbwIq21C2krxV06+0= X-Gm-Gg: ASbGnctDJmh5y0CnXkRUXjvnmKIdL743lVzu4ST3SBR/WMpVHxhIT3ow1lpVVbArrSo igWKFtnXBOjUynA089ArjzuQb4VWvd2P91yA4MxC3xyZ+Jk1tDsBzR+8aJ4BE/M+ztZdMGZMjQ+ Xg2EKe39eUyXIN3CtOmE/WtH0Dx8uvahqtxjWtMs08bPdvnyjkrOG8H1wv0ALbEKytL6DQqTVz4 NB/zghrrM7NbgwSCtjJ3PVeWkSPhQn16HRzUQxuiA== X-Google-Smtp-Source: AGHT+IHSLBbGnQ8TJMYJlgHBbadRx4pd5DWQBAvVrxnDAau83pIFqSA3bRpTZnjpT7EsJO/eJeSgZUajmYfatS60bSs= X-Received: by 2002:a17:907:72d3:b0:b34:4469:aef with SMTP id a640c23a62f3a-b34bf9574b9mr963817366b.57.1758901967339; Fri, 26 Sep 2025 08:52:47 -0700 (PDT) MIME-Version: 1.0 References: <931747.1721687375@sss.pgh.pa.us> <634aca95-6db5-4beb-b18d-67e65582817f@eisentraut.org> <4054709.1758895915@sss.pgh.pa.us> In-Reply-To: <4054709.1758895915@sss.pgh.pa.us> From: David Christensen Date: Fri, 26 Sep 2025 10:52:36 -0500 X-Gm-Features: AS18NWCkMDixPUefwMN-HSr4Z4WS7BldzNfiSYSKlO6qfmxIKaKg_J-ujgeKk6A Message-ID: Subject: Re: [PATCH] GROUP BY ALL To: Tom Lane Cc: Peter Eisentraut , pgsql-hackers , "David G. Johnston" , Jelte Fennema-Nio Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Sep 26, 2025 at 9:12=E2=80=AFAM 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=3D# create table t1 (a int, b int); > CREATE TABLE > regression=3D# SELECT a, SUM(b)+a FROM t1 GROUP BY a; > a | ?column? > ---+---------- > (0 rows) Agreed that this shouldn't be an error; added a similar test case to v2 of this patch. David