public inbox for [email protected]  
help / color / mirror / Atom feed
From: Tom Lane <[email protected]>
To: Laurenz Albe <[email protected]>
Cc: 王 博 <[email protected]>
Cc: [email protected] <[email protected]>
Cc: 李 浩 <[email protected]>
Subject: Re: Request for official clarification on SQL parameter parsing changes in PostgreSQL 15 and 16
Date: Thu, 17 Apr 2025 10:15:52 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <TYCP286MB3620D4D19E3793CFA106CCBFB6BC2@TYCP286MB3620.JPNP286.PROD.OUTLOOK.COM>
	<[email protected]>

Laurenz Albe <[email protected]> writes:
> On Thu, 2025-04-17 at 05:17 +0000, 王 博 wrote:
>> 1. In PostgreSQL 15 and later:
>>    The following SQL causes a syntax error unless a space is added after the `?`:
>>      SELECT * FROM table WHERE a = ?AND b = 123;
>>    → 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






view thread (2+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Request for official clarification on SQL parameter parsing changes in PostgreSQL 15 and 16
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox