diff options
Diffstat (limited to 'src/backend/executor')
-rw-r--r-- | src/backend/executor/execReplication.c | 7 | ||||
-rw-r--r-- | src/backend/executor/nodeModifyTable.c | 26 |
2 files changed, 32 insertions, 1 deletions
diff --git a/src/backend/executor/execReplication.c b/src/backend/executor/execReplication.c index 43ec111c37b..7b10d7ae3ac 100644 --- a/src/backend/executor/execReplication.c +++ b/src/backend/executor/execReplication.c @@ -19,6 +19,7 @@ #include "access/tableam.h" #include "access/transam.h" #include "access/xact.h" +#include "catalog/catalog.h" #include "commands/trigger.h" #include "executor/executor.h" #include "executor/nodeModifyTable.h" @@ -481,8 +482,12 @@ ExecSimpleRelationUpdate(EState *estate, EPQState *epqstate, Relation rel = resultRelInfo->ri_RelationDesc; ItemPointer tid = &(searchslot->tts_tid); - /* For now we support only tables. */ + /* + * We support only non-system tables, with + * check_publication_add_relation() accountable. + */ Assert(rel->rd_rel->relkind == RELKIND_RELATION); + Assert(!IsCatalogRelation(rel)); CheckCmdReplicaIdentity(rel, CMD_UPDATE); diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c index 1242c1da3f5..d25074181f9 100644 --- a/src/backend/executor/nodeModifyTable.c +++ b/src/backend/executor/nodeModifyTable.c @@ -1282,6 +1282,7 @@ ExecUpdate(ModifyTableState *mtstate, } else { + ItemPointerData lockedtid PG_USED_FOR_ASSERTS_ONLY; LockTupleMode lockmode; bool partition_constraint_failed; bool update_indexes; @@ -1473,6 +1474,26 @@ lreplace: ExecConstraints(resultRelInfo, slot, estate); /* + * We lack the infrastructure to follow rules in README.tuplock + * section "Locking to write inplace-updated tables". Specifically, + * we lack infrastructure to lock tupleid before this file's + * ExecProcNode() call fetches the tuple's old columns. Just take a + * lock that silences check_lock_if_inplace_updateable_rel(). This + * doesn't actually protect inplace updates like those rules intend, + * so we may lose an inplace update that overlaps a superuser running + * "UPDATE pg_class" or "UPDATE pg_database". + */ +#ifdef USE_ASSERT_CHECKING + if (IsInplaceUpdateRelation(resultRelationDesc)) + { + lockedtid = *tupleid; + LockTuple(resultRelationDesc, &lockedtid, InplaceUpdateTupleLock); + } + else + ItemPointerSetInvalid(&lockedtid); +#endif + + /* * replace the heap tuple * * Note: if es_crosscheck_snapshot isn't InvalidSnapshot, we check @@ -1488,6 +1509,11 @@ lreplace: true /* wait for commit */ , &tmfd, &lockmode, &update_indexes); +#ifdef USE_ASSERT_CHECKING + if (ItemPointerIsValid(&lockedtid)) + UnlockTuple(resultRelationDesc, &lockedtid, InplaceUpdateTupleLock); +#endif + switch (result) { case TM_SelfModified: |