PostgreSQL Source Code git master
Loading...
Searching...
No Matches
nodeModifyTable.h File Reference
#include "nodes/execnodes.h"
Include dependency graph for nodeModifyTable.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void ExecInitGenerated (ResultRelInfo *resultRelInfo, EState *estate, CmdType cmdtype)
 
void ExecComputeStoredGenerated (ResultRelInfo *resultRelInfo, EState *estate, TupleTableSlot *slot, CmdType cmdtype)
 
ModifyTableStateExecInitModifyTable (ModifyTable *node, EState *estate, int eflags)
 
void ExecEndModifyTable (ModifyTableState *node)
 
void ExecReScanModifyTable (ModifyTableState *node)
 
void ExecInitMergeTupleSlots (ModifyTableState *mtstate, ResultRelInfo *resultRelInfo)
 

Function Documentation

◆ ExecComputeStoredGenerated()

void ExecComputeStoredGenerated ( ResultRelInfo resultRelInfo,
EState estate,
TupleTableSlot slot,
CmdType  cmdtype 
)
extern

Definition at line 564 of file nodeModifyTable.c.

567{
568 Relation rel = resultRelInfo->ri_RelationDesc;
569 TupleDesc tupdesc = RelationGetDescr(rel);
570 int natts = tupdesc->natts;
571 ExprContext *econtext = GetPerTupleExprContext(estate);
574 Datum *values;
575 bool *nulls;
576
577 /* We should not be called unless this is true */
578 Assert(tupdesc->constr && tupdesc->constr->has_generated_stored);
579
580 /*
581 * Initialize the expressions if we didn't already, and check whether we
582 * can exit early because nothing needs to be computed.
583 */
584 if (cmdtype == CMD_UPDATE)
585 {
586 if (resultRelInfo->ri_GeneratedExprsU == NULL)
587 ExecInitGenerated(resultRelInfo, estate, cmdtype);
588 if (resultRelInfo->ri_NumGeneratedNeededU == 0)
589 return;
590 ri_GeneratedExprs = resultRelInfo->ri_GeneratedExprsU;
591 }
592 else
593 {
594 if (resultRelInfo->ri_GeneratedExprsI == NULL)
595 ExecInitGenerated(resultRelInfo, estate, cmdtype);
596 /* Early exit is impossible given the prior Assert */
597 Assert(resultRelInfo->ri_NumGeneratedNeededI > 0);
598 ri_GeneratedExprs = resultRelInfo->ri_GeneratedExprsI;
599 }
600
602
603 values = palloc_array(Datum, natts);
604 nulls = palloc_array(bool, natts);
605
606 slot_getallattrs(slot);
607 memcpy(nulls, slot->tts_isnull, sizeof(*nulls) * natts);
608
609 for (int i = 0; i < natts; i++)
610 {
611 CompactAttribute *attr = TupleDescCompactAttr(tupdesc, i);
612
613 if (ri_GeneratedExprs[i])
614 {
615 Datum val;
616 bool isnull;
617
618 Assert(TupleDescAttr(tupdesc, i)->attgenerated == ATTRIBUTE_GENERATED_STORED);
619
620 econtext->ecxt_scantuple = slot;
621
622 val = ExecEvalExpr(ri_GeneratedExprs[i], econtext, &isnull);
623
624 /*
625 * We must make a copy of val as we have no guarantees about where
626 * memory for a pass-by-reference Datum is located.
627 */
628 if (!isnull)
629 val = datumCopy(val, attr->attbyval, attr->attlen);
630
631 values[i] = val;
632 nulls[i] = isnull;
633 }
634 else
635 {
636 if (!nulls[i])
637 values[i] = datumCopy(slot->tts_values[i], attr->attbyval, attr->attlen);
638 }
639 }
640
641 ExecClearTuple(slot);
642 memcpy(slot->tts_values, values, sizeof(*values) * natts);
643 memcpy(slot->tts_isnull, nulls, sizeof(*nulls) * natts);
646
648}
static Datum values[MAXATTR]
Definition bootstrap.c:190
#define Assert(condition)
Definition c.h:943
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
Datum datumCopy(Datum value, bool typByVal, int typLen)
Definition datum.c:132
TupleTableSlot * ExecStoreVirtualTuple(TupleTableSlot *slot)
#define GetPerTupleExprContext(estate)
Definition executor.h:667
#define GetPerTupleMemoryContext(estate)
Definition executor.h:672
static Datum ExecEvalExpr(ExprState *state, ExprContext *econtext, bool *isNull)
Definition executor.h:403
#define palloc_array(type, count)
Definition fe_memutils.h:76
long val
Definition informix.c:689
int i
Definition isn.c:77
void ExecInitGenerated(ResultRelInfo *resultRelInfo, EState *estate, CmdType cmdtype)
@ CMD_UPDATE
Definition nodes.h:276
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition palloc.h:124
uint64_t Datum
Definition postgres.h:70
static int fb(int x)
#define RelationGetDescr(relation)
Definition rel.h:542
TupleTableSlot * ecxt_scantuple
Definition execnodes.h:287
Relation ri_RelationDesc
Definition execnodes.h:513
ExprState ** ri_GeneratedExprsI
Definition execnodes.h:599
int ri_NumGeneratedNeededU
Definition execnodes.h:604
ExprState ** ri_GeneratedExprsU
Definition execnodes.h:600
int ri_NumGeneratedNeededI
Definition execnodes.h:603
bool has_generated_stored
Definition tupdesc.h:46
TupleConstr * constr
Definition tupdesc.h:159
bool * tts_isnull
Definition tuptable.h:133
Datum * tts_values
Definition tuptable.h:131
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
Definition tupdesc.h:178
static CompactAttribute * TupleDescCompactAttr(TupleDesc tupdesc, int i)
Definition tupdesc.h:195
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition tuptable.h:476
static void slot_getallattrs(TupleTableSlot *slot)
Definition tuptable.h:390
static void ExecMaterializeSlot(TupleTableSlot *slot)
Definition tuptable.h:494

References Assert, CompactAttribute::attbyval, CompactAttribute::attlen, CMD_UPDATE, TupleDescData::constr, datumCopy(), ExprContext::ecxt_scantuple, ExecClearTuple(), ExecEvalExpr(), ExecInitGenerated(), ExecMaterializeSlot(), ExecStoreVirtualTuple(), fb(), GetPerTupleExprContext, GetPerTupleMemoryContext, TupleConstr::has_generated_stored, i, memcpy(), MemoryContextSwitchTo(), TupleDescData::natts, palloc_array, RelationGetDescr, ResultRelInfo::ri_GeneratedExprsI, ResultRelInfo::ri_GeneratedExprsU, ResultRelInfo::ri_NumGeneratedNeededI, ResultRelInfo::ri_NumGeneratedNeededU, ResultRelInfo::ri_RelationDesc, slot_getallattrs(), TupleTableSlot::tts_isnull, TupleTableSlot::tts_values, TupleDescAttr(), TupleDescCompactAttr(), val, and values.

Referenced by CopyFrom(), ExecInsert(), ExecSimpleRelationInsert(), ExecSimpleRelationUpdate(), and ExecUpdatePrepareSlot().

