PostgreSQL Source Code git master
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 
)

Definition at line 545 of file nodeModifyTable.c.

548{
549 Relation rel = resultRelInfo->ri_RelationDesc;
550 TupleDesc tupdesc = RelationGetDescr(rel);
551 int natts = tupdesc->natts;
552 ExprContext *econtext = GetPerTupleExprContext(estate);
553 ExprState **ri_GeneratedExprs;
554 MemoryContext oldContext;
555 Datum *values;
556 bool *nulls;
557
558 /* We should not be called unless this is true */
559 Assert(tupdesc->constr && tupdesc->constr->has_generated_stored);
560
561 /*
562 * Initialize the expressions if we didn't already, and check whether we
563 * can exit early because nothing needs to be computed.
564 */
565 if (cmdtype == CMD_UPDATE)
566 {
567 if (resultRelInfo->ri_GeneratedExprsU == NULL)
568 ExecInitGenerated(resultRelInfo, estate, cmdtype);
569 if (resultRelInfo->ri_NumGeneratedNeededU == 0)
570 return;
571 ri_GeneratedExprs = resultRelInfo->ri_GeneratedExprsU;
572 }
573 else
574 {
575 if (resultRelInfo->ri_GeneratedExprsI == NULL)
576 ExecInitGenerated(resultRelInfo, estate, cmdtype);
577 /* Early exit is impossible given the prior Assert */
578 Assert(resultRelInfo->ri_NumGeneratedNeededI > 0);
579 ri_GeneratedExprs = resultRelInfo->ri_GeneratedExprsI;
580 }
581
583
584 values = palloc_array(Datum, natts);
585 nulls = palloc_array(bool, natts);
586
587 slot_getallattrs(slot);
588 memcpy(nulls, slot->tts_isnull, sizeof(*nulls) * natts);
589
590 for (int i = 0; i < natts; i++)
591 {
592 CompactAttribute *attr = TupleDescCompactAttr(tupdesc, i);
593
594 if (ri_GeneratedExprs[i])
595 {
596 Datum val;
597 bool isnull;
598
599 Assert(TupleDescAttr(tupdesc, i)->attgenerated == ATTRIBUTE_GENERATED_STORED);
600
601 econtext->ecxt_scantuple = slot;
602
603 val = ExecEvalExpr(ri_GeneratedExprs[i], econtext, &isnull);
604
605 /*
606 * We must make a copy of val as we have no guarantees about where
607 * memory for a pass-by-reference Datum is located.
608 */
609 if (!isnull)
610 val = datumCopy(val, attr->attbyval, attr->attlen);
611
612 values[i] = val;
613 nulls[i] = isnull;
614 }
615 else
616 {
617 if (!nulls[i])
618 values[i] = datumCopy(slot->tts_values[i], attr->attbyval, attr->attlen);
619 }
620 }
621
622 ExecClearTuple(slot);
623 memcpy(slot->tts_values, values, sizeof(*values) * natts);
624 memcpy(slot->tts_isnull, nulls, sizeof(*nulls) * natts);
627
628 MemoryContextSwitchTo(oldContext);
629}
static Datum values[MAXATTR]
Definition: bootstrap.c:153
Datum datumCopy(Datum value, bool typByVal, int typLen)
Definition: datum.c:132
TupleTableSlot * ExecStoreVirtualTuple(TupleTableSlot *slot)
Definition: execTuples.c:1741
#define GetPerTupleExprContext(estate)
Definition: executor.h:656
#define GetPerTupleMemoryContext(estate)
Definition: executor.h:661
static Datum ExecEvalExpr(ExprState *state, ExprContext *econtext, bool *isNull)
Definition: executor.h:393
#define palloc_array(type, count)
Definition: fe_memutils.h:76
Assert(PointerIsAligned(start, uint64))
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
#define RelationGetDescr(relation)
Definition: rel.h:541
int16 attlen
Definition: tupdesc.h:71
TupleTableSlot * ecxt_scantuple
Definition: execnodes.h:273
Relation ri_RelationDesc
Definition: execnodes.h:480
ExprState ** ri_GeneratedExprsI
Definition: execnodes.h:566
int ri_NumGeneratedNeededU
Definition: execnodes.h:571
ExprState ** ri_GeneratedExprsU
Definition: execnodes.h:567
int ri_NumGeneratedNeededI
Definition: execnodes.h:570
bool has_generated_stored
Definition: tupdesc.h:46
TupleConstr * constr
Definition: tupdesc.h:141
bool * tts_isnull
Definition: tuptable.h:126
Datum * tts_values
Definition: tuptable.h:124
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
Definition: tupdesc.h:160
static CompactAttribute * TupleDescCompactAttr(TupleDesc tupdesc, int i)
Definition: tupdesc.h:175
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:457
static void slot_getallattrs(TupleTableSlot *slot)
Definition: tuptable.h:371
static void ExecMaterializeSlot(TupleTableSlot *slot)
Definition: tuptable.h:475

References Assert(), CompactAttribute::attbyval, CompactAttribute::attlen, CMD_UPDATE, TupleDescData::constr, datumCopy(), ExprContext::ecxt_scantuple, ExecClearTuple(), ExecEvalExpr(), ExecInitGenerated(), ExecMaterializeSlot(), ExecStoreVirtualTuple(), GetPerTupleExprContext, GetPerTupleMemoryContext, TupleConstr::has_generated_stored, i, 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)

Definition at line 5212 of file nodeModifyTable.c.

