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 1s6ZH4-000NUm-Jz for pgsql-hackers@arkaria.postgresql.org; Mon, 13 May 2024 17:15:44 +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 1s6ZG5-002gyN-UU for pgsql-hackers@arkaria.postgresql.org; Mon, 13 May 2024 17:14:41 +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 1s6ZG5-002gyF-Kx for pgsql-hackers@lists.postgresql.org; Mon, 13 May 2024 17:14:41 +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 1s6ZG2-0001ud-Or for pgsql-hackers@postgresql.org; Mon, 13 May 2024 17:14:40 +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 44DHEZsU762526; Mon, 13 May 2024 13:14:35 -0400 From: Tom Lane To: =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= cc: Matthias van de Meent , Artur Formella , pgsql-hackers@postgresql.org Subject: Re: Allowing additional commas between columns, and at the end of the SELECT clause In-reply-to: <877cfxhdpd.fsf@wibble.ilmari.org> References: <0368c60f-abe2-4f5f-972d-7cd1e6db2382@gmail.com> <87bk59hp5o.fsf@wibble.ilmari.org> <738732.1715609494@sss.pgh.pa.us> <877cfxhdpd.fsf@wibble.ilmari.org> Comments: In-reply-to =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= message dated "Mon, 13 May 2024 17:35:42 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <762524.1715620475.1@sss.pgh.pa.us> Date: Mon, 13 May 2024 13:14:35 -0400 Message-ID: <762525.1715620475@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= writes: > Tom Lane writes: >> I'm fairly down on this idea for SQL, because I think it creates >> ambiguity for the ROW() constructor syntax. That is: >> (x,y) is understood to be shorthand for ROW(x,y) >> (x) is not ROW(x), it's just x >> (x,) means what? > Python has a similar issue: (x, y) is a tuple, but (x) is just x, and > they use the trailing comma to disambiguate, so (x,) creates a > single-item tuple. AFAIK it's the only place where the trailing comma > is significant. Ugh :-(. The semantic principle I'd prefer to have here is "a trailing comma is ignored", but what they did breaks that. But then again, I'm not particularly a fan of anything about Python's syntax. > Yeah, a more principled approach would be to not special-case target > lists, but to allow one (and only one) trailing comma everywhere: > select, order by, group by, array constructors, row constructors, > everything that looks like a function call, etc. If it can be made to work everywhere, that would get my vote. I'm not sure if any other ambiguities arise, though. SQL has a lot of weird syntax corners (and the committee keeps adding more :-(). regards, tom lane