* Init SplitUpdate Node. A memory context is created to hold Split Tuples. * */
| 217 | * Init SplitUpdate Node. A memory context is created to hold Split Tuples. |
| 218 | * */ |
| 219 | SplitUpdateState* |
| 220 | ExecInitSplitUpdate(SplitUpdate *node, EState *estate, int eflags) |
| 221 | { |
| 222 | SplitUpdateState *splitupdatestate; |
| 223 | |
| 224 | /* Check for unsupported flags */ |
| 225 | Assert(!(eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK | EXEC_FLAG_REWIND))); |
| 226 | |
| 227 | splitupdatestate = makeNode(SplitUpdateState); |
| 228 | splitupdatestate->ps.plan = (Plan *)node; |
| 229 | splitupdatestate->ps.state = estate; |
| 230 | splitupdatestate->ps.ExecProcNode = ExecSplitUpdate; |
| 231 | splitupdatestate->processInsert = true; |
| 232 | |
| 233 | /* |
| 234 | * then initialize outer plan |
| 235 | */ |
| 236 | Plan *outerPlan = outerPlan(node); |
| 237 | outerPlanState(splitupdatestate) = ExecInitNode(outerPlan, estate, eflags); |
| 238 | |
| 239 | ExecAssignExprContext(estate, &splitupdatestate->ps); |
| 240 | |
| 241 | /* |
| 242 | * New TupleDescriptor for output TupleTableSlots (old_values + new_values, ctid, |
| 243 | * gp_segment, action). |
| 244 | */ |
| 245 | TupleDesc tupDesc = ExecTypeFromTL(node->plan.targetlist); |
| 246 | splitupdatestate->insertTuple = ExecInitExtraTupleSlot(estate, tupDesc, &TTSOpsVirtual); |
| 247 | splitupdatestate->deleteTuple = ExecInitExtraTupleSlot(estate, tupDesc, &TTSOpsVirtual); |
| 248 | |
| 249 | /* |
| 250 | * Look up the positions of the gp_segment_id in the subplan's target |
| 251 | * list, and in the result. |
| 252 | */ |
| 253 | splitupdatestate->input_segid_attno = |
| 254 | ExecFindJunkAttributeInTlist(outerPlan->targetlist, "gp_segment_id"); |
| 255 | splitupdatestate->output_segid_attno = |
| 256 | ExecFindJunkAttributeInTlist(node->plan.targetlist, "gp_segment_id"); |
| 257 | |
| 258 | /* |
| 259 | * DML nodes do not project. |
| 260 | */ |
| 261 | ExecInitResultTupleSlotTL(&splitupdatestate->ps, &TTSOpsVirtual); |
| 262 | splitupdatestate->ps.ps_ProjInfo = NULL; |
| 263 | |
| 264 | /* |
| 265 | * Initialize for computing hash key |
| 266 | */ |
| 267 | if (node->numHashAttrs > 0) |
| 268 | { |
| 269 | splitupdatestate->cdbhash = makeCdbHash(node->numHashSegments, |
| 270 | node->numHashAttrs, |
| 271 | node->hashFuncs); |
| 272 | } |
| 273 | |
| 274 | if (estate->es_instrument && (estate->es_instrument & INSTRUMENT_CDB)) |
| 275 | { |
| 276 | splitupdatestate->ps.cdbexplainbuf = makeStringInfo(); |
no test coverage detected