201 foreach(lc, targetList)
208 if (attno >= resultDesc->
natts)
210 (
errcode(ERRCODE_DATATYPE_MISMATCH),
211 errmsg(
"table row type and query-specified row type do not match"),
212 errdetail(
"Query has too many columns.")));
219 if (attr->attisdropped)
229 (
errcode(ERRCODE_DATATYPE_MISMATCH),
230 errmsg(
"table row type and query-specified row type do not match"),
231 errdetail(
"Query provides a value for a dropped column at ordinal position %d.",
234 else if (attr->attgenerated)
246 (
errcode(ERRCODE_DATATYPE_MISMATCH),
247 errmsg(
"table row type and query-specified row type do not match"),
248 errdetail(
"Query provides a value for a generated column at ordinal position %d.",
256 (
errcode(ERRCODE_DATATYPE_MISMATCH),
257 errmsg(
"table row type and query-specified row type do not match"),
258 errdetail(
"Table has type %s at ordinal position %d, but query expects %s.",
264 if (attno != resultDesc->
natts)
266 (
errcode(ERRCODE_DATATYPE_MISMATCH),
267 errmsg(
"table row type and query-specified row type do not match"),
268 errdetail(
"Query has too few columns.")));
316 elog(
ERROR,
"unrecognized commandType: %d", (
int) cmdType);
389 errmsg(
"could not serialize access due to concurrent update")));
409 elog(
ERROR,
"failed to fetch conflicting tuple for ON CONFLICT");
436 int natts = tupdesc->
natts;
438 int ri_NumGeneratedNeeded;
465 ri_NumGeneratedNeeded = 0;
467 for (
int i = 0;
i < natts;
i++)
478 elog(
ERROR,
"no generation expression found for column number %d of table \"%s\"",
496 if (attgenerated == ATTRIBUTE_GENERATED_STORED)
499 ri_NumGeneratedNeeded++;
510 if (ri_NumGeneratedNeeded == 0)
513 pfree(ri_GeneratedExprs);
514 ri_GeneratedExprs = NULL;
550 int natts = tupdesc->
natts;
584 nulls =
palloc(
sizeof(*nulls) * natts);
587 memcpy(nulls, slot->
tts_isnull,
sizeof(*nulls) * natts);
589 for (
int i = 0;
i < natts;
i++)
593 if (ri_GeneratedExprs[
i])
623 memcpy(slot->
tts_isnull, nulls,
sizeof(*nulls) * natts);
647 bool need_projection =
false;
651 foreach(l, subplan->targetlist)
656 insertTargetList =
lappend(insertTargetList, tle);
658 need_projection =
true;
728 Assert(whichrel >= 0 && whichrel < mtstate->mt_nrels);
880 resultRelInfo = partRelInfo;
891 if (resultRelationDesc->
rd_rel->relhasindex &&
944 bool flushed =
false;
962 if (resultRelInfo->
ri_Slots == NULL)
1103 if (resultRelationDesc->
rd_rel->relispartition &&
1116 List *arbiterIndexes;
1136 specConflict =
false;
1138 &conflictTid, &invalidItemPtr,
1153 &conflictTid, slot, canSetTag,
1200 slot, estate,
false,
true,
1207 specToken, !specConflict);
1241 slot, estate,
false,
1273 ar_insert_trig_tcs = NULL;
1278 ar_insert_trig_tcs);
1320 if (tupconv_map != NULL)
1333 oldSlot, slot, planSlot);
1351 *inserted_tuple = slot;
1353 *insert_destrel = resultRelInfo;
1376 int numInserted = numSlots;
1389 for (
i = 0;
i < numInserted;
i++)
1411 if (canSetTag && numInserted > 0)
1415 for (
i = 0;
i < numSlots;
i++)
1476 resultRelInfo, tupleid, oldtuple,
1477 epqreturnslot, result, &context->
tmfd,
1541 ar_delete_trig_tcs = NULL;
1546 ar_delete_trig_tcs, changingPart);
1576 bool processReturning,
1590 *tupleDeleted =
false;
1597 epqreturnslot, tmresult))
1606 Assert(oldtuple != NULL);
1650 result =
ExecDeleteAct(context, resultRelInfo, tupleid, changingPart);
1685 (
errcode(ERRCODE_TRIGGERED_DATA_CHANGE_VIOLATION),
1686 errmsg(
"tuple to be deleted was already modified by an operation triggered by the current command"),
1687 errhint(
"Consider using an AFTER trigger instead of a BEFORE trigger to propagate changes to other rows.")));
1703 errmsg(
"could not serialize access due to concurrent update")));
1738 *epqreturnslot = epqslot;
1759 (
errcode(ERRCODE_TRIGGERED_DATA_CHANGE_VIOLATION),
1760 errmsg(
"tuple to be deleted was already modified by an operation triggered by the current command"),
1761 errhint(
"Consider using an AFTER trigger instead of a BEFORE trigger to propagate changes to other rows.")));
1780 elog(
ERROR,
"unexpected table_tuple_lock status: %u",
1793 errmsg(
"could not serialize access due to concurrent delete")));
1798 elog(
ERROR,
"unrecognized table_tuple_delete status: %u",
1818 *tupleDeleted =
true;
1848 if (oldtuple != NULL)
1856 elog(
ERROR,
"failed to fetch deleted tuple for DELETE RETURNING");
1874 if (tupconv_map != NULL)
1958 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1959 errmsg(
"invalid ON UPDATE specification"),
1960 errdetail(
"The result tuple would appear in a different partition than the original tuple.")));
2001 tmresult, &tuple_deleted, &epqslot);
2033 return *tmresult ==
TM_Ok;
2049 elog(
ERROR,
"failed to fetch tuple being updated");
2063 if (tupconv_map != NULL)
2071 inserted_tuple, insert_destrel);
2107 if (resultRelationDesc->
rd_rel->relhasindex &&
2120 resultRelInfo, tupleid, oldtuple, slot,
2121 result, &context->
tmfd,
2176 bool partition_constraint_failed;
2201 partition_constraint_failed =
2202 resultRelationDesc->
rd_rel->relispartition &&
2206 if (!partition_constraint_failed &&
2214 resultRelInfo, slot, estate);
2221 if (partition_constraint_failed)
2234 tupleid, oldtuple, slot,
2235 canSetTag, updateCxt,
2258 if (insert_destrel &&
2339 tupleid, oldtuple, slot,
2389 foreach(lc, ancestorRels)
2393 bool has_noncloned_fkey =
false;
2396 if (rInfo == rootRelInfo)
2408 has_noncloned_fkey =
true;
2414 if (has_noncloned_fkey)
2416 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2417 errmsg(
"cannot move tuple across partitions when a non-root ancestor of the source partition is directly referenced in a foreign key"),
2418 errdetail(
"A foreign key points to ancestor \"%s\" but not the root ancestor \"%s\".",
2421 errhint(
"Consider defining the foreign key on table \"%s\".",
2427 rootRelInfo, sourcePartInfo, destPartInfo,
2428 tupleid, NULL, newslot,
NIL, NULL,
true);
2474 elog(
ERROR,
"cannot UPDATE during bootstrap");
2526 lockedtid = *tupleid;
2527 result =
ExecUpdateAct(context, resultRelInfo, tupleid, oldtuple, slot,
2528 canSetTag, &updateCxt);
2567 (
errcode(ERRCODE_TRIGGERED_DATA_CHANGE_VIOLATION),
2568 errmsg(
"tuple to be updated was already modified by an operation triggered by the current command"),
2569 errhint(
"Consider using an AFTER trigger instead of a BEFORE trigger to propagate changes to other rows.")));
2585 errmsg(
"could not serialize access due to concurrent update")));
2633 elog(
ERROR,
"failed to fetch tuple being updated");
2657 (
errcode(ERRCODE_TRIGGERED_DATA_CHANGE_VIOLATION),
2658 errmsg(
"tuple to be updated was already modified by an operation triggered by the current command"),
2659 errhint(
"Consider using an AFTER trigger instead of a BEFORE trigger to propagate changes to other rows.")));
2664 elog(
ERROR,
"unexpected table_tuple_lock status: %u",
2676 errmsg(
"could not serialize access due to concurrent delete")));
2681 elog(
ERROR,
"unrecognized table_tuple_update status: %u",
2786 (
errcode(ERRCODE_CARDINALITY_VIOLATION),
2788 errmsg(
"%s command cannot affect row a second time",
2789 "ON CONFLICT DO UPDATE"),
2790 errhint(
"Ensure that no rows proposed for insertion within the same command have duplicate constrained values.")));
2793 elog(
ERROR,
"attempted to lock invisible tuple");
2803 elog(
ERROR,
"unexpected self-updated tuple");
2810 errmsg(
"could not serialize access due to concurrent update")));
2834 errmsg(
"could not serialize access due to concurrent delete")));
2842 elog(
ERROR,
"unrecognized table_tuple_lock status: %u",
test);
2873 if (!
ExecQual(onConflictSetWhere, econtext))
2915 *returning =
ExecUpdate(context, resultRelInfo,
2916 conflictTid, NULL, existing,
2927 if (*returning != NULL &&
3007 matched = tupleid != NULL || oldtuple != NULL;
3010 canSetTag, &matched);
3108 Assert(tupleid != NULL || oldtuple != NULL);
3110 if (oldtuple != NULL)
3127 lockedtid = *tupleid;
3133 elog(
ERROR,
"failed to fetch the target tuple");
3151 foreach(l, actionStates)
3190 switch (commandType)
3203 tupleid, NULL, newslot, &result))
3205 if (result ==
TM_Ok)
3222 Assert(oldtuple == NULL);
3225 NULL, newslot, canSetTag,
3245 if (result ==
TM_Ok)
3248 tupleid, NULL, newslot);
3256 NULL, NULL, &result))
3258 if (result ==
TM_Ok)
3275 Assert(oldtuple == NULL);
3281 if (result ==
TM_Ok)
3295 elog(
ERROR,
"unknown action in MERGE WHEN clause");
3329 (
errcode(ERRCODE_TRIGGERED_DATA_CHANGE_VIOLATION),
3330 errmsg(
"tuple to be updated or deleted was already modified by an operation triggered by the current command"),
3331 errhint(
"Consider using an AFTER trigger instead of a BEFORE trigger to propagate changes to other rows.")));
3335 (
errcode(ERRCODE_CARDINALITY_VIOLATION),
3337 errmsg(
"%s command cannot affect row a second time",
3339 errhint(
"Ensure that not more than one source row matches any one target row.")));
3342 elog(
ERROR,
"attempted to update or delete invisible tuple");
3349 errmsg(
"could not serialize access due to concurrent delete")));
3408 errmsg(
"tuple to be merged was already moved to another partition due to concurrent update")));
3455 lockedtid = *tupleid;
3462 elog(
ERROR,
"failed to fetch the target tuple");
3498 goto lmerge_matched;
3521 (
errcode(ERRCODE_TRIGGERED_DATA_CHANGE_VIOLATION),
3522 errmsg(
"tuple to be updated or deleted was already modified by an operation triggered by the current command"),
3523 errhint(
"Consider using an AFTER trigger instead of a BEFORE trigger to propagate changes to other rows.")));
3527 (
errcode(ERRCODE_CARDINALITY_VIOLATION),
3529 errmsg(
"%s command cannot affect row a second time",
3531 errhint(
"Ensure that not more than one source row matches any one target row.")));
3534 elog(
ERROR,
"attempted to update or delete invisible tuple");
3539 elog(
ERROR,
"unexpected table_tuple_lock status: %u",
3549 elog(
ERROR,
"unexpected tuple operation result: %d", result);
3556 switch (commandType)
3580 elog(
ERROR,
"unrecognized commandType: %d",
3635 foreach(l, actionStates)
3652 switch (commandType)
3665 newslot, canSetTag, NULL, NULL);
3672 elog(
ERROR,
"unknown action in MERGE WHEN NOT MATCHED clause");
3699 if (mergeActionLists ==
NIL)
3716 foreach(lc, mergeActionLists)
3719 Node *joinCondition;
3736 foreach(l, mergeActionList)
3760 switch (
action->commandType)
3779 RELKIND_PARTITIONED_TABLE)
3847 elog(
ERROR,
"unknown action in MERGE WHEN clause");
3874 bool found_whole_row;
3891 if (rootRelation != firstResultRel)
3907 foreach(lc, wcoList)
3913 wcoExprs =
lappend(wcoExprs, wcoExpr);
3922 List *returningList;
3934 if (rootRelation != firstResultRel)
3937 if (part_attmap == NULL)
3943 returningList = (
List *)
4128 bool has_before_insert_row_trig;
4130 has_before_insert_row_trig = (partrel->
ri_TrigDesc &&
4134 !has_before_insert_row_trig ? slot : NULL;
4148 *partRelInfo = partrel;
4188 elog(
ERROR,
"ModifyTable should not be called during EvalPlanQual");
4368 if (relkind == RELKIND_RELATION ||
4369 relkind == RELKIND_MATVIEW ||
4370 relkind == RELKIND_PARTITIONED_TABLE)
4409 tuple_ctid = *tupleid;
4410 tupleid = &tuple_ctid;
4474 oldtuple = &oldtupdata;
4479 Assert(relkind == RELKIND_FOREIGN_TABLE);
4490 slot =
ExecInsert(&context, resultRelInfo, slot,
4506 if (oldtuple != NULL)
4525 elog(
ERROR,
"failed to fetch tuple being updated");
4531 slot =
ExecUpdate(&context, resultRelInfo, tupleid, oldtuple,
4539 slot =
ExecDelete(&context, resultRelInfo, tupleid, oldtuple,
4540 true,
false, node->
canSetTag, NULL, NULL, NULL);
4544 slot =
ExecMerge(&context, resultRelInfo, tupleid, oldtuple,
4589 bool missing_ok,
bool update_cache)
4611 for (
int ndx = 0; ndx < node->
mt_nrels; ndx++)
4628 elog(
ERROR,
"incorrect result relation OID %u", resultoid);
4645 List *withCheckOptionLists =
NIL;
4647 List *updateColnosLists =
NIL;
4649 List *mergeJoinConditions =
NIL;
4682 if (!keep_rel &&
i == total_nrels - 1 && resultRelations ==
NIL)
4692 resultRelations =
lappend_int(resultRelations, rti);
4699 withCheckOptionLists =
lappend(withCheckOptionLists, withCheckOptions);
4707 returningLists =
lappend(returningLists, returningList);
4713 updateColnosLists =
lappend(updateColnosLists, updateColnosList);
4719 mergeActionLists =
lappend(mergeActionLists, mergeActionList);
4725 mergeJoinConditions =
lappend(mergeJoinConditions, mergeJoinCondition);
4808 foreach(l, resultRelations)
4813 if (mergeActionLists)
4814 mergeActions =
list_nth(mergeActionLists,
i);
4851 for (
i = 0;
i < nrels;
i++)
4881 if (relkind == RELKIND_RELATION ||
4882 relkind == RELKIND_MATVIEW ||
4883 relkind == RELKIND_PARTITIONED_TABLE)
4888 elog(
ERROR,
"could not find junk ctid column");
4890 else if (relkind == RELKIND_FOREIGN_TABLE)
4909 elog(
ERROR,
"could not find junk wholerow column");
4918 elog(
ERROR,
"could not find junk wholerow column");
4944 if (rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE &&
4953 foreach(l, withCheckOptionLists)
4959 foreach(ll, wcoList)
4965 wcoExprs =
lappend(wcoExprs, wcoExpr);
4999 foreach(l, returningLists)
5026 Assert(total_nrels == 1);
5111 arowmarks =
lappend(arowmarks, aerm);
5128#ifdef USE_ASSERT_CHECKING
5129#define MT_NRELS_HASH 4
5131#define MT_NRELS_HASH 64
5144 for (
i = 0;
i < nrels;
i++)
5173 Assert(total_nrels == 1);
5273 elog(
ERROR,
"ExecReScanModifyTable is not implemented");
AttrMap * build_attrmap_by_name(TupleDesc indesc, TupleDesc outdesc, bool missing_ok)
#define AttributeNumberIsValid(attributeNumber)
bool bms_is_member(int x, const Bitmapset *a)
Bitmapset * bms_add_member(Bitmapset *a, int x)
bool bms_overlap(const Bitmapset *a, const Bitmapset *b)
static Datum values[MAXATTR]
Datum datumCopy(Datum value, bool typByVal, int typLen)
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
HTAB * hash_create(const char *tabname, int64 nelem, const HASHCTL *info, int flags)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
ExprState * ExecPrepareExpr(Expr *node, EState *estate)
ProjectionInfo * ExecBuildProjectionInfo(List *targetList, ExprContext *econtext, TupleTableSlot *slot, PlanState *parent, TupleDesc inputDesc)
ExprState * ExecInitQual(List *qual, PlanState *parent)
ProjectionInfo * ExecBuildUpdateProjection(List *targetList, bool evalTargetList, List *targetColnos, TupleDesc relDesc, ExprContext *econtext, TupleTableSlot *slot, PlanState *parent)
void ExecOpenIndices(ResultRelInfo *resultRelInfo, bool speculative)
List * ExecInsertIndexTuples(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate, bool update, bool noDupErr, bool *specConflict, List *arbiterIndexes, bool onlySummarizing)
bool ExecCheckIndexConstraints(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate, ItemPointer conflictTid, const ItemPointerData *tupleid, List *arbiterIndexes)
AttrNumber ExecFindJunkAttributeInTlist(List *targetlist, const char *attrName)
LockTupleMode ExecUpdateLockMode(EState *estate, ResultRelInfo *relinfo)
ExecRowMark * ExecFindRowMark(EState *estate, Index rti, bool missing_ok)
ExecAuxRowMark * ExecBuildAuxRowMark(ExecRowMark *erm, List *targetlist)
TupleTableSlot * EvalPlanQualSlot(EPQState *epqstate, Relation relation, Index rti)
void CheckValidResultRel(ResultRelInfo *resultRelInfo, CmdType operation, OnConflictAction onConflictAction, List *mergeActions)
void EvalPlanQualBegin(EPQState *epqstate)
bool ExecPartitionCheck(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate, bool emitError)
void EvalPlanQualInit(EPQState *epqstate, EState *parentestate, Plan *subplan, List *auxrowmarks, int epqParam, List *resultRelations)
void ExecWithCheckOptions(WCOKind kind, ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate)
void EvalPlanQualEnd(EPQState *epqstate)
void EvalPlanQualSetPlan(EPQState *epqstate, Plan *subplan, List *auxrowmarks)
TupleTableSlot * EvalPlanQual(EPQState *epqstate, Relation relation, Index rti, TupleTableSlot *inputslot)
void ExecPartitionCheckEmitError(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate)
void ExecConstraints(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate)
List * ExecGetAncestorResultRels(EState *estate, ResultRelInfo *resultRelInfo)
PartitionTupleRouting * ExecSetupPartitionTupleRouting(EState *estate, Relation rel)
ResultRelInfo * ExecFindPartition(ModifyTableState *mtstate, ResultRelInfo *rootResultRelInfo, PartitionTupleRouting *proute, TupleTableSlot *slot, EState *estate)
void ExecCleanupTupleRouting(ModifyTableState *mtstate, PartitionTupleRouting *proute)
void ExecEndNode(PlanState *node)
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
TupleTableSlot * MakeSingleTupleTableSlot(TupleDesc tupdesc, const TupleTableSlotOps *tts_ops)
const TupleTableSlotOps TTSOpsVirtual
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
TupleTableSlot * ExecStoreVirtualTuple(TupleTableSlot *slot)
void ExecInitResultTypeTL(PlanState *planstate)
void ExecInitResultTupleSlotTL(PlanState *planstate, const TupleTableSlotOps *tts_ops)
TupleTableSlot * ExecStoreAllNullTuple(TupleTableSlot *slot)
void ExecForceStoreHeapTuple(HeapTuple tuple, TupleTableSlot *slot, bool shouldFree)
TupleConversionMap * ExecGetRootToChildMap(ResultRelInfo *resultRelInfo, EState *estate)
TupleConversionMap * ExecGetChildToRootMap(ResultRelInfo *resultRelInfo)
Bitmapset * ExecGetUpdatedCols(ResultRelInfo *relinfo, EState *estate)
void ExecInitResultRelation(EState *estate, ResultRelInfo *resultRelInfo, Index rti)
void ExecAssignExprContext(EState *estate, PlanState *planstate)
TupleTableSlot * ExecGetAllNullSlot(EState *estate, ResultRelInfo *relInfo)
TupleTableSlot * ExecGetReturningSlot(EState *estate, ResultRelInfo *relInfo)
#define InstrCountFiltered1(node, delta)
#define outerPlanState(node)
#define InstrCountTuples2(node, delta)
#define EEO_FLAG_NEW_IS_NULL
#define EEO_FLAG_OLD_IS_NULL
#define EXEC_FLAG_BACKWARD
#define ResetPerTupleExprContext(estate)
static TupleTableSlot * ExecProject(ProjectionInfo *projInfo)
#define GetPerTupleExprContext(estate)
#define ResetExprContext(econtext)
#define GetPerTupleMemoryContext(estate)
static bool ExecQual(ExprState *state, ExprContext *econtext)
static TupleTableSlot * ExecProcNode(PlanState *node)
#define EvalPlanQualSetSlot(epqstate, slot)
static Datum ExecEvalExpr(ExprState *state, ExprContext *econtext, bool *isNull)
#define EXEC_FLAG_EXPLAIN_ONLY
static Datum ExecGetJunkAttribute(TupleTableSlot *slot, AttrNumber attno, bool *isNull)
#define DatumGetHeapTupleHeader(X)
Assert(PointerIsAligned(start, uint64))
static uint32 HeapTupleHeaderGetDatumLength(const HeapTupleHeaderData *tup)
void InstrUpdateTupleCount(Instrumentation *instr, double nTuples)
if(TABLE==NULL||TABLE_index==NULL)
static void ItemPointerSetInvalid(ItemPointerData *pointer)
static bool ItemPointerIndicatesMovedPartitions(const ItemPointerData *pointer)
ItemPointerData * ItemPointer
static void ItemPointerCopy(const ItemPointerData *fromPointer, ItemPointerData *toPointer)
static bool ItemPointerIsValid(const ItemPointerData *pointer)
List * lappend(List *list, void *datum)
List * lappend_int(List *list, int datum)
List * lcons(void *datum, List *list)
bool list_member_ptr(const List *list, const void *datum)
void list_free(List *list)
void UnlockTuple(Relation relation, const ItemPointerData *tid, LOCKMODE lockmode)
uint32 SpeculativeInsertionLockAcquire(TransactionId xid)
void SpeculativeInsertionLockRelease(TransactionId xid)
void LockTuple(Relation relation, const ItemPointerData *tid, LOCKMODE lockmode)
#define InplaceUpdateTupleLock
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
#define IsBootstrapProcessingMode()
#define CHECK_FOR_INTERRUPTS()
Oid exprType(const Node *expr)
static void ExecInitInsertProjection(ModifyTableState *mtstate, ResultRelInfo *resultRelInfo)
ResultRelInfo * ExecLookupResultRelByOid(ModifyTableState *node, Oid resultoid, bool missing_ok, bool update_cache)
static void ExecPendingInserts(EState *estate)
static void ExecSetupTransitionCaptureState(ModifyTableState *mtstate, EState *estate)
void ExecInitMergeTupleSlots(ModifyTableState *mtstate, ResultRelInfo *resultRelInfo)
struct ModifyTableContext ModifyTableContext
static void ExecUpdatePrepareSlot(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate)
static TupleTableSlot * ExecInsert(ModifyTableContext *context, ResultRelInfo *resultRelInfo, TupleTableSlot *slot, bool canSetTag, TupleTableSlot **inserted_tuple, ResultRelInfo **insert_destrel)
ModifyTableState * ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
static TupleTableSlot * ExecMergeMatched(ModifyTableContext *context, ResultRelInfo *resultRelInfo, ItemPointer tupleid, HeapTuple oldtuple, bool canSetTag, bool *matched)
static TupleTableSlot * ExecModifyTable(PlanState *pstate)
static bool ExecDeletePrologue(ModifyTableContext *context, ResultRelInfo *resultRelInfo, ItemPointer tupleid, HeapTuple oldtuple, TupleTableSlot **epqreturnslot, TM_Result *result)
static void ExecCheckPlanOutput(Relation resultRel, List *targetList)
TupleTableSlot * ExecGetUpdateNewTuple(ResultRelInfo *relinfo, TupleTableSlot *planSlot, TupleTableSlot *oldSlot)
static void ExecCrossPartitionUpdateForeignKey(ModifyTableContext *context, ResultRelInfo *sourcePartInfo, ResultRelInfo *destPartInfo, ItemPointer tupleid, TupleTableSlot *oldslot, TupleTableSlot *newslot)
static void ExecInitUpdateProjection(ModifyTableState *mtstate, ResultRelInfo *resultRelInfo)
static void ExecCheckTIDVisible(EState *estate, ResultRelInfo *relinfo, ItemPointer tid, TupleTableSlot *tempSlot)
static TM_Result ExecDeleteAct(ModifyTableContext *context, ResultRelInfo *resultRelInfo, ItemPointer tupleid, bool changingPart)
static void ExecCheckTupleVisible(EState *estate, Relation rel, TupleTableSlot *slot)
static TupleTableSlot * ExecUpdate(ModifyTableContext *context, ResultRelInfo *resultRelInfo, ItemPointer tupleid, HeapTuple oldtuple, TupleTableSlot *oldSlot, TupleTableSlot *slot, bool canSetTag)
void ExecComputeStoredGenerated(ResultRelInfo *resultRelInfo, EState *estate, TupleTableSlot *slot, CmdType cmdtype)
static TupleTableSlot * ExecPrepareTupleRouting(ModifyTableState *mtstate, EState *estate, PartitionTupleRouting *proute, ResultRelInfo *targetRelInfo, TupleTableSlot *slot, ResultRelInfo **partRelInfo)
static TupleTableSlot * ExecGetInsertNewTuple(ResultRelInfo *relinfo, TupleTableSlot *planSlot)
struct MTTargetRelLookup MTTargetRelLookup
struct UpdateContext UpdateContext
static TM_Result ExecUpdateAct(ModifyTableContext *context, ResultRelInfo *resultRelInfo, ItemPointer tupleid, HeapTuple oldtuple, TupleTableSlot *slot, bool canSetTag, UpdateContext *updateCxt)
static void ExecUpdateEpilogue(ModifyTableContext *context, UpdateContext *updateCxt, ResultRelInfo *resultRelInfo, ItemPointer tupleid, HeapTuple oldtuple, TupleTableSlot *slot)
void ExecInitGenerated(ResultRelInfo *resultRelInfo, EState *estate, CmdType cmdtype)
static void fireBSTriggers(ModifyTableState *node)
void ExecReScanModifyTable(ModifyTableState *node)
static TupleTableSlot * ExecDelete(ModifyTableContext *context, ResultRelInfo *resultRelInfo, ItemPointer tupleid, HeapTuple oldtuple, bool processReturning, bool changingPart, bool canSetTag, TM_Result *tmresult, bool *tupleDeleted, TupleTableSlot **epqreturnslot)
void ExecEndModifyTable(ModifyTableState *node)
static void fireASTriggers(ModifyTableState *node)
static bool ExecOnConflictUpdate(ModifyTableContext *context, ResultRelInfo *resultRelInfo, ItemPointer conflictTid, TupleTableSlot *excludedSlot, bool canSetTag, TupleTableSlot **returning)
static void ExecBatchInsert(ModifyTableState *mtstate, ResultRelInfo *resultRelInfo, TupleTableSlot **slots, TupleTableSlot **planSlots, int numSlots, EState *estate, bool canSetTag)
static bool ExecUpdatePrologue(ModifyTableContext *context, ResultRelInfo *resultRelInfo, ItemPointer tupleid, HeapTuple oldtuple, TupleTableSlot *slot, TM_Result *result)
static void ExecDeleteEpilogue(ModifyTableContext *context, ResultRelInfo *resultRelInfo, ItemPointer tupleid, HeapTuple oldtuple, bool changingPart)
static TupleTableSlot * ExecMergeNotMatched(ModifyTableContext *context, ResultRelInfo *resultRelInfo, bool canSetTag)
static TupleTableSlot * ExecProcessReturning(ModifyTableContext *context, ResultRelInfo *resultRelInfo, CmdType cmdType, TupleTableSlot *oldSlot, TupleTableSlot *newSlot, TupleTableSlot *planSlot)
static TupleTableSlot * ExecMerge(ModifyTableContext *context, ResultRelInfo *resultRelInfo, ItemPointer tupleid, HeapTuple oldtuple, bool canSetTag)
static bool ExecCrossPartitionUpdate(ModifyTableContext *context, ResultRelInfo *resultRelInfo, ItemPointer tupleid, HeapTuple oldtuple, TupleTableSlot *slot, bool canSetTag, UpdateContext *updateCxt, TM_Result *tmresult, TupleTableSlot **retry_slot, TupleTableSlot **inserted_tuple, ResultRelInfo **insert_destrel)
static void ExecInitMerge(ModifyTableState *mtstate, EState *estate)
#define IsA(nodeptr, _type_)
#define castNode(_type_, nodeptr)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
@ WCO_RLS_MERGE_UPDATE_CHECK
@ WCO_RLS_MERGE_DELETE_CHECK
FormData_pg_attribute * Form_pg_attribute
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define forboth(cell1, list1, cell2, list2)
static void * list_nth(const List *list, int n)
#define list_nth_node(type, list, n)
#define ERRCODE_T_R_SERIALIZATION_FAILURE
static Oid DatumGetObjectId(Datum X)
static Pointer DatumGetPointer(Datum X)
static TransactionId DatumGetTransactionId(Datum X)
@ MERGE_WHEN_NOT_MATCHED_BY_TARGET
@ MERGE_WHEN_NOT_MATCHED_BY_SOURCE
#define RelationGetForm(relation)
#define RelationGetRelid(relation)
#define RelationGetDescr(relation)
#define RelationGetRelationName(relation)
Node * build_column_default(Relation rel, int attrno)
Node * map_variable_attnos(Node *node, int target_varno, int sublevels_up, const AttrMap *attno_map, Oid to_rowtype, bool *found_whole_row)
int RI_FKey_trigger_type(Oid tgfoid)
Bitmapset * es_unpruned_relids
List * es_insert_pending_result_relations
MemoryContext es_query_cxt
struct EPQState * es_epq_active
List * es_insert_pending_modifytables
List * es_auxmodifytables
Snapshot es_crosscheck_snapshot
TupleTableSlot * ecxt_innertuple
TupleTableSlot * ecxt_newtuple
TupleTableSlot * ecxt_scantuple
TupleTableSlot * ecxt_oldtuple
TupleTableSlot * ecxt_outertuple
BeginForeignModify_function BeginForeignModify
EndForeignModify_function EndForeignModify
ExecForeignInsert_function ExecForeignInsert
ExecForeignUpdate_function ExecForeignUpdate
ExecForeignBatchInsert_function ExecForeignBatchInsert
GetForeignModifyBatchSize_function GetForeignModifyBatchSize
ExecForeignDelete_function ExecForeignDelete
ProjectionInfo * mas_proj
TupleTableSlot * planSlot
TupleTableSlot * cpDeletedSlot
TupleTableSlot * cpUpdateReturningSlot
ModifyTableState * mtstate
List * mt_mergeJoinConditions
TupleTableSlot * mt_merge_pending_not_matched
ResultRelInfo * resultRelInfo
struct PartitionTupleRouting * mt_partition_tuple_routing
List * mt_updateColnosLists
TupleTableSlot * mt_root_tuple_slot
List * mt_mergeActionLists
ResultRelInfo * rootResultRelInfo
struct TransitionCaptureState * mt_transition_capture
struct TransitionCaptureState * mt_oc_transition_capture
MergeActionState * mt_merge_action
List * mergeJoinConditions
Bitmapset * fdwDirectModifyPlans
List * withCheckOptionLists
OnConflictAction onConflictAction
TupleTableSlot * oc_ProjSlot
TupleTableSlot * oc_Existing
ExprState * oc_WhereClause
ProjectionInfo * oc_ProjInfo
ExprContext * ps_ExprContext
TupleTableSlot * ps_ResultTupleSlot
ExecProcNodeMtd ExecProcNode
ExprContext * pi_exprContext
TupleTableSlot * ri_PartitionTupleSlot
bool ri_projectNewInfoValid
OnConflictSetState * ri_onConflict
List * ri_onConflictArbiterIndexes
struct ResultRelInfo * ri_RootResultRelInfo
TupleTableSlot ** ri_Slots
ExprState * ri_MergeJoinCondition
RelationPtr ri_IndexRelationDescs
int ri_NumSlotsInitialized
List * ri_WithCheckOptions
TupleTableSlot * ri_oldTupleSlot
bool ri_extraUpdatedCols_valid
TriggerDesc * ri_TrigDesc
Bitmapset * ri_extraUpdatedCols
ExprState ** ri_GeneratedExprsI
int ri_NumGeneratedNeededU
List * ri_MergeActions[NUM_MERGE_MATCH_KINDS]
TupleTableSlot * ri_newTupleSlot
List * ri_WithCheckOptionExprs
ProjectionInfo * ri_projectNew
ProjectionInfo * ri_projectReturning
ExprState ** ri_GeneratedExprsU
struct FdwRoutine * ri_FdwRoutine
TupleTableSlot ** ri_PlanSlots
bool ri_usesFdwDirectModify
int ri_NumGeneratedNeededI
TupleTableSlot * tcs_original_insert_tuple
bool tcs_update_new_table
bool tcs_update_old_table
bool trig_delete_before_row
bool trig_update_instead_row
bool trig_delete_instead_row
bool trig_update_after_row
bool trig_insert_instead_row
bool trig_update_before_row
bool trig_insert_before_row
bool has_generated_virtual
bool has_generated_stored
TupleDesc tts_tupleDescriptor
const TupleTableSlotOps *const tts_ops
TU_UpdateIndexes updateIndexes
#define MinTransactionIdAttributeNumber
#define FirstLowInvalidHeapAttributeNumber
TupleTableSlot * table_slot_create(Relation relation, List **reglist)
static TM_Result table_tuple_lock(Relation rel, ItemPointer tid, Snapshot snapshot, TupleTableSlot *slot, CommandId cid, LockTupleMode mode, LockWaitPolicy wait_policy, uint8 flags, TM_FailureData *tmfd)
static void table_tuple_insert_speculative(Relation rel, TupleTableSlot *slot, CommandId cid, int options, BulkInsertStateData *bistate, uint32 specToken)
static void table_tuple_complete_speculative(Relation rel, TupleTableSlot *slot, uint32 specToken, bool succeeded)
static TM_Result table_tuple_update(Relation rel, ItemPointer otid, TupleTableSlot *slot, CommandId cid, Snapshot snapshot, Snapshot crosscheck, bool wait, TM_FailureData *tmfd, LockTupleMode *lockmode, TU_UpdateIndexes *update_indexes)
static TM_Result table_tuple_delete(Relation rel, ItemPointer tid, CommandId cid, Snapshot snapshot, Snapshot crosscheck, bool wait, TM_FailureData *tmfd, bool changingPart)
#define TUPLE_LOCK_FLAG_FIND_LAST_VERSION
static void table_tuple_insert(Relation rel, TupleTableSlot *slot, CommandId cid, int options, BulkInsertStateData *bistate)
static bool table_tuple_satisfies_snapshot(Relation rel, TupleTableSlot *slot, Snapshot snapshot)
static bool table_tuple_fetch_row_version(Relation rel, ItemPointer tid, Snapshot snapshot, TupleTableSlot *slot)
bool ExecBRUpdateTriggers(EState *estate, EPQState *epqstate, ResultRelInfo *relinfo, ItemPointer tupleid, HeapTuple fdw_trigtuple, TupleTableSlot *newslot, TM_Result *tmresult, TM_FailureData *tmfd, bool is_merge_update)
TransitionCaptureState * MakeTransitionCaptureState(TriggerDesc *trigdesc, Oid relid, CmdType cmdType)
void ExecARDeleteTriggers(EState *estate, ResultRelInfo *relinfo, ItemPointer tupleid, HeapTuple fdw_trigtuple, TransitionCaptureState *transition_capture, bool is_crosspart_update)
void ExecBSInsertTriggers(EState *estate, ResultRelInfo *relinfo)
bool ExecBRInsertTriggers(EState *estate, ResultRelInfo *relinfo, TupleTableSlot *slot)
bool ExecIRDeleteTriggers(EState *estate, ResultRelInfo *relinfo, HeapTuple trigtuple)
void ExecBSDeleteTriggers(EState *estate, ResultRelInfo *relinfo)
bool ExecIRInsertTriggers(EState *estate, ResultRelInfo *relinfo, TupleTableSlot *slot)
void ExecARUpdateTriggers(EState *estate, ResultRelInfo *relinfo, ResultRelInfo *src_partinfo, ResultRelInfo *dst_partinfo, ItemPointer tupleid, HeapTuple fdw_trigtuple, TupleTableSlot *newslot, List *recheckIndexes, TransitionCaptureState *transition_capture, bool is_crosspart_update)
bool ExecBRDeleteTriggers(EState *estate, EPQState *epqstate, ResultRelInfo *relinfo, ItemPointer tupleid, HeapTuple fdw_trigtuple, TupleTableSlot **epqslot, TM_Result *tmresult, TM_FailureData *tmfd, bool is_merge_delete)
void ExecASUpdateTriggers(EState *estate, ResultRelInfo *relinfo, TransitionCaptureState *transition_capture)
void ExecASDeleteTriggers(EState *estate, ResultRelInfo *relinfo, TransitionCaptureState *transition_capture)
void ExecARInsertTriggers(EState *estate, ResultRelInfo *relinfo, TupleTableSlot *slot, List *recheckIndexes, TransitionCaptureState *transition_capture)
void ExecASInsertTriggers(EState *estate, ResultRelInfo *relinfo, TransitionCaptureState *transition_capture)
bool ExecIRUpdateTriggers(EState *estate, ResultRelInfo *relinfo, HeapTuple trigtuple, TupleTableSlot *newslot)
void ExecBSUpdateTriggers(EState *estate, ResultRelInfo *relinfo)
TupleTableSlot * execute_attr_map_slot(AttrMap *attrMap, TupleTableSlot *in_slot, TupleTableSlot *out_slot)
TupleDesc CreateTupleDescCopy(TupleDesc tupdesc)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
static CompactAttribute * TupleDescCompactAttr(TupleDesc tupdesc, int i)
static Datum slot_getsysattr(TupleTableSlot *slot, int attnum, bool *isnull)
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
static void slot_getallattrs(TupleTableSlot *slot)
static TupleTableSlot * ExecCopySlot(TupleTableSlot *dstslot, TupleTableSlot *srcslot)
static void ExecMaterializeSlot(TupleTableSlot *slot)
void pull_varattnos(Node *node, Index varno, Bitmapset **varattnos)
bool TransactionIdIsCurrentTransactionId(TransactionId xid)
TransactionId GetCurrentTransactionId(void)
#define IsolationUsesXactSnapshot()