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 1qi1hJ-004zA8-6H for pgsql-bugs@arkaria.postgresql.org; Mon, 18 Sep 2023 00:01:05 +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 1qi1hH-00DS8G-7q for pgsql-bugs@arkaria.postgresql.org; Mon, 18 Sep 2023 00:01:03 +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 1qi1hG-00DS81-Um for pgsql-bugs@lists.postgresql.org; Mon, 18 Sep 2023 00:01:02 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qi1hE-005my5-1v for pgsql-bugs@lists.postgresql.org; Mon, 18 Sep 2023 00:01:02 +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 38I00tll4153026; Sun, 17 Sep 2023 20:00:56 -0400 From: Tom Lane To: David Rowley cc: John Naylor , 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: <837886.1693252560@sss.pgh.pa.us> <894521.1693270957@sss.pgh.pa.us> Comments: In-reply-to David Rowley message dated "Mon, 18 Sep 2023 11:36:42 +1200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4153024.1694995255.1@sss.pgh.pa.us> Date: Sun, 17 Sep 2023 20:00:55 -0400 Message-ID: <4153025.1694995255@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley writes: > 2. In master only, remove the special case added in #1 and allow any > non-integer constants to be treated as expressions. > I think #2 is a good move for the following reasons: FTR, I still think this is a bad idea. It will add more confusion than it removes, and I don't buy that it will confer any advantages, because nobody asked for it previously. However, assuming that I'm going to be out-voted: your docs changes still need work. That phrasing makes it sound like an output column name could be "expressed as an integer literal". Maybe we should restructure the whole sentence, perhaps along the lines of ... class="parameter">expression used inside a grouping_element can be an input column name or an arbitrary expression formed from input column values. For backwards compatibility with SQL-92, the expression can also be an output column name or an integer literal representing the ordinal number of an output column. In case of ambiguity, a GROUP BY item that is just a name will be interpreted as an input column name rather than an output column name. Neither formulation addresses the case of non-integer literals head on. I'm not quite sure if it's worth adding another sentence to do so. regards, tom lane