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

Function SplitTupleTableSlot

src/backend/executor/nodeSplitUpdate.c:72–164  ·  view source on GitHub ↗

Split TupleTableSlot into a DELETE and INSERT TupleTableSlot */

Source from the content-addressed store, hash-verified

70
71/* Split TupleTableSlot into a DELETE and INSERT TupleTableSlot */
72static void
73SplitTupleTableSlot(TupleTableSlot *slot,
74 List *targetList, SplitUpdate *plannode, SplitUpdateState *node,
75 Datum *values, bool *nulls)
76{
77 ListCell *element;
78 ListCell *deleteAtt = list_head(plannode->deleteColIdx);
79 ListCell *insertAtt = list_head(plannode->insertColIdx);
80
81 slot_getallattrs(slot);
82 Datum *delete_values = node->deleteTuple->tts_values;
83 bool *delete_nulls = node->deleteTuple->tts_isnull;
84 Datum *insert_values = node->insertTuple->tts_values;
85 bool *insert_nulls = node->insertTuple->tts_isnull;
86
87 /* Iterate through new TargetList and match old and new values. The action is also added in this containsTuple. */
88 foreach (element, targetList)
89 {
90 TargetEntry *tle = lfirst(element);
91 AttrNumber attno = tle->resno;
92
93 if (IsA(tle->expr, DMLActionExpr))
94 {
95 /* Set the corresponding action to the new tuples. */
96 delete_values[attno - 1] = Int32GetDatum((int)DML_DELETE);
97 delete_nulls[attno - 1] = false;
98
99 insert_values[attno - 1] = Int32GetDatum((int)DML_INSERT);
100 insert_nulls[attno -1 ] = false;
101 }
102 else if (attno <= list_length(plannode->insertColIdx))
103 {
104 /* Old and new values */
105 int deleteAttNo = lfirst_int(deleteAtt);
106 int insertAttNo = lfirst_int(insertAtt);
107
108 if (deleteAttNo == -1)
109 {
110 delete_values[attno - 1] = (Datum) 0;
111 delete_nulls[attno - 1] = true;
112 }
113 else
114 {
115 delete_values[attno - 1] = values[deleteAttNo - 1];
116 delete_nulls[attno - 1] = nulls[deleteAttNo - 1];
117 }
118
119 insert_values[attno - 1] = values[insertAttNo - 1];
120 insert_nulls[attno - 1] = nulls[insertAttNo - 1];
121
122 deleteAtt = lnext(plannode->deleteColIdx, deleteAtt);
123 insertAtt = lnext(plannode->insertColIdx, insertAtt);
124 }
125 else if (attno == node->output_segid_attno)
126 {
127 Assert(!nulls[node->input_segid_attno - 1]);
128
129 delete_values[attno - 1] = values[node->input_segid_attno - 1];

Callers 1

ExecSplitUpdateFunction · 0.85

Calls 7

list_headFunction · 0.85
slot_getallattrsFunction · 0.85
Int32GetDatumFunction · 0.85
list_lengthFunction · 0.85
lnextFunction · 0.85
evalHashKeyFunction · 0.70
foreachFunction · 0.50

Tested by

no test coverage detected