◆ ExecEndModifyTable()

void ExecEndModifyTable ( ModifyTableState node)
extern

Definition at line 5785 of file nodeModifyTable.c.

5786{
5787 int i;
5788
5789 /*
5790 * Allow any FDWs to shut down
5791 */
5792 for (i = 0; i < node->mt_nrels; i++)
5793 {
5794 int j;
5795 ResultRelInfo *resultRelInfo = node->resultRelInfo + i;
5796
5797 if (!resultRelInfo->ri_usesFdwDirectModify &&
5798 resultRelInfo->ri_FdwRoutine != NULL &&
5799 resultRelInfo->ri_FdwRoutine->EndForeignModify != NULL)
5800 resultRelInfo->ri_FdwRoutine->EndForeignModify(node->ps.state,
5801 resultRelInfo);
5802
5803 /*
5804 * Cleanup the initialized batch slots. This only matters for FDWs
5805 * with batching, but the other cases will have ri_NumSlotsInitialized
5806 * == 0.
5807 */
5808 for (j = 0; j < resultRelInfo->ri_NumSlotsInitialized; j++)
5809 {
5810 ExecDropSingleTupleTableSlot(resultRelInfo->ri_Slots[j]);
5812 }
5813 }
5814
5815 /*
5816 * Close all the partitioned tables, leaf partitions, and their indices
5817 * and release the slot used for tuple routing, if set.
5818 */
5820 {
5822
5823 if (node->mt_root_tuple_slot)
5825 }
5826
5827 /*
5828 * Terminate EPQ execution if active
5829 */
5831
5832 /*
5833 * shut down subplan
5834 */
5836}
void EvalPlanQualEnd(EPQState *epqstate)
Definition execMain.c:3208
void ExecCleanupTupleRouting(ModifyTableState *mtstate, PartitionTupleRouting *proute)
void ExecEndNode(PlanState *node)
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
#define outerPlanState(node)
Definition execnodes.h:1299
int j
Definition isn.c:78
EndForeignModify_function EndForeignModify
Definition fdwapi.h:241
ResultRelInfo * resultRelInfo
Definition execnodes.h:1446
struct PartitionTupleRouting * mt_partition_tuple_routing
Definition execnodes.h:1477
TupleTableSlot * mt_root_tuple_slot
Definition execnodes.h:1474
EPQState mt_epqstate
Definition execnodes.h:1456
EState * state
Definition execnodes.h:1203
TupleTableSlot ** ri_Slots
Definition execnodes.h:578
int ri_NumSlotsInitialized
Definition execnodes.h:576
struct FdwRoutine * ri_FdwRoutine
Definition execnodes.h:566
TupleTableSlot ** ri_PlanSlots
Definition execnodes.h:579
bool ri_usesFdwDirectModify
Definition execnodes.h:572

References FdwRoutine::EndForeignModify, EvalPlanQualEnd(), ExecCleanupTupleRouting(), ExecDropSingleTupleTableSlot(), ExecEndNode(), fb(), i, j, ModifyTableState::mt_epqstate, ModifyTableState::mt_nrels, ModifyTableState::mt_partition_tuple_routing, ModifyTableState::mt_root_tuple_slot, outerPlanState, ModifyTableState::ps, ModifyTableState::resultRelInfo, ResultRelInfo::ri_FdwRoutine, ResultRelInfo::ri_NumSlotsInitialized, ResultRelInfo::ri_PlanSlots, ResultRelInfo::ri_Slots, ResultRelInfo::ri_usesFdwDirectModify, and PlanState::state.

Referenced by ExecEndNode().

◆ ExecInitGenerated()

void ExecInitGenerated ( ResultRelInfo resultRelInfo,
EState estate,
CmdType  cmdtype 
)
extern

Definition at line 450 of file nodeModifyTable.c.

