SQL/JSON: Fix error-handling of some JsonBehavior expressions
authorAmit Langote <amitlan@postgresql.org>
Fri, 26 Jul 2024 06:59:27 +0000 (15:59 +0900)
committerAmit Langote <amitlan@postgresql.org>
Fri, 26 Jul 2024 07:00:06 +0000 (16:00 +0900)
commit63e6c5f4a2eeb22e0dd446a62c2b4b417d2b51f0
tree3ce786dcf32d88140630721cf051c32dd61033fa
parentc7301c3b6fe2feaf96d52cbf35a85ac6b95374dc
SQL/JSON: Fix error-handling of some JsonBehavior expressions

To ensure that the errors of executing a JsonBehavior expression that
is coerced in the parser are caught instead of being thrown directly,
pass ErrorSaveContext to ExecInitExprRec() when initializing it.
Also, add a EEOP_JSONEXPR_COERCION_FINISH step to handle the errors
that are caught that way.

Discussion: https://postgr.es/m/CACJufxEo4sUjKCYtda0_qt9tazqqKPmF1cqhW9KBOUeJFqQd2g@mail.gmail.com
Backpatch-through: 17
src/backend/executor/execExpr.c
src/backend/executor/execExprInterp.c
src/test/regress/expected/sqljson_jsontable.out
src/test/regress/expected/sqljson_queryfuncs.out