5213{
5214 int i;
5215
5216 /*
5217 * Allow any FDWs to shut down
5218 */
5219 for (i = 0; i < node->mt_nrels; i++)
5220 {
5221 int j;
5222 ResultRelInfo *resultRelInfo = node->resultRelInfo + i;
5223
5224 if (!resultRelInfo->ri_usesFdwDirectModify &&
5225 resultRelInfo->ri_FdwRoutine != NULL &&
5226 resultRelInfo->ri_FdwRoutine->EndForeignModify != NULL)
5227 resultRelInfo->ri_FdwRoutine->EndForeignModify(node->ps.state,
5228 resultRelInfo);
5229
5230 /*
5231 * Cleanup the initialized batch slots. This only matters for FDWs
5232 * with batching, but the other cases will have ri_NumSlotsInitialized
5233 * == 0.
5234 */
5235 for (j = 0; j < resultRelInfo->ri_NumSlotsInitialized; j++)
5236 {
5237 ExecDropSingleTupleTableSlot(resultRelInfo->ri_Slots[j]);
5239 }
5240 }
5241
5242 /*
5243 * Close all the partitioned tables, leaf partitions, and their indices
5244 * and release the slot used for tuple routing, if set.
5245 */
5247 {
5249
5250 if (node->mt_root_tuple_slot)
5252 }
5253
5254 /*
5255 * Terminate EPQ execution if active
5256 */
5258
5259 /*
5260 * shut down subplan
5261 */
5263}
void EvalPlanQualEnd(EPQState *epqstate)
Definition: execMain.c:3179
void ExecCleanupTupleRouting(ModifyTableState *mtstate, PartitionTupleRouting *proute)
void ExecEndNode(PlanState *node)
Definition: execProcnode.c:562
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
Definition: execTuples.c:1443
#define outerPlanState(node)
Definition: execnodes.h:1261
int j
Definition: isn.c:78
EndForeignModify_function EndForeignModify
Definition: fdwapi.h:237
ResultRelInfo * resultRelInfo
Definition: execnodes.h:1408
struct PartitionTupleRouting * mt_partition_tuple_routing
Definition: execnodes.h:1439
TupleTableSlot * mt_root_tuple_slot
Definition: execnodes.h:1436
EPQState mt_epqstate
Definition: execnodes.h:1418
PlanState ps
Definition: execnodes.h:1403
EState * state
Definition: execnodes.h:1167
TupleTableSlot ** ri_Slots
Definition: execnodes.h:545
int ri_NumSlotsInitialized
Definition: execnodes.h:543
struct FdwRoutine * ri_FdwRoutine
Definition: execnodes.h:533
TupleTableSlot ** ri_PlanSlots
Definition: execnodes.h:546
bool ri_usesFdwDirectModify
Definition: execnodes.h:539

References FdwRoutine::EndForeignModify, EvalPlanQualEnd(), ExecCleanupTupleRouting(), ExecDropSingleTupleTableSlot(), ExecEndNode(), 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 
)

Definition at line 431 of file nodeModifyTable.c.

