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

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: Dmitry Dolgov <9erthalion6(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-09 03:30:12
Message-ID: CAGRkXqS5E2exQ4qoRedcDNvshPG4uff3rNu46b9+Mt2o-bSe-Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi Dmitry,

> I presume jsonb_agg_transfn_worker have to be unified with the others.

I don't think the array code forgot it. skip_nulls is only used when
an object is finished, in uniqueifyJsonbObject(). Arrays never get
there, so setting it in jsonb_agg_transfn_worker() would change
nothing.

> From what I see it drops nulls due to ABSENT ON NULL

Right, ABSENT ON NULL is what drops it. What I meant is that the same
call keeps the key when it returns json:
ABSENT ON NULL RETURNING jsonb {}
ABSENT ON NULL RETURNING json {"a" : null}

So ABSENT ON NULL means two different things, depending on the result type.

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

For SQL NULL that check is PG_ARGISNULL(), which is already there.

Thanks,
Shihao

In response to

Browse pgsql-bugs by date

  From Date Subject
Previous Message shihao zhong 2026-10-09 03:13:21 Re: PostgreSQL 18.6/17.11: standby PANIC on restart after VM truncation