Re: Fix jsonpath .decimal() to honor silent mode
Ewan Young <kdbase.hack@gmail.com>
From: Ewan Young <kdbase.hack@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
Chao Li <li.evan.chao@gmail.com>
Date: 2026-07-01T12:32:05Z
Lists: pgsql-hackers
Attachments
- v2-0001-Fix-jsonpath-decimal-to-honor-silent-mode.patch (application/octet-stream) patch v2-0001
On Wed, Jul 1, 2026 at 6:31 PM Michael Paquier <michael@paquier.xyz> wrote: > > On Wed, Jul 01, 2026 at 03:52:51PM +0800, Ewan Young wrote: > > If reviewers would rather push the ErrorSaveContext down into > > numerictypmodin() (or a shared helper) > > instead of pre-validating in the caller, I'm happy to reshape it that way. > > My first impression while looking at your patch and the surroundings > of numeric.c is that we should do exactly that, and feed from the > error message received from the new function to which an escontext is > given. That would save in extra error messages (why not just reuse > the same errstrings in this case?), and we could rely on > error_occurred for the detection. Agreed, that's nicer -- v2 attached does it that way. I split numerictypmodin()'s range checks and typmod packing into a new make_numeric_typmod_safe(precision, scale, escontext) in numeric.c. It reports an out-of-range precision or scale through the escontext and returns -1, or throws when escontext is NULL. - numerictypmodin() calls it with a NULL escontext, so its behavior and error messages are unchanged. - .decimal() calls it with its own ErrorSaveContext when not throwing errors (jspThrowErrors(cxt) ? NULL : &escontext) and relies on error_occurred. So there are no new message strings, and in the throwing case the same "NUMERIC precision N must be between 1 and 1000" is raised as before. As a side effect .decimal() no longer needs to build a cstring array to reach numerictypmodin(). Thanks for the review. > -- > Michael -- Regards, Ewan Young
Commits
-
Fix redefinition of typedef Node in numeric.h
- c768637d6c29 17 (unreleased) landed
- 90789900b84a 18 (unreleased) landed
-
Fix jsonpath .decimal() to honor silent mode
- ab35b8d25286 17 (unreleased) landed
- 84001a04d552 18 (unreleased) landed
- 5bbc9b3000a5 19 (unreleased) landed
- 7b12ae729e6a master landed