mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
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
This commit is contained in:
@ -4558,6 +4558,12 @@ ExecEvalJsonCoercionFinish(ExprState *state, ExprEvalStep *op)
|
||||
*op->resvalue = (Datum) 0;
|
||||
*op->resnull = true;
|
||||
jsestate->error.value = BoolGetDatum(true);
|
||||
|
||||
/*
|
||||
* Reset for next use such as for catching errors when coercing a
|
||||
* JsonBehavior expression.
|
||||
*/
|
||||
jsestate->escontext.error_occurred = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user