From: Fujii Masao <fujii@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix parsing mode tracking when recycling datetime format cache e
Date: Fri, 20 Nov 2026 06:22:27 +0000
Message-ID: <E1xUI0w-00000000TnV-10Zy@gemulon.postgresql.org> (raw)
Fix parsing mode tracking when recycling datetime format cache entries
JSONPath datetime() could accept invalid format strings depending on
earlier datetime formatting operations in the same session. For example,
a format containing an unquoted "z" separator could be accepted after
to_char() had used it, although SQL/JSON standard mode prohibited it.
The cause was that DCH_cache_getnew() did not update the std flag when
recycling a cache entry. Since cache lookups matched both the format
string and std, a format parsed in one mode could be reused in the other.
Fix this by setting std when recycling an entry, as already done when
allocating a new one.
Backpatch to all supported versions.
Reported-by: Michael Malis <malis@pgrust.com>
Author: Andrey Rachitskiy <pl0h0yp1@gmail.com>
Reviewed-by: Aleksander Alekseev <aleksander@tigerdata.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/19594-5d9bdc019e3f7f6e@postgresql.org
Backpatch-through: 15
Branch
------
REL_19_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/68f4bb1d972ce5143bc587f0d542fc8a19fbbc50
Modified Files
--------------
src/backend/utils/adt/formatting.c | 1 +
src/test/regress/expected/jsonb_jsonpath.out | 22 ++++++++++++++++++++++
src/test/regress/sql/jsonb_jsonpath.sql | 12 ++++++++++++
3 files changed, 35 insertions(+)
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: fujii@postgresql.org
Subject: Re: pgsql: Fix parsing mode tracking when recycling datetime format cache e
In-Reply-To: <E1xUI0w-00000000TnV-10Zy@gemulon.postgresql.org>
References: <E1xUI0w-00000000TnV-10Zy@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox