pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste - Mailing list pgsql-committers

From Amit Langote
Subject pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste
Date
Msg-id E1snWJD-000FQL-Ew@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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(-)


pgsql-committers by date:

Previous
From: Richard Guo
Date:
Subject: pgsql: Fix order of parameters in a cost_sort call
Next
From: Michael Paquier
Date:
Subject: pgsql: Fix waits of REINDEX CONCURRENTLY for indexes with predicates or