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 1u5Q2B-00HZoj-BX for pgsql-general@arkaria.postgresql.org; Thu, 17 Apr 2025 14:16:07 +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 1u5Q28-0094F8-5g for pgsql-general@arkaria.postgresql.org; Thu, 17 Apr 2025 14:16:05 +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 1u5Q27-0094DO-Qm for pgsql-general@lists.postgresql.org; Thu, 17 Apr 2025 14:16:04 +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.96) (envelope-from ) id 1u5Q24-000a4d-2w for pgsql-general@lists.postgresql.org; Thu, 17 Apr 2025 14:16:04 +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 53HEFqKU2194847; Thu, 17 Apr 2025 10:15:52 -0400 From: Tom Lane To: Laurenz Albe cc: =?UTF-8?Q?=E7=8E=8B=E3=80=80=E5=8D=9A?= , "pgsql-general@lists.postgresql.org" , =?UTF-8?Q?=E6=9D=8E=E3=80=80=E6=B5=A9?= Subject: Re: Request for official clarification on SQL parameter parsing changes in PostgreSQL 15 and 16 In-reply-to: <237d58a65d887376ded17a67e7b99af5936fa9a3.camel@cybertec.at> References: <237d58a65d887376ded17a67e7b99af5936fa9a3.camel@cybertec.at> Comments: In-reply-to Laurenz Albe message dated "Thu, 17 Apr 2025 15:41:19 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <2194845.1744899352.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 17 Apr 2025 10:15:52 -0400 Message-ID: <2194846.1744899352@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Laurenz Albe writes: > On Thu, 2025-04-17 at 05:17 +0000, =E7=8E=8B=E3=80=80=E5=8D=9A wrote: >> 1. In PostgreSQL 15 and later: >> =C2=A0=C2=A0 The following SQL causes a syntax error unless a space is = added after the `?`: >> =C2=A0=C2=A0=C2=A0=C2=A0 SELECT * FROM table WHERE a =3D ?AND b =3D 123= ; >> =C2=A0=C2=A0 =E2=86=92 Adding a space (`? AND`) resolves the issue. > I'd say it is this change: > https://postgr.es/c/2549f0661bd28571d7200d6f82f752a7ee5d47e1 Yeah. This looks like "?" ought to be parsable as a separate token ... but as Dominique noted, it's not actually legal syntax in any version of Postgres. Something in your client stack must be translating "?" to "$1", "$2", etc, and so the new prohibition against junk trailing a number applies. You could fix this without application-level changes if you fixed whatever is making that substitution to add spaces around the parameter symbol. It's really a bug that it didn't do so already, since closely-adjacent cases like digits immediately after the "?" would already have caused failures. regards, tom lane