Add soft error handling to some expression nodes
authorAmit Langote <amitlan@postgresql.org>
Mon, 2 Oct 2023 02:52:28 +0000 (11:52 +0900)
committerAmit Langote <amitlan@postgresql.org>
Mon, 2 Oct 2023 02:52:28 +0000 (11:52 +0900)
commit7fbc75b26ed8ec70c729c5e7f8233896c54c900f
treec0b389d0970bf286e99e8f558c83dd2394f5f99c
parent2940f1c8373cb3b43b3b42d40786b05d6e901de1
Add soft error handling to some expression nodes

This adjusts the expression evaluation code for CoerceViaIO and
CoerceToDomain to handle errors softly if needed.

For CoerceViaIo, this means using InputFunctionCallSafe(), which
provides the option to handle errors softly, instead of calling the
type input function directly.

For CoerceToDomain, this simply entails replacing the ereport() in
ExecEvalConstraintCheck() by errsave().

In both cases, the ErrorSaveContext to be used when evaluating the
expression is stored by ExecInitExprRec() in the expression's struct
in the expression's ExprEvalStep.  The ErrorSaveContext is passed by
setting ExprState.escontext to point to it when calling
ExecInitExprRec() on the expression whose errors are to be handled
softly.

Note that no call site of ExecInitExprRec() has been changed in this
commit, so there's no functional change.  This is intended for
implementing new SQL/JSON expression nodes in future commits that
will use to it suppress errors that may occur during type coercions.

Reviewed-by: Álvaro Herrera
Discussion: https://postgr.es/m/CA+HiwqE4XTdfb1nW=Ojoy_tQSRhYt-q_kb6i5d4xcKyrLC1Nbg@mail.gmail.com
src/backend/executor/execExpr.c
src/backend/executor/execExprInterp.c
src/backend/jit/llvm/llvmjit.c
src/backend/jit/llvm/llvmjit_expr.c
src/backend/jit/llvm/llvmjit_types.c
src/include/executor/execExpr.h
src/include/jit/llvmjit.h
src/include/jit/llvmjit_emit.h
src/include/nodes/execnodes.h