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

Function ExecBuildUpdateProjection

src/backend/executor/execExpr.c:524–744  ·  view source on GitHub ↗

* ExecBuildUpdateProjection * * Build a ProjectionInfo node for constructing a new tuple during UPDATE. * The projection will be executed in the given econtext and the result will * be stored into the given tuple slot. (Caller must have ensured that tuple * slot has a descriptor matching the target rel!) * * When evalTargetList is false, targetList contains the UPDATE ... SET * expressio

Source from the content-addressed store, hash-verified

522 * ExecCheckPlanOutput, so we must do our safety checks here.
523 */
524ProjectionInfo *
525ExecBuildUpdateProjection(List *targetList,
526 bool evalTargetList,
527 List *targetColnos,
528 TupleDesc relDesc,
529 ExprContext *econtext,
530 TupleTableSlot *slot,
531 PlanState *parent)
532{
533 ProjectionInfo *projInfo = makeNode(ProjectionInfo);
534 ExprState *state;
535 int nAssignableCols;
536 bool sawJunk;
537 Bitmapset *assignedCols;
538 LastAttnumInfo deform = {0, 0, 0};
539 ExprEvalStep scratch = {0};
540 int outerattnum;
541 ListCell *lc,
542 *lc2;
543
544 projInfo->pi_exprContext = econtext;
545 /* We embed ExprState into ProjectionInfo instead of doing extra palloc */
546 projInfo->pi_state.tag = T_ExprState;
547 state = &projInfo->pi_state;
548 if (evalTargetList)
549 state->expr = (Expr *) targetList;
550 else
551 state->expr = NULL; /* not used */
552 state->parent = parent;
553 state->ext_params = NULL;
554
555 state->resultslot = slot;
556
557 /*
558 * Examine the targetList to see how many non-junk columns there are, and
559 * to verify that the non-junk columns come before the junk ones.
560 */
561 nAssignableCols = 0;
562 sawJunk = false;
563 foreach(lc, targetList)
564 {
565 TargetEntry *tle = lfirst_node(TargetEntry, lc);
566
567 if (tle->resjunk)
568 sawJunk = true;
569 else
570 {
571 if (sawJunk)
572 elog(ERROR, "subplan target list is out of order");
573 nAssignableCols++;
574 }
575 }
576
577 /* We should have one targetColnos entry per non-junk column */
578 if (nAssignableCols != list_length(targetColnos))
579 elog(ERROR, "targetColnos does not match subplan target list");
580
581 /*

Callers 3

ExecInitUpdateProjectionFunction · 0.85
ExecInitModifyTableFunction · 0.85
ExecInitPartitionInfoFunction · 0.85

Calls 15

list_lengthFunction · 0.85
bms_add_memberFunction · 0.85
bms_is_memberFunction · 0.85
get_last_attnums_walkerFunction · 0.85
ExecPushExprSlotsFunction · 0.85
forbothFunction · 0.85
exprTypeFunction · 0.85
format_type_beFunction · 0.85
ExecInitExprRecFunction · 0.85
ExprEvalPushStepFunction · 0.85
ExecReadyExprFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected