| From: | Michael Paquier <michael(at)paquier(dot)xyz> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix jsonpath .decimal() to honor silent mode |
| Date: | 2026-07-02 03:44:55 |
| Message-ID: | E1wf8MB-00121R-0x@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
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(dot)hack(at)gmail(dot)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(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Amit Kapila | 2026-07-02 04:10:33 | pgsql: Expand comment on the slot recheck in drop_local_obsolete_slots( |
| Previous Message | Amit Kapila | 2026-07-02 03:24:46 | pgsql: pgindent fix for commit a5918fddf1. |