agora inbox for pgsql-committers@postgresql.orghelp / color / mirror / Atom feed
pgsql: Fix jsonpath .decimal() to honor silent mode 4+ messages / 1 participants [nested] [flat]
* pgsql: Fix jsonpath .decimal() to honor silent mode @ 2026-07-02 03:44 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 4+ messages in thread From: Michael Paquier @ 2026-07-02 03:44 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 ------ master Details ------- https://git.postgresql.org/pg/commitdiff/7b12ae729e6a838c269e133cd740ad39a686ec9f Modified Files -------------- src/backend/utils/adt/jsonpath_exec.c | 26 +++++----------- src/backend/utils/adt/numeric.c | 44 ++++++++++++++++------------ src/include/utils/numeric.h | 2 ++ src/test/regress/expected/jsonb_jsonpath.out | 32 ++++++++++++++++++++ src/test/regress/sql/jsonb_jsonpath.sql | 7 +++++ 5 files changed, 73 insertions(+), 38 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix jsonpath .decimal() to honor silent mode @ 2026-07-02 03:44 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 4+ messages in thread From: Michael Paquier @ 2026-07-02 03:44 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/5bbc9b3000a50b4278ddd449ecea0fd7c3d91686 Modified Files -------------- src/backend/utils/adt/jsonpath_exec.c | 26 +++++----------- src/backend/utils/adt/numeric.c | 44 ++++++++++++++++------------ src/include/utils/numeric.h | 2 ++ src/test/regress/expected/jsonb_jsonpath.out | 32 ++++++++++++++++++++ src/test/regress/sql/jsonb_jsonpath.sql | 7 +++++ 5 files changed, 73 insertions(+), 38 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix jsonpath .decimal() to honor silent mode @ 2026-07-02 03:44 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 4+ messages in thread From: Michael Paquier @ 2026-07-02 03:44 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix jsonpath .decimal() to honor silent mode @ 2026-07-02 03:44 Michael Paquier <michael@paquier.xyz> 0 siblings, 0 replies; 4+ messages in thread From: Michael Paquier @ 2026-07-02 03:44 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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_17_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/ab35b8d2528641efd4b23111874665c92e7f6b65 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(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2026-07-02 03:44 UTC | newest] Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-07-02 03:44 pgsql: Fix jsonpath .decimal() to honor silent mode Michael Paquier <michael@paquier.xyz> 2026-07-02 03:44 pgsql: Fix jsonpath .decimal() to honor silent mode Michael Paquier <michael@paquier.xyz> 2026-07-02 03:44 pgsql: Fix jsonpath .decimal() to honor silent mode Michael Paquier <michael@paquier.xyz> 2026-07-02 03:44 pgsql: Fix jsonpath .decimal() to honor silent mode Michael Paquier <michael@paquier.xyz>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox