MCPcopy Create free account
hub / github.com/apache/cloudberry / ExecModifyTable

Function ExecModifyTable

src/backend/executor/nodeModifyTable.c:2630–3063  ·  view source on GitHub ↗

---------------------------------------------------------------- * ExecModifyTable * * Perform table modifications as required, and return RETURNING results * if needed. * ---------------------------------------------------------------- */

Source from the content-addressed store, hash-verified

2628 * ----------------------------------------------------------------
2629 */
2630static TupleTableSlot *
2631ExecModifyTable(PlanState *pstate)
2632{
2633 ModifyTableState *node = castNode(ModifyTableState, pstate);
2634 EState *estate = node->ps.state;
2635 CmdType operation = node->operation;
2636 ResultRelInfo *resultRelInfo;
2637 PlanState *subplanstate;
2638 AttrNumber action_attno;
2639 AttrNumber segid_attno;
2640 TupleTableSlot *slot;
2641 TupleTableSlot *planSlot;
2642 TupleTableSlot *oldSlot;
2643 ItemPointer tupleid;
2644 ItemPointerData tuple_ctid;
2645 HeapTupleData oldtupdata;
2646 HeapTuple oldtuple;
2647 PartitionTupleRouting *proute = node->mt_partition_tuple_routing;
2648 List *relinfos = NIL;
2649 ListCell *lc;
2650
2651 CHECK_FOR_INTERRUPTS();
2652
2653 /*
2654 * This should NOT get called during EvalPlanQual; we should have passed a
2655 * subplan tree to EvalPlanQual, instead. Use a runtime test not just
2656 * Assert because this condition is easy to miss in testing. (Note:
2657 * although ModifyTable should not get executed within an EvalPlanQual
2658 * operation, we do have to allow it to be initialized and shut down in
2659 * case it is within a CTE subplan. Hence this test must be here, not in
2660 * ExecInitModifyTable.)
2661 */
2662 if (estate->es_epq_active != NULL)
2663 elog(ERROR, "ModifyTable should not be called during EvalPlanQual");
2664
2665 /*
2666 * If we've already completed processing, don't try to do more. We need
2667 * this test because ExecPostprocessPlan might call us an extra time, and
2668 * our subplan's nodes aren't necessarily robust against being called
2669 * extra times.
2670 */
2671 if (node->mt_done)
2672 return NULL;
2673
2674 if (Gp_role == GP_ROLE_EXECUTE && !Gp_is_writer)
2675 {
2676 /*
2677 * Current Cloudberry MPP architecture only support one writer gang, and
2678 * only writer gang can execute DML nodes. There is no code path to reach
2679 * here. For writable CTE case as below:
2680 *
2681 * create table t(a int);
2682 * with wcte as (delete from t returning a)
2683 * insert into t select * from wcte;
2684 *
2685 * The above query will error out during parse-analyze so not reach here.
2686 * If reaching here, some bugs must happen.
2687 */

Callers 1

ExecSquelchModifyTableFunction · 0.85

Calls 15

fireBSTriggersFunction · 0.85
ExecProcNodeFunction · 0.85
ExecGetJunkAttributeFunction · 0.85
DatumGetObjectIdFunction · 0.85
ExecLookupResultRelByOidFunction · 0.85
ExecProcessReturningFunction · 0.85
DatumGetInt32Function · 0.85
ExecInitInsertProjectionFunction · 0.85
ExecGetInsertNewTupleFunction · 0.85
ExecInsertFunction · 0.85
ExecInitUpdateProjectionFunction · 0.85
ExecForceStoreHeapTupleFunction · 0.85

Tested by

no test coverage detected