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: v1-0001-Make-jsonpath-input-report-out-of-range-numbers-s.patch
Description: Binary data

Reply via email to