26#include "catalog/pg_am_d.h"
103 elog(
ERROR,
"missing operator %d(%u,%u) in opfamily %u",
150 errmsg(
"tuple to be locked was already moved to another partition due to concurrent update, retrying")));
154 errmsg(
"concurrent update, retrying")));
161 errmsg(
"concurrent delete, retrying")));
165 elog(
ERROR,
"attempted to lock invisible tuple");
168 elog(
ERROR,
"unexpected table_tuple_lock status: %u", res);
294 slot2->tts_tupleDescriptor->natts);
300 for (attrnum = 0; attrnum <
slot1->tts_tupleDescriptor->natts; attrnum++)
311 if (
att->attisdropped ||
att->attgenerated)
326 if (
slot1->tts_isnull[attrnum] !=
slot2->tts_isnull[attrnum])
332 if (
slot1->tts_isnull[attrnum] ||
slot2->tts_isnull[attrnum])
335 typentry =
eq[attrnum];
336 if (typentry ==
NULL)
343 errmsg(
"could not identify an equality operator for type %s",
345 eq[attrnum] = typentry;
350 slot1->tts_values[attrnum],
351 slot2->tts_values[attrnum])))
840 if (rel->
rd_rel->relispartition)
937 if (rel->
rd_rel->relispartition)
1053 errmsg(
"cannot update table \"%s\"",
1055 errdetail(
"Column used in the publication WHERE expression is not part of the replica identity.")));
1059 errmsg(
"cannot update table \"%s\"",
1061 errdetail(
"Column list used by the publication does not cover the replica identity.")));
1065 errmsg(
"cannot update table \"%s\"",
1067 errdetail(
"Replica identity must not contain unpublished generated columns.")));
1071 errmsg(
"cannot delete from table \"%s\"",
1073 errdetail(
"Column used in the publication WHERE expression is not part of the replica identity.")));
1077 errmsg(
"cannot delete from table \"%s\"",
1079 errdetail(
"Column list used by the publication does not cover the replica identity.")));
1083 errmsg(
"cannot delete from table \"%s\"",
1085 errdetail(
"Replica identity must not contain unpublished generated columns.")));
1103 errmsg(
"cannot update table \"%s\" because it does not have a replica identity and publishes updates",
1105 errhint(
"To enable updating the table, set REPLICA IDENTITY using ALTER TABLE.")));
1109 errmsg(
"cannot delete from table \"%s\" because it does not have a replica identity and publishes deletes",
1111 errhint(
"To enable deleting from the table, set REPLICA IDENTITY using ALTER TABLE.")));
1123 const char *nspname,
const char *
relname)
1130 errmsg(
"cannot use relation \"%s.%s\" as logical replication target",
1144 errmsg(
"relation \"%s.%s\" type mismatch: source \"%s\", target \"%s\"",
StrategyNumber IndexAmTranslateCompareType(CompareType cmptype, Oid amoid, Oid opfamily, bool missing_ok)
#define AttributeNumberIsValid(attributeNumber)
bool TimestampDifferenceExceeds(TimestampTz start_time, TimestampTz stop_time, int msec)
bool bms_is_member(int x, const Bitmapset *a)
static void LockBuffer(Buffer buffer, BufferLockMode mode)
#define PG_USED_FOR_ASSERTS_ONLY
#define Assert(condition)
#define OidIsValid(objectId)
bool IsCatalogRelation(Relation relation)
bool TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts, ReplOriginId *nodeid)
bool GetTupleTransactionInfo(TupleTableSlot *localslot, TransactionId *xmin, ReplOriginId *localorigin, TimestampTz *localts)
void ReportApplyConflict(EState *estate, ResultRelInfo *relinfo, int elevel, ConflictType type, TupleTableSlot *searchslot, TupleTableSlot *remoteslot, List *conflicttuples)
@ CT_MULTIPLE_UNIQUE_CONFLICTS
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
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)
bool ExecPartitionCheck(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate, bool emitError)
void ExecConstraints(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate)
static void BuildConflictIndexInfo(ResultRelInfo *resultRelInfo, Oid conflictindex)
void CheckSubscriptionRelkind(char localrelkind, char remoterelkind, const char *nspname, const char *relname)
static bool tuples_equal(TupleTableSlot *slot1, TupleTableSlot *slot2, TypeCacheEntry **eq, Bitmapset *columns)
bool RelationFindReplTupleSeq(Relation rel, LockTupleMode lockmode, TupleTableSlot *searchslot, TupleTableSlot *outslot)
bool RelationFindReplTupleByIndex(Relation rel, Oid idxoid, LockTupleMode lockmode, TupleTableSlot *searchslot, TupleTableSlot *outslot)
void ExecSimpleRelationDelete(ResultRelInfo *resultRelInfo, EState *estate, EPQState *epqstate, TupleTableSlot *searchslot)
static bool should_refetch_tuple(TM_Result res, TM_FailureData *tmfd)
void ExecSimpleRelationUpdate(ResultRelInfo *resultRelInfo, EState *estate, EPQState *epqstate, TupleTableSlot *searchslot, TupleTableSlot *slot)
void CheckCmdReplicaIdentity(Relation rel, CmdType cmd)
void ExecSimpleRelationInsert(ResultRelInfo *resultRelInfo, EState *estate, TupleTableSlot *slot)
bool RelationFindDeletedTupleInfoByIndex(Relation rel, Oid idxoid, TupleTableSlot *searchslot, TransactionId oldestxmin, TransactionId *delete_xid, ReplOriginId *delete_origin, TimestampTz *delete_time)
bool RelationFindDeletedTupleInfoSeq(Relation rel, TupleTableSlot *searchslot, TransactionId oldestxmin, TransactionId *delete_xid, ReplOriginId *delete_origin, TimestampTz *delete_time)
static bool FindConflictTuple(ResultRelInfo *resultRelInfo, EState *estate, Oid conflictindex, TupleTableSlot *slot, TupleTableSlot **conflictslot)
static int build_replindex_scan_key(ScanKey skey, Relation rel, Relation idxrel, TupleTableSlot *searchslot)
static void update_most_recent_deletion_info(TupleTableSlot *scanslot, TransactionId oldestxmin, TransactionId *delete_xid, TimestampTz *delete_time, ReplOriginId *delete_origin)
static void CheckAndReportConflict(ResultRelInfo *resultRelInfo, EState *estate, ConflictType type, List *recheckIndexes, TupleTableSlot *searchslot, TupleTableSlot *remoteslot)
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
HeapTuple ExecFetchSlotHeapTuple(TupleTableSlot *slot, bool materialize, bool *shouldFree)
#define palloc0_array(type, count)
#define palloc0_object(type)
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
@ HEAPTUPLE_RECENTLY_DEAD
HTSV_Result HeapTupleSatisfiesVacuum(HeapTuple htup, TransactionId OldestXmin, Buffer buffer)
static TransactionId HeapTupleHeaderGetUpdateXid(const HeapTupleHeaderData *tup)
void BuildSpeculativeIndexInfo(Relation index, IndexInfo *ii)
bool index_getnext_slot(IndexScanDesc scan, ScanDirection direction, TupleTableSlot *slot)
IndexScanDesc index_beginscan(Relation heapRelation, Relation indexRelation, Snapshot snapshot, IndexScanInstrumentation *instrument, int nkeys, int norderbys)
void index_close(Relation relation, LOCKMODE lockmode)
void index_endscan(IndexScanDesc scan)
Relation index_open(Oid relationId, LOCKMODE lockmode)
void index_rescan(IndexScanDesc scan, ScanKey keys, int nkeys, ScanKey orderbys, int norderbys)
static bool ItemPointerIndicatesMovedPartitions(const ItemPointerData *pointer)
List * lappend(List *list, void *datum)
void list_free(List *list)
bool list_member_oid(const List *list, Oid datum)
void XactLockTableWait(TransactionId xid, Relation rel, const ItemPointerData *ctid, XLTW_Oper oper)
Oid get_opclass_input_type(Oid opclass)
Oid get_opclass_family(Oid opclass)
RegProcedure get_opcode(Oid opno)
Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
void ExecComputeStoredGenerated(ResultRelInfo *resultRelInfo, EState *estate, TupleTableSlot *slot, CmdType cmdtype)
#define InvalidReplOriginId
FormData_pg_attribute * Form_pg_attribute
int errdetail_relkind_not_supported(char relkind)
static int list_length(const List *l)
#define list_make1_oid(x1)
#define foreach_oid(var, lst)
static char buf[DEFAULT_XLOG_SEG_SIZE]
#define ERRCODE_T_R_SERIALIZATION_FAILURE
static bool DatumGetBool(Datum X)
static Pointer DatumGetPointer(Datum X)
#define RelationGetRelid(relation)
#define RelationGetDescr(relation)
#define RelationGetRelationName(relation)
#define IndexRelationGetNumberOfKeyAttributes(relation)
void RelationBuildPublicationDesc(Relation relation, PublicationDesc *pubdesc)
Bitmapset * RelationGetIndexAttrBitmap(Relation relation, IndexAttrBitmapKind attrKind)
Oid RelationGetReplicaIndex(Relation relation)
@ INDEX_ATTR_BITMAP_PRIMARY_KEY
@ INDEX_ATTR_BITMAP_IDENTITY_KEY
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
Snapshot GetLatestSnapshot(void)
void PushActiveSnapshot(Snapshot snapshot)
void PopActiveSnapshot(void)
Snapshot GetActiveSnapshot(void)
#define InitDirtySnapshot(snapshotdata)
Oid GetRelationIdentityOrPK(Relation rel)
List * ri_onConflictArbiterIndexes
RelationPtr ri_IndexRelationDescs
TriggerDesc * ri_TrigDesc
IndexInfo ** ri_IndexRelationInfo
bool trig_delete_before_row
bool trig_update_before_row
bool trig_insert_before_row
bool has_generated_stored
Oid values[FLEXIBLE_ARRAY_MEMBER]
#define FirstLowInvalidHeapAttributeNumber
Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup, AttrNumber attributeNumber)
TupleTableSlot * table_slot_create(Relation relation, List **reglist)
void simple_table_tuple_update(Relation rel, ItemPointer otid, TupleTableSlot *slot, Snapshot snapshot, TU_UpdateIndexes *update_indexes)
void simple_table_tuple_insert(Relation rel, TupleTableSlot *slot)
void simple_table_tuple_delete(Relation rel, ItemPointer tid, Snapshot snapshot)
static void table_endscan(TableScanDesc scan)
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_rescan(TableScanDesc scan, ScanKeyData *key)
static bool table_scan_getnextslot(TableScanDesc sscan, ScanDirection direction, TupleTableSlot *slot)
static TableScanDesc table_beginscan(Relation rel, Snapshot snapshot, int nkeys, ScanKeyData *key)
#define InvalidTransactionId
#define TransactionIdIsValid(xid)
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)
void ExecARDeleteTriggers(EState *estate, ResultRelInfo *relinfo, ItemPointer tupleid, HeapTuple fdw_trigtuple, TransitionCaptureState *transition_capture, bool is_crosspart_update)
bool ExecBRInsertTriggers(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 ExecARInsertTriggers(EState *estate, ResultRelInfo *relinfo, TupleTableSlot *slot, List *recheckIndexes, TransitionCaptureState *transition_capture)
bool equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
static void slot_getallattrs(TupleTableSlot *slot)
static TupleTableSlot * ExecCopySlot(TupleTableSlot *dstslot, TupleTableSlot *srcslot)
static void ExecMaterializeSlot(TupleTableSlot *slot)
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
#define TYPECACHE_EQ_OPR_FINFO
CommandId GetCurrentCommandId(bool used)