453{
454 Relation rel = resultRelInfo->ri_RelationDesc;
455 TupleDesc tupdesc = RelationGetDescr(rel);
456 int natts = tupdesc->natts;
459 Bitmapset *updatedCols;
461
462 /* Nothing to do if no generated columns */
463 if (!(tupdesc->constr && (tupdesc->constr->has_generated_stored || tupdesc->constr->has_generated_virtual)))
464 return;
465
466 /*
467 * In an UPDATE, we can skip computing any generated columns that do not
468 * depend on any UPDATE target column. But if there is a BEFORE ROW
469 * UPDATE trigger, we cannot skip because the trigger might change more
470 * columns.
471 */
472 if (cmdtype == CMD_UPDATE &&
474 updatedCols = ExecGetUpdatedCols(resultRelInfo, estate);
475 else
476 updatedCols = NULL;
477
478 /*
479 * Make sure these data structures are built in the per-query memory
480 * context so they'll survive throughout the query.
481 */
483
484 ri_GeneratedExprs = (ExprState **) palloc0(natts * sizeof(ExprState *));
486
487 for (int i = 0; i < natts; i++)
488 {
489 char attgenerated = TupleDescAttr(tupdesc, i)->attgenerated;
490
491 if (attgenerated)
492 {
493 Expr *expr;
494
495 /* Fetch the GENERATED AS expression tree */
496 expr = (Expr *) build_column_default(rel, i + 1);
497 if (expr == NULL)
498 elog(ERROR, "no generation expression found for column number %d of table \"%s\"",
499 i + 1, RelationGetRelationName(rel));
500
501 /*
502 * If it's an update with a known set of update target columns,
503 * see if we can skip the computation.
504 */
505 if (updatedCols)
506 {
507 Bitmapset *attrs_used = NULL;
508
509 pull_varattnos((Node *) expr, 1, &attrs_used);
510
511 if (!bms_overlap(updatedCols, attrs_used))
512 continue; /* need not update this column */
513 }
514
515 /* No luck, so prepare the expression for execution */
516 if (attgenerated == ATTRIBUTE_GENERATED_STORED)
517 {
518 ri_GeneratedExprs[i] = ExecPrepareExpr(expr, estate);
520 }
521
522 /* If UPDATE, mark column in resultRelInfo->ri_extraUpdatedCols */
523 if (cmdtype == CMD_UPDATE)
524 resultRelInfo->ri_extraUpdatedCols =
525 bms_add_member(resultRelInfo->ri_extraUpdatedCols,
527 }
528 }
529
530 if (ri_NumGeneratedNeeded == 0)
531 {
532 /* didn't need it after all */
535 }
536
537 /* Save in appropriate set of fields */
538 if (cmdtype == CMD_UPDATE)
539 {
540 /* Don't call twice */
541 Assert(resultRelInfo->ri_GeneratedExprsU == NULL);
542
543 resultRelInfo->ri_GeneratedExprsU = ri_GeneratedExprs;
545
546 resultRelInfo->ri_extraUpdatedCols_valid = true;
547 }
548 else
549 {
550 /* Don't call twice */
551 Assert(resultRelInfo->ri_GeneratedExprsI == NULL);
552
553 resultRelInfo->ri_GeneratedExprsI = ri_GeneratedExprs;
555 }
556
558}
Bitmapset * bms_add_member(Bitmapset *a, int x)
Definition bitmapset.c:799
bool bms_overlap(const Bitmapset *a, const Bitmapset *b)
Definition bitmapset.c:575
#define ERROR
Definition elog.h:40
#define elog(elevel,...)
Definition elog.h:228
ExprState * ExecPrepareExpr(Expr *node, EState *estate)
Definition execExpr.c:786
Bitmapset * ExecGetUpdatedCols(ResultRelInfo *relinfo, EState *estate)
Definition execUtils.c:1408
void pfree(void *pointer)
Definition mcxt.c:1616
void * palloc0(Size size)
Definition mcxt.c:1417
#define RelationGetRelationName(relation)
Definition rel.h:550
Node * build_column_default(Relation rel, int attrno)
MemoryContext es_query_cxt
Definition execnodes.h:746
Definition nodes.h:135
TriggerDesc * trigdesc
Definition rel.h:117
bool ri_extraUpdatedCols_valid
Definition execnodes.h:533
Bitmapset * ri_extraUpdatedCols
Definition execnodes.h:531
bool trig_update_before_row
Definition reltrigger.h:61
bool has_generated_virtual
Definition tupdesc.h:47
#define FirstLowInvalidHeapAttributeNumber
Definition sysattr.h:27
void pull_varattnos(Node *node, Index varno, Bitmapset **varattnos)
Definition var.c:296

References Assert, bms_add_member(), bms_overlap(), build_column_default(), CMD_UPDATE, TupleDescData::constr, elog, ERROR, EState::es_query_cxt, ExecGetUpdatedCols(), ExecPrepareExpr(), fb(), FirstLowInvalidHeapAttributeNumber, TupleConstr::has_generated_stored, TupleConstr::has_generated_virtual, i, MemoryContextSwitchTo(), TupleDescData::natts, palloc0(), pfree(), pull_varattnos(), RelationGetDescr, RelationGetRelationName, ResultRelInfo::ri_extraUpdatedCols, ResultRelInfo::ri_extraUpdatedCols_valid, ResultRelInfo::ri_GeneratedExprsI, ResultRelInfo::ri_GeneratedExprsU, ResultRelInfo::ri_NumGeneratedNeededI, ResultRelInfo::ri_NumGeneratedNeededU, ResultRelInfo::ri_RelationDesc, TriggerDesc::trig_update_before_row, RelationData::trigdesc, and TupleDescAttr().

Referenced by ExecComputeStoredGenerated(), and ExecGetExtraUpdatedCols().

◆ ExecInitMergeTupleSlots()

void ExecInitMergeTupleSlots ( ModifyTableState mtstate,
ResultRelInfo resultRelInfo 
)
extern

Definition at line 4411 of file nodeModifyTable.c.

4413{
4414 EState *estate = mtstate->ps.state;
4415
4416 Assert(!resultRelInfo->ri_projectNewInfoValid);
4417
4418 resultRelInfo->ri_oldTupleSlot =
4419 table_slot_create(resultRelInfo->ri_RelationDesc,
4420 &estate->es_tupleTable);
4421 resultRelInfo->ri_newTupleSlot =
4422 table_slot_create(resultRelInfo->ri_RelationDesc,
4423 &estate->es_tupleTable);
4424 resultRelInfo->ri_projectNewInfoValid = true;
4425}
List * es_tupleTable
Definition execnodes.h:748
bool ri_projectNewInfoValid
Definition execnodes.h:542
TupleTableSlot * ri_oldTupleSlot
Definition execnodes.h:540
TupleTableSlot * ri_newTupleSlot
Definition execnodes.h:538
TupleTableSlot * table_slot_create(Relation relation, List **reglist)
Definition tableam.c:92

References Assert, EState::es_tupleTable, ModifyTableState::ps, ResultRelInfo::ri_newTupleSlot, ResultRelInfo::ri_oldTupleSlot, ResultRelInfo::ri_projectNewInfoValid, ResultRelInfo::ri_RelationDesc, PlanState::state, and table_slot_create().

Referenced by ExecInitMerge(), and ExecInitPartitionInfo().

◆ ExecInitModifyTable()

ModifyTableState * ExecInitModifyTable ( ModifyTable node,
EState estate,
int  eflags 
)
extern

Definition at line 5084 of file nodeModifyTable.c.

5085{
5086 ModifyTableState *mtstate;
5087 Plan *subplan = outerPlan(node);
5088 CmdType operation = node->operation;
5090 int nrels;
5091 List *resultRelations = NIL;
5092 List *withCheckOptionLists = NIL;
5093 List *returningLists = NIL;
5094 List *updateColnosLists = NIL;
5095 List *mergeActionLists = NIL;
5096 List *mergeJoinConditions = NIL;
5097 ResultRelInfo *resultRelInfo;
5098 List *arowmarks;
5099 ListCell *l;
5100 int i;
5101 Relation rel;
5102
5103 /* check for unsupported flags */
5104 Assert(!(eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK)));
5105
5106 /*
5107 * Only consider unpruned relations for initializing their ResultRelInfo
5108 * struct and other fields such as withCheckOptions, etc.
5109 *
5110 * Note: We must avoid pruning every result relation. This is important
5111 * for MERGE, since even if every result relation is pruned from the
5112 * subplan, there might still be NOT MATCHED rows, for which there may be
5113 * INSERT actions to perform. To allow these actions to be found, at
5114 * least one result relation must be kept. Also, when inserting into a
5115 * partitioned table, ExecInitPartitionInfo() needs a ResultRelInfo struct
5116 * as a reference for building the ResultRelInfo of the target partition.
5117 * In either case, it doesn't matter which result relation is kept, so we
5118 * just keep the first one, if all others have been pruned. See also,
5119 * ExecDoInitialPruning(), which ensures that this first result relation
5120 * has been locked.
5121 */
5122 i = 0;
5123 foreach(l, node->resultRelations)
5124 {
5125 Index rti = lfirst_int(l);
5126 bool keep_rel;
5127
5129 if (!keep_rel && i == total_nrels - 1 && resultRelations == NIL)
5130 {
5131 /* all result relations pruned; keep the first one */
5132 keep_rel = true;
5133 rti = linitial_int(node->resultRelations);
5134 i = 0;
5135 }
5136
5137 if (keep_rel)
5138 {
5139 resultRelations = lappend_int(resultRelations, rti);
5140 if (node->withCheckOptionLists)
5141 {
5144 i);
5145
5146 withCheckOptionLists = lappend(withCheckOptionLists, withCheckOptions);
5147 }
5148 if (node->returningLists)
5149 {
5150 List *returningList = list_nth_node(List,
5151 node->returningLists,
5152 i);
5153
5154 returningLists = lappend(returningLists, returningList);
5155 }
5156 if (node->updateColnosLists)
5157 {
5159
5160 updateColnosLists = lappend(updateColnosLists, updateColnosList);
5161 }
5162 if (node->mergeActionLists)
5163 {
5164 List *mergeActionList = list_nth(node->mergeActionLists, i);
5165
5166 mergeActionLists = lappend(mergeActionLists, mergeActionList);
5167 }
5168 if (node->mergeJoinConditions)
5169 {
5170 List *mergeJoinCondition = list_nth(node->mergeJoinConditions, i);
5171
5172 mergeJoinConditions = lappend(mergeJoinConditions, mergeJoinCondition);
5173 }
5174 }
5175 i++;
5176 }
5177 nrels = list_length(resultRelations);
5178 Assert(nrels > 0);
5179
5180 /*
5181 * create state structure
5182 */
5183 mtstate = makeNode(ModifyTableState);
5184 mtstate->ps.plan = (Plan *) node;
5185 mtstate->ps.state = estate;
5186 mtstate->ps.ExecProcNode = ExecModifyTable;
5187
5188 mtstate->operation = operation;
5189 mtstate->canSetTag = node->canSetTag;
5190 mtstate->mt_done = false;
5191
5192 mtstate->mt_nrels = nrels;
5193 mtstate->resultRelInfo = palloc_array(ResultRelInfo, nrels);
5194
5196 mtstate->mt_merge_inserted = 0;
5197 mtstate->mt_merge_updated = 0;
5198 mtstate->mt_merge_deleted = 0;
5199 mtstate->mt_updateColnosLists = updateColnosLists;
5200 mtstate->mt_mergeActionLists = mergeActionLists;
5201 mtstate->mt_mergeJoinConditions = mergeJoinConditions;
5202
5203 /*----------
5204 * Resolve the target relation. This is the same as:
5205 *
5206 * - the relation for which we will fire FOR STATEMENT triggers,
5207 * - the relation into whose tuple format all captured transition tuples
5208 * must be converted, and
5209 * - the root partitioned table used for tuple routing.
5210 *
5211 * If it's a partitioned or inherited table, the root partition or
5212 * appendrel RTE doesn't appear elsewhere in the plan and its RT index is
5213 * given explicitly in node->rootRelation. Otherwise, the target relation
5214 * is the sole relation in the node->resultRelations list and, since it can
5215 * never be pruned, also in the resultRelations list constructed above.
5216 *----------
5217 */
5218 if (node->rootRelation > 0)
5219 {
5223 node->rootRelation);
5224 }
5225 else
5226 {
5227 Assert(list_length(node->resultRelations) == 1);
5228 Assert(list_length(resultRelations) == 1);
5229 mtstate->rootResultRelInfo = mtstate->resultRelInfo;
5230 ExecInitResultRelation(estate, mtstate->resultRelInfo,
5231 linitial_int(resultRelations));
5232 }
5233
5234 /* set up epqstate with dummy subplan data for the moment */
5235 EvalPlanQualInit(&mtstate->mt_epqstate, estate, NULL, NIL,
5236 node->epqParam, resultRelations);
5237 mtstate->fireBSTriggers = true;
5238
5239 /*
5240 * Build state for collecting transition tuples. This requires having a
5241 * valid trigger query context, so skip it in explain-only mode.
5242 */
5243 if (!(eflags & EXEC_FLAG_EXPLAIN_ONLY))
5244 ExecSetupTransitionCaptureState(mtstate, estate);
5245
5246 /*
5247 * Open all the result relations and initialize the ResultRelInfo structs.
5248 * (But root relation was initialized above, if it's part of the array.)
5249 * We must do this before initializing the subplan, because direct-modify
5250 * FDWs expect their ResultRelInfos to be available.
5251 */
5252 resultRelInfo = mtstate->resultRelInfo;
5253 i = 0;
5254 foreach(l, resultRelations)
5255 {
5256 Index resultRelation = lfirst_int(l);
5258
5259 if (mergeActionLists)
5260 mergeActions = list_nth(mergeActionLists, i);
5261
5262 if (resultRelInfo != mtstate->rootResultRelInfo)
5263 {
5264 ExecInitResultRelation(estate, resultRelInfo, resultRelation);
5265
5266 /*
5267 * For child result relations, store the root result relation
5268 * pointer. We do so for the convenience of places that want to
5269 * look at the query's original target relation but don't have the
5270 * mtstate handy.
5271 */
5272 resultRelInfo->ri_RootResultRelInfo = mtstate->rootResultRelInfo;
5273 }
5274
5275 /* Initialize the usesFdwDirectModify flag */
5276 resultRelInfo->ri_usesFdwDirectModify =
5278
5279 /*
5280 * Verify result relation is a valid target for the current operation
5281 */
5282 CheckValidResultRel(resultRelInfo, operation, node->onConflictAction,
5283 mergeActions);
5284
5285 resultRelInfo++;
5286 i++;
5287 }
5288
5289 /*
5290 * Now we may initialize the subplan.
5291 */
5292 outerPlanState(mtstate) = ExecInitNode(subplan, estate, eflags);
5293
5294 /*
5295 * Do additional per-result-relation initialization.
5296 */
5297 for (i = 0; i < nrels; i++)
5298 {
5299 resultRelInfo = &mtstate->resultRelInfo[i];
5300
5301 /* Let FDWs init themselves for foreign-table result rels */
5302 if (!resultRelInfo->ri_usesFdwDirectModify &&
5303 resultRelInfo->ri_FdwRoutine != NULL &&
5304 resultRelInfo->ri_FdwRoutine->BeginForeignModify != NULL)
5305 {
5306 List *fdw_private = (List *) list_nth(node->fdwPrivLists, i);
5307
5308 resultRelInfo->ri_FdwRoutine->BeginForeignModify(mtstate,
5309 resultRelInfo,
5310 fdw_private,
5311 i,
5312 eflags);
5313 }
5314
5315 /*
5316 * For UPDATE/DELETE/MERGE, find the appropriate junk attr now, either
5317 * a 'ctid' or 'wholerow' attribute depending on relkind. For foreign
5318 * tables, the FDW might have created additional junk attr(s), but
5319 * those are no concern of ours.
5320 */
5323 {
5324 char relkind;
5325
5326 relkind = resultRelInfo->ri_RelationDesc->rd_rel->relkind;
5327 if (relkind == RELKIND_RELATION ||
5328 relkind == RELKIND_MATVIEW ||
5329 relkind == RELKIND_PARTITIONED_TABLE)
5330 {
5331 resultRelInfo->ri_RowIdAttNo =
5332 ExecFindJunkAttributeInTlist(subplan->targetlist, "ctid");
5333
5334 /*
5335 * For heap relations, a ctid junk attribute must be present.
5336 * Partitioned tables should only appear here when all leaf
5337 * partitions were pruned, in which case no rows can be
5338 * produced and ctid is not needed.
5339 */
5340 if (relkind == RELKIND_PARTITIONED_TABLE)
5341 Assert(nrels == 1);
5342 else if (!AttributeNumberIsValid(resultRelInfo->ri_RowIdAttNo))
5343 elog(ERROR, "could not find junk ctid column");
5344 }
5345 else if (relkind == RELKIND_FOREIGN_TABLE)
5346 {
5347 /*
5348 * We don't support MERGE with foreign tables for now. (It's
5349 * problematic because the implementation uses CTID.)
5350 */
5352
5353 /*
5354 * When there is a row-level trigger, there should be a
5355 * wholerow attribute. We also require it to be present in
5356 * UPDATE and MERGE, so we can get the values of unchanged
5357 * columns.
5358 */
5359 resultRelInfo->ri_RowIdAttNo =
5361 "wholerow");
5362 if ((mtstate->operation == CMD_UPDATE || mtstate->operation == CMD_MERGE) &&
5363 !AttributeNumberIsValid(resultRelInfo->ri_RowIdAttNo))
5364 elog(ERROR, "could not find junk wholerow column");
5365 }
5366 else
5367 {
5368 /* Other valid target relkinds must provide wholerow */
5369 resultRelInfo->ri_RowIdAttNo =
5371 "wholerow");
5372 if (!AttributeNumberIsValid(resultRelInfo->ri_RowIdAttNo))
5373 elog(ERROR, "could not find junk wholerow column");
5374 }
5375 }
5376 }
5377
5378 /*
5379 * If this is an inherited update/delete/merge, there will be a junk
5380 * attribute named "tableoid" present in the subplan's targetlist. It
5381 * will be used to identify the result relation for a given tuple to be
5382 * updated/deleted/merged.
5383 */
5384 mtstate->mt_resultOidAttno =
5385 ExecFindJunkAttributeInTlist(subplan->targetlist, "tableoid");
5387 mtstate->mt_lastResultOid = InvalidOid; /* force lookup at first tuple */
5388 mtstate->mt_lastResultIndex = 0; /* must be zero if no such attr */
5389
5390 /* Get the root target relation */
5391 rel = mtstate->rootResultRelInfo->ri_RelationDesc;
5392
5393 /*
5394 * Build state for tuple routing if it's a partitioned INSERT. An UPDATE
5395 * or MERGE might need this too, but only if it actually moves tuples
5396 * between partitions; in that case setup is done by
5397 * ExecCrossPartitionUpdate.
5398 */
5399 if (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE &&
5402 ExecSetupPartitionTupleRouting(estate, rel);
5403
5404 /*
5405 * Initialize any WITH CHECK OPTION constraints if needed.
5406 */
5407 resultRelInfo = mtstate->resultRelInfo;
5408 foreach(l, withCheckOptionLists)
5409 {
5410 List *wcoList = (List *) lfirst(l);
5411 List *wcoExprs = NIL;
5412 ListCell *ll;
5413
5414 foreach(ll, wcoList)
5415 {
5417 ExprState *wcoExpr = ExecInitQual((List *) wco->qual,
5418 &mtstate->ps);
5419
5421 }
5422
5423 resultRelInfo->ri_WithCheckOptions = wcoList;
5424 resultRelInfo->ri_WithCheckOptionExprs = wcoExprs;
5425 resultRelInfo++;
5426 }
5427
5428 /*
5429 * Initialize RETURNING projections if needed.
5430 */
5431 if (returningLists)
5432 {
5433 TupleTableSlot *slot;
5434 ExprContext *econtext;
5435
5436 /*
5437 * Initialize result tuple slot and assign its rowtype using the plan
5438 * node's declared targetlist, which the planner set up to be the same
5439 * as the first (before runtime pruning) RETURNING list. We assume
5440 * all the result rels will produce compatible output.
5441 */
5443 slot = mtstate->ps.ps_ResultTupleSlot;
5444
5445 /* Need an econtext too */
5446 if (mtstate->ps.ps_ExprContext == NULL)
5447 ExecAssignExprContext(estate, &mtstate->ps);
5448 econtext = mtstate->ps.ps_ExprContext;
5449
5450 /*
5451 * Build a projection for each result rel.
5452 */
5453 resultRelInfo = mtstate->resultRelInfo;
5454 foreach(l, returningLists)
5455 {
5456 List *rlist = (List *) lfirst(l);
5457
5458 resultRelInfo->ri_returningList = rlist;
5459 resultRelInfo->ri_projectReturning =
5460 ExecBuildProjectionInfo(rlist, econtext, slot, &mtstate->ps,
5461 resultRelInfo->ri_RelationDesc->rd_att);
5462 resultRelInfo++;
5463 }
5464 }
5465 else
5466 {
5467 /*
5468 * We still must construct a dummy result tuple type, because InitPlan
5469 * expects one (maybe should change that?).
5470 */
5471 ExecInitResultTypeTL(&mtstate->ps);
5472
5473 mtstate->ps.ps_ExprContext = NULL;
5474 }
5475
5476 /* Set the list of arbiter indexes if needed for ON CONFLICT */
5477 resultRelInfo = mtstate->resultRelInfo;
5478 if (node->onConflictAction != ONCONFLICT_NONE)
5479 {
5480 /* insert may only have one relation, inheritance is not expanded */
5481 Assert(total_nrels == 1);
5482 resultRelInfo->ri_onConflictArbiterIndexes = node->arbiterIndexes;
5483 }
5484
5485 /*
5486 * For ON CONFLICT DO SELECT/UPDATE, initialize the ON CONFLICT action
5487 * state.
5488 */
5489 if (node->onConflictAction == ONCONFLICT_UPDATE ||
5491 {
5493
5494 /* already exists if created by RETURNING processing above */
5495 if (mtstate->ps.ps_ExprContext == NULL)
5496 ExecAssignExprContext(estate, &mtstate->ps);
5497
5498 /* action state for DO SELECT/UPDATE */
5499 resultRelInfo->ri_onConflict = onconfl;
5500
5501 /* lock strength for DO SELECT [FOR UPDATE/SHARE] */
5503
5504 /* initialize slot for the existing tuple */
5505 onconfl->oc_Existing =
5506 table_slot_create(resultRelInfo->ri_RelationDesc,
5507 &mtstate->ps.state->es_tupleTable);
5508
5509 /*
5510 * For ON CONFLICT DO UPDATE, initialize target list and projection.
5511 */
5513 {
5514 ExprContext *econtext;
5516
5517 econtext = mtstate->ps.ps_ExprContext;
5518 relationDesc = resultRelInfo->ri_RelationDesc->rd_att;
5519
5520 /*
5521 * Create the tuple slot for the UPDATE SET projection. We want a
5522 * slot of the table's type here, because the slot will be used to
5523 * insert into the table, and for RETURNING processing - which may
5524 * access system attributes.
5525 */
5526 onconfl->oc_ProjSlot =
5527 table_slot_create(resultRelInfo->ri_RelationDesc,
5528 &mtstate->ps.state->es_tupleTable);
5529
5530 /* build UPDATE SET projection state */
5531 onconfl->oc_ProjInfo =
5533 true,
5534 node->onConflictCols,
5536 econtext,
5537 onconfl->oc_ProjSlot,
5538 &mtstate->ps);
5539 }
5540
5541 /* initialize state to evaluate the WHERE clause, if any */
5542 if (node->onConflictWhere)
5543 {
5544 ExprState *qualexpr;
5545
5546 qualexpr = ExecInitQual((List *) node->onConflictWhere,
5547 &mtstate->ps);
5548 onconfl->oc_WhereClause = qualexpr;
5549 }
5550 }
5551
5552 /*
5553 * If needed, initialize the target range for FOR PORTION OF.
5554 */
5555 if (node->forPortionOf)
5556 {
5558 TupleDesc tupDesc;
5559 ForPortionOfExpr *forPortionOf;
5560 Datum targetRange;
5561 bool isNull;
5562 ExprContext *econtext;
5565
5566 rootRelInfo = mtstate->resultRelInfo;
5567 if (rootRelInfo->ri_RootResultRelInfo)
5569
5570 tupDesc = rootRelInfo->ri_RelationDesc->rd_att;
5571 forPortionOf = (ForPortionOfExpr *) node->forPortionOf;
5572
5573 /* Eval the FOR PORTION OF target */
5574 if (mtstate->ps.ps_ExprContext == NULL)
5575 ExecAssignExprContext(estate, &mtstate->ps);
5576 econtext = mtstate->ps.ps_ExprContext;
5577
5578 exprState = ExecPrepareExpr((Expr *) forPortionOf->targetRange, estate);
5579 targetRange = ExecEvalExpr(exprState, econtext, &isNull);
5580
5581 /*
5582 * FOR PORTION OF ... TO ... FROM should never give us a NULL target,
5583 * but FOR PORTION OF (...) could.
5584 */
5585 if (isNull)
5586 ereport(ERROR,
5587 (errmsg("FOR PORTION OF target was null")),
5588 executor_errposition(estate, forPortionOf->targetLocation));
5589
5590 /* Create state for FOR PORTION OF operation */
5591
5593 fpoState->fp_rangeName = forPortionOf->range_name;
5594 fpoState->fp_rangeType = forPortionOf->rangeType;
5595 fpoState->fp_rangeAttno = forPortionOf->rangeVar->varattno;
5596 fpoState->fp_targetRange = targetRange;
5597
5598 /* Initialize slot for the existing tuple */
5599
5600 fpoState->fp_Existing =
5601 table_slot_create(rootRelInfo->ri_RelationDesc,
5602 &mtstate->ps.state->es_tupleTable);
5603
5604 /* Create the tuple slot for INSERTing the temporal leftovers */
5605
5606 fpoState->fp_Leftover =
5607 ExecInitExtraTupleSlot(mtstate->ps.state, tupDesc, &TTSOpsVirtual);
5608
5609 rootRelInfo->ri_forPortionOf = fpoState;
5610
5611 /*
5612 * Make sure the root relation has the FOR PORTION OF clause too. Each
5613 * partition needs its own TupleTableSlot, since they can have
5614 * different descriptors, so they'll use the root fpoState to
5615 * initialize one if necessary.
5616 */
5617 if (node->rootRelation > 0)
5619
5620 if (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE &&
5621 mtstate->mt_partition_tuple_routing == NULL)
5622 {
5623 /*
5624 * We will need tuple routing to insert temporal leftovers. Since
5625 * we are initializing things before ExecCrossPartitionUpdate
5626 * runs, we must do everything it needs as well.
5627 */
5630
5631 /* Things built here have to last for the query duration. */
5633
5636
5637 /*
5638 * Before a partition's tuple can be re-routed, it must first be
5639 * converted to the root's format, so we'll need a slot for
5640 * storing such tuples.
5641 */
5642 Assert(mtstate->mt_root_tuple_slot == NULL);
5644
5646 }
5647
5648 /*
5649 * Don't free the ExprContext here because the result must last for
5650 * the whole query.
5651 */
5652 }
5653
5654 /*
5655 * If we have any secondary relations in an UPDATE or DELETE, they need to
5656 * be treated like non-locked relations in SELECT FOR UPDATE, i.e., the
5657 * EvalPlanQual mechanism needs to be told about them. This also goes for
5658 * the source relations in a MERGE. Locate the relevant ExecRowMarks.
5659 */
5660 arowmarks = NIL;
5661 foreach(l, node->rowMarks)
5662 {
5664 RangeTblEntry *rte = exec_rt_fetch(rc->rti, estate);
5667
5668 /* ignore "parent" rowmarks; they are irrelevant at runtime */
5669 if (rc->isParent)
5670 continue;
5671
5672 /*
5673 * Also ignore rowmarks belonging to child tables that have been
5674 * pruned in ExecDoInitialPruning().
5675 */
5676 if (rte->rtekind == RTE_RELATION &&
5677 !bms_is_member(rc->rti, estate->es_unpruned_relids))
5678 continue;
5679
5680 /* Find ExecRowMark and build ExecAuxRowMark */
5681 erm = ExecFindRowMark(estate, rc->rti, false);
5684 }
5685
5686 /* For a MERGE command, initialize its state */
5687 if (mtstate->operation == CMD_MERGE)
5688 ExecInitMerge(mtstate, estate);
5689
5690 EvalPlanQualSetPlan(&mtstate->mt_epqstate, subplan, arowmarks);
5691
5692 /*
5693 * If there are a lot of result relations, use a hash table to speed the
5694 * lookups. If there are not a lot, a simple linear search is faster.
5695 *
5696 * It's not clear where the threshold is, but try 64 for starters. In a
5697 * debugging build, use a small threshold so that we get some test
5698 * coverage of both code paths.
5699 */
5700#ifdef USE_ASSERT_CHECKING
5701#define MT_NRELS_HASH 4
5702#else
5703#define MT_NRELS_HASH 64
5704#endif
5705 if (nrels >= MT_NRELS_HASH)
5706 {
5708
5709 hash_ctl.keysize = sizeof(Oid);
5710 hash_ctl.entrysize = sizeof(MTTargetRelLookup);
5712 mtstate->mt_resultOidHash =
5713 hash_create("ModifyTable target hash",
5714 nrels, &hash_ctl,
5716 for (i = 0; i < nrels; i++)
5717 {
5718 Oid hashkey;
5720 bool found;
5721
5722 resultRelInfo = &mtstate->resultRelInfo[i];
5723 hashkey = RelationGetRelid(resultRelInfo->ri_RelationDesc);
5726 HASH_ENTER, &found);
5727 Assert(!found);
5728 mtlookup->relationIndex = i;
5729 }
5730 }
5731 else
5732 mtstate->mt_resultOidHash = NULL;
5733
5734 /*
5735 * Determine if the FDW supports batch insert and determine the batch size
5736 * (a FDW may support batching, but it may be disabled for the
5737 * server/table).
5738 *
5739 * We only do this for INSERT, so that for UPDATE/DELETE the batch size
5740 * remains set to 0.
5741 */
5742 if (operation == CMD_INSERT)
5743 {
5744 /* insert may only have one relation, inheritance is not expanded */
5745 Assert(total_nrels == 1);
5746 resultRelInfo = mtstate->resultRelInfo;
5747 if (!resultRelInfo->ri_usesFdwDirectModify &&
5748 resultRelInfo->ri_FdwRoutine != NULL &&
5749 resultRelInfo->ri_FdwRoutine->GetForeignModifyBatchSize &&
5750 resultRelInfo->ri_FdwRoutine->ExecForeignBatchInsert)
5751 {
5752 resultRelInfo->ri_BatchSize =
5753 resultRelInfo->ri_FdwRoutine->GetForeignModifyBatchSize(resultRelInfo);
5754 Assert(resultRelInfo->ri_BatchSize >= 1);
5755 }
5756 else
5757 resultRelInfo->ri_BatchSize = 1;
5758 }
5759
5760 /*
5761 * Lastly, if this is not the primary (canSetTag) ModifyTable node, add it
5762 * to estate->es_auxmodifytables so that it will be run to completion by
5763 * ExecPostprocessPlan. (It'd actually work fine to add the primary
5764 * ModifyTable node too, but there's no need.) Note the use of lcons not
5765 * lappend: we need later-initialized ModifyTable nodes to be shut down
5766 * before earlier ones. This ensures that we don't throw away RETURNING
5767 * rows that need to be seen by a later CTE subplan.
5768 */
5769 if (!mtstate->canSetTag)
5770 estate->es_auxmodifytables = lcons(mtstate,
5771 estate->es_auxmodifytables);
5772
5773 return mtstate;
5774}
#define AttributeNumberIsValid(attributeNumber)
Definition attnum.h:34
bool bms_is_member(int x, const Bitmapset *a)
Definition bitmapset.c:510
unsigned int Index
Definition c.h:698
static DataChecksumsWorkerOperation operation
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
Definition dynahash.c:889
HTAB * hash_create(const char *tabname, int64 nelem, const HASHCTL *info, int flags)
Definition dynahash.c:360
#define ereport(elevel,...)
Definition elog.h:152
ProjectionInfo * ExecBuildProjectionInfo(List *targetList, ExprContext *econtext, TupleTableSlot *slot, PlanState *parent, TupleDesc inputDesc)
Definition execExpr.c:391
ExprState * ExecInitQual(List *qual, PlanState *parent)
Definition execExpr.c:250
ProjectionInfo * ExecBuildUpdateProjection(List *targetList, bool evalTargetList, List *targetColnos, TupleDesc relDesc, ExprContext *econtext, TupleTableSlot *slot, PlanState *parent)
Definition execExpr.c:568
AttrNumber ExecFindJunkAttributeInTlist(List *targetlist, const char *attrName)
Definition execJunk.c:222
ExecRowMark * ExecFindRowMark(EState *estate, Index rti, bool missing_ok)
Definition execMain.c:2585
ExecAuxRowMark * ExecBuildAuxRowMark(ExecRowMark *erm, List *targetlist)
Definition execMain.c:2608
void CheckValidResultRel(ResultRelInfo *resultRelInfo, CmdType operation, OnConflictAction onConflictAction, List *mergeActions)
Definition execMain.c:1065
void EvalPlanQualInit(EPQState *epqstate, EState *parentestate, Plan *subplan, List *auxrowmarks, int epqParam, List *resultRelations)
Definition execMain.c:2747
void EvalPlanQualSetPlan(EPQState *epqstate, Plan *subplan, List *auxrowmarks)
Definition execMain.c:2788
PartitionTupleRouting * ExecSetupPartitionTupleRouting(EState *estate, Relation rel)
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
const TupleTableSlotOps TTSOpsVirtual
Definition execTuples.c:84
void ExecInitResultTypeTL(PlanState *planstate)
TupleTableSlot * ExecInitExtraTupleSlot(EState *estate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
void ExecInitResultTupleSlotTL(PlanState *planstate, const TupleTableSlotOps *tts_ops)
int executor_errposition(EState *estate, int location)
Definition execUtils.c:962
void ExecInitResultRelation(EState *estate, ResultRelInfo *resultRelInfo, Index rti)
Definition execUtils.c:906
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition execUtils.c:490
#define EXEC_FLAG_BACKWARD
Definition executor.h:70
static RangeTblEntry * exec_rt_fetch(Index rti, EState *estate)
Definition executor.h:710
#define EXEC_FLAG_EXPLAIN_ONLY
Definition executor.h:67
#define EXEC_FLAG_MARK
Definition executor.h:71
@ HASH_ENTER
Definition hsearch.h:109
#define HASH_CONTEXT
Definition hsearch.h:97
#define HASH_ELEM
Definition hsearch.h:90
#define HASH_BLOBS
Definition hsearch.h:92
List * lappend(List *list, void *datum)
Definition list.c:339
List * lappend_int(List *list, int datum)
Definition list.c:357
List * lcons(void *datum, List *list)
Definition list.c:495
MemoryContext CurrentMemoryContext
Definition mcxt.c:160
static void ExecSetupTransitionCaptureState(ModifyTableState *mtstate, EState *estate)
static TupleTableSlot * ExecModifyTable(PlanState *pstate)
#define MT_NRELS_HASH
static void ExecInitMerge(ModifyTableState *mtstate, EState *estate)
@ ONCONFLICT_NONE
Definition nodes.h:428
@ ONCONFLICT_SELECT
Definition nodes.h:431
@ ONCONFLICT_UPDATE
Definition nodes.h:430
CmdType
Definition nodes.h:273
@ CMD_MERGE
Definition nodes.h:279
@ CMD_INSERT
Definition nodes.h:277
@ CMD_DELETE
Definition nodes.h:278
#define makeNode(_type_)
Definition nodes.h:161
static char * errmsg
@ RTE_RELATION
#define lfirst(lc)
Definition pg_list.h:172
#define lfirst_node(type, lc)
Definition pg_list.h:176
static int list_length(const List *l)
Definition pg_list.h:152
#define NIL
Definition pg_list.h:68
#define lfirst_int(lc)
Definition pg_list.h:173
#define linitial_int(l)
Definition pg_list.h:179
static void * list_nth(const List *list, int n)
Definition pg_list.h:331
#define list_nth_node(type, list, n)
Definition pg_list.h:359
#define outerPlan(node)
Definition plannodes.h:267
#define InvalidOid
unsigned int Oid
#define RelationGetRelid(relation)
Definition rel.h:516
Bitmapset * es_unpruned_relids
Definition execnodes.h:709
List * es_auxmodifytables
Definition execnodes.h:763
BeginForeignModify_function BeginForeignModify
Definition fdwapi.h:235
ExecForeignBatchInsert_function ExecForeignBatchInsert
Definition fdwapi.h:237
GetForeignModifyBatchSize_function GetForeignModifyBatchSize
Definition fdwapi.h:238
ParseLoc targetLocation
Definition primnodes.h:2452
Size keysize
Definition hsearch.h:69
Definition pg_list.h:54
List * mt_mergeJoinConditions
Definition execnodes.h:1510
TupleTableSlot * mt_merge_pending_not_matched
Definition execnodes.h:1496
double mt_merge_deleted
Definition execnodes.h:1501
List * mt_updateColnosLists
Definition execnodes.h:1508
double mt_merge_inserted
Definition execnodes.h:1499
double mt_merge_updated
Definition execnodes.h:1500
List * mt_mergeActionLists
Definition execnodes.h:1509
HTAB * mt_resultOidHash
Definition execnodes.h:1468
ResultRelInfo * rootResultRelInfo
Definition execnodes.h:1454
List * updateColnosLists
Definition plannodes.h:350
List * arbiterIndexes
Definition plannodes.h:370
List * onConflictCols
Definition plannodes.h:376
List * mergeJoinConditions
Definition plannodes.h:388
CmdType operation
Definition plannodes.h:340
Node * forPortionOf
Definition plannodes.h:380
List * resultRelations
Definition plannodes.h:348
Bitmapset * fdwDirectModifyPlans
Definition plannodes.h:362
List * onConflictSet
Definition plannodes.h:374
List * mergeActionLists
Definition plannodes.h:386
bool canSetTag
Definition plannodes.h:342
List * fdwPrivLists
Definition plannodes.h:360
List * returningLists
Definition plannodes.h:358
List * withCheckOptionLists
Definition plannodes.h:352
LockClauseStrength onConflictLockStrength
Definition plannodes.h:372
Index rootRelation
Definition plannodes.h:346
Node * onConflictWhere
Definition plannodes.h:378
List * rowMarks
Definition plannodes.h:364
OnConflictAction onConflictAction
Definition plannodes.h:368
LockClauseStrength oc_LockStrength
Definition execnodes.h:450
Plan * plan
Definition execnodes.h:1201
ExprContext * ps_ExprContext
Definition execnodes.h:1242
TupleTableSlot * ps_ResultTupleSlot
Definition execnodes.h:1241
ExecProcNodeMtd ExecProcNode
Definition execnodes.h:1207
List * targetlist
Definition plannodes.h:235
TupleDesc rd_att
Definition rel.h:112
Form_pg_class rd_rel
Definition rel.h:111
OnConflictActionState * ri_onConflict
Definition execnodes.h:616
List * ri_onConflictArbiterIndexes
Definition execnodes.h:613
struct ResultRelInfo * ri_RootResultRelInfo
Definition execnodes.h:654
List * ri_WithCheckOptions
Definition execnodes.h:582
ForPortionOfState * ri_forPortionOf
Definition execnodes.h:625
List * ri_WithCheckOptionExprs
Definition execnodes.h:585
ProjectionInfo * ri_projectReturning
Definition execnodes.h:610
List * ri_returningList
Definition execnodes.h:607
AttrNumber ri_RowIdAttNo
Definition execnodes.h:528
AttrNumber varattno
Definition primnodes.h:275

References ModifyTable::arbiterIndexes, Assert, AttributeNumberIsValid, FdwRoutine::BeginForeignModify, bms_is_member(), ModifyTableState::canSetTag, ModifyTable::canSetTag, CheckValidResultRel(), CMD_DELETE, CMD_INSERT, CMD_MERGE, CMD_UPDATE, CurrentMemoryContext, elog, ModifyTable::epqParam, ereport, errmsg, ERROR, EState::es_auxmodifytables, EState::es_query_cxt, EState::es_tupleTable, EState::es_unpruned_relids, EvalPlanQualInit(), EvalPlanQualSetPlan(), EXEC_FLAG_BACKWARD, EXEC_FLAG_EXPLAIN_ONLY, EXEC_FLAG_MARK, exec_rt_fetch(), ExecAssignExprContext(), ExecBuildAuxRowMark(), ExecBuildProjectionInfo(), ExecBuildUpdateProjection(), ExecEvalExpr(), ExecFindJunkAttributeInTlist(), ExecFindRowMark(), FdwRoutine::ExecForeignBatchInsert, ExecInitExtraTupleSlot(), ExecInitMerge(), ExecInitNode(), ExecInitQual(), ExecInitResultRelation(), ExecInitResultTupleSlotTL(), ExecInitResultTypeTL(), ExecModifyTable(), ExecPrepareExpr(), PlanState::ExecProcNode, ExecSetupPartitionTupleRouting(), ExecSetupTransitionCaptureState(), executor_errposition(), fb(), ModifyTable::fdwDirectModifyPlans, ModifyTable::fdwPrivLists, ModifyTableState::fireBSTriggers, ModifyTable::forPortionOf, FdwRoutine::GetForeignModifyBatchSize, HASH_BLOBS, HASH_CONTEXT, hash_create(), HASH_ELEM, HASH_ENTER, hash_search(), i, InvalidOid, PlanRowMark::isParent, HASHCTL::keysize, lappend(), lappend_int(), lcons(), lfirst, lfirst_int, lfirst_node, linitial_int, list_length(), list_nth(), list_nth_node, makeNode, MemoryContextSwitchTo(), ModifyTable::mergeActionLists, ModifyTable::mergeJoinConditions, ModifyTableState::mt_done, ModifyTableState::mt_epqstate, ModifyTableState::mt_lastResultIndex, ModifyTableState::mt_lastResultOid, ModifyTableState::mt_merge_deleted, ModifyTableState::mt_merge_inserted, ModifyTableState::mt_merge_pending_not_matched, ModifyTableState::mt_merge_updated, ModifyTableState::mt_mergeActionLists, ModifyTableState::mt_mergeJoinConditions, ModifyTableState::mt_nrels, MT_NRELS_HASH, ModifyTableState::mt_partition_tuple_routing, ModifyTableState::mt_resultOidAttno, ModifyTableState::mt_resultOidHash, ModifyTableState::mt_root_tuple_slot, ModifyTableState::mt_updateColnosLists, NIL, OnConflictActionState::oc_LockStrength, ONCONFLICT_NONE, ONCONFLICT_SELECT, ONCONFLICT_UPDATE, ModifyTable::onConflictAction, ModifyTable::onConflictCols, ModifyTable::onConflictLockStrength, ModifyTable::onConflictSet, ModifyTable::onConflictWhere, operation, ModifyTableState::operation, ModifyTable::operation, outerPlan, outerPlanState, palloc_array, PlanState::plan, ModifyTableState::ps, PlanState::ps_ExprContext, PlanState::ps_ResultTupleSlot, ForPortionOfExpr::range_name, ForPortionOfExpr::rangeType, ForPortionOfExpr::rangeVar, RelationData::rd_att, RelationData::rd_rel, RelationGetRelid, ModifyTable::resultRelations, ModifyTableState::resultRelInfo, ModifyTable::returningLists, ResultRelInfo::ri_BatchSize, ResultRelInfo::ri_FdwRoutine, ResultRelInfo::ri_forPortionOf, ResultRelInfo::ri_onConflict, ResultRelInfo::ri_onConflictArbiterIndexes, ResultRelInfo::ri_projectReturning, ResultRelInfo::ri_RelationDesc, ResultRelInfo::ri_returningList, ResultRelInfo::ri_RootResultRelInfo, ResultRelInfo::ri_RowIdAttNo, ResultRelInfo::ri_usesFdwDirectModify, ResultRelInfo::ri_WithCheckOptionExprs, ResultRelInfo::ri_WithCheckOptions, ModifyTable::rootRelation, ModifyTableState::rootResultRelInfo, ModifyTable::rowMarks, RTE_RELATION, PlanRowMark::rti, PlanState::state, table_slot_create(), Plan::targetlist, ForPortionOfExpr::targetLocation, ForPortionOfExpr::targetRange, TTSOpsVirtual, ModifyTable::updateColnosLists, Var::varattno, and ModifyTable::withCheckOptionLists.

Referenced by ExecInitNode().

◆ ExecReScanModifyTable()

void ExecReScanModifyTable ( ModifyTableState node)
extern

Definition at line 5839 of file nodeModifyTable.c.

5840{
5841 /*
5842 * Currently, we don't need to support rescan on ModifyTable nodes. The
5843 * semantics of that would be a bit debatable anyway.
5844 */
5845 elog(ERROR, "ExecReScanModifyTable is not implemented");
5846}

References elog, and ERROR.

Referenced by ExecReScan().