22 #include "catalog/pg_am_d.h"
112 Anum_pg_index_indclass);
123 int table_attno = indkey->
values[index_attoff];
148 elog(
ERROR,
"missing operator %d(%u,%u) in opfamily %u",
149 eq_strategy, optype, optype, opfamily);
195 bool isIdxSafeToSkipDuplicates;
222 if (!isIdxSafeToSkipDuplicates)
278 errmsg(
"tuple to be locked was already moved to another partition due to concurrent update, retrying")));
282 errmsg(
"concurrent update, retrying")));
288 errmsg(
"concurrent delete, retrying")));
291 elog(
ERROR,
"attempted to lock invisible tuple");
294 elog(
ERROR,
"unexpected table_tuple_lock status: %u",
res);
334 if (att->attisdropped || att->attgenerated)
350 typentry = eq[attrnum];
351 if (typentry == NULL)
357 (
errcode(ERRCODE_UNDEFINED_FUNCTION),
358 errmsg(
"could not identify an equality operator for type %s",
360 eq[attrnum] = typentry;
462 errmsg(
"tuple to be locked was already moved to another partition due to concurrent update, retrying")));
466 errmsg(
"concurrent update, retrying")));
472 errmsg(
"concurrent delete, retrying")));
475 elog(
ERROR,
"attempted to lock invisible tuple");
478 elog(
ERROR,
"unexpected table_tuple_lock status: %u",
res);
499 bool skip_tuple =
false;
528 if (rel->
rd_rel->relispartition)
536 slot, estate,
false,
false,
541 recheckIndexes, NULL);
564 bool skip_tuple =
false;
578 tid, NULL, slot, NULL, NULL))
596 if (rel->
rd_rel->relispartition)
604 slot, estate,
true,
false,
612 recheckIndexes, NULL,
false);
629 bool skip_tuple =
false;
640 tid, NULL, NULL, NULL, NULL);
650 tid, NULL, NULL,
false);
666 if (rel->
rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
688 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
689 errmsg(
"cannot update table \"%s\"",
691 errdetail(
"Column used in the publication WHERE expression is not part of the replica identity.")));
694 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
695 errmsg(
"cannot update table \"%s\"",
697 errdetail(
"Column list used by the publication does not cover the replica identity.")));
700 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
701 errmsg(
"cannot delete from table \"%s\"",
703 errdetail(
"Column used in the publication WHERE expression is not part of the replica identity.")));
706 (
errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
707 errmsg(
"cannot delete from table \"%s\"",
709 errdetail(
"Column list used by the publication does not cover the replica identity.")));
716 if (rel->
rd_rel->relreplident == REPLICA_IDENTITY_FULL)
726 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
727 errmsg(
"cannot update table \"%s\" because it does not have a replica identity and publishes updates",
729 errhint(
"To enable updating the table, set REPLICA IDENTITY using ALTER TABLE.")));
732 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
733 errmsg(
"cannot delete from table \"%s\" because it does not have a replica identity and publishes deletes",
735 errhint(
"To enable deleting from the table, set REPLICA IDENTITY using ALTER TABLE.")));
748 if (relkind != RELKIND_RELATION && relkind != RELKIND_PARTITIONED_TABLE)
750 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
751 errmsg(
"cannot use relation \"%s.%s\" as logical replication target",
#define AttributeNumberIsValid(attributeNumber)
#define PG_USED_FOR_ASSERTS_ONLY
#define OidIsValid(objectId)
static void PGresult * res
elog(ERROR, "%s: %s", p2, msg)
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 ExecPartitionCheck(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate, bool emitError)
void ExecConstraints(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate)
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)
void CheckSubscriptionRelkind(char relkind, const char *nspname, const char *relname)
StrategyNumber get_equal_strategy_number_for_am(Oid am)
static bool tuples_equal(TupleTableSlot *slot1, TupleTableSlot *slot2, TypeCacheEntry **eq)
static StrategyNumber get_equal_strategy_number(Oid opclass)
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)
static int build_replindex_scan_key(ScanKey skey, Relation rel, Relation idxrel, TupleTableSlot *searchslot)
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
bool index_getnext_slot(IndexScanDesc scan, ScanDirection direction, TupleTableSlot *slot)
void index_close(Relation relation, LOCKMODE lockmode)
IndexScanDesc index_beginscan(Relation heapRelation, Relation indexRelation, Snapshot snapshot, int nkeys, int norderbys)
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)
Assert(fmt[strlen(fmt) - 1] !='\n')
void list_free(List *list)
void XactLockTableWait(TransactionId xid, Relation rel, ItemPointer ctid, XLTW_Oper oper)
Oid get_opclass_method(Oid opclass)
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 * palloc0(Size size)
void ExecComputeStoredGenerated(ResultRelInfo *resultRelInfo, EState *estate, TupleTableSlot *slot, CmdType cmdtype)
FormData_pg_attribute * Form_pg_attribute
int errdetail_relkind_not_supported(char relkind)
#define ERRCODE_T_R_SERIALIZATION_FAILURE
static bool DatumGetBool(Datum X)
static Pointer DatumGetPointer(Datum X)
#define RelationGetDescr(relation)
#define RelationGetRelationName(relation)
#define IndexRelationGetNumberOfKeyAttributes(relation)
void RelationBuildPublicationDesc(Relation relation, PublicationDesc *pubdesc)
Oid RelationGetReplicaIndex(Relation relation)
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
Snapshot GetLatestSnapshot(void)
void PushActiveSnapshot(Snapshot snapshot)
void PopActiveSnapshot(void)
#define InitDirtySnapshot(snapshotdata)
Oid GetRelationIdentityOrPK(Relation rel)
#define HTEqualStrategyNumber
#define BTEqualStrategyNumber
PublicationActions pubactions
bool cols_valid_for_delete
bool cols_valid_for_update
struct HeapTupleData * rd_indextuple
TriggerDesc * ri_TrigDesc
bool trig_delete_before_row
bool trig_update_before_row
bool trig_insert_before_row
bool has_generated_stored
TupleDesc tts_tupleDescriptor
int16 values[FLEXIBLE_ARRAY_MEMBER]
Oid values[FLEXIBLE_ARRAY_MEMBER]
Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup, AttrNumber attributeNumber)
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)
TupleTableSlot * table_slot_create(Relation relation, List **reglist)
static TableScanDesc table_beginscan(Relation rel, Snapshot snapshot, int nkeys, struct ScanKeyData *key)
static void table_endscan(TableScanDesc scan)
static void table_rescan(TableScanDesc scan, struct ScanKeyData *key)
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 bool table_scan_getnextslot(TableScanDesc sscan, ScanDirection direction, TupleTableSlot *slot)
#define TransactionIdIsValid(xid)
bool ExecBRUpdateTriggers(EState *estate, EPQState *epqstate, ResultRelInfo *relinfo, ItemPointer tupleid, HeapTuple fdw_trigtuple, TupleTableSlot *newslot, TM_Result *tmresult, TM_FailureData *tmfd)
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)
void ExecARInsertTriggers(EState *estate, ResultRelInfo *relinfo, TupleTableSlot *slot, List *recheckIndexes, TransitionCaptureState *transition_capture)
bool equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
#define TupleDescAttr(tupdesc, i)
static TupleTableSlot * ExecCopySlot(TupleTableSlot *dstslot, TupleTableSlot *srcslot)
static void slot_getallattrs(TupleTableSlot *slot)
static void ExecMaterializeSlot(TupleTableSlot *slot)
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
#define TYPECACHE_EQ_OPR_FINFO
CommandId GetCurrentCommandId(bool used)