postgresql/src/include/executor
Amit Langote aaaf9449ec Add soft error handling to some expression nodes
This adjusts the code for CoerceViaIO and CoerceToDomain expression
nodes to handle errors softly.

For CoerceViaIo, this adds a new ExprEvalStep opcode
EEOP_IOCOERCE_SAFE, which is implemented in the new accompanying
function ExecEvalCoerceViaIOSafe().  The only difference from
EEOP_IOCOERCE's inline implementation is that the input function
receives an ErrorSaveContext via the function's
FunctionCallInfo.context, which it can use to handle errors softly.

For CoerceToDomain, this simply entails replacing the ereport() in
ExecEvalConstraintNotNull() and ExecEvalConstraintCheck() by
errsave() passing it the ErrorSaveContext passed in the expression's
ExprEvalStep.

In both cases, the ErrorSaveContext to be used is passed by setting
ExprState.escontext to point to it before calling ExecInitExprRec()
on the expression tree whose errors are to be handled softly.

Note that there's no functional change as of this commit as no call
site of ExecInitExprRec() has been changed.  This is intended for
implementing new SQL/JSON expression nodes in future commits.

Extracted from a much larger patch to add SQL/JSON query functions.

Author: Nikita Glukhov <n.gluhov@postgrespro.ru>
Author: Teodor Sigaev <teodor@sigaev.ru>
Author: Oleg Bartunov <obartunov@gmail.com>
Author: Alexander Korotkov <aekorotkov@gmail.com>
Author: Andrew Dunstan <andrew@dunslane.net>
Author: Amit Langote <amitlangote09@gmail.com>

Reviewers have included (in no particular order) Andres Freund,
Alexander Korotkov, Pavel Stehule, Andrew Alsup, Erik Rijkers,
Zihong Yu, Himanshu Upadhyaya, Daniel Gustafsson, Justin Pryzby,
Álvaro Herrera, Jian He, Peter Eisentraut

Discussion: https://postgr.es/m/cd0bb935-0158-78a7-08b5-904886deac4b@postgrespro.ru
Discussion: https://postgr.es/m/20220616233130.rparivafipt6doj3@alap3.anarazel.de
Discussion: https://postgr.es/m/abd9b83b-aa66-f230-3d6d-734817f0995d%40postgresql.org
Discussion: https://postgr.es/m/CA+HiwqHROpf9e644D8BRqYvaAPmgBZVup-xKMDPk-nd4EpgzHw@mail.gmail.com
Discussion: https://postgr.es/m/CA+HiwqE4XTdfb1nW=Ojoy_tQSRhYt-q_kb6i5d4xcKyrLC1Nbg@mail.gmail.com
2024-01-24 15:04:33 +09:00
..
execAsync.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
execExpr.h Add soft error handling to some expression nodes 2024-01-24 15:04:33 +09:00
execParallel.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
execPartition.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
execdebug.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
execdesc.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
executor.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
functions.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
hashjoin.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
instrument.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeAgg.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeAppend.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeBitmapAnd.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeBitmapHeapscan.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeBitmapIndexscan.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeBitmapOr.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeCtescan.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeCustom.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeForeignscan.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeFunctionscan.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeGather.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeGatherMerge.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeGroup.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeHash.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeHashjoin.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeIncrementalSort.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeIndexonlyscan.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeIndexscan.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeLimit.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeLockRows.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeMaterial.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeMemoize.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeMergeAppend.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeMergejoin.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeModifyTable.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeNamedtuplestorescan.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeNestloop.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeProjectSet.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeRecursiveunion.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeResult.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeSamplescan.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeSeqscan.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeSetOp.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeSort.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeSubplan.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeSubqueryscan.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeTableFuncscan.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeTidrangescan.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeTidscan.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeUnique.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeValuesscan.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeWindowAgg.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
nodeWorktablescan.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
spi.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
spi_priv.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
tablefunc.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
tqueue.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
tstoreReceiver.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
tuptable.h Update copyright for 2024 2024-01-03 20:49:05 -05:00