pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: Staroverov Ilja <i.staroverov@ftdata.ru>
Cc: Sami Imseih <samimseih.pg@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: pg_stat_statements replaces SQL/JSON ON EMPTY / ON ERROR keywords with parameters
Date: Thu, 22 Oct 2026 17:28:23 +0900
Message-ID: <atnJJiWcHyhd8_NI@paquier.xyz> (raw)
In-Reply-To: <E00D8F2E-7706-4227-8FE9-C899FAFB4C3C@localhost.localdomain>
References: <457969A9-5D24-422F-B09E-F388053DE028@localhost.localdomain>
	<athe8udYm0H_xy0q@paquier.xyz>
	<E00D8F2E-7706-4227-8FE9-C899FAFB4C3C@localhost.localdomain>

On Wed, Oct 21, 2026 at 09:04:09AM +0000, Staroverov Ilja wrote:
> Agreed for 0003. 0002 changes neither: it only leaves the location of
> the behavior Consts unset, and locations are recorded, not hashed, so
> the query IDs stay the same. But it's your call whether that's worth
> back-patching.

v1 offers a nice coverage.  I have noticed a couple of holes here and
there, but globally that was fine.

+     2 | SELECT JSON_VALUE(js, $1 $2 ON EMPTY ERROR ON ERROR) FROM pgss_sqljson_tab

Urg, yeah.  In this one $2 is a DEFAULT keyword.  That's confusing..
Sami has mentioned that on another thread.  It does not prevent doing
something with the tests first; query jumbing can sometimes feel
tricky to feel (not be!) right.

+     2 | SELECT JSON_VALUE(js, $1 DEFAULT $2 ON EMPTY) FROM pgss_sqljson_tab
+     1 | SELECT JSON_VALUE(js, $1 DEFAULT $2 ON ERROR) FROM pgss_sqljson_tab

These ones are separated due to the different last keywords, and
perhaps more arguable, but it's confusing to replace the
NULL/DEFAULT/EMPTY by dollar parameters.  And we have quite a few more
of these incorrect patterns.

These SQL/JSON patterns are so various that adding a mention of the
defaults is a good idea.  I've expanded that a bit more.

The ON ERROR and ON EMPTY patterns can also be combined together in a
single query.  I've added more of them.

under NESTED, PATH is optional.  Having patterns where it's gone seems
necessary to me.  Similarly, no NESTED in a PLAN is the same a no
PLAN.

There were a few more patterns that were not treated in plans with
combinations of UNION, INNER, CROSS..  Things like UNION/UNION and
CROSS/CROSS included.

And a few more notes for things missing:
* WITHOUT UNIQUE
* JSON_ARRAYAGG(ORDER BY [DESC])
* JSON_TABLE(UNKNOWN ON ERROR)
* JSON_SERIALIZE(FORMAT)
* PASSING in JSON_QUERY

No backpatch can happen on that, I am afraid.  The query ID stability
matters on stable branches, even if some if the keywords are currently
eaten due to the locations.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (12+ messages)  latest in thread

Message-ID: <atnJJiWcHyhd8_NI@paquier.xyz>
Permalink:  ../atnJJiWcHyhd8_NI@paquier.xyz/
Also on:    postgresql.org/message-id/atnJJiWcHyhd8_NI@paquier.xyz

 · 

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: michael@paquier.xyz, i.staroverov@ftdata.ru, samimseih.pg@gmail.com
  Subject: Re: pg_stat_statements replaces SQL/JSON ON EMPTY / ON ERROR keywords with parameters
  In-Reply-To: <atnJJiWcHyhd8_NI@paquier.xyz>
  References: <457969A9-5D24-422F-B09E-F388053DE028@localhost.localdomain> <athe8udYm0H_xy0q@paquier.xyz> <E00D8F2E-7706-4227-8FE9-C899FAFB4C3C@localhost.localdomain> <atnJJiWcHyhd8_NI@paquier.xyz>

* 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