diff options
Diffstat (limited to 'src/backend/executor/execExprInterp.c')
-rw-r--r-- | src/backend/executor/execExprInterp.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/backend/executor/execExprInterp.c b/src/backend/executor/execExprInterp.c index 7c1f51e2e0a..a25ab7570fe 100644 --- a/src/backend/executor/execExprInterp.c +++ b/src/backend/executor/execExprInterp.c @@ -484,6 +484,7 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull) &&CASE_EEOP_AGGREF, &&CASE_EEOP_GROUPING_FUNC, &&CASE_EEOP_WINDOW_FUNC, + &&CASE_EEOP_MERGE_SUPPORT_FUNC, &&CASE_EEOP_SUBPLAN, &&CASE_EEOP_AGG_STRICT_DESERIALIZE, &&CASE_EEOP_AGG_DESERIALIZE, @@ -1592,6 +1593,14 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull) EEO_NEXT(); } + EEO_CASE(EEOP_MERGE_SUPPORT_FUNC) + { + /* too complex/uncommon for an inline implementation */ + ExecEvalMergeSupportFunc(state, op, econtext); + + EEO_NEXT(); + } + EEO_CASE(EEOP_SUBPLAN) { /* too complex for an inline implementation */ @@ -4246,6 +4255,45 @@ ExecEvalGroupingFunc(ExprState *state, ExprEvalStep *op) } /* + * ExecEvalMergeSupportFunc + * + * Returns information about the current MERGE action for its RETURNING list. + */ +void +ExecEvalMergeSupportFunc(ExprState *state, ExprEvalStep *op, + ExprContext *econtext) +{ + ModifyTableState *mtstate = castNode(ModifyTableState, state->parent); + MergeActionState *relaction = mtstate->mt_merge_action; + + if (!relaction) + elog(ERROR, "no merge action in progress"); + + /* Return the MERGE action ("INSERT", "UPDATE", or "DELETE") */ + switch (relaction->mas_action->commandType) + { + case CMD_INSERT: + *op->resvalue = PointerGetDatum(cstring_to_text_with_len("INSERT", 6)); + *op->resnull = false; + break; + case CMD_UPDATE: + *op->resvalue = PointerGetDatum(cstring_to_text_with_len("UPDATE", 6)); + *op->resnull = false; + break; + case CMD_DELETE: + *op->resvalue = PointerGetDatum(cstring_to_text_with_len("DELETE", 6)); + *op->resnull = false; + break; + case CMD_NOTHING: + elog(ERROR, "unexpected merge action: DO NOTHING"); + break; + default: + elog(ERROR, "unrecognized commandType: %d", + (int) relaction->mas_action->commandType); + } +} + +/* * Hand off evaluation of a subplan to nodeSubplan.c */ void |