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 1qaiLO-00AC1e-UW for pgsql-bugs@arkaria.postgresql.org; Mon, 28 Aug 2023 19:56:14 +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 1qaiLM-00FJDp-9W for pgsql-bugs@arkaria.postgresql.org; Mon, 28 Aug 2023 19:56:12 +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 1qaiLM-00FJDb-0K for pgsql-bugs@lists.postgresql.org; Mon, 28 Aug 2023 19:56:11 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qaiLE-001TGt-Ed for pgsql-bugs@lists.postgresql.org; Mon, 28 Aug 2023 19:56:10 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 37SJu0Zw837887; Mon, 28 Aug 2023 15:56:00 -0400 From: Tom Lane To: John Naylor cc: David Micallef , Peter Eisentraut , pgsql-bugs@lists.postgresql.org Subject: Re: group by true now errors with non-integer constant in GROUP BY In-reply-to: References: Comments: In-reply-to John Naylor message dated "Mon, 28 Aug 2023 16:24:32 +0700" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <837885.1693252560.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 28 Aug 2023 15:56:00 -0400 Message-ID: <837886.1693252560@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk John Naylor writes: > On Mon, Aug 28, 2023 at 1:28=E2=80=AFPM David Micallef > wrote: >> ERROR: non-integer constant in GROUP BY > I can confirm the reproducer script fails with commit 941460fcf731a ("Ad= d > Boolean node"). (So actually all 15.x were affected.) Yeah, same result from bisecting here. I had had the idea that this was an intentional semantics change to reduce the probability of error, but that commit didn't mention any such thing, so that's a tough claim to make as far as the historical intent goes. Having said that ... it seems to me that it was pure coincidence that "group by true" worked before, and I'm not sure we should install a grotty hack to make it work again. In particular, why should we allow Boolean Consts but not other non-integer Consts? (And if we do, don't we need to change that error message?) The bigger picture here is: what is the use-case for grouping by a constant at all? Assuming that it is an error seems like a good foolproofing restriction. The reason we felt we could keep the "group by N" SQL92-ism after SQL99 redefined GROUP BY arguments is exactly that there's no obvious use-case for grouping by a constant. As soon as you allow it, "group by N" becomes hopelessly ambiguous. So my druthers would be to reject this as a non-bug. But if we accept it as something to fix, we need to revisit exactly which conditions are errors here. Perhaps rather than "reject all non-integer cases", we should only reject the Float case, and let others fall through to the SQL99 code. (I would not be happy allowing Float, because that'd mean that "group by 4" and "group by 4.0" mean fundamentally different things.) regards, tom lane