Hi Joao, Thank you for testing the v3 patch and for the detailed feedback. I appreciate you checking both the invalid-key cases and the existing behavior, as well as running the regression tests on Linux.
Regards, Yeongjae Min On Sun, 15 Nov 2026 05:46:50 -0300, Joao Rito <[email protected]> wrote: Hi Yeongjae, Thanks for the patch. I tested v3 on current master (81b2179b492, built with cassert and tap tests) and it applies cleanly. On master, with a NULL key and a NULL value, JSON_OBJECT ... ABSENT ON NULL RETURNING json returns {} instead of an error. The same happens for an array key, a ROW key, and json and jsonb keys, with RETURNING json and jsonb, and for a domain over int[] with RETURNING json. A jsonb NULL key with a NULL value already fails on master ("argument 1: key must not be null"), so the NULL key problem is only in the json path. Two aggregate cases, json_object_agg_strict(ARRAY[1], NULL::text) and jsonb_object_agg_strict('{"a":1}'::jsonb, NULL::text), also returned an empty object on master. Dmitry already raised the aggregate case. I only confirm it on current master. With the patch all of these raise an error: "null value not allowed for object key" for the json path and "key value must be scalar, not array, composite, or json" for non-scalar keys. A composite key with a cast to json and a NULL value is now rejected, as it already was with a non-NULL value. A valid key with a NULL value is still omitted (tested with text, int, numeric, bool, timestamptz, name, bytea, int4range and enum keys). A NULL key with a non-NULL value still fails as on master. With WITH UNIQUE KEYS, duplicate keys with omitted values and a NULL key with a NULL value (json) give the same result as master. json_build_object, jsonb_build_object and json_object(text[]) also give the same output as master. The regress suite passes (243 subtests) and the server log has no TRAP or assertion lines. What I did not test: check-world, the isolation and tap suites, pgindent, the docs change and its build, the back branches, other platforms (I ran one Linux build), planning or performance effects, and a detailed read of the C code. I found no problem with the patch from what I could test. Regards, Joao Rito
