Re: BUG #19735: `jsonb_object_agg_unique_strict` drops a JSONB `null` value as if it were SQL NULL - Mailing list pgsql-bugs

From Dmitry Dolgov
Subject Re: BUG #19735: `jsonb_object_agg_unique_strict` drops a JSONB `null` value as if it were SQL NULL
Date
Msg-id asdM441VSWVzFNoJ@ddolgov-thinkpadt14sgen1.rmtde.csb
Whole thread
In response to Re: BUG #19735: `jsonb_object_agg_unique_strict` drops a JSONB `null` value as if it were SQL NULL  (shihao zhong <zhong950419@gmail.com>)
Responses Re: BUG #19735: `jsonb_object_agg_unique_strict` drops a JSONB `null` value as if it were SQL NULL
List pgsql-bugs
> On Wed, Oct 07, 2026 at 10:30:48PM -0400, shihao zhong wrote:
> Hi Dmitry,
> 
> I agree the docs should say which nulls are meant.
> 
> I am not sure it was intended though. The jsonb array functions keep
> a JSON null

This is the one difference from most of the other functions,
jsonb_agg_transfn_worker for some reason does not set skip_nulls, even
though it has absent_on_null available. jsonb_object_agg_transfn_worker
does it like:

    result->parseState->skip_nulls = absent_on_null;

I presume jsonb_agg_transfn_worker have to be unified with the others.

> , and JSON_OBJECT() drops the key only with RETURNING jsonb:

From what I see it drops nulls due to ABSENT ON NULL, e.g. ABSENT ON
NULL WITHOUT UNIQUE KEYS will do the same. Otherwise ditto,
jsonb_build_object_worker sets skip_nulls like above if ABSENT ON NULL
is specified. 

> Skipping only SQL NULLs needs no check per element in jsonb, the
> caller knows which values it skipped.

I mean to check per every element in the to be aggregated set.



pgsql-bugs by date:

Previous
From: David Rowley
Date:
Subject: Re: PG18: use-after-free in exec partition pruning after an EPQ recheck in LockRows
Next
From: Andrey Rachitskiy
Date:
Subject: Re: PG18: use-after-free in exec partition pruning after an EPQ recheck in LockRows