Hi hackers,
The jsonpath string method .split_part() bypasses lax-mode error suppression.
This is because executeStringInternalMethod() uses DirectFunctionCall1(numeric_int4, ...)
to convert the field number from numeric to int4. This throws ereport(ERROR) directly,
bypassing the jspThrowErrors(cxt) / RETURN_ERROR mechanism that other methods
like .double() use correctly.
Reproduction:
-- These should return NULL in lax mode, but throw hard ERRORs:
SELECT '"hello-world"'::jsonb @? '$.split_part("-", 99999999999)';
SELECT '"hello-world"'::jsonb @? '$.split_part("-", 0)';
ERROR: integer out of range
ERROR: field position must not be zero
Fix by replacing the bare DirectFunctionCall with numeric_int4_safe()
using ErrorSaveContext to catch overflow, and adding an explicit field==0
check, both gated behind RETURN_ERROR so errors are properly suppressed
in lax/silent mode while still raised in strict/non-silent mode.
Thanks,
Satya