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

Function ExecGetInsertNewTuple

src/backend/executor/nodeModifyTable.c:579–612  ·  view source on GitHub ↗

* ExecGetInsertNewTuple * This prepares a "new" tuple ready to be inserted into given result * relation, by removing any junk columns of the plan's output tuple * and (if necessary) coercing the tuple to the right tuple format. */

Source from the content-addressed store, hash-verified

577 * and (if necessary) coercing the tuple to the right tuple format.
578 */
579static TupleTableSlot *
580ExecGetInsertNewTuple(ResultRelInfo *relinfo,
581 TupleTableSlot *planSlot)
582{
583 ProjectionInfo *newProj = relinfo->ri_projectNew;
584 ExprContext *econtext;
585
586 /*
587 * If there's no projection to be done, just make sure the slot is of the
588 * right type for the target rel. If the planSlot is the right type we
589 * can use it as-is, else copy the data into ri_newTupleSlot.
590 */
591 if (newProj == NULL)
592 {
593 if (relinfo->ri_newTupleSlot->tts_ops != planSlot->tts_ops)
594 {
595 ExecCopySlot(relinfo->ri_newTupleSlot, planSlot);
596 return relinfo->ri_newTupleSlot;
597 }
598 else
599 return planSlot;
600 }
601
602 /*
603 * Else project; since the projection output slot is ri_newTupleSlot, this
604 * will also fix any slot-type problem.
605 *
606 * Note: currently, this is dead code, because INSERT cases don't receive
607 * any junk columns so there's never a projection to be done.
608 */
609 econtext = newProj->pi_exprContext;
610 econtext->ecxt_outertuple = planSlot;
611 return ExecProject(newProj);
612}
613
614/*
615 * ExecGetUpdateNewTuple

Callers 1

ExecModifyTableFunction · 0.85

Calls 2

ExecCopySlotFunction · 0.85
ExecProjectFunction · 0.85

Tested by

no test coverage detected