agora inbox for pgsql-committers@postgresql.org
help / color / mirror / Atom feedFrom: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix jsonpath .decimal() to honor silent mode
Date: Thu, 02 Jul 2026 03:44:55 +0000
Message-ID: <E1wf8MB-00121R-0x@gemulon.postgresql.org> (raw)
Fix jsonpath .decimal() to honor silent mode
The jsonpath .decimal(precision[, scale]) method built its numeric
typmod by calling numerictypmodin() through DirectFunctionCall1(), which
can throw a hard error for an incorrect set of precision and/or scale
vaulues. This breaks the silent mode supported by this function, that
should not fail.
Most of the jsonpath code uses the soft error reporting to bypass
errors, which is what this fix does by avoiding a direct use of
numerictypmodin(). Its code is refactored to use a new routine called
make_numeric_typmod_safe(), able to take an error context in input.
numerictypmodin() sets no context, mapping to its previous behavior.
The jsonpath code sets or not a context depending on the use of the
silent mode. This result leads to some nice simplifications:
numerictypmodin() feeds on an array, we can now pass directly values for
the scale and precision.
Oversight in 66ea94e8e606.
Author: Ewan Young <kdbase.hack@gmail.com>
Discussion: https://postgr.es/m/CAON2xHMaigKABiyPBBq3Sjd3gp7uWMJXnnMHt=s85V1ij3KP1w@mail.gmail.com
Backpatch-through: 17
Branch
------
REL_18_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/84001a04d552ffd00863a3a9f67f42fc8cb0b677
Modified Files
--------------
src/backend/utils/adt/jsonpath_exec.c | 24 ++++-----------
src/backend/utils/adt/numeric.c | 44 ++++++++++++++++------------
src/include/utils/numeric.h | 5 ++++
src/test/regress/expected/jsonb_jsonpath.out | 32 ++++++++++++++++++++
src/test/regress/sql/jsonb_jsonpath.sql | 7 +++++
5 files changed, 75 insertions(+), 37 deletions(-)
view thread (4+ messages) latest in thread
Message-ID: <E1wf8MB-00121R-0x@gemulon.postgresql.org>
Permalink: ../E1wf8MB-00121R-0x@gemulon.postgresql.org/
Also on: postgresql.org/message-id/E1wf8MB-00121R-0x@gemulon.postgresql.org
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: pgsql-committers@postgresql.org
Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Fix jsonpath .decimal() to honor silent mode
In-Reply-To: <E1wf8MB-00121R-0x@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 agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox