aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/access')
-rw-r--r--src/backend/access/heap/heapam_visibility.c9
-rw-r--r--src/backend/access/index/genam.c8
2 files changed, 11 insertions, 6 deletions
diff --git a/src/backend/access/heap/heapam_visibility.c b/src/backend/access/heap/heapam_visibility.c
index e146605bd57..05f6946fe60 100644
--- a/src/backend/access/heap/heapam_visibility.c
+++ b/src/backend/access/heap/heapam_visibility.c
@@ -962,6 +962,15 @@ HeapTupleSatisfiesMVCC(HeapTuple htup, Snapshot snapshot,
{
HeapTupleHeader tuple = htup->t_data;
+ /*
+ * Assert that the caller has registered the snapshot. This function
+ * doesn't care about the registration as such, but in general you
+ * shouldn't try to use a snapshot without registration because it might
+ * get invalidated while it's still in use, and this is a convenient place
+ * to check for that.
+ */
+ Assert(snapshot->regd_count > 0 || snapshot->active_count > 0);
+
Assert(ItemPointerIsValid(&htup->t_self));
Assert(htup->t_tableOid != InvalidOid);
diff --git a/src/backend/access/index/genam.c b/src/backend/access/index/genam.c
index 886c05655f4..8f532e14590 100644
--- a/src/backend/access/index/genam.c
+++ b/src/backend/access/index/genam.c
@@ -577,17 +577,13 @@ systable_recheck_tuple(SysScanDesc sysscan, HeapTuple tup)
Assert(tup == ExecFetchSlotHeapTuple(sysscan->slot, false, NULL));
- /*
- * Trust that table_tuple_satisfies_snapshot() and its subsidiaries
- * (commonly LockBuffer() and HeapTupleSatisfiesMVCC()) do not themselves
- * acquire snapshots, so we need not register the snapshot. Those
- * facilities are too low-level to have any business scanning tables.
- */
freshsnap = GetCatalogSnapshot(RelationGetRelid(sysscan->heap_rel));
+ freshsnap = RegisterSnapshot(freshsnap);
result = table_tuple_satisfies_snapshot(sysscan->heap_rel,
sysscan->slot,
freshsnap);
+ UnregisterSnapshot(freshsnap);
/*
* Handle the concurrent abort while fetching the catalog tuple during