84 foreach(lc, targetList)
92 if (attno >= resultDesc->
natts)
94 (
errcode(ERRCODE_DATATYPE_MISMATCH),
95 errmsg(
"table row type and query-specified row type do not match"),
96 errdetail(
"Query has too many columns.")));
97 attr = resultDesc->
attrs[attno++];
99 if (!attr->attisdropped)
104 (
errcode(ERRCODE_DATATYPE_MISMATCH),
105 errmsg(
"table row type and query-specified row type do not match"),
106 errdetail(
"Table has type %s at ordinal position %d, but query expects %s.",
121 (
errcode(ERRCODE_DATATYPE_MISMATCH),
122 errmsg(
"table row type and query-specified row type do not match"),
123 errdetail(
"Query provides a value for a dropped column at ordinal position %d.",
127 if (attno != resultDesc->
natts)
129 (
errcode(ERRCODE_DATATYPE_MISMATCH),
130 errmsg(
"table row type and query-specified row type do not match"),
131 errdetail(
"Query has too few columns.")));
199 (
errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
200 errmsg(
"could not serialize access due to concurrent update")));
221 elog(
ERROR,
"failed to fetch conflicting tuple for ON CONFLICT");
239 List *arbiterIndexes,
274 if (resultRelationDesc->
rd_rel->relhasoids)
352 resultRelInfo, slot, estate);
380 specConflict =
false;
396 &conflictTid, planSlot, slot,
397 estate, canSetTag, &returning))
436 estate,
true, &specConflict,
663 (
errcode(ERRCODE_TRIGGERED_DATA_CHANGE_VIOLATION),
664 errmsg(
"tuple to be updated was already modified by an operation triggered by the current command"),
665 errhint(
"Consider using an AFTER trigger instead of a BEFORE trigger to propagate changes to other rows.")));
676 (
errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
677 errmsg(
"could not serialize access due to concurrent update")));
691 *tupleid = hufd.
ctid;
699 elog(
ERROR,
"unrecognized heap_delete status: %u", result);
739 if (oldtuple !=
NULL)
741 deltuple = *oldtuple;
746 deltuple.
t_self = *tupleid;
748 &deltuple, &delbuffer,
false,
NULL))
749 elog(
ERROR,
"failed to fetch deleted tuple for DELETE RETURNING");
817 elog(
ERROR,
"cannot UPDATE during bootstrap");
836 tupleid, oldtuple, slot);
905 resultRelInfo, slot, estate);
922 result =
heap_update(resultRelationDesc, tupleid, tuple,
956 (
errcode(ERRCODE_TRIGGERED_DATA_CHANGE_VIOLATION),
957 errmsg(
"tuple to be updated was already modified by an operation triggered by the current command"),
958 errhint(
"Consider using an AFTER trigger instead of a BEFORE trigger to propagate changes to other rows.")));
969 (
errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
970 errmsg(
"could not serialize access due to concurrent update")));
984 *tupleid = hufd.
ctid;
994 elog(
ERROR,
"unrecognized heap_update status: %u", result);
1086 tuple.
t_self = *conflictTid;
1116 (
errcode(ERRCODE_CARDINALITY_VIOLATION),
1117 errmsg(
"ON CONFLICT DO UPDATE command cannot affect row a second time"),
1118 errhint(
"Ensure that no rows proposed for insertion within the same command have duplicate constrained values.")));
1121 elog(
ERROR,
"attempted to lock invisible tuple");
1130 elog(
ERROR,
"unexpected self-updated tuple");
1135 (
errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
1136 errmsg(
"could not serialize access due to concurrent update")));
1149 elog(
ERROR,
"unrecognized heap_lock_tuple status: %u", test);
1189 if (!
ExecQual(onConflictSetWhere, econtext,
false))
1327 elog(
ERROR,
"ModifyTable should not be called during EvalPlanQual");
1421 if (junkfilter !=
NULL)
1443 tuple_ctid = *tupleid;
1445 tupleid = &tuple_ctid;
1480 oldtuple = &oldtupdata;
1501 slot =
ExecUpdate(tupleid, oldtuple, slot, planSlot,
1505 slot =
ExecDelete(tupleid, oldtuple, planSlot,
1592 foreach(l, node->
plans)
1654 foreach(ll, wcoList)
1660 wcoExprs =
lappend(wcoExprs, wcoExpr);
1796 for (i = 0; i < nplans; i++)
1826 bool junk_filter_needed =
false;
1837 junk_filter_needed =
true;
1844 junk_filter_needed =
true;
1851 if (junk_filter_needed)
1854 for (i = 0; i < nplans; i++)
1878 elog(
ERROR,
"could not find junk ctid column");
1892 elog(
ERROR,
"could not find junk wholerow column");
1988 elog(
ERROR,
"ExecReScanModifyTable is not implemented");
ExecForeignDelete_function ExecForeignDelete
void ExecASDeleteTriggers(EState *estate, ResultRelInfo *relinfo)
TupleTableSlot * ExecStoreTuple(HeapTuple tuple, TupleTableSlot *slot, Buffer buffer, bool shouldFree)
JunkFilter * ri_junkFilter
TupleTableSlot * ExecModifyTable(ModifyTableState *node)
TupleTableSlot * ExecProcNode(PlanState *node)
bool ExecIRDeleteTriggers(EState *estate, ResultRelInfo *relinfo, HeapTuple trigtuple)
#define IsA(nodeptr, _type_)
Bitmapset * fdwDirectModifyPlans
void SpeculativeInsertionLockRelease(TransactionId xid)
TupleTableSlot * ExecInitExtraTupleSlot(EState *estate)
static bool ExecOnConflictUpdate(ModifyTableState *mtstate, ResultRelInfo *resultRelInfo, ItemPointer conflictTid, TupleTableSlot *planSlot, TupleTableSlot *excludedSlot, EState *estate, bool canSetTag, TupleTableSlot **returning)
int errhint(const char *fmt,...)
void ExecWithCheckOptions(WCOKind kind, ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate)
void ExecBSDeleteTriggers(EState *estate, ResultRelInfo *relinfo)
void heap_abort_speculative(Relation relation, HeapTuple tuple)
ProjectionInfo * ri_onConflictSetProj
void ExecReScanModifyTable(ModifyTableState *node)
List * ExecInsertIndexTuples(TupleTableSlot *slot, ItemPointer tupleid, EState *estate, bool noDupErr, bool *specConflict, List *arbiterIndexes)
#define ResetPerTupleExprContext(estate)
TupleTableSlot * ExecStoreAllNullTuple(TupleTableSlot *slot)
#define RelationGetDescr(relation)
bool TransactionIdIsCurrentTransactionId(TransactionId xid)
static TupleTableSlot * ExecUpdate(ItemPointer tupleid, HeapTuple oldtuple, TupleTableSlot *slot, TupleTableSlot *planSlot, EPQState *epqstate, EState *estate, bool canSetTag)
List * withCheckOptionLists
HTSU_Result heap_lock_tuple(Relation relation, HeapTuple tuple, CommandId cid, LockTupleMode mode, LockWaitPolicy wait_policy, bool follow_updates, Buffer *buffer, HeapUpdateFailureData *hufd)
void ExecEndNode(PlanState *node)
void ExecASUpdateTriggers(EState *estate, ResultRelInfo *relinfo)
ResultRelInfo * resultRelInfo
bool heap_fetch(Relation relation, Snapshot snapshot, HeapTuple tuple, Buffer *userbuf, bool keep_buf, Relation stats_relation)
AttrNumber ExecFindJunkAttribute(JunkFilter *junkfilter, const char *attrName)
ExecForeignInsert_function ExecForeignInsert
ExprContext * ps_ExprContext
TupleTableSlot * EvalPlanQual(EState *estate, EPQState *epqstate, Relation relation, Index rti, int lockmode, ItemPointer tid, TransactionId priorXmax)
static void fireBSTriggers(ModifyTableState *node)
TupleTableSlot * ExecBRUpdateTriggers(EState *estate, EPQState *epqstate, ResultRelInfo *relinfo, ItemPointer tupleid, HeapTuple fdw_trigtuple, TupleTableSlot *slot)
TupleTableSlot * ExecIRInsertTriggers(EState *estate, ResultRelInfo *relinfo, TupleTableSlot *slot)
TupleTableSlot * mt_conflproj
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Form_pg_attribute * attrs
void ExecConstraints(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate)
#define IsolationUsesXactSnapshot()
#define HeapTupleHeaderSetSpeculativeToken(tup, token)
Snapshot es_crosscheck_snapshot
int errcode(int sqlerrcode)
uint32 SpeculativeInsertionLockAcquire(TransactionId xid)
TupleTableSlot * ExecProject(ProjectionInfo *projInfo, ExprDoneCond *isDone)
void ReleaseBuffer(Buffer buffer)
void EvalPlanQualSetPlan(EPQState *epqstate, Plan *subplan, List *auxrowmarks)
#define DatumGetHeapTupleHeader(X)
bool ExecCheckIndexConstraints(TupleTableSlot *slot, EState *estate, ItemPointer conflictTid, List *arbiterIndexes)
void ExecFreeExprContext(PlanState *planstate)
void ExecAssignResultType(PlanState *planstate, TupleDesc tupDesc)
#define HEAP_INSERT_SPECULATIVE
#define HeapTupleSatisfiesVisibility(tuple, snapshot, buffer)
TupleTableSlot * ExecIRUpdateTriggers(EState *estate, ResultRelInfo *relinfo, HeapTuple trigtuple, TupleTableSlot *slot)
void ExecOpenIndices(ResultRelInfo *resultRelInfo, bool speculative)
TupleTableSlot * mt_existing
void EvalPlanQualEnd(EPQState *epqstate)
ItemPointerData * ItemPointer
List * ri_WithCheckOptionExprs
#define HeapTupleSetOid(tuple, oid)
bool trig_insert_instead_row
static TupleTableSlot * ExecDelete(ItemPointer tupleid, HeapTuple oldtuple, TupleTableSlot *planSlot, EPQState *epqstate, EState *estate, bool canSetTag)
OnConflictAction mt_onconflict
TupleTableSlot * ps_ResultTupleSlot
ExprState * ExecInitExpr(Expr *node, PlanState *parent)
HTSU_Result heap_delete(Relation relation, ItemPointer tid, CommandId cid, Snapshot crosscheck, bool wait, HeapUpdateFailureData *hufd)
static void ExecCheckTIDVisible(EState *estate, ResultRelInfo *relinfo, ItemPointer tid)
void ExecInitResultTupleSlot(EState *estate, PlanState *planstate)
void ExecARUpdateTriggers(EState *estate, ResultRelInfo *relinfo, ItemPointer tupleid, HeapTuple fdw_trigtuple, HeapTuple newtuple, List *recheckIndexes)
bool ri_usesFdwDirectModify
#define EXEC_FLAG_BACKWARD
TransactionId GetCurrentTransactionId(void)
static void ExecCheckHeapTupleVisible(EState *estate, HeapTuple tuple, Buffer buffer)
void ExecBSInsertTriggers(EState *estate, ResultRelInfo *relinfo)
void * list_nth(const List *list, int n)
ResultRelInfo * es_result_relations
JunkFilter * ExecInitJunkFilter(List *targetList, bool hasoid, TupleTableSlot *slot)
int errdetail(const char *fmt,...)
ProjectionInfo * ExecBuildProjectionInfo(List *targetList, ExprContext *econtext, TupleTableSlot *slot, TupleDesc inputDesc)
TupleTableSlot * ecxt_innertuple
bool trig_update_before_row
bool ExecQual(List *qual, ExprContext *econtext, bool resultForNull)
ProjectionInfo * ri_projectReturning
FormData_pg_attribute * Form_pg_attribute
void CheckValidResultRel(Relation resultRel, CmdType operation)
struct FdwRoutine * ri_FdwRoutine
ModifyTableState * ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
#define RELKIND_FOREIGN_TABLE
void setLastTid(const ItemPointer tid)
TupleTableSlot * es_trig_tuple_slot
EndForeignModify_function EndForeignModify
#define InstrCountFiltered1(node, delta)
#define ereport(elevel, rest)
Oid heap_insert(Relation relation, HeapTuple tup, CommandId cid, int options, BulkInsertState bistate)
TriggerDesc * ri_TrigDesc
TupleDesc ExecTypeFromTL(List *targetList, bool hasoid)
List * lappend(List *list, void *datum)
bool trig_update_instead_row
static TupleTableSlot * ExecProcessReturning(ResultRelInfo *resultRelInfo, TupleTableSlot *tupleSlot, TupleTableSlot *planSlot)
#define AttributeNumberIsValid(attributeNumber)
TupleDesc tts_tupleDescriptor
static void fireASTriggers(ModifyTableState *node)
void ExecARDeleteTriggers(EState *estate, ResultRelInfo *relinfo, ItemPointer tupleid, HeapTuple fdw_trigtuple)
bool trig_insert_before_row
bool trig_delete_instead_row
void * palloc0(Size size)
List * es_auxmodifytables
TupleTableSlot * ExecFilterJunk(JunkFilter *junkfilter, TupleTableSlot *slot)
void ExecSetSlotDescriptor(TupleTableSlot *slot, TupleDesc tupdesc)
void ExecASInsertTriggers(EState *estate, ResultRelInfo *relinfo)
List * ri_WithCheckOptions
void EvalPlanQualInit(EPQState *epqstate, EState *estate, Plan *subplan, List *auxrowmarks, int epqParam)
HTSU_Result heap_update(Relation relation, ItemPointer otid, HeapTuple newtup, CommandId cid, Snapshot crosscheck, bool wait, HeapUpdateFailureData *hufd, LockTupleMode *lockmode)
List * ri_onConflictSetWhere
ExecForeignUpdate_function ExecForeignUpdate
List * lcons(void *datum, List *list)
TupleTableSlot * ecxt_outertuple
static void ExecCheckPlanOutput(Relation resultRel, List *targetList)
bool ExecBRDeleteTriggers(EState *estate, EPQState *epqstate, ResultRelInfo *relinfo, ItemPointer tupleid, HeapTuple fdw_trigtuple)
#define HeapTupleIsHeapOnly(tuple)
#define Assert(condition)
LockTupleMode ExecUpdateLockMode(EState *estate, ResultRelInfo *relinfo)
OnConflictAction onConflictAction
#define InstrCountFiltered2(node, delta)
void heap_finish_speculative(Relation relation, HeapTuple tuple)
#define HeapTupleHeaderGetXmin(tup)
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Oid exprType(const Node *expr)
static int list_length(const List *l)
TupleTableSlot * ecxt_scantuple
#define BufferIsValid(bufnum)
HeapTuple ExecMaterializeSlot(TupleTableSlot *slot)
static TupleTableSlot * ExecInsert(ModifyTableState *mtstate, TupleTableSlot *slot, TupleTableSlot *planSlot, List *arbiterIndexes, OnConflictAction onconflict, EState *estate, bool canSetTag)
bool ItemPointerEquals(ItemPointer pointer1, ItemPointer pointer2)
void ExecARInsertTriggers(EState *estate, ResultRelInfo *relinfo, HeapTuple trigtuple, List *recheckIndexes)
#define DatumGetPointer(X)
#define IsBootstrapProcessingMode()
void ExecBSUpdateTriggers(EState *estate, ResultRelInfo *relinfo)
#define ItemPointerSetInvalid(pointer)
int errmsg(const char *fmt,...)
Datum ExecGetJunkAttribute(TupleTableSlot *slot, AttrNumber attno, bool *isNull)
void list_free(List *list)
ExprContext * CreateExprContext(EState *estate)
TupleTableSlot * ExecBRInsertTriggers(EState *estate, ResultRelInfo *relinfo, TupleTableSlot *slot)
ExprContext * pi_exprContext
BeginForeignModify_function BeginForeignModify
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
bool bms_is_member(int x, const Bitmapset *a)
#define RelationGetRelid(relation)
void ExecEndModifyTable(ModifyTableState *node)
RelationPtr ri_IndexRelationDescs
ExecAuxRowMark * ExecBuildAuxRowMark(ExecRowMark *erm, List *targetlist)
#define ResetExprContext(econtext)
#define EvalPlanQualSetSlot(epqstate, slot)
bool trig_delete_before_row
ExecRowMark * ExecFindRowMark(EState *estate, Index rti, bool missing_ok)
#define HeapTupleHeaderGetDatumLength(tup)
ResultRelInfo * es_result_relation_info