| From: | Ishjaap Singh <ishjaap(dot)singh07(at)gmail(dot)com> |
|---|---|
| To: | pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Make jsonpath input report out-of-range numbers softly |
| Date: | 2026-11-24 14:28:25 |
| Message-ID: | CA+Y2BmeZnC1v4DpxOcrcsTL0uar+FSgf+RhsQS6VKRpgo4SETA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi hackers,
jsonpath input reports most bad input softly, but a number that's too
big still raises a hard error:
SELECT pg_input_is_valid('1e1000000', 'jsonpath');
ERROR: value overflows numeric format
SELECT pg_input_is_valid('$.**{2147483648}', 'jsonpath');
ERROR: value "2147483648" is out of range for type integer
Both should return false. On 17 and later, COPY ... (ON_ERROR ignore)
into a jsonpath column stops at such a line instead of skipping it.
The attached patch makes makeItemNumeric() use
DirectInputFunctionCallSafe() and the .**{} bounds use
pg_strtoint32_safe(), and aborts the parse when they fail, like the
like_regex rule already does. Plain casts still raise the same errors.
The new tests in jsonpath.sql fail without the code change, and make
check passes.
The recent .split_part() and .decimal() fixes (954e57708ea,
7b12ae729e6) did the same for errors raised while a path runs. I could
not find a posted fix for this one.
The patch is against master and also applies to REL_19. REL_16 to
REL_18 need small grammar changes; I can send versions for those if
it's going to be back-patched.
Regards,
Ishjaap Singh
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Make-jsonpath-input-report-out-of-range-numbers-s.patch | application/octet-stream | 8.1 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David Geier | 2026-11-24 14:32:45 | Re: Numeric equality and hashing without detoasting |
| Previous Message | Manu | 2026-11-24 14:02:58 | Re: REINDEX CONCURRENTLY reports lockers_done > lockers_total |