434{
435 Relation rel = resultRelInfo->ri_RelationDesc;
436 TupleDesc tupdesc = RelationGetDescr(rel);
437 int natts = tupdesc->natts;
438 ExprState **ri_GeneratedExprs;
439 int ri_NumGeneratedNeeded;
440 Bitmapset *updatedCols;
441 MemoryContext oldContext;
442
443 /* Nothing to do if no generated columns */
444 if (!(tupdesc->constr && (tupdesc->constr->has_generated_stored || tupdesc->constr->has_generated_virtual)))
445 return;
446
447 /*
448 * In an UPDATE, we can skip computing any generated columns that do not
449 * depend on any UPDATE target column. But if there is a BEFORE ROW
450 * UPDATE trigger, we cannot skip because the trigger might change more
451 * columns.
452 */
453 if (cmdtype == CMD_UPDATE &&
455 updatedCols = ExecGetUpdatedCols(resultRelInfo, estate);
456 else
457 updatedCols = NULL;
458
459 /*
460 * Make sure these data structures are built in the per-query memory
461 * context so they'll survive throughout the query.
462 */
463 oldContext = MemoryContextSwitchTo(estate->es_query_cxt);
464
465 ri_GeneratedExprs = (ExprState **) palloc0(natts * sizeof(ExprState *));
466 ri_NumGeneratedNeeded = 0;
467
468 for (int i = 0; i < natts; i++)
469 {
470 char attgenerated = TupleDescAttr(tupdesc, i)->attgenerated;
471
472 if (attgenerated)
473 {
474 Expr *expr;
475
476 /* Fetch the GENERATED AS expression tree */
477 expr = (Expr *) build_column_default(rel, i + 1);
478 if (expr == NULL)
479 elog(ERROR, "no generation expression found for column number %d of table \"%s\"",
480 i + 1, RelationGetRelationName(rel));
481
482 /*
483 * If it's an update with a known set of update target columns,
484 * see if we can skip the computation.
485 */
486 if (updatedCols)
487 {
488 Bitmapset *attrs_used = NULL;
489
490 pull_varattnos((Node *) expr, 1, &attrs_used);
491
492 if (!bms_overlap(updatedCols, attrs_used))
493 continue; /* need not update this column */
494 }
495
496 /* No luck, so prepare the expression for execution */
497 if (attgenerated == ATTRIBUTE_GENERATED_STORED)
498 {
499 ri_GeneratedExprs[i] = ExecPrepareExpr(expr, estate);
500 ri_NumGeneratedNeeded++;
501 }
502
503 /* If UPDATE, mark column in resultRelInfo->ri_extraUpdatedCols */
504 if (cmdtype == CMD_UPDATE)
505 resultRelInfo->ri_extraUpdatedCols =
506 bms_add_member(resultRelInfo->ri_extraUpdatedCols,
508 }
509 }
510
511 if (ri_NumGeneratedNeeded == 0)
512 {
513 /* didn't need it after all */
514 pfree(ri_GeneratedExprs);
515 ri_GeneratedExprs = NULL;
516 }
517
518 /* Save in appropriate set of fields */
519 if (cmdtype == CMD_UPDATE)
520 {
521 /* Don't call twice */
522 Assert(resultRelInfo->ri_GeneratedExprsU == NULL);
523
524 resultRelInfo->ri_GeneratedExprsU = ri_GeneratedExprs;
525 resultRelInfo->ri_NumGeneratedNeededU = ri_NumGeneratedNeeded;
526
527 resultRelInfo->ri_extraUpdatedCols_valid = true;
528 }
529 else
530 {
531 /* Don't call twice */
532 Assert(resultRelInfo->ri_GeneratedExprsI == NULL);
533
534 resultRelInfo->ri_GeneratedExprsI = ri_GeneratedExprs;
535 resultRelInfo->ri_NumGeneratedNeededI = ri_NumGeneratedNeeded;
536 }
537
538 MemoryContextSwitchTo(oldContext);
539}
Bitmapset * bms_add_member(Bitmapset *a, int x)
Definition: bitmapset.c:814
bool bms_overlap(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:581
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:226
ExprState * ExecPrepareExpr(Expr *node, EState *estate)
Definition: execExpr.c:765
Bitmapset * ExecGetUpdatedCols(ResultRelInfo *relinfo, EState *estate)
Definition: execUtils.c:1382
void pfree(void *pointer)
Definition: mcxt.c:1594
void * palloc0(Size size)
Definition: mcxt.c:1395
#define RelationGetRelationName(relation)
Definition: rel.h:549
Node * build_column_default(Relation rel, int attrno)
MemoryContext es_query_cxt
Definition: execnodes.h:710
Definition: nodes.h:135
TriggerDesc * trigdesc
Definition: rel.h:117
bool ri_extraUpdatedCols_valid
Definition: execnodes.h:500
Bitmapset * ri_extraUpdatedCols
Definition: execnodes.h:498
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(), 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 
)

Definition at line 3969 of file nodeModifyTable.c.

3971{
3972 EState *estate = mtstate->ps.state;
3973
3974 Assert(!resultRelInfo->ri_projectNewInfoValid);
3975
3976 resultRelInfo->ri_oldTupleSlot =
3977 table_slot_create(resultRelInfo->ri_RelationDesc,
3978 &estate->es_tupleTable);
3979 resultRelInfo->ri_newTupleSlot =
3980 table_slot_create(resultRelInfo->ri_RelationDesc,
3981 &estate->es_tupleTable);
3982 resultRelInfo->ri_projectNewInfoValid = true;
3983}
List * es_tupleTable
Definition: execnodes.h:712
bool ri_projectNewInfoValid
Definition: execnodes.h:509
TupleTableSlot * ri_oldTupleSlot
Definition: execnodes.h:507
TupleTableSlot * ri_newTupleSlot
Definition: execnodes.h:505
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 
)

Definition at line 4637 of file nodeModifyTable.c.

4638{
4639 ModifyTableState *mtstate;
4640 Plan *subplan = outerPlan(node);
4641 CmdType operation = node->operation;
4642 int total_nrels = list_length(node->resultRelations);
4643 int nrels;
4644 List *resultRelations = NIL;
4645 List *withCheckOptionLists = NIL;
4646 List *returningLists = NIL;
4647 List *updateColnosLists = NIL;
4648 List *mergeActionLists = NIL;
4649 List *mergeJoinConditions = NIL;
4650 ResultRelInfo *resultRelInfo;
4651 List *arowmarks;
4652 ListCell *l;
4653 int i;
4654 Relation rel;
4655
4656 /* check for unsupported flags */
4657 Assert(!(eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK)));
4658
4659 /*
4660 * Only consider unpruned relations for initializing their ResultRelInfo
4661 * struct and other fields such as withCheckOptions, etc.
4662 *
4663 * Note: We must avoid pruning every result relation. This is important
4664 * for MERGE, since even if every result relation is pruned from the
4665 * subplan, there might still be NOT MATCHED rows, for which there may be
4666 * INSERT actions to perform. To allow these actions to be found, at
4667 * least one result relation must be kept. Also, when inserting into a
4668 * partitioned table, ExecInitPartitionInfo() needs a ResultRelInfo struct
4669 * as a reference for building the ResultRelInfo of the target partition.
4670 * In either case, it doesn't matter which result relation is kept, so we
4671 * just keep the first one, if all others have been pruned. See also,
4672 * ExecDoInitialPruning(), which ensures that this first result relation
4673 * has been locked.
4674 */
4675 i = 0;
4676 foreach(l, node->resultRelations)
4677 {
4678 Index rti = lfirst_int(l);
4679 bool keep_rel;
4680
4681 keep_rel = bms_is_member(rti, estate->es_unpruned_relids);
4682 if (!keep_rel && i == total_nrels - 1 && resultRelations == NIL)
4683 {
4684 /* all result relations pruned; keep the first one */
4685 keep_rel = true;
4686 rti = linitial_int(node->resultRelations);
4687 i = 0;
4688 }
4689
4690 if (keep_rel)
4691 {
4692 resultRelations = lappend_int(resultRelations, rti);
4693 if (node->withCheckOptionLists)
4694 {
4695 List *withCheckOptions = list_nth_node(List,
4697 i);
4698
4699 withCheckOptionLists = lappend(withCheckOptionLists, withCheckOptions);
4700 }
4701 if (node->returningLists)
4702 {
4703 List *returningList = list_nth_node(List,
4704 node->returningLists,
4705 i);
4706
4707 returningLists = lappend(returningLists, returningList);
4708 }
4709 if (node->updateColnosLists)
4710 {
4711 List *updateColnosList = list_nth(node->updateColnosLists, i);
4712
4713 updateColnosLists = lappend(updateColnosLists, updateColnosList);
4714 }
4715 if (node->mergeActionLists)
4716 {
4717 List *mergeActionList = list_nth(node->mergeActionLists, i);
4718
4719 mergeActionLists = lappend(mergeActionLists, mergeActionList);
4720 }
4721 if (node->mergeJoinConditions)
4722 {
4723 List *mergeJoinCondition = list_nth(node->mergeJoinConditions, i);
4724
4725 mergeJoinConditions = lappend(mergeJoinConditions, mergeJoinCondition);
4726 }
4727 }
4728 i++;
4729 }
4730 nrels = list_length(resultRelations);
4731 Assert(nrels > 0);
4732
4733 /*
4734 * create state structure
4735 */
4736 mtstate = makeNode(ModifyTableState);
4737 mtstate->ps.plan = (Plan *) node;
4738 mtstate->ps.state = estate;
4739 mtstate->ps.ExecProcNode = ExecModifyTable;
4740
4741 mtstate->operation = operation;
4742 mtstate->canSetTag = node->canSetTag;
4743 mtstate->mt_done = false;
4744
4745 mtstate->mt_nrels = nrels;
4746 mtstate->resultRelInfo = palloc_array(ResultRelInfo, nrels);
4747
4748 mtstate->mt_merge_pending_not_matched = NULL;
4749 mtstate->mt_merge_inserted = 0;
4750 mtstate->mt_merge_updated = 0;
4751 mtstate->mt_merge_deleted = 0;
4752 mtstate->mt_updateColnosLists = updateColnosLists;
4753 mtstate->mt_mergeActionLists = mergeActionLists;
4754 mtstate->mt_mergeJoinConditions = mergeJoinConditions;
4755
4756 /*----------
4757 * Resolve the target relation. This is the same as:
4758 *
4759 * - the relation for which we will fire FOR STATEMENT triggers,
4760 * - the relation into whose tuple format all captured transition tuples
4761 * must be converted, and
4762 * - the root partitioned table used for tuple routing.
4763 *
4764 * If it's a partitioned or inherited table, the root partition or
4765 * appendrel RTE doesn't appear elsewhere in the plan and its RT index is
4766 * given explicitly in node->rootRelation. Otherwise, the target relation
4767 * is the sole relation in the node->resultRelations list and, since it can
4768 * never be pruned, also in the resultRelations list constructed above.
4769 *----------
4770 */
4771 if (node->rootRelation > 0)
4772 {
4776 node->rootRelation);
4777 }
4778 else
4779 {
4780 Assert(list_length(node->resultRelations) == 1);
4781 Assert(list_length(resultRelations) == 1);
4782 mtstate->rootResultRelInfo = mtstate->resultRelInfo;
4783 ExecInitResultRelation(estate, mtstate->resultRelInfo,
4784 linitial_int(resultRelations));
4785 }
4786
4787 /* set up epqstate with dummy subplan data for the moment */
4788 EvalPlanQualInit(&mtstate->mt_epqstate, estate, NULL, NIL,
4789 node->epqParam, resultRelations);
4790 mtstate->fireBSTriggers = true;
4791
4792 /*
4793 * Build state for collecting transition tuples. This requires having a
4794 * valid trigger query context, so skip it in explain-only mode.
4795 */
4796 if (!(eflags & EXEC_FLAG_EXPLAIN_ONLY))
4797 ExecSetupTransitionCaptureState(mtstate, estate);
4798
4799 /*
4800 * Open all the result relations and initialize the ResultRelInfo structs.
4801 * (But root relation was initialized above, if it's part of the array.)
4802 * We must do this before initializing the subplan, because direct-modify
4803 * FDWs expect their ResultRelInfos to be available.
4804 */
4805 resultRelInfo = mtstate->resultRelInfo;
4806 i = 0;
4807 foreach(l, resultRelations)
4808 {
4809 Index resultRelation = lfirst_int(l);
4810 List *mergeActions = NIL;
4811
4812 if (mergeActionLists)
4813 mergeActions = list_nth(mergeActionLists, i);
4814
4815 if (resultRelInfo != mtstate->rootResultRelInfo)
4816 {
4817 ExecInitResultRelation(estate, resultRelInfo, resultRelation);
4818
4819 /*
4820 * For child result relations, store the root result relation
4821 * pointer. We do so for the convenience of places that want to
4822 * look at the query's original target relation but don't have the
4823 * mtstate handy.
4824 */
4825 resultRelInfo->ri_RootResultRelInfo = mtstate->rootResultRelInfo;
4826 }
4827
4828 /* Initialize the usesFdwDirectModify flag */
4829 resultRelInfo->ri_usesFdwDirectModify =
4831
4832 /*
4833 * Verify result relation is a valid target for the current operation
4834 */
4835 CheckValidResultRel(resultRelInfo, operation, node->onConflictAction,
4836 mergeActions);
4837
4838 resultRelInfo++;
4839 i++;
4840 }
4841
4842 /*
4843 * Now we may initialize the subplan.
4844 */
4845 outerPlanState(mtstate) = ExecInitNode(subplan, estate, eflags);
4846
4847 /*
4848 * Do additional per-result-relation initialization.
4849 */
4850 for (i = 0; i < nrels; i++)
4851 {
4852 resultRelInfo = &mtstate->resultRelInfo[i];
4853
4854 /* Let FDWs init themselves for foreign-table result rels */
4855 if (!resultRelInfo->ri_usesFdwDirectModify &&
4856 resultRelInfo->ri_FdwRoutine != NULL &&
4857 resultRelInfo->ri_FdwRoutine->BeginForeignModify != NULL)
4858 {
4859 List *fdw_private = (List *) list_nth(node->fdwPrivLists, i);
4860
4861 resultRelInfo->ri_FdwRoutine->BeginForeignModify(mtstate,
4862 resultRelInfo,
4863 fdw_private,
4864 i,
4865 eflags);
4866 }
4867
4868 /*
4869 * For UPDATE/DELETE/MERGE, find the appropriate junk attr now, either
4870 * a 'ctid' or 'wholerow' attribute depending on relkind. For foreign
4871 * tables, the FDW might have created additional junk attr(s), but
4872 * those are no concern of ours.
4873 */
4874 if (operation == CMD_UPDATE || operation == CMD_DELETE ||
4875 operation == CMD_MERGE)
4876 {
4877 char relkind;
4878
4879 relkind = resultRelInfo->ri_RelationDesc->rd_rel->relkind;
4880 if (relkind == RELKIND_RELATION ||
4881 relkind == RELKIND_MATVIEW ||
4882 relkind == RELKIND_PARTITIONED_TABLE)
4883 {
4884 resultRelInfo->ri_RowIdAttNo =
4885 ExecFindJunkAttributeInTlist(subplan->targetlist, "ctid");
4886 if (!AttributeNumberIsValid(resultRelInfo->ri_RowIdAttNo))
4887 elog(ERROR, "could not find junk ctid column");
4888 }
4889 else if (relkind == RELKIND_FOREIGN_TABLE)
4890 {
4891 /*
4892 * We don't support MERGE with foreign tables for now. (It's
4893 * problematic because the implementation uses CTID.)
4894 */
4895 Assert(operation != CMD_MERGE);
4896
4897 /*
4898 * When there is a row-level trigger, there should be a
4899 * wholerow attribute. We also require it to be present in
4900 * UPDATE and MERGE, so we can get the values of unchanged
4901 * columns.
4902 */
4903 resultRelInfo->ri_RowIdAttNo =
4905 "wholerow");
4906 if ((mtstate->operation == CMD_UPDATE || mtstate->operation == CMD_MERGE) &&
4907 !AttributeNumberIsValid(resultRelInfo->ri_RowIdAttNo))
4908 elog(ERROR, "could not find junk wholerow column");
4909 }
4910 else
4911 {
4912 /* Other valid target relkinds must provide wholerow */
4913 resultRelInfo->ri_RowIdAttNo =
4915 "wholerow");
4916 if (!AttributeNumberIsValid(resultRelInfo->ri_RowIdAttNo))
4917 elog(ERROR, "could not find junk wholerow column");
4918 }
4919 }
4920 }
4921
4922 /*
4923 * If this is an inherited update/delete/merge, there will be a junk
4924 * attribute named "tableoid" present in the subplan's targetlist. It
4925 * will be used to identify the result relation for a given tuple to be
4926 * updated/deleted/merged.
4927 */
4928 mtstate->mt_resultOidAttno =
4929 ExecFindJunkAttributeInTlist(subplan->targetlist, "tableoid");
4930 Assert(AttributeNumberIsValid(mtstate->mt_resultOidAttno) || total_nrels == 1);
4931 mtstate->mt_lastResultOid = InvalidOid; /* force lookup at first tuple */
4932 mtstate->mt_lastResultIndex = 0; /* must be zero if no such attr */
4933
4934 /* Get the root target relation */
4935 rel = mtstate->rootResultRelInfo->ri_RelationDesc;
4936
4937 /*
4938 * Build state for tuple routing if it's a partitioned INSERT. An UPDATE
4939 * or MERGE might need this too, but only if it actually moves tuples
4940 * between partitions; in that case setup is done by
4941 * ExecCrossPartitionUpdate.
4942 */
4943 if (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE &&
4944 operation == CMD_INSERT)
4946 ExecSetupPartitionTupleRouting(estate, rel);
4947
4948 /*
4949 * Initialize any WITH CHECK OPTION constraints if needed.
4950 */
4951 resultRelInfo = mtstate->resultRelInfo;
4952 foreach(l, withCheckOptionLists)
4953 {
4954 List *wcoList = (List *) lfirst(l);
4955 List *wcoExprs = NIL;
4956 ListCell *ll;
4957
4958 foreach(ll, wcoList)
4959 {
4960 WithCheckOption *wco = (WithCheckOption *) lfirst(ll);
4961 ExprState *wcoExpr = ExecInitQual((List *) wco->qual,
4962 &mtstate->ps);
4963
4964 wcoExprs = lappend(wcoExprs, wcoExpr);
4965 }
4966
4967 resultRelInfo->ri_WithCheckOptions = wcoList;
4968 resultRelInfo->ri_WithCheckOptionExprs = wcoExprs;
4969 resultRelInfo++;
4970 }
4971
4972 /*
4973 * Initialize RETURNING projections if needed.
4974 */
4975 if (returningLists)
4976 {
4977 TupleTableSlot *slot;
4978 ExprContext *econtext;
4979
4980 /*
4981 * Initialize result tuple slot and assign its rowtype using the plan
4982 * node's declared targetlist, which the planner set up to be the same
4983 * as the first (before runtime pruning) RETURNING list. We assume
4984 * all the result rels will produce compatible output.
4985 */
4987 slot = mtstate->ps.ps_ResultTupleSlot;
4988
4989 /* Need an econtext too */
4990 if (mtstate->ps.ps_ExprContext == NULL)
4991 ExecAssignExprContext(estate, &mtstate->ps);
4992 econtext = mtstate->ps.ps_ExprContext;
4993
4994 /*
4995 * Build a projection for each result rel.
4996 */
4997 resultRelInfo = mtstate->resultRelInfo;
4998 foreach(l, returningLists)
4999 {
5000 List *rlist = (List *) lfirst(l);
5001
5002 resultRelInfo->ri_returningList = rlist;
5003 resultRelInfo->ri_projectReturning =
5004 ExecBuildProjectionInfo(rlist, econtext, slot, &mtstate->ps,
5005 resultRelInfo->ri_RelationDesc->rd_att);
5006 resultRelInfo++;
5007 }
5008 }
5009 else
5010 {
5011 /*
5012 * We still must construct a dummy result tuple type, because InitPlan
5013 * expects one (maybe should change that?).
5014 */
5015 ExecInitResultTypeTL(&mtstate->ps);
5016
5017 mtstate->ps.ps_ExprContext = NULL;
5018 }
5019
5020 /* Set the list of arbiter indexes if needed for ON CONFLICT */
5021 resultRelInfo = mtstate->resultRelInfo;
5022 if (node->onConflictAction != ONCONFLICT_NONE)
5023 {
5024 /* insert may only have one relation, inheritance is not expanded */
5025 Assert(total_nrels == 1);
5026 resultRelInfo->ri_onConflictArbiterIndexes = node->arbiterIndexes;
5027 }
5028
5029 /*
5030 * If needed, Initialize target list, projection and qual for ON CONFLICT
5031 * DO UPDATE.
5032 */
5034 {
5036 ExprContext *econtext;
5037 TupleDesc relationDesc;
5038
5039 /* already exists if created by RETURNING processing above */
5040 if (mtstate->ps.ps_ExprContext == NULL)
5041 ExecAssignExprContext(estate, &mtstate->ps);
5042
5043 econtext = mtstate->ps.ps_ExprContext;
5044 relationDesc = resultRelInfo->ri_RelationDesc->rd_att;
5045
5046 /* create state for DO UPDATE SET operation */
5047 resultRelInfo->ri_onConflict = onconfl;
5048
5049 /* initialize slot for the existing tuple */
5050 onconfl->oc_Existing =
5051 table_slot_create(resultRelInfo->ri_RelationDesc,
5052 &mtstate->ps.state->es_tupleTable);
5053
5054 /*
5055 * Create the tuple slot for the UPDATE SET projection. We want a slot
5056 * of the table's type here, because the slot will be used to insert
5057 * into the table, and for RETURNING processing - which may access
5058 * system attributes.
5059 */
5060 onconfl->oc_ProjSlot =
5061 table_slot_create(resultRelInfo->ri_RelationDesc,
5062 &mtstate->ps.state->es_tupleTable);
5063
5064 /* build UPDATE SET projection state */
5065 onconfl->oc_ProjInfo =
5067 true,
5068 node->onConflictCols,
5069 relationDesc,
5070 econtext,
5071 onconfl->oc_ProjSlot,
5072 &mtstate->ps);
5073
5074 /* initialize state to evaluate the WHERE clause, if any */
5075 if (node->onConflictWhere)
5076 {
5077 ExprState *qualexpr;
5078
5079 qualexpr = ExecInitQual((List *) node->onConflictWhere,
5080 &mtstate->ps);
5081 onconfl->oc_WhereClause = qualexpr;
5082 }
5083 }
5084
5085 /*
5086 * If we have any secondary relations in an UPDATE or DELETE, they need to
5087 * be treated like non-locked relations in SELECT FOR UPDATE, i.e., the
5088 * EvalPlanQual mechanism needs to be told about them. This also goes for
5089 * the source relations in a MERGE. Locate the relevant ExecRowMarks.
5090 */
5091 arowmarks = NIL;
5092 foreach(l, node->rowMarks)
5093 {
5095 ExecRowMark *erm;
5096 ExecAuxRowMark *aerm;
5097
5098 /*
5099 * Ignore "parent" rowmarks, because they are irrelevant at runtime.
5100 * Also ignore the rowmarks belonging to child tables that have been
5101 * pruned in ExecDoInitialPruning().
5102 */
5103 if (rc->isParent ||
5104 !bms_is_member(rc->rti, estate->es_unpruned_relids))
5105 continue;
5106
5107 /* Find ExecRowMark and build ExecAuxRowMark */
5108 erm = ExecFindRowMark(estate, rc->rti, false);
5109 aerm = ExecBuildAuxRowMark(erm, subplan->targetlist);
5110 arowmarks = lappend(arowmarks, aerm);
5111 }
5112
5113 /* For a MERGE command, initialize its state */
5114 if (mtstate->operation == CMD_MERGE)
5115 ExecInitMerge(mtstate, estate);
5116
5117 EvalPlanQualSetPlan(&mtstate->mt_epqstate, subplan, arowmarks);
5118
5119 /*
5120 * If there are a lot of result relations, use a hash table to speed the
5121 * lookups. If there are not a lot, a simple linear search is faster.
5122 *
5123 * It's not clear where the threshold is, but try 64 for starters. In a
5124 * debugging build, use a small threshold so that we get some test
5125 * coverage of both code paths.
5126 */
5127#ifdef USE_ASSERT_CHECKING
5128#define MT_NRELS_HASH 4
5129#else
5130#define MT_NRELS_HASH 64
5131#endif
5132 if (nrels >= MT_NRELS_HASH)
5133 {
5134 HASHCTL hash_ctl;
5135
5136 hash_ctl.keysize = sizeof(Oid);
5137 hash_ctl.entrysize = sizeof(MTTargetRelLookup);
5138 hash_ctl.hcxt = CurrentMemoryContext;
5139 mtstate->mt_resultOidHash =
5140 hash_create("ModifyTable target hash",
5141 nrels, &hash_ctl,
5143 for (i = 0; i < nrels; i++)
5144 {
5145 Oid hashkey;
5146 MTTargetRelLookup *mtlookup;
5147 bool found;
5148
5149 resultRelInfo = &mtstate->resultRelInfo[i];
5150 hashkey = RelationGetRelid(resultRelInfo->ri_RelationDesc);
5151 mtlookup = (MTTargetRelLookup *)
5152 hash_search(mtstate->mt_resultOidHash, &hashkey,
5153 HASH_ENTER, &found);
5154 Assert(!found);
5155 mtlookup->relationIndex = i;
5156 }
5157 }
5158 else
5159 mtstate->mt_resultOidHash = NULL;
5160
5161 /*
5162 * Determine if the FDW supports batch insert and determine the batch size
5163 * (a FDW may support batching, but it may be disabled for the
5164 * server/table).
5165 *
5166 * We only do this for INSERT, so that for UPDATE/DELETE the batch size
5167 * remains set to 0.
5168 */
5169 if (operation == CMD_INSERT)
5170 {
5171 /* insert may only have one relation, inheritance is not expanded */
5172 Assert(total_nrels == 1);
5173 resultRelInfo = mtstate->resultRelInfo;
5174 if (!resultRelInfo->ri_usesFdwDirectModify &&
5175 resultRelInfo->ri_FdwRoutine != NULL &&
5176 resultRelInfo->ri_FdwRoutine->GetForeignModifyBatchSize &&
5177 resultRelInfo->ri_FdwRoutine->ExecForeignBatchInsert)
5178 {
5179 resultRelInfo->ri_BatchSize =
5180 resultRelInfo->ri_FdwRoutine->GetForeignModifyBatchSize(resultRelInfo);
5181 Assert(resultRelInfo->ri_BatchSize >= 1);
5182 }
5183 else
5184 resultRelInfo->ri_BatchSize = 1;
5185 }
5186
5187 /*
5188 * Lastly, if this is not the primary (canSetTag) ModifyTable node, add it
5189 * to estate->es_auxmodifytables so that it will be run to completion by
5190 * ExecPostprocessPlan. (It'd actually work fine to add the primary
5191 * ModifyTable node too, but there's no need.) Note the use of lcons not
5192 * lappend: we need later-initialized ModifyTable nodes to be shut down
5193 * before earlier ones. This ensures that we don't throw away RETURNING
5194 * rows that need to be seen by a later CTE subplan.
5195 */
5196 if (!mtstate->canSetTag)
5197 estate->es_auxmodifytables = lcons(mtstate,
5198 estate->es_auxmodifytables);
5199
5200 return mtstate;
5201}
#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:633
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
Definition: dynahash.c:952
HTAB * hash_create(const char *tabname, int64 nelem, const HASHCTL *info, int flags)
Definition: dynahash.c:358
ProjectionInfo * ExecBuildProjectionInfo(List *targetList, ExprContext *econtext, TupleTableSlot *slot, PlanState *parent, TupleDesc inputDesc)
Definition: execExpr.c:370
ExprState * ExecInitQual(List *qual, PlanState *parent)
Definition: execExpr.c:229
ProjectionInfo * ExecBuildUpdateProjection(List *targetList, bool evalTargetList, List *targetColnos, TupleDesc relDesc, ExprContext *econtext, TupleTableSlot *slot, PlanState *parent)
Definition: execExpr.c:547
AttrNumber ExecFindJunkAttributeInTlist(List *targetlist, const char *attrName)
Definition: execJunk.c:222
ExecRowMark * ExecFindRowMark(EState *estate, Index rti, bool missing_ok)
Definition: execMain.c:2556
ExecAuxRowMark * ExecBuildAuxRowMark(ExecRowMark *erm, List *targetlist)
Definition: execMain.c:2579
void CheckValidResultRel(ResultRelInfo *resultRelInfo, CmdType operation, OnConflictAction onConflictAction, List *mergeActions)
Definition: execMain.c:1050
void EvalPlanQualInit(EPQState *epqstate, EState *parentestate, Plan *subplan, List *auxrowmarks, int epqParam, List *resultRelations)
Definition: execMain.c:2718
void EvalPlanQualSetPlan(EPQState *epqstate, Plan *subplan, List *auxrowmarks)
Definition: execMain.c:2759
PartitionTupleRouting * ExecSetupPartitionTupleRouting(EState *estate, Relation rel)
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
Definition: execProcnode.c:142
const TupleTableSlotOps TTSOpsVirtual
Definition: execTuples.c:84
void ExecInitResultTypeTL(PlanState *planstate)
Definition: execTuples.c:1944
void ExecInitResultTupleSlotTL(PlanState *planstate, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1988
void ExecInitResultRelation(EState *estate, ResultRelInfo *resultRelInfo, Index rti)
Definition: execUtils.c:880
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:485
#define EXEC_FLAG_BACKWARD
Definition: executor.h:69
#define EXEC_FLAG_EXPLAIN_ONLY
Definition: executor.h:66
#define EXEC_FLAG_MARK
Definition: executor.h:70
@ HASH_ENTER
Definition: hsearch.h:114
#define HASH_CONTEXT
Definition: hsearch.h:102
#define HASH_ELEM
Definition: hsearch.h:95
#define HASH_BLOBS
Definition: hsearch.h:97
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)
struct MTTargetRelLookup MTTargetRelLookup
#define MT_NRELS_HASH
static void ExecInitMerge(ModifyTableState *mtstate, EState *estate)
@ ONCONFLICT_NONE
Definition: nodes.h:428
@ 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
#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:299
#define list_nth_node(type, list, n)
Definition: pg_list.h:327
#define outerPlan(node)
Definition: plannodes.h:261
#define InvalidOid
Definition: postgres_ext.h:37
unsigned int Oid
Definition: postgres_ext.h:32
#define RelationGetRelid(relation)
Definition: rel.h:515
Bitmapset * es_unpruned_relids
Definition: execnodes.h:673
List * es_auxmodifytables
Definition: execnodes.h:727
BeginForeignModify_function BeginForeignModify
Definition: fdwapi.h:231
ExecForeignBatchInsert_function ExecForeignBatchInsert
Definition: fdwapi.h:233
GetForeignModifyBatchSize_function GetForeignModifyBatchSize
Definition: fdwapi.h:234
Size keysize
Definition: hsearch.h:75
Size entrysize
Definition: hsearch.h:76
MemoryContext hcxt
Definition: hsearch.h:86
Definition: pg_list.h:54
List * mt_mergeJoinConditions
Definition: execnodes.h:1472
CmdType operation
Definition: execnodes.h:1404
TupleTableSlot * mt_merge_pending_not_matched
Definition: execnodes.h:1458
double mt_merge_deleted
Definition: execnodes.h:1463
List * mt_updateColnosLists
Definition: execnodes.h:1470
double mt_merge_inserted
Definition: execnodes.h:1461
double mt_merge_updated
Definition: execnodes.h:1462
List * mt_mergeActionLists
Definition: execnodes.h:1471
HTAB * mt_resultOidHash
Definition: execnodes.h:1430
ResultRelInfo * rootResultRelInfo
Definition: execnodes.h:1416
List * updateColnosLists
Definition: plannodes.h:344
List * arbiterIndexes
Definition: plannodes.h:364
List * onConflictCols
Definition: plannodes.h:368
List * mergeJoinConditions
Definition: plannodes.h:378
CmdType operation
Definition: plannodes.h:334
int epqParam
Definition: plannodes.h:360
List * resultRelations
Definition: plannodes.h:342
Bitmapset * fdwDirectModifyPlans
Definition: plannodes.h:356
List * onConflictSet
Definition: plannodes.h:366
List * mergeActionLists
Definition: plannodes.h:376
bool canSetTag
Definition: plannodes.h:336
List * fdwPrivLists
Definition: plannodes.h:354
List * returningLists
Definition: plannodes.h:352
List * withCheckOptionLists
Definition: plannodes.h:346
Index rootRelation
Definition: plannodes.h:340
Node * onConflictWhere
Definition: plannodes.h:370
List * rowMarks
Definition: plannodes.h:358
OnConflictAction onConflictAction
Definition: plannodes.h:362
TupleTableSlot * oc_ProjSlot
Definition: execnodes.h:434
TupleTableSlot * oc_Existing
Definition: execnodes.h:433
ExprState * oc_WhereClause
Definition: execnodes.h:436
ProjectionInfo * oc_ProjInfo
Definition: execnodes.h:435
bool isParent
Definition: plannodes.h:1604
Plan * plan
Definition: execnodes.h:1165
ExprContext * ps_ExprContext
Definition: execnodes.h:1204
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:1203
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:1171
List * targetlist
Definition: plannodes.h:229
TupleDesc rd_att
Definition: rel.h:112
Form_pg_class rd_rel
Definition: rel.h:111
OnConflictSetState * ri_onConflict
Definition: execnodes.h:583
List * ri_onConflictArbiterIndexes
Definition: execnodes.h:580
struct ResultRelInfo * ri_RootResultRelInfo
Definition: execnodes.h:618
List * ri_WithCheckOptions
Definition: execnodes.h:549
List * ri_WithCheckOptionExprs
Definition: execnodes.h:552
ProjectionInfo * ri_projectReturning
Definition: execnodes.h:577
List * ri_returningList
Definition: execnodes.h:574
AttrNumber ri_RowIdAttNo
Definition: execnodes.h:495
int ri_BatchSize
Definition: execnodes.h:544

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, HASHCTL::entrysize, ModifyTable::epqParam, ERROR, EState::es_auxmodifytables, EState::es_tupleTable, EState::es_unpruned_relids, EvalPlanQualInit(), EvalPlanQualSetPlan(), EXEC_FLAG_BACKWARD, EXEC_FLAG_EXPLAIN_ONLY, EXEC_FLAG_MARK, ExecAssignExprContext(), ExecBuildAuxRowMark(), ExecBuildProjectionInfo(), ExecBuildUpdateProjection(), ExecFindJunkAttributeInTlist(), ExecFindRowMark(), FdwRoutine::ExecForeignBatchInsert, ExecInitMerge(), ExecInitNode(), ExecInitQual(), ExecInitResultRelation(), ExecInitResultTupleSlotTL(), ExecInitResultTypeTL(), ExecModifyTable(), PlanState::ExecProcNode, ExecSetupPartitionTupleRouting(), ExecSetupTransitionCaptureState(), ModifyTable::fdwDirectModifyPlans, ModifyTable::fdwPrivLists, ModifyTableState::fireBSTriggers, FdwRoutine::GetForeignModifyBatchSize, HASH_BLOBS, HASH_CONTEXT, hash_create(), HASH_ELEM, HASH_ENTER, hash_search(), HASHCTL::hcxt, 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, 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_updateColnosLists, NIL, OnConflictSetState::oc_Existing, OnConflictSetState::oc_ProjInfo, OnConflictSetState::oc_ProjSlot, OnConflictSetState::oc_WhereClause, ONCONFLICT_NONE, ONCONFLICT_UPDATE, ModifyTable::onConflictAction, ModifyTable::onConflictCols, ModifyTable::onConflictSet, ModifyTable::onConflictWhere, ModifyTableState::operation, ModifyTable::operation, outerPlan, outerPlanState, palloc_array, PlanState::plan, ModifyTableState::ps, PlanState::ps_ExprContext, PlanState::ps_ResultTupleSlot, WithCheckOption::qual, RelationData::rd_att, RelationData::rd_rel, RelationGetRelid, MTTargetRelLookup::relationIndex, ModifyTable::resultRelations, ModifyTableState::resultRelInfo, ModifyTable::returningLists, ResultRelInfo::ri_BatchSize, ResultRelInfo::ri_FdwRoutine, 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, PlanRowMark::rti, PlanState::state, table_slot_create(), Plan::targetlist, TTSOpsVirtual, ModifyTable::updateColnosLists, and ModifyTable::withCheckOptionLists.

Referenced by ExecInitNode().

◆ ExecReScanModifyTable()

void ExecReScanModifyTable ( ModifyTableState node)

Definition at line 5266 of file nodeModifyTable.c.

5267{
5268 /*
5269 * Currently, we don't need to support rescan on ModifyTable nodes. The
5270 * semantics of that would be a bit debatable anyway.
5271 */
5272 elog(ERROR, "ExecReScanModifyTable is not implemented");
5273}

References elog, and ERROR.

Referenced by ExecReScan().