Request for official clarification on SQL parameter parsing changes in PostgreSQL 15 and 16 - Mailing list pgsql-general

From 王 博
Subject Request for official clarification on SQL parameter parsing changes in PostgreSQL 15 and 16
Date
Msg-id TYCP286MB3620D4D19E3793CFA106CCBFB6BC2@TYCP286MB3620.JPNP286.PROD.OUTLOOK.COM
Whole thread Raw
Responses Re: Request for official clarification on SQL parameter parsing changes in PostgreSQL 15 and 16
Re: Request for official clarification on SQL parameter parsing changes in PostgreSQL 15 and 16
List pgsql-general

Hello PostgreSQL Community,

 

We have encountered unexpected SQL parsing errors during application upgrades from PostgreSQL 14 to 15 and 16, related to the use of JDBC-style parameter placeholders (`?`) in our legacy applications.

 

Specifically:

 

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.

   This did not cause an error in PostgreSQL 14.

 

2. In PostgreSQL 16:

   The following SQL causes a syntax error:

     SELECT * FROM table WHERE a = ?ORDER BY b;

   → This query runs in PostgreSQL 15, but causes an error in 16 unless a space is added after `?`.

 

We understand that this behavior may stem from changes to the parser to make it more strict and SQL-compliant. However, we were unable to find any explicit mention of these changes in the official release notes of PostgreSQL 15 or 16.

 

Our client is asking for official documentation or a statement confirming whether this behavior change was intentional and when it was introduced.

 

Could anyone kindly point us to:

- Relevant release note sections, commits, or discussions on this change

- Confirmation that these are intentional parser changes (and not regressions)

 

Any help or references would be greatly appreciated.

 

Best regards, 
Wang Bo

pgsql-general by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: Fwd: Identify system databases
Next
From: Dominique Devienne
Date:
Subject: Re: Request for official clarification on SQL parameter parsing changes in PostgreSQL 15 and 16