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.universal...@gmail.com>
Author: Jian He <jian.universal...@gmail.com>
Author: Amit Langote <amitlangot...@gmail.com>
Discussion: 
https://postgr.es/m/cacjufxeo4sujkcytda0_qt9tazqqkpmf1cqhw9kbouejfqq...@mail.gmail.com
Backpatch-through: 17

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3a97460970f344660971ee75d7f5a181bf87f633

Modified Files
--------------
src/backend/executor/execExpr.c | 30 ++++++++++++++++++++++--------
1 file changed, 22 insertions(+), 8 deletions(-)

Reply via email to