| From: | 민영재 <dudwo990413(at)gmail(dot)com> |
|---|---|
| To: | Joao Rito <joaovictor(dot)rito(at)gmail(dot)com> |
| Cc: | Dmitry Dolgov <9erthalion6(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, pgsql-bugs(at)lists(dot)postgresql(dot)org, theshallow27(at)gmail(dot)com |
| Subject: | Re: BUG #19736: `JSON_OBJECT ... ABSENT ON NULL` accepts invalid keys when the value is NULL |
| Date: | 2026-11-15 16:22:24 |
| Message-ID: | CAP=tSTDoD5=MiE2j3++sHM4b3FXemp1bcxGP9vYbopbZZn2niw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs pgsql-hackers |
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 <joaovictor(dot)rito(at)gmail(dot)com>
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | shveta malik | 2026-11-16 03:54:10 | Re: BUG #19864: pg_get_publication_tables() gets cache lookup error after concurrent DROP PUBLICATION |
| Previous Message | Zsolt Parragi | 2026-11-15 16:15:02 | Re: BUG #19897: Recovery fails after "LOG: consistent recovery state reached" |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jeevan Chalke | 2026-11-15 16:49:42 | Re: PL/pgSQL: apply the too_many_rows extra check to EXECUTE ... INTO |
| Previous Message | Alexander Korotkov | 2026-11-15 15:03:20 | Re: test: avoid redundant standby catchup in 049_wait_for_lsn |