pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dmitry Dolgov <9erthalion6@gmail.com>
To: shihao zhong <zhong950419@gmail.com>
Cc: Álvaro Herrera <alvherre@kurilemu.de>
Cc: Andrew Dunstan <andrew@dunslane.net>
Cc: pgsql-bugs@lists.postgresql.org
Cc: theshallow27@gmail.com
Subject: Re: BUG #19735: `jsonb_object_agg_unique_strict` drops a JSONB `null` value as if it were SQL NULL
Date: Thu, 8 Oct 2026 10:09:26 +0200
Message-ID: <asdM441VSWVzFNoJ@ddolgov-thinkpadt14sgen1.rmtde.csb> (raw)
In-Reply-To: <CAGRkXqSpWKiSUqBtcsDFDPCvbzALM+BnJN26DKu03TwPL3cRZg@mail.gmail.com>
References: <19735-488819822dc79bca@postgresql.org>
	<CAGRkXqS7KdfpuBJELU_K-c69REdtJGvgn76p0h9O4mBk=MOSmQ@mail.gmail.com>
	<asYJhYbXXBPV_D5x@ddolgov-thinkpadt14sgen1.rmtde.csb>
	<CAGRkXqSpWKiSUqBtcsDFDPCvbzALM+BnJN26DKu03TwPL3cRZg@mail.gmail.com>

> 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.






view thread (6+ messages)  latest in thread

Message-ID: <asdM441VSWVzFNoJ@ddolgov-thinkpadt14sgen1.rmtde.csb>
Permalink:  ../asdM441VSWVzFNoJ@ddolgov-thinkpadt14sgen1.rmtde.csb/
Also on:    postgresql.org/message-id/asdM441VSWVzFNoJ@ddolgov-thinkpadt14sgen1.rmtde.csb

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: 9erthalion6@gmail.com, zhong950419@gmail.com, alvherre@kurilemu.de, andrew@dunslane.net, theshallow27@gmail.com
  Subject: Re: BUG #19735: `jsonb_object_agg_unique_strict` drops a JSONB `null` value as if it were SQL NULL
  In-Reply-To: <asdM441VSWVzFNoJ@ddolgov-thinkpadt14sgen1.rmtde.csb>
  References: <19735-488819822dc79bca@postgresql.org> <CAGRkXqS7KdfpuBJELU_K-c69REdtJGvgn76p0h9O4mBk=MOSmQ@mail.gmail.com> <asYJhYbXXBPV_D5x@ddolgov-thinkpadt14sgen1.rmtde.csb> <CAGRkXqSpWKiSUqBtcsDFDPCvbzALM+BnJN26DKu03TwPL3cRZg@mail.gmail.com> <asdM441VSWVzFNoJ@ddolgov-thinkpadt14sgen1.rmtde.csb>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox