pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Amit Langote <amitlan@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste
Date: Mon, 09 Sep 2024 04:47:27 +0000
Message-ID: <E1snWJD-000FQL-Ew@gemulon.postgresql.org> (raw)

SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY steps

When the ON ERROR / ON EMPTY behavior is to return NULL, returning
NULL directly from ExecEvalJsonExprPath() suffices. Therefore, there's
no need to create separate steps to check the error/empty flag or
those to evaluate the the constant NULL expression.  This speeds up
common cases because the default ON ERROR / ON EMPTY behavior for
JSON_QUERY() and JSON_VALUE() is to return NULL.  However, these steps
are necessary if the RETURNING type is a domain, as constraints on the
domain may need to be checked.

Reported-by: Jian He <jian.universality@gmail.com>
Author: Jian He <jian.universality@gmail.com>
Author: Amit Langote <amitlangote09@gmail.com>
Discussion: https://postgr.es/m/CACJufxEo4sUjKCYtda0_qt9tazqqKPmF1cqhW9KBOUeJFqQd2g@mail.gmail.com
Backpatch-through: 17

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/dd8bea88abf4794d99270ced884a8bc1e387255d

Modified Files
--------------
src/backend/executor/execExpr.c       | 32 ++++++++++++++++++++++++++------
src/backend/executor/execExprInterp.c | 14 ++++++++------
2 files changed, 34 insertions(+), 12 deletions(-)



view thread (9+ messages)  latest in thread

Message-ID: <E1snWJD-000FQL-Ew@gemulon.postgresql.org>
Permalink:  ../E1snWJD-000FQL-Ew@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1snWJD-000FQL-Ew@gemulon.postgresql.org

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: amitlan@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste
  In-Reply-To: <E1snWJD-000FQL-Ew@gemulon.postgresql.org>

* 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