From 56fadbedbd2f697400b89e7b767cfa4ec67932d6 Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Wed, 20 Feb 2019 12:31:07 +0900 Subject: [PATCH] Mark correctly initial slot snapshots with MVCC type when built MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When building an initial slot snapshot, snapshots are marked with historic MVCC snapshots as type with the marker field being set in SnapBuildBuildSnapshot() but not overriden in SnapBuildInitialSnapshot(). Existing callers of SnapBuildBuildSnapshot() do not care about the type of snapshot used, but extensions calling it actually may, as reported. While on it, mark correctly the snapshot type when importing one. This is cosmetic as the field is enforced to 0. Author: Antonin Houska Reviewed-by: Álvaro Herrera, Michael Paquier Discussion: https://postgr.es/m/23215.1527665193@localhost Backpatch-through: 9.4 --- src/backend/replication/logical/snapbuild.c | 2 ++ src/backend/utils/time/snapmgr.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c index ad44b2bf43..a59896f082 100644 --- a/src/backend/replication/logical/snapbuild.c +++ b/src/backend/replication/logical/snapbuild.c @@ -616,6 +616,8 @@ SnapBuildInitialSnapshot(SnapBuild *builder) TransactionIdAdvance(xid); } + /* adjust remaining snapshot fields as needed */ + snap->snapshot_type = SNAPSHOT_MVCC; snap->xcnt = newxcnt; snap->xip = newxip; diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c index 6e02585e10..3b442935bb 100644 --- a/src/backend/utils/time/snapmgr.c +++ b/src/backend/utils/time/snapmgr.c @@ -1509,6 +1509,8 @@ ImportSnapshot(const char *idstr) src_isolevel = parseIntFromText("iso:", &filebuf, path); src_readonly = parseIntFromText("ro:", &filebuf, path); + snapshot.snapshot_type = SNAPSHOT_MVCC; + snapshot.xmin = parseXidFromText("xmin:", &filebuf, path); snapshot.xmax = parseXidFromText("xmax:", &filebuf, path);