Re: BUG #19735: `jsonb_object_agg_unique_strict` drops a JSONB `null` value as if it were SQL NULL

From: Dmitry Dolgov <9erthalion6(at)gmail(dot)com>
To: shihao zhong <zhong950419(at)gmail(dot)com>
Cc: Álvaro Herrera <alvherre(at)kurilemu(dot)de>, Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-bugs(at)lists(dot)postgresql(dot)org, theshallow27(at)gmail(dot)com
Subject: Re: BUG #19735: `jsonb_object_agg_unique_strict` drops a JSONB `null` value as if it were SQL NULL
Date: 2026-10-08 08:09:26
Message-ID: asdM441VSWVzFNoJ@ddolgov-thinkpadt14sgen1.rmtde.csb
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Andrey Rachitskiy 2026-10-08 08:30:07 Re: PG18: use-after-free in exec partition pruning after an EPQ recheck in LockRows
Previous Message David Rowley 2026-10-08 08:08:38 Re: PG18: use-after-free in exec partition pruning after an EPQ recheck in LockRows