From 8b65cf4c5edabdcae45ceaef7b9ac236879aae50 Mon Sep 17 00:00:00 2001 From: Kevin Grittner Date: Fri, 8 Apr 2016 14:30:10 -0500 Subject: [PATCH] Modify BufferGetPage() to prepare for "snapshot too old" feature This patch is a no-op patch which is intended to reduce the chances of failures of omission once the functional part of the "snapshot too old" patch goes in. It adds parameters for snapshot, relation, and an enum to specify whether the snapshot age check needs to be done for the page at this point. This initial patch passes NULL for the first two new parameters and BGP_NO_SNAPSHOT_TEST for the third. The follow-on patch will change the places where the test needs to be made. --- contrib/bloom/blinsert.c | 3 +- contrib/bloom/blscan.c | 2 +- contrib/bloom/blutils.c | 8 +- contrib/bloom/blvacuum.c | 2 +- contrib/pageinspect/btreefuncs.c | 8 +- contrib/pageinspect/rawpage.c | 4 +- contrib/pg_visibility/pg_visibility.c | 4 +- contrib/pgstattuple/pgstatapprox.c | 2 +- contrib/pgstattuple/pgstatindex.c | 6 +- contrib/pgstattuple/pgstattuple.c | 12 ++- src/backend/access/brin/brin.c | 15 ++- src/backend/access/brin/brin_pageops.c | 52 +++++++---- src/backend/access/brin/brin_revmap.c | 18 ++-- src/backend/access/brin/brin_xlog.c | 16 ++-- src/backend/access/gin/ginbtree.c | 68 +++++++++----- src/backend/access/gin/gindatapage.c | 18 ++-- src/backend/access/gin/ginentrypage.c | 18 ++-- src/backend/access/gin/ginfast.c | 22 ++--- src/backend/access/gin/ginget.c | 58 +++++++----- src/backend/access/gin/gininsert.c | 6 +- src/backend/access/gin/ginutil.c | 12 ++- src/backend/access/gin/ginvacuum.c | 29 +++--- src/backend/access/gin/ginxlog.c | 34 +++---- src/backend/access/gist/gist.c | 48 ++++++---- src/backend/access/gist/gistbuild.c | 14 +-- src/backend/access/gist/gistget.c | 4 +- src/backend/access/gist/gistutil.c | 6 +- src/backend/access/gist/gistvacuum.c | 6 +- src/backend/access/gist/gistxlog.c | 8 +- src/backend/access/hash/hash.c | 16 ++-- src/backend/access/hash/hashinsert.c | 11 ++- src/backend/access/hash/hashovfl.c | 30 +++--- src/backend/access/hash/hashpage.c | 21 +++-- src/backend/access/hash/hashsearch.c | 17 ++-- src/backend/access/hash/hashutil.c | 2 +- src/backend/access/heap/heapam.c | 108 +++++++++++++--------- src/backend/access/heap/hio.c | 27 ++++-- src/backend/access/heap/pruneheap.c | 12 ++- src/backend/access/heap/visibilitymap.c | 21 +++-- src/backend/access/nbtree/nbtinsert.c | 47 +++++----- src/backend/access/nbtree/nbtpage.c | 78 ++++++++-------- src/backend/access/nbtree/nbtree.c | 2 +- src/backend/access/nbtree/nbtsearch.c | 44 +++++---- src/backend/access/nbtree/nbtutils.c | 4 +- src/backend/access/nbtree/nbtxlog.c | 37 ++++---- src/backend/access/spgist/spgdoinsert.c | 39 +++++--- src/backend/access/spgist/spginsert.c | 12 ++- src/backend/access/spgist/spgscan.c | 9 +- src/backend/access/spgist/spgutils.c | 19 ++-- src/backend/access/spgist/spgvacuum.c | 13 ++- src/backend/access/spgist/spgxlog.c | 50 +++++----- src/backend/access/transam/generic_xlog.c | 20 ++-- src/backend/access/transam/xloginsert.c | 8 +- src/backend/access/transam/xlogutils.c | 8 +- src/backend/catalog/index.c | 4 +- src/backend/commands/analyze.c | 2 +- src/backend/commands/sequence.c | 12 +-- src/backend/commands/trigger.c | 2 +- src/backend/commands/vacuumlazy.c | 12 +-- src/backend/executor/nodeBitmapHeapscan.c | 4 +- src/backend/executor/nodeSamplescan.c | 4 +- src/backend/storage/buffer/bufmgr.c | 4 +- src/backend/storage/freespace/freespace.c | 29 ++++-- src/backend/storage/freespace/fsmpage.c | 2 +- src/include/storage/bufmgr.h | 24 ++++- 65 files changed, 735 insertions(+), 522 deletions(-) diff --git a/contrib/bloom/blinsert.c b/contrib/bloom/blinsert.c index 6eecb12187..cc12808375 100644 --- a/contrib/bloom/blinsert.c +++ b/contrib/bloom/blinsert.c @@ -204,7 +204,8 @@ blinsert(Relation index, Datum *values, bool *isnull, */ metaBuffer = ReadBuffer(index, BLOOM_METAPAGE_BLKNO); LockBuffer(metaBuffer, BUFFER_LOCK_SHARE); - metaData = BloomPageGetMeta(BufferGetPage(metaBuffer)); + metaData = BloomPageGetMeta(BufferGetPage(metaBuffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST)); if (metaData->nEnd > metaData->nStart) { diff --git a/contrib/bloom/blscan.c b/contrib/bloom/blscan.c index ba13783549..ae937f6671 100644 --- a/contrib/bloom/blscan.c +++ b/contrib/bloom/blscan.c @@ -138,7 +138,7 @@ blgetbitmap(IndexScanDesc scan, TIDBitmap *tbm) blkno, RBM_NORMAL, bas); LockBuffer(buffer, BUFFER_LOCK_SHARE); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (!BloomPageIsDeleted(page)) { diff --git a/contrib/bloom/blutils.c b/contrib/bloom/blutils.c index 76d6ba8022..6c7dc1d07d 100644 --- a/contrib/bloom/blutils.c +++ b/contrib/bloom/blutils.c @@ -139,11 +139,12 @@ initBloomState(BloomState *state, Relation index) buffer = ReadBuffer(index, BLOOM_METAPAGE_BLKNO); LockBuffer(buffer, BUFFER_LOCK_SHARE); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (!BloomPageIsMeta(page)) elog(ERROR, "Relation is not a bloom index"); - meta = BloomPageGetMeta(BufferGetPage(buffer)); + meta = BloomPageGetMeta(BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST)); if (meta->magickNumber != BLOOM_MAGICK_NUMBER) elog(ERROR, "Relation is not a bloom index"); @@ -315,7 +316,8 @@ BloomNewBuffer(Relation index) */ if (ConditionalLockBuffer(buffer)) { - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); if (PageIsNew(page)) return buffer; /* OK to use, if never initialized */ diff --git a/contrib/bloom/blvacuum.c b/contrib/bloom/blvacuum.c index 19c010c252..ee40ebbd97 100644 --- a/contrib/bloom/blvacuum.c +++ b/contrib/bloom/blvacuum.c @@ -194,7 +194,7 @@ blvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats) buffer = ReadBufferExtended(index, MAIN_FORKNUM, blkno, RBM_NORMAL, info->strategy); LockBuffer(buffer, BUFFER_LOCK_SHARE); - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (BloomPageIsDeleted(page)) { diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c index d088ce5719..cdeffe3e01 100644 --- a/contrib/pageinspect/btreefuncs.c +++ b/contrib/pageinspect/btreefuncs.c @@ -90,7 +90,7 @@ typedef struct BTPageStat static void GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat) { - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); PageHeader phdr = (PageHeader) page; OffsetNumber maxoff = PageGetMaxOffsetNumber(page); BTPageOpaque opaque = (BTPageOpaque) PageGetSpecialPointer(page); @@ -317,7 +317,9 @@ bt_page_items(PG_FUNCTION_ARGS) uargs = palloc(sizeof(struct user_args)); uargs->page = palloc(BLCKSZ); - memcpy(uargs->page, BufferGetPage(buffer), BLCKSZ); + memcpy(uargs->page, + BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST), + BLCKSZ); UnlockReleaseBuffer(buffer); relation_close(rel, AccessShareLock); @@ -447,7 +449,7 @@ bt_metap(PG_FUNCTION_ARGS) buffer = ReadBuffer(rel, 0); LockBuffer(buffer, BUFFER_LOCK_SHARE); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); metad = BTPageGetMeta(page); /* Build a tuple descriptor for our result type */ diff --git a/contrib/pageinspect/rawpage.c b/contrib/pageinspect/rawpage.c index 71d0c8d2ca..139419ae1a 100644 --- a/contrib/pageinspect/rawpage.c +++ b/contrib/pageinspect/rawpage.c @@ -147,7 +147,9 @@ get_raw_page_internal(text *relname, ForkNumber forknum, BlockNumber blkno) buf = ReadBufferExtended(rel, forknum, blkno, RBM_NORMAL, NULL); LockBuffer(buf, BUFFER_LOCK_SHARE); - memcpy(raw_page_data, BufferGetPage(buf), BLCKSZ); + memcpy(raw_page_data, + BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST), + BLCKSZ); LockBuffer(buf, BUFFER_LOCK_UNLOCK); ReleaseBuffer(buf); diff --git a/contrib/pg_visibility/pg_visibility.c b/contrib/pg_visibility/pg_visibility.c index 5e5c7cce24..4a626c2364 100644 --- a/contrib/pg_visibility/pg_visibility.c +++ b/contrib/pg_visibility/pg_visibility.c @@ -107,7 +107,7 @@ pg_visibility(PG_FUNCTION_ARGS) buffer = ReadBuffer(rel, blkno); LockBuffer(buffer, BUFFER_LOCK_SHARE); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); values[2] = BoolGetDatum(PageIsAllVisible(page)); UnlockReleaseBuffer(buffer); @@ -333,7 +333,7 @@ collect_visibility_data(Oid relid, bool include_pd) bstrategy); LockBuffer(buffer, BUFFER_LOCK_SHARE); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (PageIsAllVisible(page)) info->bits[blkno] |= (1 << 2); diff --git a/contrib/pgstattuple/pgstatapprox.c b/contrib/pgstattuple/pgstatapprox.c index a49ff543d2..b7734fac88 100644 --- a/contrib/pgstattuple/pgstatapprox.c +++ b/contrib/pgstattuple/pgstatapprox.c @@ -100,7 +100,7 @@ statapprox_heap(Relation rel, output_type *stat) LockBuffer(buf, BUFFER_LOCK_SHARE); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* * It's not safe to call PageGetHeapFreeSpace() on new pages, so we diff --git a/contrib/pgstattuple/pgstatindex.c b/contrib/pgstattuple/pgstatindex.c index 9f1377c4cd..4596632c09 100644 --- a/contrib/pgstattuple/pgstatindex.c +++ b/contrib/pgstattuple/pgstatindex.c @@ -173,7 +173,7 @@ pgstatindex_impl(Relation rel, FunctionCallInfo fcinfo) */ { Buffer buffer = ReadBufferExtended(rel, MAIN_FORKNUM, 0, RBM_NORMAL, bstrategy); - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); BTMetaPageData *metad = BTPageGetMeta(page); indexStat.version = metad->btm_version; @@ -211,7 +211,7 @@ pgstatindex_impl(Relation rel, FunctionCallInfo fcinfo) buffer = ReadBufferExtended(rel, MAIN_FORKNUM, blkno, RBM_NORMAL, bstrategy); LockBuffer(buffer, BUFFER_LOCK_SHARE); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); /* Determine page type, and update totals */ @@ -399,7 +399,7 @@ pgstatginindex(PG_FUNCTION_ARGS) */ buffer = ReadBuffer(rel, GIN_METAPAGE_BLKNO); LockBuffer(buffer, GIN_SHARE); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); metadata = GinPageGetMeta(page); stats.version = metadata->ginVersion; diff --git a/contrib/pgstattuple/pgstattuple.c b/contrib/pgstattuple/pgstattuple.c index c1122b496a..46655ac01c 100644 --- a/contrib/pgstattuple/pgstattuple.c +++ b/contrib/pgstattuple/pgstattuple.c @@ -320,7 +320,8 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo) buffer = ReadBufferExtended(rel, MAIN_FORKNUM, block, RBM_NORMAL, scan->rs_strategy); LockBuffer(buffer, BUFFER_LOCK_SHARE); - stat.free_space += PageGetHeapFreeSpace((Page) BufferGetPage(buffer)); + stat.free_space += PageGetHeapFreeSpace + (BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST)); UnlockReleaseBuffer(buffer); block++; } @@ -333,7 +334,8 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo) buffer = ReadBufferExtended(rel, MAIN_FORKNUM, block, RBM_NORMAL, scan->rs_strategy); LockBuffer(buffer, BUFFER_LOCK_SHARE); - stat.free_space += PageGetHeapFreeSpace((Page) BufferGetPage(buffer)); + stat.free_space += PageGetHeapFreeSpace + (BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST)); UnlockReleaseBuffer(buffer); block++; } @@ -358,7 +360,7 @@ pgstat_btree_page(pgstattuple_type *stat, Relation rel, BlockNumber blkno, buf = ReadBufferExtended(rel, MAIN_FORKNUM, blkno, RBM_NORMAL, bstrategy); LockBuffer(buf, BT_READ); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* Page is valid, see what to do with it */ if (PageIsNew(page)) @@ -402,7 +404,7 @@ pgstat_hash_page(pgstattuple_type *stat, Relation rel, BlockNumber blkno, _hash_getlock(rel, blkno, HASH_SHARE); buf = _hash_getbuf_with_strategy(rel, blkno, HASH_READ, 0, bstrategy); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (PageGetSpecialSize(page) == MAXALIGN(sizeof(HashPageOpaqueData))) { @@ -447,7 +449,7 @@ pgstat_gist_page(pgstattuple_type *stat, Relation rel, BlockNumber blkno, buf = ReadBufferExtended(rel, MAIN_FORKNUM, blkno, RBM_NORMAL, bstrategy); LockBuffer(buf, GIST_SHARE); gistcheckpage(rel, buf); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (GistPageIsLeaf(page)) { diff --git a/src/backend/access/brin/brin.c b/src/backend/access/brin/brin.c index c740952923..6f6f1b1b41 100644 --- a/src/backend/access/brin/brin.c +++ b/src/backend/access/brin/brin.c @@ -208,7 +208,8 @@ brininsert(Relation idxRel, Datum *values, bool *nulls, } else { - Page page = BufferGetPage(buf); + Page page = BufferGetPage(buf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); ItemId lp = PageGetItemId(page, off); Size origsz; BrinTuple *origtup; @@ -617,7 +618,8 @@ brinbuild(Relation heap, Relation index, IndexInfo *indexInfo) Assert(BufferGetBlockNumber(meta) == BRIN_METAPAGE_BLKNO); LockBuffer(meta, BUFFER_LOCK_EXCLUSIVE); - brin_metapage_init(BufferGetPage(meta), BrinGetPagesPerRange(index), + brin_metapage_init(BufferGetPage(meta, NULL, NULL, BGP_NO_SNAPSHOT_TEST), + BrinGetPagesPerRange(index), BRIN_CURRENT_VERSION); MarkBufferDirty(meta); @@ -636,7 +638,7 @@ brinbuild(Relation heap, Relation index, IndexInfo *indexInfo) recptr = XLogInsert(RM_BRIN_ID, XLOG_BRIN_CREATE_INDEX); - page = BufferGetPage(meta); + page = BufferGetPage(meta, NULL, NULL, BGP_NO_SNAPSHOT_TEST); PageSetLSN(page, recptr); } @@ -686,7 +688,9 @@ brinbuildempty(Relation index) /* Initialize and xlog metabuffer. */ START_CRIT_SECTION(); - brin_metapage_init(BufferGetPage(metabuf), BrinGetPagesPerRange(index), + brin_metapage_init(BufferGetPage(metabuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), + BrinGetPagesPerRange(index), BRIN_CURRENT_VERSION); MarkBufferDirty(metabuf); log_newpage_buffer(metabuf, false); @@ -941,7 +945,8 @@ terminate_brin_buildstate(BrinBuildState *state) { Page page; - page = BufferGetPage(state->bs_currentInsertBuf); + page = BufferGetPage(state->bs_currentInsertBuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); RecordPageWithFreeSpace(state->bs_irel, BufferGetBlockNumber(state->bs_currentInsertBuf), PageGetFreeSpace(page)); diff --git a/src/backend/access/brin/brin_pageops.c b/src/backend/access/brin/brin_pageops.c index d0ca485caa..a522b0b5dc 100644 --- a/src/backend/access/brin/brin_pageops.c +++ b/src/backend/access/brin/brin_pageops.c @@ -110,7 +110,7 @@ brin_doupdate(Relation idxrel, BlockNumber pagesPerRange, newbuf = InvalidBuffer; extended = false; } - oldpage = BufferGetPage(oldbuf); + oldpage = BufferGetPage(oldbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); oldlp = PageGetItemId(oldpage, oldoff); /* @@ -228,7 +228,8 @@ brin_doupdate(Relation idxrel, BlockNumber pagesPerRange, * Not enough free space on the oldpage. Put the new tuple on the new * page, and update the revmap. */ - Page newpage = BufferGetPage(newbuf); + Page newpage = BufferGetPage(newbuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); Buffer revmapbuf; ItemPointerData newtid; OffsetNumber newoff; @@ -245,7 +246,9 @@ brin_doupdate(Relation idxrel, BlockNumber pagesPerRange, * need to do that here. */ if (extended) - brin_page_init(BufferGetPage(newbuf), BRIN_PAGETYPE_REGULAR); + brin_page_init(BufferGetPage(newbuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), + BRIN_PAGETYPE_REGULAR); PageIndexDeleteNoCompact(oldpage, &oldoff, 1); newoff = PageAddItem(newpage, (Item) newtup, newsz, @@ -298,7 +301,9 @@ brin_doupdate(Relation idxrel, BlockNumber pagesPerRange, PageSetLSN(oldpage, recptr); PageSetLSN(newpage, recptr); - PageSetLSN(BufferGetPage(revmapbuf), recptr); + PageSetLSN(BufferGetPage(revmapbuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), + recptr); } END_CRIT_SECTION(); @@ -326,7 +331,9 @@ brin_can_do_samepage_update(Buffer buffer, Size origsz, Size newsz) { return ((newsz <= origsz) || - PageGetExactFreeSpace(BufferGetPage(buffer)) >= (newsz - origsz)); + PageGetExactFreeSpace(BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST)) + >= (newsz - origsz)); } /* @@ -381,7 +388,9 @@ brin_doinsert(Relation idxrel, BlockNumber pagesPerRange, * it's still a regular page. */ LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE); - if (br_page_get_freespace(BufferGetPage(*buffer)) < itemsz) + if (br_page_get_freespace(BufferGetPage(*buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST)) + < itemsz) { UnlockReleaseBuffer(*buffer); *buffer = InvalidBuffer; @@ -404,13 +413,15 @@ brin_doinsert(Relation idxrel, BlockNumber pagesPerRange, /* Now obtain lock on revmap buffer */ revmapbuf = brinLockRevmapPageForUpdate(revmap, heapBlk); - page = BufferGetPage(*buffer); + page = BufferGetPage(*buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); blk = BufferGetBlockNumber(*buffer); /* Execute the actual insertion */ START_CRIT_SECTION(); if (extended) - brin_page_init(BufferGetPage(*buffer), BRIN_PAGETYPE_REGULAR); + brin_page_init(BufferGetPage(*buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), + BRIN_PAGETYPE_REGULAR); off = PageAddItem(page, (Item) tup, itemsz, InvalidOffsetNumber, false, false); if (off == InvalidOffsetNumber) @@ -447,7 +458,8 @@ brin_doinsert(Relation idxrel, BlockNumber pagesPerRange, recptr = XLogInsert(RM_BRIN_ID, info); PageSetLSN(page, recptr); - PageSetLSN(BufferGetPage(revmapbuf), recptr); + PageSetLSN(BufferGetPage(revmapbuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), recptr); } END_CRIT_SECTION(); @@ -515,7 +527,7 @@ brin_start_evacuating_page(Relation idxRel, Buffer buf) OffsetNumber maxoff; Page page; - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (PageIsNew(page)) return false; @@ -551,7 +563,7 @@ brin_evacuate_page(Relation idxRel, BlockNumber pagesPerRange, OffsetNumber maxoff; Page page; - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); Assert(BrinPageFlags(page) & BRIN_EVACUATE_PAGE); @@ -598,7 +610,7 @@ brin_evacuate_page(Relation idxRel, BlockNumber pagesPerRange, bool brin_page_cleanup(Relation idxrel, Buffer buf) { - Page page = BufferGetPage(buf); + Page page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); Size freespace; /* @@ -627,8 +639,10 @@ brin_page_cleanup(Relation idxrel, Buffer buf) } /* Nothing to be done for non-regular index pages */ - if (BRIN_IS_META_PAGE(BufferGetPage(buf)) || - BRIN_IS_REVMAP_PAGE(BufferGetPage(buf))) + if (BRIN_IS_META_PAGE(BufferGetPage(buf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST)) || + BRIN_IS_REVMAP_PAGE(BufferGetPage(buf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST))) return false; /* Measure free space and record it */ @@ -738,7 +752,8 @@ brin_getinsertbuffer(Relation irel, Buffer oldbuf, Size itemsz, if (BufferIsValid(oldbuf) && oldblk < newblk) { LockBuffer(oldbuf, BUFFER_LOCK_EXCLUSIVE); - if (!BRIN_IS_REGULAR_PAGE(BufferGetPage(oldbuf))) + if (!BRIN_IS_REGULAR_PAGE(BufferGetPage(oldbuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST))) { LockBuffer(oldbuf, BUFFER_LOCK_UNLOCK); @@ -770,7 +785,7 @@ brin_getinsertbuffer(Relation irel, Buffer oldbuf, Size itemsz, if (extensionLockHeld) UnlockRelationForExtension(irel, ExclusiveLock); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* * We have a new buffer to insert into. Check that the new page has @@ -805,7 +820,8 @@ brin_getinsertbuffer(Relation irel, Buffer oldbuf, Size itemsz, if (BufferIsValid(oldbuf) && oldblk > newblk) { LockBuffer(oldbuf, BUFFER_LOCK_EXCLUSIVE); - Assert(BRIN_IS_REGULAR_PAGE(BufferGetPage(oldbuf))); + Assert(BRIN_IS_REGULAR_PAGE(BufferGetPage(oldbuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST))); } return buf; @@ -862,7 +878,7 @@ brin_initialize_empty_new_buffer(Relation idxrel, Buffer buffer) BufferGetBlockNumber(buffer))); START_CRIT_SECTION(); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); brin_page_init(page, BRIN_PAGETYPE_REGULAR); MarkBufferDirty(buffer); log_newpage_buffer(buffer, true); diff --git a/src/backend/access/brin/brin_revmap.c b/src/backend/access/brin/brin_revmap.c index b2c273daf6..ce21cbabb7 100644 --- a/src/backend/access/brin/brin_revmap.c +++ b/src/backend/access/brin/brin_revmap.c @@ -73,10 +73,12 @@ brinRevmapInitialize(Relation idxrel, BlockNumber *pagesPerRange) BrinRevmap *revmap; Buffer meta; BrinMetaPageData *metadata; + Page page; meta = ReadBuffer(idxrel, BRIN_METAPAGE_BLKNO); LockBuffer(meta, BUFFER_LOCK_SHARE); - metadata = (BrinMetaPageData *) PageGetContents(BufferGetPage(meta)); + page = BufferGetPage(meta, NULL, NULL, BGP_NO_SNAPSHOT_TEST); + metadata = (BrinMetaPageData *) PageGetContents(page); revmap = palloc(sizeof(BrinRevmap)); revmap->rm_irel = idxrel; @@ -159,7 +161,7 @@ brinSetHeapBlockItemptr(Buffer buf, BlockNumber pagesPerRange, Page page; /* The correct page should already be pinned and locked */ - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); contents = (RevmapContents *) PageGetContents(page); iptr = (ItemPointerData *) contents->rm_tids; iptr += HEAPBLK_TO_REVMAP_INDEX(pagesPerRange, heapBlk); @@ -226,7 +228,8 @@ brinGetTupleForHeapBlock(BrinRevmap *revmap, BlockNumber heapBlk, LockBuffer(revmap->rm_currBuf, BUFFER_LOCK_SHARE); contents = (RevmapContents *) - PageGetContents(BufferGetPage(revmap->rm_currBuf)); + PageGetContents(BufferGetPage(revmap->rm_currBuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST)); iptr = contents->rm_tids; iptr += HEAPBLK_TO_REVMAP_INDEX(revmap->rm_pagesPerRange, heapBlk); @@ -261,7 +264,7 @@ brinGetTupleForHeapBlock(BrinRevmap *revmap, BlockNumber heapBlk, *buf = ReadBuffer(idxRel, blk); } LockBuffer(*buf, mode); - page = BufferGetPage(*buf); + page = BufferGetPage(*buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* If we land on a revmap page, start over */ if (BRIN_IS_REGULAR_PAGE(page)) @@ -393,7 +396,8 @@ revmap_physical_extend(BrinRevmap *revmap) * another backend can extend the index with regular BRIN pages. */ LockBuffer(revmap->rm_metaBuf, BUFFER_LOCK_EXCLUSIVE); - metapage = BufferGetPage(revmap->rm_metaBuf); + metapage = BufferGetPage(revmap->rm_metaBuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); metadata = (BrinMetaPageData *) PageGetContents(metapage); /* @@ -413,7 +417,7 @@ revmap_physical_extend(BrinRevmap *revmap) { buf = ReadBuffer(irel, mapBlk); LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); } else { @@ -436,7 +440,7 @@ revmap_physical_extend(BrinRevmap *revmap) return; } LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (needLock) UnlockRelationForExtension(irel, ExclusiveLock); diff --git a/src/backend/access/brin/brin_xlog.c b/src/backend/access/brin/brin_xlog.c index deb7af4ca6..36e4a99fc1 100644 --- a/src/backend/access/brin/brin_xlog.c +++ b/src/backend/access/brin/brin_xlog.c @@ -30,7 +30,7 @@ brin_xlog_createidx(XLogReaderState *record) /* create the index' metapage */ buf = XLogInitBufferForRedo(record, 0); Assert(BufferIsValid(buf)); - page = (Page) BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); brin_metapage_init(page, xlrec->pagesPerRange, xlrec->version); PageSetLSN(page, lsn); MarkBufferDirty(buf); @@ -58,7 +58,7 @@ brin_xlog_insert_update(XLogReaderState *record, if (XLogRecGetInfo(record) & XLOG_BRIN_INIT_PAGE) { buffer = XLogInitBufferForRedo(record, 0); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); brin_page_init(page, BRIN_PAGETYPE_REGULAR); action = BLK_NEEDS_REDO; } @@ -81,7 +81,7 @@ brin_xlog_insert_update(XLogReaderState *record, Assert(tuple->bt_blkno == xlrec->heapBlk); - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); offnum = xlrec->offnum; if (PageGetMaxOffsetNumber(page) + 1 < offnum) elog(PANIC, "brin_xlog_insert_update: invalid max offset number"); @@ -103,7 +103,7 @@ brin_xlog_insert_update(XLogReaderState *record, ItemPointerData tid; ItemPointerSet(&tid, regpgno, xlrec->offnum); - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); brinSetHeapBlockItemptr(buffer, xlrec->pagesPerRange, xlrec->heapBlk, tid); @@ -145,7 +145,7 @@ brin_xlog_update(XLogReaderState *record) Page page; OffsetNumber offnum; - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); offnum = xlrec->oldOffnum; if (PageGetMaxOffsetNumber(page) + 1 < offnum) @@ -186,7 +186,7 @@ brin_xlog_samepage_update(XLogReaderState *record) brintuple = (BrinTuple *) XLogRecGetBlockData(record, 0, &tuplen); - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); offnum = xlrec->offnum; if (PageGetMaxOffsetNumber(page) + 1 < offnum) @@ -232,7 +232,7 @@ brin_xlog_revmap_extend(XLogReaderState *record) Page metapg; BrinMetaPageData *metadata; - metapg = BufferGetPage(metabuf); + metapg = BufferGetPage(metabuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); metadata = (BrinMetaPageData *) PageGetContents(metapg); Assert(metadata->lastRevmapPage == xlrec->targetBlk - 1); @@ -248,7 +248,7 @@ brin_xlog_revmap_extend(XLogReaderState *record) */ buf = XLogInitBufferForRedo(record, 1); - page = (Page) BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); brin_page_init(page, BRIN_PAGETYPE_REVMAP); PageSetLSN(page, lsn); diff --git a/src/backend/access/gin/ginbtree.c b/src/backend/access/gin/ginbtree.c index 06ba9cb957..13258cca0e 100644 --- a/src/backend/access/gin/ginbtree.c +++ b/src/backend/access/gin/ginbtree.c @@ -36,7 +36,7 @@ ginTraverseLock(Buffer buffer, bool searchMode) int access = GIN_SHARE; LockBuffer(buffer, GIN_SHARE); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (GinPageIsLeaf(page)) { if (searchMode == FALSE) @@ -89,7 +89,7 @@ ginFindLeafPage(GinBtree btree, bool searchMode) stack->off = InvalidOffsetNumber; - page = BufferGetPage(stack->buffer); + page = BufferGetPage(stack->buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); access = ginTraverseLock(stack->buffer, searchMode); @@ -115,7 +115,8 @@ ginFindLeafPage(GinBtree btree, bool searchMode) stack->buffer = ginStepRight(stack->buffer, btree->index, access); stack->blkno = rightlink; - page = BufferGetPage(stack->buffer); + page = BufferGetPage(stack->buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); if (!searchMode && GinPageIsIncompleteSplit(page)) ginFinishSplit(btree, stack, false, NULL); @@ -161,7 +162,7 @@ Buffer ginStepRight(Buffer buffer, Relation index, int lockmode) { Buffer nextbuffer; - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); bool isLeaf = GinPageIsLeaf(page); bool isData = GinPageIsData(page); BlockNumber blkno = GinPageGetOpaque(page)->rightlink; @@ -171,7 +172,7 @@ ginStepRight(Buffer buffer, Relation index, int lockmode) UnlockReleaseBuffer(buffer); /* Sanity check that the page we stepped to is of similar kind. */ - page = BufferGetPage(nextbuffer); + page = BufferGetPage(nextbuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (isLeaf != GinPageIsLeaf(page) || isData != GinPageIsData(page)) elog(ERROR, "right sibling of GIN page is of different type"); @@ -243,7 +244,7 @@ ginFindParents(GinBtree btree, GinBtreeStack *stack) for (;;) { LockBuffer(buffer, GIN_EXCLUSIVE); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (GinPageIsLeaf(page)) elog(ERROR, "Lost path"); @@ -274,7 +275,7 @@ ginFindParents(GinBtree btree, GinBtreeStack *stack) break; } buffer = ginStepRight(buffer, btree->index, GIN_EXCLUSIVE); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* finish any incomplete splits, as above */ if (GinPageIsIncompleteSplit(page)) @@ -325,7 +326,8 @@ ginPlaceToPage(GinBtree btree, GinBtreeStack *stack, void *insertdata, BlockNumber updateblkno, Buffer childbuf, GinStatsData *buildStats) { - Page page = BufferGetPage(stack->buffer); + Page page = BufferGetPage(stack->buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); GinPlaceToPageRC rc; uint16 xlflags = 0; Page childpage = NULL; @@ -344,7 +346,7 @@ ginPlaceToPage(GinBtree btree, GinBtreeStack *stack, { Assert(BufferIsValid(childbuf)); Assert(updateblkno != InvalidBlockNumber); - childpage = BufferGetPage(childbuf); + childpage = BufferGetPage(childbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); } /* @@ -456,7 +458,8 @@ ginPlaceToPage(GinBtree btree, GinBtreeStack *stack, data.flags = xlflags; if (childbuf != InvalidBuffer) { - Page childpage = BufferGetPage(childbuf); + Page childpage = BufferGetPage(childbuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); GinPageGetOpaque(childpage)->flags &= ~GIN_INCOMPLETE_SPLIT; @@ -538,14 +541,21 @@ ginPlaceToPage(GinBtree btree, GinBtreeStack *stack, if (stack->parent == NULL) { MarkBufferDirty(lbuffer); - memcpy(BufferGetPage(stack->buffer), newrootpg, BLCKSZ); - memcpy(BufferGetPage(lbuffer), newlpage, BLCKSZ); - memcpy(BufferGetPage(rbuffer), newrpage, BLCKSZ); + memcpy(BufferGetPage(stack->buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), + newrootpg, BLCKSZ); + memcpy(BufferGetPage(lbuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST), + newlpage, BLCKSZ); + memcpy(BufferGetPage(rbuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST), + newrpage, BLCKSZ); } else { - memcpy(BufferGetPage(stack->buffer), newlpage, BLCKSZ); - memcpy(BufferGetPage(rbuffer), newrpage, BLCKSZ); + memcpy(BufferGetPage(stack->buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), + newlpage, BLCKSZ); + memcpy(BufferGetPage(rbuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST), + newrpage, BLCKSZ); } /* write WAL record */ @@ -577,10 +587,16 @@ ginPlaceToPage(GinBtree btree, GinBtreeStack *stack, XLogRegisterData((char *) &data, sizeof(ginxlogSplit)); recptr = XLogInsert(RM_GIN_ID, XLOG_GIN_SPLIT); - PageSetLSN(BufferGetPage(stack->buffer), recptr); - PageSetLSN(BufferGetPage(rbuffer), recptr); + PageSetLSN(BufferGetPage(stack->buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), + recptr); + PageSetLSN(BufferGetPage(rbuffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), + recptr); if (stack->parent == NULL) - PageSetLSN(BufferGetPage(lbuffer), recptr); + PageSetLSN(BufferGetPage(lbuffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), + recptr); if (BufferIsValid(childbuf)) PageSetLSN(childpage, recptr); } @@ -662,11 +678,12 @@ ginFinishSplit(GinBtree btree, GinBtreeStack *stack, bool freestack, * page that has no downlink in the parent, and splitting it further * would fail. */ - if (GinPageIsIncompleteSplit(BufferGetPage(parent->buffer))) + if (GinPageIsIncompleteSplit(BufferGetPage(parent->buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST))) ginFinishSplit(btree, parent, false, buildStats); /* move right if it's needed */ - page = BufferGetPage(parent->buffer); + page = BufferGetPage(parent->buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); while ((parent->off = btree->findChildPtr(btree, page, stack->blkno, parent->off)) == InvalidOffsetNumber) { if (GinPageRightMost(page)) @@ -684,15 +701,17 @@ ginFinishSplit(GinBtree btree, GinBtreeStack *stack, bool freestack, parent->buffer = ginStepRight(parent->buffer, btree->index, GIN_EXCLUSIVE); parent->blkno = BufferGetBlockNumber(parent->buffer); - page = BufferGetPage(parent->buffer); + page = BufferGetPage(parent->buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); - if (GinPageIsIncompleteSplit(BufferGetPage(parent->buffer))) + if (GinPageIsIncompleteSplit(BufferGetPage(parent->buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST))) ginFinishSplit(btree, parent, false, buildStats); } /* insert the downlink */ insertdata = btree->prepareDownlink(btree, stack->buffer); - updateblkno = GinPageGetOpaque(BufferGetPage(stack->buffer))->rightlink; + updateblkno = GinPageGetOpaque(BufferGetPage(stack->buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST))->rightlink; done = ginPlaceToPage(btree, parent, insertdata, updateblkno, stack->buffer, buildStats); @@ -742,7 +761,8 @@ ginInsertValue(GinBtree btree, GinBtreeStack *stack, void *insertdata, bool done; /* If the leaf page was incompletely split, finish the split first */ - if (GinPageIsIncompleteSplit(BufferGetPage(stack->buffer))) + if (GinPageIsIncompleteSplit(BufferGetPage(stack->buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST))) ginFinishSplit(btree, stack, false, buildStats); done = ginPlaceToPage(btree, stack, diff --git a/src/backend/access/gin/gindatapage.c b/src/backend/access/gin/gindatapage.c index a55bb4a45d..9c501a1af5 100644 --- a/src/backend/access/gin/gindatapage.c +++ b/src/backend/access/gin/gindatapage.c @@ -246,7 +246,7 @@ dataLocateItem(GinBtree btree, GinBtreeStack *stack) maxoff; PostingItem *pitem = NULL; int result; - Page page = BufferGetPage(stack->buffer); + Page page = BufferGetPage(stack->buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); Assert(!GinPageIsLeaf(page)); Assert(GinPageIsData(page)); @@ -432,7 +432,7 @@ dataPlaceToPageLeaf(GinBtree btree, Buffer buf, GinBtreeStack *stack, GinBtreeDataLeafInsertData *items = insertdata; ItemPointer newItems = &items->items[items->curitem]; int maxitems = items->nitem - items->curitem; - Page page = BufferGetPage(buf); + Page page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); int i; ItemPointerData rbound; ItemPointerData lbound; @@ -714,7 +714,7 @@ dataPlaceToPageLeaf(GinBtree btree, Buffer buf, GinBtreeStack *stack, void ginVacuumPostingTreeLeaf(Relation indexrel, Buffer buffer, GinVacuumState *gvs) { - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); disassembledLeaf *leaf; bool removedsomething = false; dlist_iter iter; @@ -953,7 +953,7 @@ registerLeafRecompressWALData(Buffer buf, disassembledLeaf *leaf) static void dataPlaceToPageLeafRecompress(Buffer buf, disassembledLeaf *leaf) { - Page page = BufferGetPage(buf); + Page page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); char *ptr; int newsize; bool modified = false; @@ -1091,7 +1091,7 @@ dataPlaceToPageInternal(GinBtree btree, Buffer buf, GinBtreeStack *stack, void *insertdata, BlockNumber updateblkno, Page *newlpage, Page *newrpage) { - Page page = BufferGetPage(buf); + Page page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); OffsetNumber off = stack->off; PostingItem *pitem; @@ -1141,7 +1141,7 @@ dataPlaceToPage(GinBtree btree, Buffer buf, GinBtreeStack *stack, void *insertdata, BlockNumber updateblkno, Page *newlpage, Page *newrpage) { - Page page = BufferGetPage(buf); + Page page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); Assert(GinPageIsData(page)); @@ -1164,7 +1164,7 @@ dataSplitPageInternal(GinBtree btree, Buffer origbuf, void *insertdata, BlockNumber updateblkno, Page *newlpage, Page *newrpage) { - Page oldpage = BufferGetPage(origbuf); + Page oldpage = BufferGetPage(origbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); OffsetNumber off = stack->off; int nitems = GinPageGetOpaque(oldpage)->maxoff; int nleftitems; @@ -1242,7 +1242,7 @@ static void * dataPrepareDownlink(GinBtree btree, Buffer lbuf) { PostingItem *pitem = palloc(sizeof(PostingItem)); - Page lpage = BufferGetPage(lbuf); + Page lpage = BufferGetPage(lbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); PostingItemSetBlockNumber(pitem, BufferGetBlockNumber(lbuf)); pitem->key = *GinDataPageGetRightBound(lpage); @@ -1726,7 +1726,7 @@ createPostingTree(Relation index, ItemPointerData *items, uint32 nitems, * All set. Get a new physical page, and copy the in-memory page to it. */ buffer = GinNewBuffer(index); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); blkno = BufferGetBlockNumber(buffer); START_CRIT_SECTION(); diff --git a/src/backend/access/gin/ginentrypage.c b/src/backend/access/gin/ginentrypage.c index 2512745648..8a5d9e1727 100644 --- a/src/backend/access/gin/ginentrypage.c +++ b/src/backend/access/gin/ginentrypage.c @@ -274,7 +274,8 @@ entryLocateEntry(GinBtree btree, GinBtreeStack *stack) maxoff; IndexTuple itup = NULL; int result; - Page page = BufferGetPage(stack->buffer); + Page page = BufferGetPage(stack->buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); Assert(!GinPageIsLeaf(page)); Assert(!GinPageIsData(page)); @@ -345,7 +346,8 @@ entryLocateEntry(GinBtree btree, GinBtreeStack *stack) static bool entryLocateLeafEntry(GinBtree btree, GinBtreeStack *stack) { - Page page = BufferGetPage(stack->buffer); + Page page = BufferGetPage(stack->buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); OffsetNumber low, high; @@ -461,7 +463,7 @@ entryIsEnoughSpace(GinBtree btree, Buffer buf, OffsetNumber off, { Size releasedsz = 0; Size addedsz; - Page page = BufferGetPage(buf); + Page page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); Assert(insertData->entry); Assert(!GinPageIsData(page)); @@ -525,7 +527,7 @@ entryPlaceToPage(GinBtree btree, Buffer buf, GinBtreeStack *stack, Page *newlpage, Page *newrpage) { GinBtreeEntryInsertData *insertData = insertPayload; - Page page = BufferGetPage(buf); + Page page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); OffsetNumber off = stack->off; OffsetNumber placed; @@ -592,8 +594,10 @@ entrySplitPage(GinBtree btree, Buffer origbuf, char *ptr; IndexTuple itup; Page page; - Page lpage = PageGetTempPageCopy(BufferGetPage(origbuf)); - Page rpage = PageGetTempPageCopy(BufferGetPage(origbuf)); + Page lpage = PageGetTempPageCopy(BufferGetPage(origbuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST)); + Page rpage = PageGetTempPageCopy(BufferGetPage(origbuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST)); Size pageSize = PageGetPageSize(lpage); char tupstore[2 * BLCKSZ]; @@ -674,7 +678,7 @@ static void * entryPrepareDownlink(GinBtree btree, Buffer lbuf) { GinBtreeEntryInsertData *insertData; - Page lpage = BufferGetPage(lbuf); + Page lpage = BufferGetPage(lbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); BlockNumber lblkno = BufferGetBlockNumber(lbuf); IndexTuple itup; diff --git a/src/backend/access/gin/ginfast.c b/src/backend/access/gin/ginfast.c index 2ddf5680f6..08ec16f126 100644 --- a/src/backend/access/gin/ginfast.c +++ b/src/backend/access/gin/ginfast.c @@ -53,7 +53,7 @@ static int32 writeListPage(Relation index, Buffer buffer, IndexTuple *tuples, int32 ntuples, BlockNumber rightlink) { - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); int32 i, freesize, size = 0; @@ -239,7 +239,7 @@ ginHeapTupleFastInsert(GinState *ginstate, GinTupleCollector *collector) data.newRightlink = data.prevTail = InvalidBlockNumber; metabuffer = ReadBuffer(index, GIN_METAPAGE_BLKNO); - metapage = BufferGetPage(metabuffer); + metapage = BufferGetPage(metabuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (collector->sumsize + collector->ntuples * sizeof(ItemIdData) > GinListPageSize) { @@ -310,7 +310,7 @@ ginHeapTupleFastInsert(GinState *ginstate, GinTupleCollector *collector) buffer = ReadBuffer(index, metadata->tail); LockBuffer(buffer, GIN_EXCLUSIVE); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); Assert(GinPageGetOpaque(page)->rightlink == InvalidBlockNumber); @@ -344,7 +344,7 @@ ginHeapTupleFastInsert(GinState *ginstate, GinTupleCollector *collector) buffer = ReadBuffer(index, metadata->tail); LockBuffer(buffer, GIN_EXCLUSIVE); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); off = (PageIsEmpty(page)) ? FirstOffsetNumber : OffsetNumberNext(PageGetMaxOffsetNumber(page)); @@ -514,7 +514,7 @@ shiftList(Relation index, Buffer metabuffer, BlockNumber newHead, GinMetaPageData *metadata; BlockNumber blknoToDelete; - metapage = BufferGetPage(metabuffer); + metapage = BufferGetPage(metabuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); metadata = GinPageGetMeta(metapage); blknoToDelete = metadata->head; @@ -533,7 +533,7 @@ shiftList(Relation index, Buffer metabuffer, BlockNumber newHead, freespace[data.ndeleted] = blknoToDelete; buffers[data.ndeleted] = ReadBuffer(index, blknoToDelete); LockBuffer(buffers[data.ndeleted], GIN_EXCLUSIVE); - page = BufferGetPage(buffers[data.ndeleted]); + page = BufferGetPage(buffers[data.ndeleted], NULL, NULL, BGP_NO_SNAPSHOT_TEST); data.ndeleted++; @@ -582,7 +582,7 @@ shiftList(Relation index, Buffer metabuffer, BlockNumber newHead, for (i = 0; i < data.ndeleted; i++) { - page = BufferGetPage(buffers[i]); + page = BufferGetPage(buffers[i], NULL, NULL, BGP_NO_SNAPSHOT_TEST); GinPageGetOpaque(page)->flags = GIN_DELETED; MarkBufferDirty(buffers[i]); } @@ -606,7 +606,7 @@ shiftList(Relation index, Buffer metabuffer, BlockNumber newHead, for (i = 0; i < data.ndeleted; i++) { - page = BufferGetPage(buffers[i]); + page = BufferGetPage(buffers[i], NULL, NULL, BGP_NO_SNAPSHOT_TEST); PageSetLSN(page, recptr); } } @@ -760,7 +760,7 @@ ginInsertCleanup(GinState *ginstate, metabuffer = ReadBuffer(index, GIN_METAPAGE_BLKNO); LockBuffer(metabuffer, GIN_SHARE); - metapage = BufferGetPage(metabuffer); + metapage = BufferGetPage(metabuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); metadata = GinPageGetMeta(metapage); if (metadata->head == InvalidBlockNumber) @@ -776,7 +776,7 @@ ginInsertCleanup(GinState *ginstate, blkno = metadata->head; buffer = ReadBuffer(index, blkno); LockBuffer(buffer, GIN_SHARE); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); LockBuffer(metabuffer, GIN_UNLOCK); @@ -943,7 +943,7 @@ ginInsertCleanup(GinState *ginstate, vacuum_delay_point(); buffer = ReadBuffer(index, blkno); LockBuffer(buffer, GIN_SHARE); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); } ReleaseBuffer(metabuffer); diff --git a/src/backend/access/gin/ginget.c b/src/backend/access/gin/ginget.c index 53290a4279..33683278e1 100644 --- a/src/backend/access/gin/ginget.c +++ b/src/backend/access/gin/ginget.c @@ -19,6 +19,7 @@ #include "miscadmin.h" #include "utils/datum.h" #include "utils/memutils.h" +#include "utils/rel.h" /* GUC parameter */ int GinFuzzySearchLimit = 0; @@ -39,7 +40,8 @@ typedef struct pendingPosition static bool moveRightIfItNeeded(GinBtreeData *btree, GinBtreeStack *stack) { - Page page = BufferGetPage(stack->buffer); + Page page = BufferGetPage(stack->buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); if (stack->off > PageGetMaxOffsetNumber(page)) { @@ -63,7 +65,7 @@ moveRightIfItNeeded(GinBtreeData *btree, GinBtreeStack *stack) */ static void scanPostingTree(Relation index, GinScanEntry scanEntry, - BlockNumber rootPostingTree) + BlockNumber rootPostingTree, Snapshot snapshot) { GinBtreeData btree; GinBtreeStack *stack; @@ -82,7 +84,7 @@ scanPostingTree(Relation index, GinScanEntry scanEntry, */ for (;;) { - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if ((GinPageGetOpaque(page)->flags & GIN_DELETED) == 0) { int n = GinDataLeafPageGetItemsToTbm(page, scanEntry->matchBitmap); @@ -114,7 +116,7 @@ scanPostingTree(Relation index, GinScanEntry scanEntry, */ static bool collectMatchBitmap(GinBtreeData *btree, GinBtreeStack *stack, - GinScanEntry scanEntry) + GinScanEntry scanEntry, Snapshot snapshot) { OffsetNumber attnum; Form_pg_attribute attr; @@ -144,7 +146,7 @@ collectMatchBitmap(GinBtreeData *btree, GinBtreeStack *stack, if (moveRightIfItNeeded(btree, stack) == false) return true; - page = BufferGetPage(stack->buffer); + page = BufferGetPage(stack->buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, stack->off)); /* @@ -224,14 +226,14 @@ collectMatchBitmap(GinBtreeData *btree, GinBtreeStack *stack, LockBuffer(stack->buffer, GIN_UNLOCK); /* Collect all the TIDs in this entry's posting tree */ - scanPostingTree(btree->index, scanEntry, rootPostingTree); + scanPostingTree(btree->index, scanEntry, rootPostingTree, snapshot); /* * We lock again the entry page and while it was unlocked insert * might have occurred, so we need to re-find our position. */ LockBuffer(stack->buffer, GIN_SHARE); - page = BufferGetPage(stack->buffer); + page = BufferGetPage(stack->buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (!GinPageIsLeaf(page)) { /* @@ -251,7 +253,7 @@ collectMatchBitmap(GinBtreeData *btree, GinBtreeStack *stack, if (moveRightIfItNeeded(btree, stack) == false) elog(ERROR, "lost saved point in index"); /* must not happen !!! */ - page = BufferGetPage(stack->buffer); + page = BufferGetPage(stack->buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, stack->off)); if (gintuple_get_attrnum(btree->ginstate, itup) != attnum) @@ -291,7 +293,7 @@ collectMatchBitmap(GinBtreeData *btree, GinBtreeStack *stack, * Start* functions setup beginning state of searches: finds correct buffer and pins it. */ static void -startScanEntry(GinState *ginstate, GinScanEntry entry) +startScanEntry(GinState *ginstate, GinScanEntry entry, Snapshot snapshot) { GinBtreeData btreeEntry; GinBtreeStack *stackEntry; @@ -319,7 +321,7 @@ restartScanEntry: entry->queryKey, entry->queryCategory, ginstate); stackEntry = ginFindLeafPage(&btreeEntry, true); - page = BufferGetPage(stackEntry->buffer); + page = BufferGetPage(stackEntry->buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); needUnlock = TRUE; entry->isFinished = TRUE; @@ -335,7 +337,7 @@ restartScanEntry: * for the entry type. */ btreeEntry.findItem(&btreeEntry, stackEntry); - if (collectMatchBitmap(&btreeEntry, stackEntry, entry) == false) + if (!collectMatchBitmap(&btreeEntry, stackEntry, entry, snapshot)) { /* * GIN tree was seriously restructured, so we will cleanup all @@ -393,7 +395,7 @@ restartScanEntry: */ IncrBufferRefCount(entry->buffer); - page = BufferGetPage(entry->buffer); + page = BufferGetPage(entry->buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* * Load the first page into memory. @@ -535,7 +537,7 @@ startScan(IndexScanDesc scan) uint32 i; for (i = 0; i < so->totalentries; i++) - startScanEntry(ginstate, so->entries[i]); + startScanEntry(ginstate, so->entries[i], scan->xs_snapshot); if (GinFuzzySearchLimit > 0) { @@ -580,7 +582,8 @@ startScan(IndexScanDesc scan) * keep it pinned to prevent interference with vacuum. */ static void -entryLoadMoreItems(GinState *ginstate, GinScanEntry entry, ItemPointerData advancePast) +entryLoadMoreItems(GinState *ginstate, GinScanEntry entry, + ItemPointerData advancePast, Snapshot snapshot) { Page page; int i; @@ -638,7 +641,7 @@ entryLoadMoreItems(GinState *ginstate, GinScanEntry entry, ItemPointerData advan GinItemPointerGetOffsetNumber(&advancePast), !stepright); - page = BufferGetPage(entry->buffer); + page = BufferGetPage(entry->buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); for (;;) { entry->offset = InvalidOffsetNumber; @@ -670,7 +673,7 @@ entryLoadMoreItems(GinState *ginstate, GinScanEntry entry, ItemPointerData advan entry->buffer = ginStepRight(entry->buffer, ginstate->index, GIN_SHARE); - page = BufferGetPage(entry->buffer); + page = BufferGetPage(entry->buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); } stepright = true; @@ -734,7 +737,7 @@ entryLoadMoreItems(GinState *ginstate, GinScanEntry entry, ItemPointerData advan */ static void entryGetItem(GinState *ginstate, GinScanEntry entry, - ItemPointerData advancePast) + ItemPointerData advancePast, Snapshot snapshot) { Assert(!entry->isFinished); @@ -857,7 +860,7 @@ entryGetItem(GinState *ginstate, GinScanEntry entry, /* If we've processed the current batch, load more items */ while (entry->offset >= entry->nlist) { - entryLoadMoreItems(ginstate, entry, advancePast); + entryLoadMoreItems(ginstate, entry, advancePast, snapshot); if (entry->isFinished) { @@ -896,7 +899,7 @@ entryGetItem(GinState *ginstate, GinScanEntry entry, */ static void keyGetItem(GinState *ginstate, MemoryContext tempCtx, GinScanKey key, - ItemPointerData advancePast) + ItemPointerData advancePast, Snapshot snapshot) { ItemPointerData minItem; ItemPointerData curPageLossy; @@ -943,7 +946,7 @@ keyGetItem(GinState *ginstate, MemoryContext tempCtx, GinScanKey key, */ if (ginCompareItemPointers(&entry->curItem, &advancePast) <= 0) { - entryGetItem(ginstate, entry, advancePast); + entryGetItem(ginstate, entry, advancePast, snapshot); if (entry->isFinished) continue; } @@ -1001,7 +1004,7 @@ keyGetItem(GinState *ginstate, MemoryContext tempCtx, GinScanKey key, if (ginCompareItemPointers(&entry->curItem, &advancePast) <= 0) { - entryGetItem(ginstate, entry, advancePast); + entryGetItem(ginstate, entry, advancePast, snapshot); if (entry->isFinished) continue; } @@ -1210,7 +1213,8 @@ scanGetItem(IndexScanDesc scan, ItemPointerData advancePast, GinScanKey key = so->keys + i; /* Fetch the next item for this key that is > advancePast. */ - keyGetItem(&so->ginstate, so->tempCtx, key, advancePast); + keyGetItem(&so->ginstate, so->tempCtx, key, advancePast, + scan->xs_snapshot); if (key->isFinished) return false; @@ -1331,7 +1335,8 @@ scanGetCandidate(IndexScanDesc scan, pendingPosition *pos) ItemPointerSetInvalid(&pos->item); for (;;) { - page = BufferGetPage(pos->pendingBuffer); + page = BufferGetPage(pos->pendingBuffer, NULL, + NULL, BGP_NO_SNAPSHOT_TEST); maxoff = PageGetMaxOffsetNumber(page); if (pos->firstOffset > maxoff) @@ -1511,7 +1516,8 @@ collectMatchesForHeapRow(IndexScanDesc scan, pendingPosition *pos) memset(datumExtracted + pos->firstOffset - 1, 0, sizeof(bool) * (pos->lastOffset - pos->firstOffset)); - page = BufferGetPage(pos->pendingBuffer); + page = BufferGetPage(pos->pendingBuffer, NULL, + NULL, BGP_NO_SNAPSHOT_TEST); for (i = 0; i < so->nkeys; i++) { @@ -1698,12 +1704,14 @@ scanPendingInsert(IndexScanDesc scan, TIDBitmap *tbm, int64 *ntids) int i; pendingPosition pos; Buffer metabuffer = ReadBuffer(scan->indexRelation, GIN_METAPAGE_BLKNO); + Page page; BlockNumber blkno; *ntids = 0; LockBuffer(metabuffer, GIN_SHARE); - blkno = GinPageGetMeta(BufferGetPage(metabuffer))->head; + page = BufferGetPage(metabuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); + blkno = GinPageGetMeta(page)->head; /* * fetch head of list before unlocking metapage. head page must be pinned diff --git a/src/backend/access/gin/gininsert.c b/src/backend/access/gin/gininsert.c index cd21e0e655..126501149d 100644 --- a/src/backend/access/gin/gininsert.c +++ b/src/backend/access/gin/gininsert.c @@ -193,7 +193,7 @@ ginEntryInsert(GinState *ginstate, ginPrepareEntryScan(&btree, attnum, key, category, ginstate); stack = ginFindLeafPage(&btree, false); - page = BufferGetPage(stack->buffer); + page = BufferGetPage(stack->buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (btree.findItem(&btree, stack)) { @@ -352,10 +352,10 @@ ginbuild(Relation heap, Relation index, IndexInfo *indexInfo) recptr = XLogInsert(RM_GIN_ID, XLOG_GIN_CREATE_INDEX); - page = BufferGetPage(RootBuffer); + page = BufferGetPage(RootBuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); PageSetLSN(page, recptr); - page = BufferGetPage(MetaBuffer); + page = BufferGetPage(MetaBuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); PageSetLSN(page, recptr); } diff --git a/src/backend/access/gin/ginutil.c b/src/backend/access/gin/ginutil.c index 94502678ab..de3532b80e 100644 --- a/src/backend/access/gin/ginutil.c +++ b/src/backend/access/gin/ginutil.c @@ -273,7 +273,8 @@ GinNewBuffer(Relation index) */ if (ConditionalLockBuffer(buffer)) { - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); if (PageIsNew(page)) return buffer; /* OK to use, if never initialized */ @@ -318,14 +319,15 @@ GinInitPage(Page page, uint32 f, Size pageSize) void GinInitBuffer(Buffer b, uint32 f) { - GinInitPage(BufferGetPage(b), f, BufferGetPageSize(b)); + GinInitPage(BufferGetPage(b, NULL, NULL, BGP_NO_SNAPSHOT_TEST), + f, BufferGetPageSize(b)); } void GinInitMetabuffer(Buffer b) { GinMetaPageData *metadata; - Page page = BufferGetPage(b); + Page page = BufferGetPage(b, NULL, NULL, BGP_NO_SNAPSHOT_TEST); GinInitPage(page, GIN_META, BufferGetPageSize(b)); @@ -605,7 +607,7 @@ ginGetStats(Relation index, GinStatsData *stats) metabuffer = ReadBuffer(index, GIN_METAPAGE_BLKNO); LockBuffer(metabuffer, GIN_SHARE); - metapage = BufferGetPage(metabuffer); + metapage = BufferGetPage(metabuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); metadata = GinPageGetMeta(metapage); stats->nPendingPages = metadata->nPendingPages; @@ -632,7 +634,7 @@ ginUpdateStats(Relation index, const GinStatsData *stats) metabuffer = ReadBuffer(index, GIN_METAPAGE_BLKNO); LockBuffer(metabuffer, GIN_EXCLUSIVE); - metapage = BufferGetPage(metabuffer); + metapage = BufferGetPage(metabuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); metadata = GinPageGetMeta(metapage); START_CRIT_SECTION(); diff --git a/src/backend/access/gin/ginvacuum.c b/src/backend/access/gin/ginvacuum.c index 6a4b98a4e7..f26dc799b5 100644 --- a/src/backend/access/gin/ginvacuum.c +++ b/src/backend/access/gin/ginvacuum.c @@ -87,7 +87,8 @@ ginVacuumItemPointers(GinVacuumState *gvs, ItemPointerData *items, static void xlogVacuumPage(Relation index, Buffer buffer) { - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); XLogRecPtr recptr; /* This is only used for entry tree leaf pages. */ @@ -118,7 +119,7 @@ ginVacuumPostingTreeLeaves(GinVacuumState *gvs, BlockNumber blkno, bool isRoot, buffer = ReadBufferExtended(gvs->index, MAIN_FORKNUM, blkno, RBM_NORMAL, gvs->strategy); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* * We should be sure that we don't concurrent with inserts, insert process @@ -212,14 +213,14 @@ ginDeletePage(GinVacuumState *gvs, BlockNumber deleteBlkno, BlockNumber leftBlkn START_CRIT_SECTION(); /* Unlink the page by changing left sibling's rightlink */ - page = BufferGetPage(dBuffer); + page = BufferGetPage(dBuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); rightlink = GinPageGetOpaque(page)->rightlink; - page = BufferGetPage(lBuffer); + page = BufferGetPage(lBuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); GinPageGetOpaque(page)->rightlink = rightlink; /* Delete downlink from parent */ - parentPage = BufferGetPage(pBuffer); + parentPage = BufferGetPage(pBuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); #ifdef USE_ASSERT_CHECKING do { @@ -230,7 +231,7 @@ ginDeletePage(GinVacuumState *gvs, BlockNumber deleteBlkno, BlockNumber leftBlkn #endif GinPageDeletePostingItem(parentPage, myoff); - page = BufferGetPage(dBuffer); + page = BufferGetPage(dBuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* * we shouldn't change rightlink field to save workability of running @@ -268,7 +269,8 @@ ginDeletePage(GinVacuumState *gvs, BlockNumber deleteBlkno, BlockNumber leftBlkn recptr = XLogInsert(RM_GIN_ID, XLOG_GIN_DELETE_PAGE); PageSetLSN(page, recptr); PageSetLSN(parentPage, recptr); - PageSetLSN(BufferGetPage(lBuffer), recptr); + PageSetLSN(BufferGetPage(lBuffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), recptr); } if (!isParentRoot) @@ -324,7 +326,7 @@ ginScanToDelete(GinVacuumState *gvs, BlockNumber blkno, bool isRoot, buffer = ReadBufferExtended(gvs->index, MAIN_FORKNUM, blkno, RBM_NORMAL, gvs->strategy); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); Assert(GinPageIsData(page)); @@ -407,7 +409,8 @@ ginVacuumPostingTree(GinVacuumState *gvs, BlockNumber rootBlkno) static Page ginVacuumEntryPage(GinVacuumState *gvs, Buffer buffer, BlockNumber *roots, uint32 *nroot) { - Page origpage = BufferGetPage(buffer), + Page origpage = BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), tmppage; OffsetNumber i, maxoff = PageGetMaxOffsetNumber(origpage); @@ -554,7 +557,8 @@ ginbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, /* find leaf page */ for (;;) { - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); IndexTuple itup; LockBuffer(buffer, GIN_SHARE); @@ -589,7 +593,8 @@ ginbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, for (;;) { - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); Page resPage; uint32 i; @@ -703,7 +708,7 @@ ginvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats) buffer = ReadBufferExtended(index, MAIN_FORKNUM, blkno, RBM_NORMAL, info->strategy); LockBuffer(buffer, GIN_SHARE); - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (PageIsNew(page) || GinPageIsDeleted(page)) { diff --git a/src/backend/access/gin/ginxlog.c b/src/backend/access/gin/ginxlog.c index b4d310f337..8bfa7ec18c 100644 --- a/src/backend/access/gin/ginxlog.c +++ b/src/backend/access/gin/ginxlog.c @@ -28,7 +28,7 @@ ginRedoClearIncompleteSplit(XLogReaderState *record, uint8 block_id) if (XLogReadBufferForRedo(record, block_id, &buffer) == BLK_NEEDS_REDO) { - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); GinPageGetOpaque(page)->flags &= ~GIN_INCOMPLETE_SPLIT; PageSetLSN(page, lsn); @@ -48,7 +48,7 @@ ginRedoCreateIndex(XLogReaderState *record) MetaBuffer = XLogInitBufferForRedo(record, 0); Assert(BufferGetBlockNumber(MetaBuffer) == GIN_METAPAGE_BLKNO); - page = (Page) BufferGetPage(MetaBuffer); + page = BufferGetPage(MetaBuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); GinInitMetabuffer(MetaBuffer); @@ -57,7 +57,7 @@ ginRedoCreateIndex(XLogReaderState *record) RootBuffer = XLogInitBufferForRedo(record, 1); Assert(BufferGetBlockNumber(RootBuffer) == GIN_ROOT_BLKNO); - page = (Page) BufferGetPage(RootBuffer); + page = BufferGetPage(RootBuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); GinInitBuffer(RootBuffer, GIN_LEAF); @@ -78,7 +78,7 @@ ginRedoCreatePTree(XLogReaderState *record) Page page; buffer = XLogInitBufferForRedo(record, 0); - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); GinInitBuffer(buffer, GIN_DATA | GIN_LEAF | GIN_COMPRESSED); @@ -98,7 +98,7 @@ ginRedoCreatePTree(XLogReaderState *record) static void ginRedoInsertEntry(Buffer buffer, bool isLeaf, BlockNumber rightblkno, void *rdata) { - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); ginxlogInsertEntry *data = (ginxlogInsertEntry *) rdata; OffsetNumber offset = data->offset; IndexTuple itup; @@ -293,7 +293,7 @@ ginRedoRecompress(Page page, ginxlogRecompressDataLeaf *data) static void ginRedoInsertData(Buffer buffer, bool isLeaf, BlockNumber rightblkno, void *rdata) { - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (isLeaf) { @@ -350,7 +350,7 @@ ginRedoInsert(XLogReaderState *record) if (XLogReadBufferForRedo(record, 0, &buffer) == BLK_NEEDS_REDO) { - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); Size len; char *payload = XLogRecGetBlockData(record, 0, &len); @@ -431,7 +431,7 @@ ginRedoVacuumDataLeafPage(XLogReaderState *record) if (XLogReadBufferForRedo(record, 0, &buffer) == BLK_NEEDS_REDO) { - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); Size len; ginxlogVacuumDataLeafPage *xlrec; @@ -460,7 +460,7 @@ ginRedoDeletePage(XLogReaderState *record) if (XLogReadBufferForRedo(record, 0, &dbuffer) == BLK_NEEDS_REDO) { - page = BufferGetPage(dbuffer); + page = BufferGetPage(dbuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); Assert(GinPageIsData(page)); GinPageGetOpaque(page)->flags = GIN_DELETED; PageSetLSN(page, lsn); @@ -469,7 +469,7 @@ ginRedoDeletePage(XLogReaderState *record) if (XLogReadBufferForRedo(record, 1, &pbuffer) == BLK_NEEDS_REDO) { - page = BufferGetPage(pbuffer); + page = BufferGetPage(pbuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); Assert(GinPageIsData(page)); Assert(!GinPageIsLeaf(page)); GinPageDeletePostingItem(page, data->parentOffset); @@ -479,7 +479,7 @@ ginRedoDeletePage(XLogReaderState *record) if (XLogReadBufferForRedo(record, 2, &lbuffer) == BLK_NEEDS_REDO) { - page = BufferGetPage(lbuffer); + page = BufferGetPage(lbuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); Assert(GinPageIsData(page)); GinPageGetOpaque(page)->rightlink = data->rightLink; PageSetLSN(page, lsn); @@ -510,7 +510,7 @@ ginRedoUpdateMetapage(XLogReaderState *record) */ metabuffer = XLogInitBufferForRedo(record, 0); Assert(BufferGetBlockNumber(metabuffer) == GIN_METAPAGE_BLKNO); - metapage = BufferGetPage(metabuffer); + metapage = BufferGetPage(metabuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); GinInitPage(metapage, GIN_META, BufferGetPageSize(metabuffer)); memcpy(GinPageGetMeta(metapage), &data->metadata, sizeof(GinMetaPageData)); @@ -524,7 +524,7 @@ ginRedoUpdateMetapage(XLogReaderState *record) */ if (XLogReadBufferForRedo(record, 1, &buffer) == BLK_NEEDS_REDO) { - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); OffsetNumber off; int i; Size tupsize; @@ -572,7 +572,7 @@ ginRedoUpdateMetapage(XLogReaderState *record) */ if (XLogReadBufferForRedo(record, 1, &buffer) == BLK_NEEDS_REDO) { - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); GinPageGetOpaque(page)->rightlink = data->newRightlink; @@ -603,7 +603,7 @@ ginRedoInsertListPage(XLogReaderState *record) /* We always re-initialize the page. */ buffer = XLogInitBufferForRedo(record, 0); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); GinInitBuffer(buffer, GIN_LIST); GinPageGetOpaque(page)->rightlink = data->rightlink; @@ -652,7 +652,7 @@ ginRedoDeleteListPages(XLogReaderState *record) metabuffer = XLogInitBufferForRedo(record, 0); Assert(BufferGetBlockNumber(metabuffer) == GIN_METAPAGE_BLKNO); - metapage = BufferGetPage(metabuffer); + metapage = BufferGetPage(metabuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); GinInitPage(metapage, GIN_META, BufferGetPageSize(metabuffer)); @@ -681,7 +681,7 @@ ginRedoDeleteListPages(XLogReaderState *record) Page page; buffer = XLogInitBufferForRedo(record, i + 1); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); GinInitBuffer(buffer, GIN_DELETED); PageSetLSN(page, lsn); diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c index 996363c2de..999e71cafc 100644 --- a/src/backend/access/gist/gist.c +++ b/src/backend/access/gist/gist.c @@ -211,7 +211,8 @@ gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate, bool markfollowright) { BlockNumber blkno = BufferGetBlockNumber(buffer); - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); bool is_leaf = (GistPageIsLeaf(page)) ? true : false; XLogRecPtr recptr; int i; @@ -316,7 +317,9 @@ gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate, dist->buffer = buffer; dist->block.blkno = BufferGetBlockNumber(buffer); - dist->page = PageGetTempPageCopySpecial(BufferGetPage(buffer)); + dist->page = + PageGetTempPageCopySpecial(BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST)); /* clean all flags except F_LEAF */ GistPageGetOpaque(dist->page)->flags = (is_leaf) ? F_LEAF : 0; @@ -328,7 +331,7 @@ gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate, /* Allocate new page */ ptr->buffer = gistNewBuffer(rel); GISTInitBuffer(ptr->buffer, (is_leaf) ? F_LEAF : 0); - ptr->page = BufferGetPage(ptr->buffer); + ptr->page = BufferGetPage(ptr->buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); ptr->block.blkno = BufferGetBlockNumber(ptr->buffer); } @@ -354,7 +357,10 @@ gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate, int i; rootpg.buffer = buffer; - rootpg.page = PageGetTempPageCopySpecial(BufferGetPage(rootpg.buffer)); + rootpg.page = + PageGetTempPageCopySpecial(BufferGetPage(rootpg.buffer, + NULL, NULL, + BGP_NO_SNAPSHOT_TEST)); GistPageGetOpaque(rootpg.page)->flags = 0; /* Prepare a vector of all the downlinks */ @@ -462,8 +468,11 @@ gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate, * The first page in the chain was a temporary working copy meant to * replace the old page. Copy it over the old page. */ - PageRestoreTempPage(dist->page, BufferGetPage(dist->buffer)); - dist->page = BufferGetPage(dist->buffer); + PageRestoreTempPage(dist->page, BufferGetPage(dist->buffer, + NULL, NULL, + BGP_NO_SNAPSHOT_TEST)); + dist->page = BufferGetPage(dist->buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); /* Write the WAL record */ if (RelationNeedsWAL(rel)) @@ -554,7 +563,8 @@ gistplacetopage(Relation rel, Size freespace, GISTSTATE *giststate, */ if (BufferIsValid(leftchildbuf)) { - Page leftpg = BufferGetPage(leftchildbuf); + Page leftpg = BufferGetPage(leftchildbuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); GistPageSetNSN(leftpg, recptr); GistClearFollowRight(leftpg); @@ -614,7 +624,8 @@ gistdoinsert(Relation r, IndexTuple itup, Size freespace, GISTSTATE *giststate) gistcheckpage(state.r, stack->buffer); } - stack->page = (Page) BufferGetPage(stack->buffer); + stack->page = BufferGetPage(stack->buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); stack->lsn = PageGetLSN(stack->page); Assert(!RelationNeedsWAL(state.r) || !XLogRecPtrIsInvalid(stack->lsn)); @@ -699,7 +710,8 @@ gistdoinsert(Relation r, IndexTuple itup, Size freespace, GISTSTATE *giststate) LockBuffer(stack->buffer, GIST_UNLOCK); LockBuffer(stack->buffer, GIST_EXCLUSIVE); xlocked = true; - stack->page = (Page) BufferGetPage(stack->buffer); + stack->page = BufferGetPage(stack->buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); if (PageGetLSN(stack->page) != stack->lsn) { @@ -763,7 +775,8 @@ gistdoinsert(Relation r, IndexTuple itup, Size freespace, GISTSTATE *giststate) LockBuffer(stack->buffer, GIST_UNLOCK); LockBuffer(stack->buffer, GIST_EXCLUSIVE); xlocked = true; - stack->page = (Page) BufferGetPage(stack->buffer); + stack->page = BufferGetPage(stack->buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); stack->lsn = PageGetLSN(stack->page); if (stack->blkno == GIST_ROOT_BLKNO) @@ -853,7 +866,7 @@ gistFindPath(Relation r, BlockNumber child, OffsetNumber *downlinkoffnum) buffer = ReadBuffer(r, top->blkno); LockBuffer(buffer, GIST_SHARE); gistcheckpage(r, buffer); - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (GistPageIsLeaf(page)) { @@ -941,7 +954,8 @@ gistFindCorrectParent(Relation r, GISTInsertStack *child) GISTInsertStack *parent = child->parent; gistcheckpage(r, parent->buffer); - parent->page = (Page) BufferGetPage(parent->buffer); + parent->page = BufferGetPage(parent->buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); /* here we don't need to distinguish between split and page update */ if (child->downlinkoffnum == InvalidOffsetNumber || @@ -982,7 +996,8 @@ gistFindCorrectParent(Relation r, GISTInsertStack *child) parent->buffer = ReadBuffer(r, parent->blkno); LockBuffer(parent->buffer, GIST_EXCLUSIVE); gistcheckpage(r, parent->buffer); - parent->page = (Page) BufferGetPage(parent->buffer); + parent->page = BufferGetPage(parent->buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); } /* @@ -1006,7 +1021,8 @@ gistFindCorrectParent(Relation r, GISTInsertStack *child) while (ptr) { ptr->buffer = ReadBuffer(r, ptr->blkno); - ptr->page = (Page) BufferGetPage(ptr->buffer); + ptr->page = BufferGetPage(ptr->buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); ptr = ptr->parent; } @@ -1028,7 +1044,7 @@ static IndexTuple gistformdownlink(Relation rel, Buffer buf, GISTSTATE *giststate, GISTInsertStack *stack) { - Page page = BufferGetPage(buf); + Page page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); OffsetNumber maxoff; OffsetNumber offset; IndexTuple downlink = NULL; @@ -1109,7 +1125,7 @@ gistfixsplit(GISTInsertState *state, GISTSTATE *giststate) GISTPageSplitInfo *si = palloc(sizeof(GISTPageSplitInfo)); IndexTuple downlink; - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* Form the new downlink tuples to insert to parent */ downlink = gistformdownlink(state->r, buf, giststate, stack); diff --git a/src/backend/access/gist/gistbuild.c b/src/backend/access/gist/gistbuild.c index 4e43a6932a..8e7389c05f 100644 --- a/src/backend/access/gist/gistbuild.c +++ b/src/backend/access/gist/gistbuild.c @@ -169,7 +169,7 @@ gistbuild(Relation heap, Relation index, IndexInfo *indexInfo) /* initialize the root page */ buffer = gistNewBuffer(index); Assert(BufferGetBlockNumber(buffer) == GIST_ROOT_BLKNO); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); START_CRIT_SECTION(); @@ -589,7 +589,7 @@ gistProcessItup(GISTBuildState *buildstate, IndexTuple itup, buffer = ReadBuffer(indexrel, blkno); LockBuffer(buffer, GIST_EXCLUSIVE); - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); childoffnum = gistchoose(indexrel, page, itup, giststate); iid = PageGetItemId(page, childoffnum); idxtuple = (IndexTuple) PageGetItem(page, iid); @@ -699,7 +699,8 @@ gistbufferinginserttuples(GISTBuildState *buildstate, Buffer buffer, int level, */ if (is_split && BufferGetBlockNumber(buffer) == GIST_ROOT_BLKNO) { - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); OffsetNumber off; OffsetNumber maxoff; @@ -866,7 +867,7 @@ gistBufferingFindCorrectParent(GISTBuildState *buildstate, } buffer = ReadBuffer(buildstate->indexrel, parent); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); LockBuffer(buffer, GIST_EXCLUSIVE); gistcheckpage(buildstate->indexrel, buffer); maxoff = PageGetMaxOffsetNumber(page); @@ -1067,7 +1068,7 @@ gistGetMaxLevel(Relation index) * pro forma. */ LockBuffer(buffer, GIST_SHARE); - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (GistPageIsLeaf(page)) { @@ -1167,7 +1168,8 @@ gistMemorizeAllDownlinks(GISTBuildState *buildstate, Buffer parentbuf) OffsetNumber maxoff; OffsetNumber off; BlockNumber parentblkno = BufferGetBlockNumber(parentbuf); - Page page = BufferGetPage(parentbuf); + Page page = BufferGetPage(parentbuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); Assert(!GistPageIsLeaf(page)); diff --git a/src/backend/access/gist/gistget.c b/src/backend/access/gist/gistget.c index 81383835c8..13a039947b 100644 --- a/src/backend/access/gist/gistget.c +++ b/src/backend/access/gist/gistget.c @@ -54,7 +54,7 @@ gistkillitems(IndexScanDesc scan) LockBuffer(buffer, GIST_SHARE); gistcheckpage(scan->indexRelation, buffer); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* * If page LSN differs it means that the page was modified since the last read. @@ -336,7 +336,7 @@ gistScanPage(IndexScanDesc scan, GISTSearchItem *pageItem, double *myDistances, buffer = ReadBuffer(scan->indexRelation, pageItem->blkno); LockBuffer(buffer, GIST_SHARE); gistcheckpage(scan->indexRelation, buffer); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = GistPageGetOpaque(page); /* diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c index fac166d4c2..5d16cf51e8 100644 --- a/src/backend/access/gist/gistutil.c +++ b/src/backend/access/gist/gistutil.c @@ -701,7 +701,7 @@ GISTInitBuffer(Buffer b, uint32 f) Size pageSize; pageSize = BufferGetPageSize(b); - page = BufferGetPage(b); + page = BufferGetPage(b, NULL, NULL, BGP_NO_SNAPSHOT_TEST); PageInit(page, pageSize, sizeof(GISTPageOpaqueData)); opaque = GistPageGetOpaque(page); @@ -718,7 +718,7 @@ GISTInitBuffer(Buffer b, uint32 f) void gistcheckpage(Relation rel, Buffer buf) { - Page page = BufferGetPage(buf); + Page page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* * ReadBuffer verifies that every newly-read page passes @@ -776,7 +776,7 @@ gistNewBuffer(Relation r) */ if (ConditionalLockBuffer(buffer)) { - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (PageIsNew(page)) return buffer; /* OK to use, if never initialized */ diff --git a/src/backend/access/gist/gistvacuum.c b/src/backend/access/gist/gistvacuum.c index 7947ff9dbe..9d9f5dcf41 100644 --- a/src/backend/access/gist/gistvacuum.c +++ b/src/backend/access/gist/gistvacuum.c @@ -75,7 +75,7 @@ gistvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats) buffer = ReadBufferExtended(rel, MAIN_FORKNUM, blkno, RBM_NORMAL, info->strategy); LockBuffer(buffer, GIST_SHARE); - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (PageIsNew(page) || GistPageIsDeleted(page)) { @@ -166,7 +166,7 @@ gistbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, RBM_NORMAL, info->strategy); LockBuffer(buffer, GIST_SHARE); gistcheckpage(rel, buffer); - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (GistPageIsLeaf(page)) { @@ -176,7 +176,7 @@ gistbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, LockBuffer(buffer, GIST_UNLOCK); LockBuffer(buffer, GIST_EXCLUSIVE); - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (stack->blkno == GIST_ROOT_BLKNO && !GistPageIsLeaf(page)) { /* only the root can become non-leaf during relock */ diff --git a/src/backend/access/gist/gistxlog.c b/src/backend/access/gist/gistxlog.c index b48e97cc66..8ef6e98e7d 100644 --- a/src/backend/access/gist/gistxlog.c +++ b/src/backend/access/gist/gistxlog.c @@ -46,7 +46,7 @@ gistRedoClearFollowRight(XLogReaderState *record, uint8 block_id) action = XLogReadBufferForRedo(record, block_id, &buffer); if (action == BLK_NEEDS_REDO || action == BLK_RESTORED) { - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); GistPageSetNSN(page, lsn); GistClearFollowRight(page); @@ -78,7 +78,7 @@ gistRedoPageUpdateRecord(XLogReaderState *record) data = begin = XLogRecGetBlockData(record, 0, &datalen); - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* Delete old tuples */ if (xldata->ntodelete > 0) @@ -199,7 +199,7 @@ gistRedoPageSplitRecord(XLogReaderState *record) } buffer = XLogInitBufferForRedo(record, i + 1); - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); data = XLogRecGetBlockData(record, i + 1, &datalen); tuples = decodePageSplitRecord(data, datalen, &num); @@ -265,7 +265,7 @@ gistRedoCreateIndex(XLogReaderState *record) buffer = XLogInitBufferForRedo(record, 0); Assert(BufferGetBlockNumber(buffer) == GIST_ROOT_BLKNO); - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); GISTInitBuffer(buffer, F_LEAF); diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.c index 3d48c4f031..a5032e1251 100644 --- a/src/backend/access/hash/hash.c +++ b/src/backend/access/hash/hash.c @@ -278,7 +278,7 @@ hashgettuple(IndexScanDesc scan, ScanDirection dir) buf = so->hashso_curbuf; Assert(BufferIsValid(buf)); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); maxoffnum = PageGetMaxOffsetNumber(page); for (offnum = ItemPointerGetOffsetNumber(current); offnum <= maxoffnum; @@ -327,7 +327,8 @@ hashgettuple(IndexScanDesc scan, ScanDirection dir) while (res) { offnum = ItemPointerGetOffsetNumber(current); - page = BufferGetPage(so->hashso_curbuf); + page = BufferGetPage(so->hashso_curbuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); if (!ItemIdIsDead(PageGetItemId(page, offnum))) break; res = _hash_next(scan, dir); @@ -370,7 +371,8 @@ hashgetbitmap(IndexScanDesc scan, TIDBitmap *tbm) OffsetNumber offnum; offnum = ItemPointerGetOffsetNumber(&(so->hashso_curpos)); - page = BufferGetPage(so->hashso_curbuf); + page = BufferGetPage(so->hashso_curbuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); add_tuple = !ItemIdIsDead(PageGetItemId(page, offnum)); } else @@ -515,7 +517,8 @@ hashbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, * each bucket. */ metabuf = _hash_getbuf(rel, HASH_METAPAGE, HASH_READ, LH_META_PAGE); - metap = HashPageGetMeta(BufferGetPage(metabuf)); + metap = HashPageGetMeta(BufferGetPage(metabuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST)); orig_maxbucket = metap->hashm_maxbucket; orig_ntuples = metap->hashm_ntuples; memcpy(&local_metapage, metap, sizeof(local_metapage)); @@ -559,7 +562,7 @@ loop_top: buf = _hash_getbuf_with_strategy(rel, blkno, HASH_WRITE, LH_BUCKET_PAGE | LH_OVERFLOW_PAGE, info->strategy); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (HashPageOpaque) PageGetSpecialPointer(page); Assert(opaque->hasho_bucket == cur_bucket); @@ -614,7 +617,8 @@ loop_top: /* Write-lock metapage and check for split since we started */ metabuf = _hash_getbuf(rel, HASH_METAPAGE, HASH_WRITE, LH_META_PAGE); - metap = HashPageGetMeta(BufferGetPage(metabuf)); + metap = HashPageGetMeta(BufferGetPage(metabuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST)); if (cur_maxbucket != metap->hashm_maxbucket) { diff --git a/src/backend/access/hash/hashinsert.c b/src/backend/access/hash/hashinsert.c index acd2e64763..92152e3104 100644 --- a/src/backend/access/hash/hashinsert.c +++ b/src/backend/access/hash/hashinsert.c @@ -53,7 +53,8 @@ _hash_doinsert(Relation rel, IndexTuple itup) /* Read the metapage */ metabuf = _hash_getbuf(rel, HASH_METAPAGE, HASH_READ, LH_META_PAGE); - metap = HashPageGetMeta(BufferGetPage(metabuf)); + metap = HashPageGetMeta(BufferGetPage(metabuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST)); /* * Check whether the item can fit on a hash page at all. (Eventually, we @@ -111,7 +112,7 @@ _hash_doinsert(Relation rel, IndexTuple itup) /* Fetch the primary bucket page for the bucket */ buf = _hash_getbuf(rel, blkno, HASH_WRITE, LH_BUCKET_PAGE); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); pageopaque = (HashPageOpaque) PageGetSpecialPointer(page); Assert(pageopaque->hasho_bucket == bucket); @@ -131,7 +132,7 @@ _hash_doinsert(Relation rel, IndexTuple itup) */ _hash_relbuf(rel, buf); buf = _hash_getbuf(rel, nextblkno, HASH_WRITE, LH_OVERFLOW_PAGE); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); } else { @@ -145,7 +146,7 @@ _hash_doinsert(Relation rel, IndexTuple itup) /* chain to a new overflow page */ buf = _hash_addovflpage(rel, metabuf, buf); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* should fit now, given test above */ Assert(PageGetFreeSpace(page) >= itemsz); @@ -206,7 +207,7 @@ _hash_pgaddtup(Relation rel, Buffer buf, Size itemsize, IndexTuple itup) uint32 hashkey; _hash_checkpage(rel, buf, LH_BUCKET_PAGE | LH_OVERFLOW_PAGE); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* Find where to insert the tuple (preserving page's hashkey ordering) */ hashkey = _hash_get_indextuple_hashkey(itup); diff --git a/src/backend/access/hash/hashovfl.c b/src/backend/access/hash/hashovfl.c index db3e268a76..3a8916a53d 100644 --- a/src/backend/access/hash/hashovfl.c +++ b/src/backend/access/hash/hashovfl.c @@ -123,7 +123,7 @@ _hash_addovflpage(Relation rel, Buffer metabuf, Buffer buf) { BlockNumber nextblkno; - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); pageopaque = (HashPageOpaque) PageGetSpecialPointer(page); nextblkno = pageopaque->hasho_nextblkno; @@ -137,7 +137,7 @@ _hash_addovflpage(Relation rel, Buffer metabuf, Buffer buf) } /* now that we have correct backlink, initialize new overflow page */ - ovflpage = BufferGetPage(ovflbuf); + ovflpage = BufferGetPage(ovflbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); ovflopaque = (HashPageOpaque) PageGetSpecialPointer(ovflpage); ovflopaque->hasho_prevblkno = BufferGetBlockNumber(buf); ovflopaque->hasho_nextblkno = InvalidBlockNumber; @@ -186,7 +186,8 @@ _hash_getovflpage(Relation rel, Buffer metabuf) _hash_chgbufaccess(rel, metabuf, HASH_NOLOCK, HASH_WRITE); _hash_checkpage(rel, metabuf, LH_META_PAGE); - metap = HashPageGetMeta(BufferGetPage(metabuf)); + metap = HashPageGetMeta(BufferGetPage(metabuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST)); /* start search at hashm_firstfree */ orig_firstfree = metap->hashm_firstfree; @@ -224,7 +225,7 @@ _hash_getovflpage(Relation rel, Buffer metabuf) _hash_chgbufaccess(rel, metabuf, HASH_READ, HASH_NOLOCK); mapbuf = _hash_getbuf(rel, mapblkno, HASH_WRITE, LH_BITMAP_PAGE); - mappage = BufferGetPage(mapbuf); + mappage = BufferGetPage(mapbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); freep = HashPageGetBitmap(mappage); for (; bit <= last_inpage; j++, bit += BITS_PER_MAP) @@ -396,7 +397,7 @@ _hash_freeovflpage(Relation rel, Buffer ovflbuf, /* Get information from the doomed page */ _hash_checkpage(rel, ovflbuf, LH_OVERFLOW_PAGE); ovflblkno = BufferGetBlockNumber(ovflbuf); - ovflpage = BufferGetPage(ovflbuf); + ovflpage = BufferGetPage(ovflbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); ovflopaque = (HashPageOpaque) PageGetSpecialPointer(ovflpage); nextblkno = ovflopaque->hasho_nextblkno; prevblkno = ovflopaque->hasho_prevblkno; @@ -423,7 +424,7 @@ _hash_freeovflpage(Relation rel, Buffer ovflbuf, HASH_WRITE, LH_BUCKET_PAGE | LH_OVERFLOW_PAGE, bstrategy); - Page prevpage = BufferGetPage(prevbuf); + Page prevpage = BufferGetPage(prevbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); HashPageOpaque prevopaque = (HashPageOpaque) PageGetSpecialPointer(prevpage); Assert(prevopaque->hasho_bucket == bucket); @@ -437,7 +438,7 @@ _hash_freeovflpage(Relation rel, Buffer ovflbuf, HASH_WRITE, LH_OVERFLOW_PAGE, bstrategy); - Page nextpage = BufferGetPage(nextbuf); + Page nextpage = BufferGetPage(nextbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); HashPageOpaque nextopaque = (HashPageOpaque) PageGetSpecialPointer(nextpage); Assert(nextopaque->hasho_bucket == bucket); @@ -449,7 +450,8 @@ _hash_freeovflpage(Relation rel, Buffer ovflbuf, /* Read the metapage so we can determine which bitmap page to use */ metabuf = _hash_getbuf(rel, HASH_METAPAGE, HASH_READ, LH_META_PAGE); - metap = HashPageGetMeta(BufferGetPage(metabuf)); + metap = HashPageGetMeta(BufferGetPage(metabuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST)); /* Identify which bit to set */ ovflbitno = blkno_to_bitno(metap, ovflblkno); @@ -466,7 +468,7 @@ _hash_freeovflpage(Relation rel, Buffer ovflbuf, /* Clear the bitmap bit to indicate that this overflow page is free */ mapbuf = _hash_getbuf(rel, blkno, HASH_WRITE, LH_BITMAP_PAGE); - mappage = BufferGetPage(mapbuf); + mappage = BufferGetPage(mapbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); freep = HashPageGetBitmap(mappage); Assert(ISSET(freep, bitmapbit)); CLRBIT(freep, bitmapbit); @@ -521,7 +523,7 @@ _hash_initbitmap(Relation rel, HashMetaPage metap, BlockNumber blkno, * that it's not worth worrying about. */ buf = _hash_getnewbuf(rel, blkno, forkNum); - pg = BufferGetPage(buf); + pg = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* initialize the page's special space */ op = (HashPageOpaque) PageGetSpecialPointer(pg); @@ -601,7 +603,7 @@ _hash_squeezebucket(Relation rel, HASH_WRITE, LH_BUCKET_PAGE, bstrategy); - wpage = BufferGetPage(wbuf); + wpage = BufferGetPage(wbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); wopaque = (HashPageOpaque) PageGetSpecialPointer(wpage); /* @@ -631,7 +633,7 @@ _hash_squeezebucket(Relation rel, HASH_WRITE, LH_OVERFLOW_PAGE, bstrategy); - rpage = BufferGetPage(rbuf); + rpage = BufferGetPage(rbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); ropaque = (HashPageOpaque) PageGetSpecialPointer(rpage); Assert(ropaque->hasho_bucket == bucket); } while (BlockNumberIsValid(ropaque->hasho_nextblkno)); @@ -696,7 +698,7 @@ _hash_squeezebucket(Relation rel, HASH_WRITE, LH_OVERFLOW_PAGE, bstrategy); - wpage = BufferGetPage(wbuf); + wpage = BufferGetPage(wbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); wopaque = (HashPageOpaque) PageGetSpecialPointer(wpage); Assert(wopaque->hasho_bucket == bucket); wbuf_dirty = false; @@ -752,7 +754,7 @@ _hash_squeezebucket(Relation rel, HASH_WRITE, LH_OVERFLOW_PAGE, bstrategy); - rpage = BufferGetPage(rbuf); + rpage = BufferGetPage(rbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); ropaque = (HashPageOpaque) PageGetSpecialPointer(rpage); Assert(ropaque->hasho_bucket == bucket); } diff --git a/src/backend/access/hash/hashpage.c b/src/backend/access/hash/hashpage.c index 178463fcb6..2e2588be3b 100644 --- a/src/backend/access/hash/hashpage.c +++ b/src/backend/access/hash/hashpage.c @@ -161,7 +161,8 @@ _hash_getinitbuf(Relation rel, BlockNumber blkno) /* ref count and lock type are correct */ /* initialize the page */ - _hash_pageinit(BufferGetPage(buf), BufferGetPageSize(buf)); + _hash_pageinit(BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST), + BufferGetPageSize(buf)); return buf; } @@ -210,7 +211,8 @@ _hash_getnewbuf(Relation rel, BlockNumber blkno, ForkNumber forkNum) /* ref count and lock type are correct */ /* initialize the page */ - _hash_pageinit(BufferGetPage(buf), BufferGetPageSize(buf)); + _hash_pageinit(BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST), + BufferGetPageSize(buf)); return buf; } @@ -384,7 +386,7 @@ _hash_metapinit(Relation rel, double num_tuples, ForkNumber forkNum) * the physical index length. */ metabuf = _hash_getnewbuf(rel, HASH_METAPAGE, forkNum); - pg = BufferGetPage(metabuf); + pg = BufferGetPage(metabuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); pageopaque = (HashPageOpaque) PageGetSpecialPointer(pg); pageopaque->hasho_prevblkno = InvalidBlockNumber; @@ -452,7 +454,7 @@ _hash_metapinit(Relation rel, double num_tuples, ForkNumber forkNum) CHECK_FOR_INTERRUPTS(); buf = _hash_getnewbuf(rel, BUCKET_TO_BLKNO(metap, i), forkNum); - pg = BufferGetPage(buf); + pg = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); pageopaque = (HashPageOpaque) PageGetSpecialPointer(pg); pageopaque->hasho_prevblkno = InvalidBlockNumber; pageopaque->hasho_nextblkno = InvalidBlockNumber; @@ -517,7 +519,8 @@ _hash_expandtable(Relation rel, Buffer metabuf) _hash_chgbufaccess(rel, metabuf, HASH_NOLOCK, HASH_WRITE); _hash_checkpage(rel, metabuf, LH_META_PAGE); - metap = HashPageGetMeta(BufferGetPage(metabuf)); + metap = HashPageGetMeta(BufferGetPage(metabuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST)); /* * Check to see if split is still needed; someone else might have already @@ -774,10 +777,10 @@ _hash_splitbucket(Relation rel, * either bucket. */ obuf = _hash_getbuf(rel, start_oblkno, HASH_WRITE, LH_BUCKET_PAGE); - opage = BufferGetPage(obuf); + opage = BufferGetPage(obuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); oopaque = (HashPageOpaque) PageGetSpecialPointer(opage); - npage = BufferGetPage(nbuf); + npage = BufferGetPage(nbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* initialize the new bucket's primary page */ nopaque = (HashPageOpaque) PageGetSpecialPointer(npage); @@ -841,7 +844,7 @@ _hash_splitbucket(Relation rel, _hash_chgbufaccess(rel, nbuf, HASH_WRITE, HASH_NOLOCK); /* chain to a new overflow page */ nbuf = _hash_addovflpage(rel, metabuf, nbuf); - npage = BufferGetPage(nbuf); + npage = BufferGetPage(nbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* we don't need nopaque within the loop */ } @@ -888,7 +891,7 @@ _hash_splitbucket(Relation rel, /* Else, advance to next old page */ obuf = _hash_getbuf(rel, oblkno, HASH_WRITE, LH_OVERFLOW_PAGE); - opage = BufferGetPage(obuf); + opage = BufferGetPage(obuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); oopaque = (HashPageOpaque) PageGetSpecialPointer(opage); } diff --git a/src/backend/access/hash/hashsearch.c b/src/backend/access/hash/hashsearch.c index 6025a3fac7..dd1f464e53 100644 --- a/src/backend/access/hash/hashsearch.c +++ b/src/backend/access/hash/hashsearch.c @@ -55,7 +55,7 @@ _hash_next(IndexScanDesc scan, ScanDirection dir) current = &(so->hashso_curpos); offnum = ItemPointerGetOffsetNumber(current); _hash_checkpage(rel, buf, LH_BUCKET_PAGE | LH_OVERFLOW_PAGE); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, offnum)); so->hashso_heappos = itup->t_tid; @@ -79,7 +79,7 @@ _hash_readnext(Relation rel, if (BlockNumberIsValid(blkno)) { *bufp = _hash_getbuf(rel, blkno, HASH_READ, LH_OVERFLOW_PAGE); - *pagep = BufferGetPage(*bufp); + *pagep = BufferGetPage(*bufp, NULL, NULL, BGP_NO_SNAPSHOT_TEST); *opaquep = (HashPageOpaque) PageGetSpecialPointer(*pagep); } } @@ -102,7 +102,7 @@ _hash_readprev(Relation rel, { *bufp = _hash_getbuf(rel, blkno, HASH_READ, LH_BUCKET_PAGE | LH_OVERFLOW_PAGE); - *pagep = BufferGetPage(*bufp); + *pagep = BufferGetPage(*bufp, NULL, NULL, BGP_NO_SNAPSHOT_TEST); *opaquep = (HashPageOpaque) PageGetSpecialPointer(*pagep); } } @@ -188,7 +188,9 @@ _hash_first(IndexScanDesc scan, ScanDirection dir) /* Read the metapage */ metabuf = _hash_getbuf(rel, HASH_METAPAGE, HASH_READ, LH_META_PAGE); - metap = HashPageGetMeta(BufferGetPage(metabuf)); + page = BufferGetPage(metabuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); + metap = HashPageGetMeta(page); /* * Loop until we get a lock on the correct target bucket. @@ -240,7 +242,8 @@ _hash_first(IndexScanDesc scan, ScanDirection dir) /* Fetch the primary bucket page for the bucket */ buf = _hash_getbuf(rel, blkno, HASH_READ, LH_BUCKET_PAGE); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); opaque = (HashPageOpaque) PageGetSpecialPointer(page); Assert(opaque->hasho_bucket == bucket); @@ -258,7 +261,7 @@ _hash_first(IndexScanDesc scan, ScanDirection dir) /* if we're here, _hash_step found a valid tuple */ offnum = ItemPointerGetOffsetNumber(current); _hash_checkpage(rel, buf, LH_BUCKET_PAGE | LH_OVERFLOW_PAGE); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, offnum)); so->hashso_heappos = itup->t_tid; @@ -294,7 +297,7 @@ _hash_step(IndexScanDesc scan, Buffer *bufP, ScanDirection dir) buf = *bufP; _hash_checkpage(rel, buf, LH_BUCKET_PAGE | LH_OVERFLOW_PAGE); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (HashPageOpaque) PageGetSpecialPointer(page); /* diff --git a/src/backend/access/hash/hashutil.c b/src/backend/access/hash/hashutil.c index 456954b063..5dbc2a489d 100644 --- a/src/backend/access/hash/hashutil.c +++ b/src/backend/access/hash/hashutil.c @@ -155,7 +155,7 @@ _hash_log2(uint32 num) void _hash_checkpage(Relation rel, Buffer buf, int flags) { - Page page = BufferGetPage(buf); + Page page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* * ReadBuffer verifies that every newly-read page passes diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index 34ba385748..66b23540fe 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -394,7 +394,7 @@ heapgetpage(HeapScanDesc scan, BlockNumber page) */ LockBuffer(buffer, BUFFER_LOCK_SHARE); - dp = (Page) BufferGetPage(buffer); + dp = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); lines = PageGetMaxOffsetNumber(dp); ntup = 0; @@ -537,7 +537,7 @@ heapgettup(HeapScanDesc scan, LockBuffer(scan->rs_cbuf, BUFFER_LOCK_SHARE); - dp = (Page) BufferGetPage(scan->rs_cbuf); + dp = BufferGetPage(scan->rs_cbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); lines = PageGetMaxOffsetNumber(dp); /* page and lineoff now reference the physically next tid */ @@ -582,7 +582,7 @@ heapgettup(HeapScanDesc scan, LockBuffer(scan->rs_cbuf, BUFFER_LOCK_SHARE); - dp = (Page) BufferGetPage(scan->rs_cbuf); + dp = BufferGetPage(scan->rs_cbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); lines = PageGetMaxOffsetNumber(dp); if (!scan->rs_inited) @@ -616,7 +616,7 @@ heapgettup(HeapScanDesc scan, heapgetpage(scan, page); /* Since the tuple was previously fetched, needn't lock page here */ - dp = (Page) BufferGetPage(scan->rs_cbuf); + dp = BufferGetPage(scan->rs_cbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); lineoff = ItemPointerGetOffsetNumber(&(tuple->t_self)); lpp = PageGetItemId(dp, lineoff); Assert(ItemIdIsNormal(lpp)); @@ -745,7 +745,7 @@ heapgettup(HeapScanDesc scan, LockBuffer(scan->rs_cbuf, BUFFER_LOCK_SHARE); - dp = (Page) BufferGetPage(scan->rs_cbuf); + dp = BufferGetPage(scan->rs_cbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); lines = PageGetMaxOffsetNumber((Page) dp); linesleft = lines; if (backward) @@ -832,7 +832,7 @@ heapgettup_pagemode(HeapScanDesc scan, lineindex = scan->rs_cindex + 1; } - dp = (Page) BufferGetPage(scan->rs_cbuf); + dp = BufferGetPage(scan->rs_cbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); lines = scan->rs_ntuples; /* page and lineindex now reference the next visible tid */ @@ -875,7 +875,7 @@ heapgettup_pagemode(HeapScanDesc scan, page = scan->rs_cblock; /* current page */ } - dp = (Page) BufferGetPage(scan->rs_cbuf); + dp = BufferGetPage(scan->rs_cbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); lines = scan->rs_ntuples; if (!scan->rs_inited) @@ -908,7 +908,7 @@ heapgettup_pagemode(HeapScanDesc scan, heapgetpage(scan, page); /* Since the tuple was previously fetched, needn't lock page here */ - dp = (Page) BufferGetPage(scan->rs_cbuf); + dp = BufferGetPage(scan->rs_cbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); lineoff = ItemPointerGetOffsetNumber(&(tuple->t_self)); lpp = PageGetItemId(dp, lineoff); Assert(ItemIdIsNormal(lpp)); @@ -1027,7 +1027,7 @@ heapgettup_pagemode(HeapScanDesc scan, heapgetpage(scan, page); - dp = (Page) BufferGetPage(scan->rs_cbuf); + dp = BufferGetPage(scan->rs_cbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); lines = scan->rs_ntuples; linesleft = lines; if (backward) @@ -1871,7 +1871,7 @@ heap_fetch(Relation relation, * Need share lock on buffer to examine tuple commit status. */ LockBuffer(buffer, BUFFER_LOCK_SHARE); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* * We'd better check for out-of-range offnum in case of VACUUM since the @@ -1986,7 +1986,7 @@ heap_hot_search_buffer(ItemPointer tid, Relation relation, Buffer buffer, Snapshot snapshot, HeapTuple heapTuple, bool *all_dead, bool first_call) { - Page dp = (Page) BufferGetPage(buffer); + Page dp = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); TransactionId prev_xmax = InvalidTransactionId; OffsetNumber offnum; bool at_chain_start; @@ -2200,7 +2200,7 @@ heap_get_latest_tid(Relation relation, */ buffer = ReadBuffer(relation, ItemPointerGetBlockNumber(&ctid)); LockBuffer(buffer, BUFFER_LOCK_SHARE); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* * Check for bogus item number. This is not treated as an error @@ -2418,10 +2418,12 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid, RelationPutHeapTuple(relation, buffer, heaptup, (options & HEAP_INSERT_SPECULATIVE) != 0); - if (PageIsAllVisible(BufferGetPage(buffer))) + if (PageIsAllVisible(BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST))) { all_visible_cleared = true; - PageClearAllVisible(BufferGetPage(buffer)); + PageClearAllVisible(BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST)); visibilitymap_clear(relation, ItemPointerGetBlockNumber(&(heaptup->t_self)), vmbuffer); @@ -2446,7 +2448,8 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid, xl_heap_insert xlrec; xl_heap_header xlhdr; XLogRecPtr recptr; - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); uint8 info = XLOG_HEAP_INSERT; int bufflags = 0; @@ -2705,7 +2708,7 @@ heap_multi_insert(Relation relation, HeapTuple *tuples, int ntuples, buffer = RelationGetBufferForTuple(relation, heaptuples[ndone]->t_len, InvalidBuffer, options, bistate, &vmbuffer, NULL); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* NO EREPORT(ERROR) from here till changes are logged */ START_CRIT_SECTION(); @@ -3019,7 +3022,7 @@ heap_delete(Relation relation, ItemPointer tid, block = ItemPointerGetBlockNumber(tid); buffer = ReadBuffer(relation, block); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* * Before locking the buffer, pin the visibility map page if it appears to @@ -3509,7 +3512,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup, block = ItemPointerGetBlockNumber(otid); buffer = ReadBuffer(relation, block); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* * Before locking the buffer, pin the visibility map page if it appears to @@ -4110,17 +4113,22 @@ l2: oldtup.t_data->t_ctid = heaptup->t_self; /* clear PD_ALL_VISIBLE flags */ - if (PageIsAllVisible(BufferGetPage(buffer))) + if (PageIsAllVisible(BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST))) { all_visible_cleared = true; - PageClearAllVisible(BufferGetPage(buffer)); + PageClearAllVisible(BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST)); visibilitymap_clear(relation, BufferGetBlockNumber(buffer), vmbuffer); } - if (newbuf != buffer && PageIsAllVisible(BufferGetPage(newbuf))) + if (newbuf != buffer && + PageIsAllVisible(BufferGetPage(newbuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST))) { all_visible_cleared_new = true; - PageClearAllVisible(BufferGetPage(newbuf)); + PageClearAllVisible(BufferGetPage(newbuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST)); visibilitymap_clear(relation, BufferGetBlockNumber(newbuf), vmbuffer_new); } @@ -4151,9 +4159,12 @@ l2: all_visible_cleared_new); if (newbuf != buffer) { - PageSetLSN(BufferGetPage(newbuf), recptr); + PageSetLSN(BufferGetPage(newbuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), + recptr); } - PageSetLSN(BufferGetPage(buffer), recptr); + PageSetLSN(BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST), + recptr); } END_CRIT_SECTION(); @@ -4517,7 +4528,7 @@ heap_lock_tuple(Relation relation, HeapTuple tuple, *buffer = ReadBuffer(relation, ItemPointerGetBlockNumber(tid)); LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE); - page = BufferGetPage(*buffer); + page = BufferGetPage(*buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); lp = PageGetItemId(page, ItemPointerGetOffsetNumber(tid)); Assert(ItemIdIsNormal(lp)); @@ -5695,7 +5706,8 @@ l4: { xl_heap_lock_updated xlrec; XLogRecPtr recptr; - Page page = BufferGetPage(buf); + Page page = BufferGetPage(buf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); XLogBeginInsert(); XLogRegisterBuffer(0, buf, REGBUF_STANDARD); @@ -5802,7 +5814,7 @@ heap_finish_speculative(Relation relation, HeapTuple tuple) buffer = ReadBuffer(relation, ItemPointerGetBlockNumber(&(tuple->t_self))); LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE); - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); offnum = ItemPointerGetOffsetNumber(&(tuple->t_self)); if (PageGetMaxOffsetNumber(page) >= offnum) @@ -5896,7 +5908,7 @@ heap_abort_speculative(Relation relation, HeapTuple tuple) block = ItemPointerGetBlockNumber(tid); buffer = ReadBuffer(relation, block); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE); @@ -6043,7 +6055,7 @@ heap_inplace_update(Relation relation, HeapTuple tuple) buffer = ReadBuffer(relation, ItemPointerGetBlockNumber(&(tuple->t_self))); LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE); - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); offnum = ItemPointerGetOffsetNumber(&(tuple->t_self)); if (PageGetMaxOffsetNumber(page) >= offnum) @@ -7298,7 +7310,8 @@ log_heap_update(Relation reln, Buffer oldbuf, uint16 prefixlen = 0, suffixlen = 0; XLogRecPtr recptr; - Page page = BufferGetPage(newbuf); + Page page = BufferGetPage(newbuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); bool need_tuple_data = RelationIsLogicallyLogged(reln); bool init; int bufflags; @@ -7747,7 +7760,8 @@ heap_xlog_clean(XLogReaderState *record) &buffer); if (action == BLK_NEEDS_REDO) { - Page page = (Page) BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); OffsetNumber *end; OffsetNumber *redirected; OffsetNumber *nowdead; @@ -7853,7 +7867,7 @@ heap_xlog_visible(XLogReaderState *record) * XLOG record's LSN, we mustn't mark the page all-visible, because * the subsequent update won't be replayed to clear the flag. */ - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); PageSetAllVisible(page); @@ -7879,7 +7893,8 @@ heap_xlog_visible(XLogReaderState *record) if (XLogReadBufferForRedoExtended(record, 0, RBM_ZERO_ON_ERROR, false, &vmbuffer) == BLK_NEEDS_REDO) { - Page vmpage = BufferGetPage(vmbuffer); + Page vmpage = BufferGetPage(vmbuffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); Relation reln; /* initialize the page if it was read as zeros */ @@ -7946,7 +7961,8 @@ heap_xlog_freeze_page(XLogReaderState *record) if (XLogReadBufferForRedo(record, 0, &buffer) == BLK_NEEDS_REDO) { - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); xl_heap_freeze_tuple *tuples; tuples = (xl_heap_freeze_tuple *) XLogRecGetBlockData(record, 0, NULL); @@ -8033,7 +8049,7 @@ heap_xlog_delete(XLogReaderState *record) if (XLogReadBufferForRedo(record, 0, &buffer) == BLK_NEEDS_REDO) { - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (PageGetMaxOffsetNumber(page) >= xlrec->offnum) lp = PageGetItemId(page, xlrec->offnum); @@ -8116,7 +8132,7 @@ heap_xlog_insert(XLogReaderState *record) if (XLogRecGetInfo(record) & XLOG_HEAP_INIT_PAGE) { buffer = XLogInitBufferForRedo(record, 0); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); PageInit(page, BufferGetPageSize(buffer), 0); action = BLK_NEEDS_REDO; } @@ -8127,7 +8143,7 @@ heap_xlog_insert(XLogReaderState *record) Size datalen; char *data; - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (PageGetMaxOffsetNumber(page) + 1 < xlrec->offnum) elog(PANIC, "invalid max offset number"); @@ -8232,7 +8248,7 @@ heap_xlog_multi_insert(XLogReaderState *record) if (isinit) { buffer = XLogInitBufferForRedo(record, 0); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); PageInit(page, BufferGetPageSize(buffer), 0); action = BLK_NEEDS_REDO; } @@ -8248,7 +8264,7 @@ heap_xlog_multi_insert(XLogReaderState *record) tupdata = XLogRecGetBlockData(record, 0, &len); endptr = tupdata + len; - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); for (i = 0; i < xlrec->ntuples; i++) { @@ -8399,7 +8415,7 @@ heap_xlog_update(XLogReaderState *record, bool hot_update) &obuffer); if (oldaction == BLK_NEEDS_REDO) { - page = BufferGetPage(obuffer); + page = BufferGetPage(obuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); offnum = xlrec->old_offnum; if (PageGetMaxOffsetNumber(page) >= offnum) lp = PageGetItemId(page, offnum); @@ -8446,7 +8462,7 @@ heap_xlog_update(XLogReaderState *record, bool hot_update) else if (XLogRecGetInfo(record) & XLOG_HEAP_INIT_PAGE) { nbuffer = XLogInitBufferForRedo(record, 0); - page = (Page) BufferGetPage(nbuffer); + page = BufferGetPage(nbuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); PageInit(page, BufferGetPageSize(nbuffer), 0); newaction = BLK_NEEDS_REDO; } @@ -8479,7 +8495,7 @@ heap_xlog_update(XLogReaderState *record, bool hot_update) recdata = XLogRecGetBlockData(record, 0, &datalen); recdata_end = recdata + datalen; - page = BufferGetPage(nbuffer); + page = BufferGetPage(nbuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); offnum = xlrec->new_offnum; if (PageGetMaxOffsetNumber(page) + 1 < offnum) @@ -8609,7 +8625,7 @@ heap_xlog_confirm(XLogReaderState *record) if (XLogReadBufferForRedo(record, 0, &buffer) == BLK_NEEDS_REDO) { - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); offnum = xlrec->offnum; if (PageGetMaxOffsetNumber(page) >= offnum) @@ -8645,7 +8661,7 @@ heap_xlog_lock(XLogReaderState *record) if (XLogReadBufferForRedo(record, 0, &buffer) == BLK_NEEDS_REDO) { - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); offnum = xlrec->offnum; if (PageGetMaxOffsetNumber(page) >= offnum) @@ -8695,7 +8711,7 @@ heap_xlog_lock_updated(XLogReaderState *record) if (XLogReadBufferForRedo(record, 0, &buffer) == BLK_NEEDS_REDO) { - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); offnum = xlrec->offnum; if (PageGetMaxOffsetNumber(page) >= offnum) @@ -8734,7 +8750,7 @@ heap_xlog_inplace(XLogReaderState *record) { char *newtup = XLogRecGetBlockData(record, 0, &newlen); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); offnum = xlrec->offnum; if (PageGetMaxOffsetNumber(page) >= offnum) diff --git a/src/backend/access/heap/hio.c b/src/backend/access/heap/hio.c index 6b850920c7..a041ca0c75 100644 --- a/src/backend/access/heap/hio.c +++ b/src/backend/access/heap/hio.c @@ -48,7 +48,7 @@ RelationPutHeapTuple(Relation relation, Assert(!token || HeapTupleHeaderIsSpeculative(tuple->t_data)); /* Add the tuple to the page */ - pageHeader = BufferGetPage(buffer); + pageHeader = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); offnum = PageAddItem(pageHeader, (Item) tuple->t_data, tuple->t_len, InvalidOffsetNumber, false, true); @@ -132,10 +132,13 @@ GetVisibilityMapPins(Relation relation, Buffer buffer1, Buffer buffer2, while (1) { /* Figure out which pins we need but don't have. */ - need_to_pin_buffer1 = PageIsAllVisible(BufferGetPage(buffer1)) + need_to_pin_buffer1 = + PageIsAllVisible(BufferGetPage(buffer1, NULL, NULL, + BGP_NO_SNAPSHOT_TEST)) && !visibilitymap_pin_ok(block1, *vmbuffer1); need_to_pin_buffer2 = buffer2 != InvalidBuffer - && PageIsAllVisible(BufferGetPage(buffer2)) + && PageIsAllVisible(BufferGetPage(buffer2, NULL, NULL, + BGP_NO_SNAPSHOT_TEST)) && !visibilitymap_pin_ok(block2, *vmbuffer2); if (!need_to_pin_buffer1 && !need_to_pin_buffer2) return; @@ -205,7 +208,7 @@ RelationAddExtraBlocks(Relation relation, BulkInsertState bistate) /* Extend by one page. */ LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); PageInit(page, BufferGetPageSize(buffer), 0); MarkBufferDirty(buffer); blockNum = BufferGetBlockNumber(buffer); @@ -397,7 +400,8 @@ loop: { /* easy case */ buffer = ReadBufferBI(relation, targetBlock, bistate); - if (PageIsAllVisible(BufferGetPage(buffer))) + if (PageIsAllVisible(BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST))) visibilitymap_pin(relation, targetBlock, vmbuffer); LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE); } @@ -405,7 +409,8 @@ loop: { /* also easy case */ buffer = otherBuffer; - if (PageIsAllVisible(BufferGetPage(buffer))) + if (PageIsAllVisible(BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST))) visibilitymap_pin(relation, targetBlock, vmbuffer); LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE); } @@ -413,7 +418,8 @@ loop: { /* lock other buffer first */ buffer = ReadBuffer(relation, targetBlock); - if (PageIsAllVisible(BufferGetPage(buffer))) + if (PageIsAllVisible(BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST))) visibilitymap_pin(relation, targetBlock, vmbuffer); LockBuffer(otherBuffer, BUFFER_LOCK_EXCLUSIVE); LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE); @@ -422,7 +428,8 @@ loop: { /* lock target buffer first */ buffer = ReadBuffer(relation, targetBlock); - if (PageIsAllVisible(BufferGetPage(buffer))) + if (PageIsAllVisible(BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST))) visibilitymap_pin(relation, targetBlock, vmbuffer); LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE); LockBuffer(otherBuffer, BUFFER_LOCK_EXCLUSIVE); @@ -462,7 +469,7 @@ loop: * Now we can check to see if there's enough free space here. If so, * we're done. */ - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); pageFreeSpace = PageGetHeapFreeSpace(page); if (len + saveFreeSpace <= pageFreeSpace) { @@ -583,7 +590,7 @@ loop: * is empty (this should never happen, but if it does we don't want to * risk wiping out valid data). */ - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (!PageIsNew(page)) elog(ERROR, "page %u of relation \"%s\" should be empty but is not", diff --git a/src/backend/access/heap/pruneheap.c b/src/backend/access/heap/pruneheap.c index 59beadda9d..19201b0bca 100644 --- a/src/backend/access/heap/pruneheap.c +++ b/src/backend/access/heap/pruneheap.c @@ -74,7 +74,7 @@ static void heap_prune_record_unused(PruneState *prstate, OffsetNumber offnum); void heap_page_prune_opt(Relation relation, Buffer buffer) { - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); Size minfree; TransactionId OldestXmin; @@ -174,7 +174,7 @@ heap_page_prune(Relation relation, Buffer buffer, TransactionId OldestXmin, bool report_stats, TransactionId *latestRemovedXid) { int ndeleted = 0; - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); OffsetNumber offnum, maxoff; PruneState prstate; @@ -261,7 +261,8 @@ heap_page_prune(Relation relation, Buffer buffer, TransactionId OldestXmin, prstate.nowunused, prstate.nunused, prstate.latestRemovedXid); - PageSetLSN(BufferGetPage(buffer), recptr); + PageSetLSN(BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), recptr); } } else @@ -347,7 +348,7 @@ heap_prune_chain(Relation relation, Buffer buffer, OffsetNumber rootoffnum, PruneState *prstate) { int ndeleted = 0; - Page dp = (Page) BufferGetPage(buffer); + Page dp = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); TransactionId priorXmax = InvalidTransactionId; ItemId rootlp; HeapTupleHeader htup; @@ -673,7 +674,8 @@ heap_page_prune_execute(Buffer buffer, OffsetNumber *nowdead, int ndead, OffsetNumber *nowunused, int nunused) { - Page page = (Page) BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); OffsetNumber *offnum; int i; diff --git a/src/backend/access/heap/visibilitymap.c b/src/backend/access/heap/visibilitymap.c index eaab4beccb..694d78406f 100644 --- a/src/backend/access/heap/visibilitymap.c +++ b/src/backend/access/heap/visibilitymap.c @@ -179,7 +179,8 @@ visibilitymap_clear(Relation rel, BlockNumber heapBlk, Buffer buf) elog(ERROR, "wrong buffer passed to visibilitymap_clear"); LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE); - map = PageGetContents(BufferGetPage(buf)); + map = PageGetContents(BufferGetPage(buf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST)); if (map[mapByte] & mask) { @@ -287,7 +288,7 @@ visibilitymap_set(Relation rel, BlockNumber heapBlk, Buffer heapBuf, if (!BufferIsValid(vmBuf) || BufferGetBlockNumber(vmBuf) != mapBlock) elog(ERROR, "wrong VM buffer passed to visibilitymap_set"); - page = BufferGetPage(vmBuf); + page = BufferGetPage(vmBuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); map = (uint8 *)PageGetContents(page); LockBuffer(vmBuf, BUFFER_LOCK_EXCLUSIVE); @@ -312,7 +313,8 @@ visibilitymap_set(Relation rel, BlockNumber heapBlk, Buffer heapBuf, */ if (XLogHintBitIsNeeded()) { - Page heapPage = BufferGetPage(heapBuf); + Page heapPage = BufferGetPage(heapBuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); /* caller is expected to set PD_ALL_VISIBLE first */ Assert(PageIsAllVisible(heapPage)); @@ -377,7 +379,8 @@ visibilitymap_get_status(Relation rel, BlockNumber heapBlk, Buffer *buf) return false; } - map = PageGetContents(BufferGetPage(*buf)); + map = PageGetContents(BufferGetPage(*buf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST)); /* * A single byte read is atomic. There could be memory-ordering effects @@ -426,7 +429,8 @@ visibilitymap_count(Relation rel, BlockNumber *all_visible, BlockNumber *all_fro * immediately stale anyway if anyone is concurrently setting or * clearing bits, and we only really need an approximate value. */ - map = (unsigned char *) PageGetContents(BufferGetPage(mapBuffer)); + map = (unsigned char *) PageGetContents(BufferGetPage + (mapBuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST)); for (i = 0; i < MAPSIZE; i++) { @@ -493,7 +497,7 @@ visibilitymap_truncate(Relation rel, BlockNumber nheapblocks) return; } - page = BufferGetPage(mapBuffer); + page = BufferGetPage(mapBuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); map = PageGetContents(page); LockBuffer(mapBuffer, BUFFER_LOCK_EXCLUSIVE); @@ -587,8 +591,9 @@ vm_readbuf(Relation rel, BlockNumber blkno, bool extend) */ buf = ReadBufferExtended(rel, VISIBILITYMAP_FORKNUM, blkno, RBM_ZERO_ON_ERROR, NULL); - if (PageIsNew(BufferGetPage(buf))) - PageInit(BufferGetPage(buf), BLCKSZ, 0); + if (PageIsNew(BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST))) + PageInit(BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST), + BLCKSZ, 0); return buf; } diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c index 3e100aabec..bf7a817551 100644 --- a/src/backend/access/nbtree/nbtinsert.c +++ b/src/backend/access/nbtree/nbtinsert.c @@ -255,7 +255,7 @@ _bt_check_unique(Relation rel, IndexTuple itup, Relation heapRel, InitDirtySnapshot(SnapshotDirty); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); maxoff = PageGetMaxOffsetNumber(page); @@ -472,7 +472,7 @@ _bt_check_unique(Relation rel, IndexTuple itup, Relation heapRel, { nblkno = opaque->btpo_next; nbuf = _bt_relandgetbuf(rel, nbuf, nblkno, BT_READ); - page = BufferGetPage(nbuf); + page = BufferGetPage(nbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); if (!P_IGNORE(opaque)) break; @@ -546,7 +546,7 @@ _bt_findinsertloc(Relation rel, Relation heapRel) { Buffer buf = *bufptr; - Page page = BufferGetPage(buf); + Page page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); Size itemsz; BTPageOpaque lpageop; bool movedright, @@ -646,7 +646,7 @@ _bt_findinsertloc(Relation rel, for (;;) { rbuf = _bt_relandgetbuf(rel, rbuf, rblkno, BT_WRITE); - page = BufferGetPage(rbuf); + page = BufferGetPage(rbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); lpageop = (BTPageOpaque) PageGetSpecialPointer(page); /* @@ -742,7 +742,7 @@ _bt_insertonpg(Relation rel, OffsetNumber firstright = InvalidOffsetNumber; Size itemsz; - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); lpageop = (BTPageOpaque) PageGetSpecialPointer(page); /* child buffer must be given iff inserting on an internal page */ @@ -824,7 +824,7 @@ _bt_insertonpg(Relation rel, Assert(!P_ISLEAF(lpageop)); metabuf = _bt_getbuf(rel, BTREE_METAPAGE, BT_WRITE); - metapg = BufferGetPage(metabuf); + metapg = BufferGetPage(metabuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); metad = BTPageGetMeta(metapg); if (metad->btm_fastlevel >= lpageop->btpo.level) @@ -854,7 +854,7 @@ _bt_insertonpg(Relation rel, /* clear INCOMPLETE_SPLIT flag on child if inserting a downlink */ if (BufferIsValid(cbuf)) { - Page cpage = BufferGetPage(cbuf); + Page cpage = BufferGetPage(cbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); BTPageOpaque cpageop = (BTPageOpaque) PageGetSpecialPointer(cpage); Assert(P_INCOMPLETE_SPLIT(cpageop)); @@ -922,7 +922,8 @@ _bt_insertonpg(Relation rel, } if (BufferIsValid(cbuf)) { - PageSetLSN(BufferGetPage(cbuf), recptr); + PageSetLSN(BufferGetPage(cbuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), recptr); } PageSetLSN(page, recptr); @@ -995,9 +996,9 @@ _bt_split(Relation rel, Buffer buf, Buffer cbuf, OffsetNumber firstright, * possibly-confusing junk behind, we are careful to rewrite rightpage as * zeroes before throwing any error. */ - origpage = BufferGetPage(buf); + origpage = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); leftpage = PageGetTempPage(origpage); - rightpage = BufferGetPage(rbuf); + rightpage = BufferGetPage(rbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); origpagenumber = BufferGetBlockNumber(buf); rightpagenumber = BufferGetBlockNumber(rbuf); @@ -1186,7 +1187,7 @@ _bt_split(Relation rel, Buffer buf, Buffer cbuf, OffsetNumber firstright, if (!P_RIGHTMOST(oopaque)) { sbuf = _bt_getbuf(rel, oopaque->btpo_next, BT_WRITE); - spage = BufferGetPage(sbuf); + spage = BufferGetPage(sbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); sopaque = (BTPageOpaque) PageGetSpecialPointer(spage); if (sopaque->btpo_prev != origpagenumber) { @@ -1256,7 +1257,8 @@ _bt_split(Relation rel, Buffer buf, Buffer cbuf, OffsetNumber firstright, */ if (!isleaf) { - Page cpage = BufferGetPage(cbuf); + Page cpage = BufferGetPage(cbuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); BTPageOpaque cpageop = (BTPageOpaque) PageGetSpecialPointer(cpage); cpageop->btpo_flags &= ~BTP_INCOMPLETE_SPLIT; @@ -1343,7 +1345,8 @@ _bt_split(Relation rel, Buffer buf, Buffer cbuf, OffsetNumber firstright, } if (!isleaf) { - PageSetLSN(BufferGetPage(cbuf), recptr); + PageSetLSN(BufferGetPage(cbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST), + recptr); } } @@ -1666,7 +1669,7 @@ _bt_insert_parent(Relation rel, { BlockNumber bknum = BufferGetBlockNumber(buf); BlockNumber rbknum = BufferGetBlockNumber(rbuf); - Page page = BufferGetPage(buf); + Page page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); IndexTuple new_item; BTStackData fakestack; IndexTuple ritem; @@ -1741,7 +1744,7 @@ _bt_insert_parent(Relation rel, void _bt_finish_split(Relation rel, Buffer lbuf, BTStack stack) { - Page lpage = BufferGetPage(lbuf); + Page lpage = BufferGetPage(lbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); BTPageOpaque lpageop = (BTPageOpaque) PageGetSpecialPointer(lpage); Buffer rbuf; Page rpage; @@ -1753,7 +1756,7 @@ _bt_finish_split(Relation rel, Buffer lbuf, BTStack stack) /* Lock right sibling, the one missing the downlink */ rbuf = _bt_getbuf(rel, lpageop->btpo_next, BT_WRITE); - rpage = BufferGetPage(rbuf); + rpage = BufferGetPage(rbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); rpageop = (BTPageOpaque) PageGetSpecialPointer(rpage); /* Could this be a root split? */ @@ -1765,7 +1768,7 @@ _bt_finish_split(Relation rel, Buffer lbuf, BTStack stack) /* acquire lock on the metapage */ metabuf = _bt_getbuf(rel, BTREE_METAPAGE, BT_WRITE); - metapg = BufferGetPage(metabuf); + metapg = BufferGetPage(metabuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); metad = BTPageGetMeta(metapg); was_root = (metad->btm_root == BufferGetBlockNumber(lbuf)); @@ -1813,7 +1816,7 @@ _bt_getstackbuf(Relation rel, BTStack stack, int access) BTPageOpaque opaque; buf = _bt_getbuf(rel, blkno, access); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); if (access == BT_WRITE && P_INCOMPLETE_SPLIT(opaque)) @@ -1939,17 +1942,17 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf) lbkno = BufferGetBlockNumber(lbuf); rbkno = BufferGetBlockNumber(rbuf); - lpage = BufferGetPage(lbuf); + lpage = BufferGetPage(lbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); lopaque = (BTPageOpaque) PageGetSpecialPointer(lpage); /* get a new root page */ rootbuf = _bt_getbuf(rel, P_NEW, BT_WRITE); - rootpage = BufferGetPage(rootbuf); + rootpage = BufferGetPage(rootbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); rootblknum = BufferGetBlockNumber(rootbuf); /* acquire lock on the metapage */ metabuf = _bt_getbuf(rel, BTREE_METAPAGE, BT_WRITE); - metapg = BufferGetPage(metabuf); + metapg = BufferGetPage(metabuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); metad = BTPageGetMeta(metapg); /* @@ -2173,7 +2176,7 @@ _bt_vacuum_one_page(Relation rel, Buffer buffer, Relation heapRel) OffsetNumber offnum, minoff, maxoff; - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); BTPageOpaque opaque = (BTPageOpaque) PageGetSpecialPointer(page); /* diff --git a/src/backend/access/nbtree/nbtpage.c b/src/backend/access/nbtree/nbtpage.c index 67755d75ac..36b1804761 100644 --- a/src/backend/access/nbtree/nbtpage.c +++ b/src/backend/access/nbtree/nbtpage.c @@ -130,7 +130,7 @@ _bt_getroot(Relation rel, int access) rootlevel = metad->btm_fastlevel; rootbuf = _bt_getbuf(rel, rootblkno, BT_READ); - rootpage = BufferGetPage(rootbuf); + rootpage = BufferGetPage(rootbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); rootopaque = (BTPageOpaque) PageGetSpecialPointer(rootpage); /* @@ -156,7 +156,7 @@ _bt_getroot(Relation rel, int access) } metabuf = _bt_getbuf(rel, BTREE_METAPAGE, BT_READ); - metapg = BufferGetPage(metabuf); + metapg = BufferGetPage(metabuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); metaopaque = (BTPageOpaque) PageGetSpecialPointer(metapg); metad = BTPageGetMeta(metapg); @@ -213,7 +213,7 @@ _bt_getroot(Relation rel, int access) */ rootbuf = _bt_getbuf(rel, P_NEW, BT_WRITE); rootblkno = BufferGetBlockNumber(rootbuf); - rootpage = BufferGetPage(rootbuf); + rootpage = BufferGetPage(rootbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); rootopaque = (BTPageOpaque) PageGetSpecialPointer(rootpage); rootopaque->btpo_prev = rootopaque->btpo_next = P_NONE; rootopaque->btpo_flags = (BTP_LEAF | BTP_ROOT); @@ -295,7 +295,7 @@ _bt_getroot(Relation rel, int access) for (;;) { rootbuf = _bt_relandgetbuf(rel, rootbuf, rootblkno, BT_READ); - rootpage = BufferGetPage(rootbuf); + rootpage = BufferGetPage(rootbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); rootopaque = (BTPageOpaque) PageGetSpecialPointer(rootpage); if (!P_IGNORE(rootopaque)) @@ -360,7 +360,7 @@ _bt_gettrueroot(Relation rel) rel->rd_amcache = NULL; metabuf = _bt_getbuf(rel, BTREE_METAPAGE, BT_READ); - metapg = BufferGetPage(metabuf); + metapg = BufferGetPage(metabuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); metaopaque = (BTPageOpaque) PageGetSpecialPointer(metapg); metad = BTPageGetMeta(metapg); @@ -397,7 +397,7 @@ _bt_gettrueroot(Relation rel) for (;;) { rootbuf = _bt_relandgetbuf(rel, rootbuf, rootblkno, BT_READ); - rootpage = BufferGetPage(rootbuf); + rootpage = BufferGetPage(rootbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); rootopaque = (BTPageOpaque) PageGetSpecialPointer(rootpage); if (!P_IGNORE(rootopaque)) @@ -446,7 +446,7 @@ _bt_getrootheight(Relation rel) BTPageOpaque metaopaque; metabuf = _bt_getbuf(rel, BTREE_METAPAGE, BT_READ); - metapg = BufferGetPage(metabuf); + metapg = BufferGetPage(metabuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); metaopaque = (BTPageOpaque) PageGetSpecialPointer(metapg); metad = BTPageGetMeta(metapg); @@ -501,7 +501,7 @@ _bt_getrootheight(Relation rel) void _bt_checkpage(Relation rel, Buffer buf) { - Page page = BufferGetPage(buf); + Page page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* * ReadBuffer verifies that every newly-read page passes @@ -616,7 +616,7 @@ _bt_getbuf(Relation rel, BlockNumber blkno, int access) buf = ReadBuffer(rel, blkno); if (ConditionalLockBuffer(buf)) { - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (_bt_page_recyclable(page)) { /* @@ -674,7 +674,7 @@ _bt_getbuf(Relation rel, BlockNumber blkno, int access) UnlockRelationForExtension(rel, ExclusiveLock); /* Initialize the new page before returning it */ - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); Assert(PageIsNew(page)); _bt_pageinit(page, BufferGetPageSize(buf)); } @@ -789,7 +789,7 @@ _bt_delitems_vacuum(Relation rel, Buffer buf, OffsetNumber *itemnos, int nitems, BlockNumber lastBlockVacuumed) { - Page page = BufferGetPage(buf); + Page page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); BTPageOpaque opaque; /* No ereport(ERROR) until changes are logged */ @@ -862,7 +862,7 @@ _bt_delitems_delete(Relation rel, Buffer buf, OffsetNumber *itemnos, int nitems, Relation heapRel) { - Page page = BufferGetPage(buf); + Page page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); BTPageOpaque opaque; /* Shouldn't be called unless there's something to do */ @@ -931,7 +931,7 @@ _bt_is_page_halfdead(Relation rel, BlockNumber blk) bool result; buf = _bt_getbuf(rel, blk, BT_READ); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); result = P_ISHALFDEAD(opaque); @@ -991,7 +991,7 @@ _bt_lock_branch_parent(Relation rel, BlockNumber child, BTStack stack, parent = stack->bts_blkno; poffset = stack->bts_offset; - page = BufferGetPage(pbuf); + page = BufferGetPage(pbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); maxoff = PageGetMaxOffsetNumber(page); @@ -1035,7 +1035,7 @@ _bt_lock_branch_parent(Relation rel, BlockNumber child, BTStack stack, BTPageOpaque lopaque; lbuf = _bt_getbuf(rel, leftsib, BT_READ); - lpage = BufferGetPage(lbuf); + lpage = BufferGetPage(lbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); lopaque = (BTPageOpaque) PageGetSpecialPointer(lpage); /* @@ -1126,7 +1126,7 @@ _bt_pagedel(Relation rel, Buffer buf) for (;;) { - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); /* @@ -1231,7 +1231,7 @@ _bt_pagedel(Relation rel, Buffer buf) Page lpage; lbuf = _bt_getbuf(rel, leftsib, BT_READ); - lpage = BufferGetPage(lbuf); + lpage = BufferGetPage(lbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); lopaque = (BTPageOpaque) PageGetSpecialPointer(lpage); /* @@ -1332,7 +1332,7 @@ _bt_mark_page_halfdead(Relation rel, Buffer leafbuf, BTStack stack) IndexTuple itup; IndexTupleData trunctuple; - page = BufferGetPage(leafbuf); + page = BufferGetPage(leafbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); Assert(!P_RIGHTMOST(opaque) && !P_ISROOT(opaque) && !P_ISDELETED(opaque) && @@ -1385,7 +1385,7 @@ _bt_mark_page_halfdead(Relation rel, Buffer leafbuf, BTStack stack) * contents. The test on the next-child downlink is known to sometimes * fail in the field, though. */ - page = BufferGetPage(topparent); + page = BufferGetPage(topparent, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); #ifdef USE_ASSERT_CHECKING @@ -1417,7 +1417,7 @@ _bt_mark_page_halfdead(Relation rel, Buffer leafbuf, BTStack stack) * to copy the right sibling's downlink over the target downlink, and then * delete the following item. */ - page = BufferGetPage(topparent); + page = BufferGetPage(topparent, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); itemid = PageGetItemId(page, topoff); @@ -1432,7 +1432,7 @@ _bt_mark_page_halfdead(Relation rel, Buffer leafbuf, BTStack stack) * highest internal page in the branch we're deleting. We use the tid of * the high key to store it. */ - page = BufferGetPage(leafbuf); + page = BufferGetPage(leafbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); opaque->btpo_flags |= BTP_HALF_DEAD; @@ -1469,7 +1469,7 @@ _bt_mark_page_halfdead(Relation rel, Buffer leafbuf, BTStack stack) XLogRegisterBuffer(0, leafbuf, REGBUF_WILL_INIT); XLogRegisterBuffer(1, topparent, REGBUF_STANDARD); - page = BufferGetPage(leafbuf); + page = BufferGetPage(leafbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); xlrec.leftblk = opaque->btpo_prev; xlrec.rightblk = opaque->btpo_next; @@ -1478,9 +1478,9 @@ _bt_mark_page_halfdead(Relation rel, Buffer leafbuf, BTStack stack) recptr = XLogInsert(RM_BTREE_ID, XLOG_BTREE_MARK_PAGE_HALFDEAD); - page = BufferGetPage(topparent); + page = BufferGetPage(topparent, NULL, NULL, BGP_NO_SNAPSHOT_TEST); PageSetLSN(page, recptr); - page = BufferGetPage(leafbuf); + page = BufferGetPage(leafbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); PageSetLSN(page, recptr); } @@ -1525,7 +1525,7 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, bool *rightsib_empty) ItemPointer leafhikey; BlockNumber nextchild; - page = BufferGetPage(leafbuf); + page = BufferGetPage(leafbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); Assert(P_ISLEAF(opaque) && P_ISHALFDEAD(opaque)); @@ -1551,7 +1551,7 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, bool *rightsib_empty) /* fetch the block number of the topmost parent's left sibling */ buf = _bt_getbuf(rel, target, BT_READ); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); leftsib = opaque->btpo_prev; targetlevel = opaque->btpo.level; @@ -1589,7 +1589,7 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, bool *rightsib_empty) if (leftsib != P_NONE) { lbuf = _bt_getbuf(rel, leftsib, BT_WRITE); - page = BufferGetPage(lbuf); + page = BufferGetPage(lbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); while (P_ISDELETED(opaque) || opaque->btpo_next != target) { @@ -1603,7 +1603,7 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, bool *rightsib_empty) return false; } lbuf = _bt_getbuf(rel, leftsib, BT_WRITE); - page = BufferGetPage(lbuf); + page = BufferGetPage(lbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); } } @@ -1616,7 +1616,7 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, bool *rightsib_empty) * empty page. */ LockBuffer(buf, BT_WRITE); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); /* @@ -1660,7 +1660,7 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, bool *rightsib_empty) */ rightsib = opaque->btpo_next; rbuf = _bt_getbuf(rel, rightsib, BT_WRITE); - page = BufferGetPage(rbuf); + page = BufferGetPage(rbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); if (opaque->btpo_prev != target) elog(ERROR, "right sibling's left-link doesn't match: " @@ -1684,13 +1684,13 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, bool *rightsib_empty) */ if (leftsib == P_NONE && rightsib_is_rightmost) { - page = BufferGetPage(rbuf); + page = BufferGetPage(rbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); if (P_RIGHTMOST(opaque)) { /* rightsib will be the only one left on the level */ metabuf = _bt_getbuf(rel, BTREE_METAPAGE, BT_WRITE); - metapg = BufferGetPage(metabuf); + metapg = BufferGetPage(metabuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); metad = BTPageGetMeta(metapg); /* @@ -1721,12 +1721,12 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, bool *rightsib_empty) */ if (BufferIsValid(lbuf)) { - page = BufferGetPage(lbuf); + page = BufferGetPage(lbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); Assert(opaque->btpo_next == target); opaque->btpo_next = rightsib; } - page = BufferGetPage(rbuf); + page = BufferGetPage(rbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); Assert(opaque->btpo_prev == target); opaque->btpo_prev = leftsib; @@ -1754,7 +1754,7 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, bool *rightsib_empty) * will continue to do so, holding back RecentGlobalXmin, for the duration * of that scan. */ - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); opaque->btpo_flags &= ~BTP_HALF_DEAD; opaque->btpo_flags |= BTP_DELETED; @@ -1826,18 +1826,18 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, bool *rightsib_empty) { PageSetLSN(metapg, recptr); } - page = BufferGetPage(rbuf); + page = BufferGetPage(rbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); PageSetLSN(page, recptr); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); PageSetLSN(page, recptr); if (BufferIsValid(lbuf)) { - page = BufferGetPage(lbuf); + page = BufferGetPage(lbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); PageSetLSN(page, recptr); } if (target != leafblkno) { - page = BufferGetPage(leafbuf); + page = BufferGetPage(leafbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); PageSetLSN(page, recptr); } } diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c index bf8ade375d..5d4eefc7d7 100644 --- a/src/backend/access/nbtree/nbtree.c +++ b/src/backend/access/nbtree/nbtree.c @@ -910,7 +910,7 @@ restart: buf = ReadBufferExtended(rel, MAIN_FORKNUM, blkno, RBM_NORMAL, info->strategy); LockBuffer(buf, BT_READ); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (!PageIsNew(page)) { _bt_checkpage(rel, buf); diff --git a/src/backend/access/nbtree/nbtsearch.c b/src/backend/access/nbtree/nbtsearch.c index 14dffe07db..83f790f791 100644 --- a/src/backend/access/nbtree/nbtsearch.c +++ b/src/backend/access/nbtree/nbtsearch.c @@ -30,7 +30,7 @@ static bool _bt_readpage(IndexScanDesc scan, ScanDirection dir, static void _bt_saveitem(BTScanOpaque so, int itemIndex, OffsetNumber offnum, IndexTuple itup); static bool _bt_steppage(IndexScanDesc scan, ScanDirection dir); -static Buffer _bt_walk_left(Relation rel, Buffer buf); +static Buffer _bt_walk_left(Relation rel, Buffer buf, Snapshot snapshot); static bool _bt_endpoint(IndexScanDesc scan, ScanDirection dir); static void _bt_drop_lock_and_maybe_pin(IndexScanDesc scan, BTScanPos sp); @@ -96,7 +96,9 @@ _bt_search(Relation rel, int keysz, ScanKey scankey, bool nextkey, /* If index is empty and access = BT_READ, no root page is created. */ if (!BufferIsValid(*bufP)) + { return (BTStack) NULL; + } /* Loop iterates once per level descended in the tree */ for (;;) @@ -127,7 +129,7 @@ _bt_search(Relation rel, int keysz, ScanKey scankey, bool nextkey, BT_READ); /* if this is a leaf page, we're done */ - page = BufferGetPage(*bufP); + page = BufferGetPage(*bufP, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); if (P_ISLEAF(opaque)) break; @@ -231,7 +233,7 @@ _bt_moveright(Relation rel, for (;;) { - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); if (P_RIGHTMOST(opaque)) @@ -319,7 +321,7 @@ _bt_binsrch(Relation rel, int32 result, cmpval; - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); low = P_FIRSTDATAKEY(opaque); @@ -1141,7 +1143,7 @@ _bt_readpage(IndexScanDesc scan, ScanDirection dir, OffsetNumber offnum) */ Assert(BufferIsValid(so->currPos.buf)); - page = BufferGetPage(so->currPos.buf); + page = BufferGetPage(so->currPos.buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); minoff = P_FIRSTDATAKEY(opaque); maxoff = PageGetMaxOffsetNumber(page); @@ -1335,7 +1337,8 @@ _bt_steppage(IndexScanDesc scan, ScanDirection dir) /* step right one page */ so->currPos.buf = _bt_getbuf(rel, blkno, BT_READ); /* check for deleted page */ - page = BufferGetPage(so->currPos.buf); + page = BufferGetPage(so->currPos.buf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); if (!P_IGNORE(opaque)) { @@ -1394,7 +1397,8 @@ _bt_steppage(IndexScanDesc scan, ScanDirection dir) } /* Step to next physical page */ - so->currPos.buf = _bt_walk_left(rel, so->currPos.buf); + so->currPos.buf = _bt_walk_left(rel, so->currPos.buf, + scan->xs_snapshot); /* if we're physically at end of index, return failure */ if (so->currPos.buf == InvalidBuffer) @@ -1408,7 +1412,8 @@ _bt_steppage(IndexScanDesc scan, ScanDirection dir) * it's not half-dead and contains matching tuples. Else loop back * and do it all again. */ - page = BufferGetPage(so->currPos.buf); + page = BufferGetPage(so->currPos.buf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); if (!P_IGNORE(opaque)) { @@ -1442,12 +1447,12 @@ _bt_steppage(IndexScanDesc scan, ScanDirection dir) * again if it's important. */ static Buffer -_bt_walk_left(Relation rel, Buffer buf) +_bt_walk_left(Relation rel, Buffer buf, Snapshot snapshot) { Page page; BTPageOpaque opaque; - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); for (;;) @@ -1471,7 +1476,7 @@ _bt_walk_left(Relation rel, Buffer buf) /* check for interrupts while we're not holding any buffer lock */ CHECK_FOR_INTERRUPTS(); buf = _bt_getbuf(rel, blkno, BT_READ); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); /* @@ -1497,13 +1502,14 @@ _bt_walk_left(Relation rel, Buffer buf) break; blkno = opaque->btpo_next; buf = _bt_relandgetbuf(rel, buf, blkno, BT_READ); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); } /* Return to the original page to see what's up */ buf = _bt_relandgetbuf(rel, buf, obknum, BT_READ); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); if (P_ISDELETED(opaque)) { @@ -1520,7 +1526,8 @@ _bt_walk_left(Relation rel, Buffer buf) RelationGetRelationName(rel)); blkno = opaque->btpo_next; buf = _bt_relandgetbuf(rel, buf, blkno, BT_READ); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); if (!P_ISDELETED(opaque)) break; @@ -1579,7 +1586,7 @@ _bt_get_endpoint(Relation rel, uint32 level, bool rightmost) if (!BufferIsValid(buf)) return InvalidBuffer; - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); for (;;) @@ -1598,7 +1605,8 @@ _bt_get_endpoint(Relation rel, uint32 level, bool rightmost) elog(ERROR, "fell off the end of index \"%s\"", RelationGetRelationName(rel)); buf = _bt_relandgetbuf(rel, buf, blkno, BT_READ); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); } @@ -1619,7 +1627,7 @@ _bt_get_endpoint(Relation rel, uint32 level, bool rightmost) blkno = ItemPointerGetBlockNumber(&(itup->t_tid)); buf = _bt_relandgetbuf(rel, buf, blkno, BT_READ); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); } @@ -1665,7 +1673,7 @@ _bt_endpoint(IndexScanDesc scan, ScanDirection dir) } PredicateLockPage(rel, BufferGetBlockNumber(buf), scan->xs_snapshot); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); opaque = (BTPageOpaque) PageGetSpecialPointer(page); Assert(P_ISLEAF(opaque)); diff --git a/src/backend/access/nbtree/nbtutils.c b/src/backend/access/nbtree/nbtutils.c index 83c553ca27..edd36f996e 100644 --- a/src/backend/access/nbtree/nbtutils.c +++ b/src/backend/access/nbtree/nbtutils.c @@ -1756,7 +1756,7 @@ _bt_killitems(IndexScanDesc scan) */ LockBuffer(so->currPos.buf, BT_READ); - page = BufferGetPage(so->currPos.buf); + page = BufferGetPage(so->currPos.buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); } else { @@ -1769,7 +1769,7 @@ _bt_killitems(IndexScanDesc scan) if (!BufferIsValid(buf)) return; - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (PageGetLSN(page) == so->currPos.lsn) so->currPos.buf = buf; else diff --git a/src/backend/access/nbtree/nbtxlog.c b/src/backend/access/nbtree/nbtxlog.c index f8691bbc44..e49aad44a9 100644 --- a/src/backend/access/nbtree/nbtxlog.c +++ b/src/backend/access/nbtree/nbtxlog.c @@ -89,7 +89,7 @@ _bt_restore_meta(XLogReaderState *record, uint8 block_id) Assert(len == sizeof(xl_btree_metadata)); Assert(BufferGetBlockNumber(metabuf) == BTREE_METAPAGE); xlrec = (xl_btree_metadata *) ptr; - metapg = BufferGetPage(metabuf); + metapg = BufferGetPage(metabuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); _bt_pageinit(metapg, BufferGetPageSize(metabuf)); @@ -130,7 +130,8 @@ _bt_clear_incomplete_split(XLogReaderState *record, uint8 block_id) if (XLogReadBufferForRedo(record, block_id, &buf) == BLK_NEEDS_REDO) { - Page page = (Page) BufferGetPage(buf); + Page page = BufferGetPage(buf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); BTPageOpaque pageop = (BTPageOpaque) PageGetSpecialPointer(page); Assert((pageop->btpo_flags & BTP_INCOMPLETE_SPLIT) != 0); @@ -167,7 +168,7 @@ btree_xlog_insert(bool isleaf, bool ismeta, XLogReaderState *record) Size datalen; char *datapos = XLogRecGetBlockData(record, 0, &datalen); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (PageAddItem(page, (Item) datapos, datalen, xlrec->offnum, false, false) == InvalidOffsetNumber) @@ -224,7 +225,7 @@ btree_xlog_split(bool onleft, bool isroot, XLogReaderState *record) /* Reconstruct right (new) sibling page from scratch */ rbuf = XLogInitBufferForRedo(record, 1); datapos = XLogRecGetBlockData(record, 1, &datalen); - rpage = (Page) BufferGetPage(rbuf); + rpage = BufferGetPage(rbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); _bt_pageinit(rpage, BufferGetPageSize(rbuf)); ropaque = (BTPageOpaque) PageGetSpecialPointer(rpage); @@ -266,7 +267,8 @@ btree_xlog_split(bool onleft, bool isroot, XLogReaderState *record) * but it helps debugging. See also _bt_restore_page(), which does * the same for the right page. */ - Page lpage = (Page) BufferGetPage(lbuf); + Page lpage = BufferGetPage(lbuf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); BTPageOpaque lopaque = (BTPageOpaque) PageGetSpecialPointer(lpage); OffsetNumber off; Item newitem = NULL; @@ -368,7 +370,8 @@ btree_xlog_split(bool onleft, bool isroot, XLogReaderState *record) if (XLogReadBufferForRedo(record, 2, &buffer) == BLK_NEEDS_REDO) { - Page page = (Page) BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); BTPageOpaque pageop = (BTPageOpaque) PageGetSpecialPointer(page); pageop->btpo_prev = rightsib; @@ -476,7 +479,7 @@ btree_xlog_vacuum(XLogReaderState *record) ptr = XLogRecGetBlockData(record, 0, &len); - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (len > 0) { @@ -570,7 +573,7 @@ btree_xlog_delete_get_latestRemovedXid(XLogReaderState *record) if (!BufferIsValid(ibuffer)) return InvalidTransactionId; LockBuffer(ibuffer, BT_READ); - ipage = (Page) BufferGetPage(ibuffer); + ipage = BufferGetPage(ibuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* * Loop through the deleted index items to obtain the TransactionId from @@ -597,7 +600,7 @@ btree_xlog_delete_get_latestRemovedXid(XLogReaderState *record) return InvalidTransactionId; } LockBuffer(hbuffer, BUFFER_LOCK_SHARE); - hpage = (Page) BufferGetPage(hbuffer); + hpage = BufferGetPage(hbuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* * Look up the heap tuple header that the index tuple points at by @@ -693,7 +696,7 @@ btree_xlog_delete(XLogReaderState *record) */ if (XLogReadBufferForRedo(record, 0, &buffer) == BLK_NEEDS_REDO) { - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (XLogRecGetDataLen(record) > SizeOfBtreeDelete) { @@ -745,7 +748,7 @@ btree_xlog_mark_page_halfdead(uint8 info, XLogReaderState *record) OffsetNumber nextoffset; BlockNumber rightsib; - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); pageop = (BTPageOpaque) PageGetSpecialPointer(page); poffset = xlrec->poffset; @@ -769,7 +772,7 @@ btree_xlog_mark_page_halfdead(uint8 info, XLogReaderState *record) /* Rewrite the leaf page as a halfdead page */ buffer = XLogInitBufferForRedo(record, 0); - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); _bt_pageinit(page, BufferGetPageSize(buffer)); pageop = (BTPageOpaque) PageGetSpecialPointer(page); @@ -825,7 +828,7 @@ btree_xlog_unlink_page(uint8 info, XLogReaderState *record) /* Fix left-link of right sibling */ if (XLogReadBufferForRedo(record, 2, &buffer) == BLK_NEEDS_REDO) { - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); pageop = (BTPageOpaque) PageGetSpecialPointer(page); pageop->btpo_prev = leftsib; @@ -840,7 +843,7 @@ btree_xlog_unlink_page(uint8 info, XLogReaderState *record) { if (XLogReadBufferForRedo(record, 1, &buffer) == BLK_NEEDS_REDO) { - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); pageop = (BTPageOpaque) PageGetSpecialPointer(page); pageop->btpo_next = rightsib; @@ -853,7 +856,7 @@ btree_xlog_unlink_page(uint8 info, XLogReaderState *record) /* Rewrite target page as empty deleted page */ buffer = XLogInitBufferForRedo(record, 0); - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); _bt_pageinit(page, BufferGetPageSize(buffer)); pageop = (BTPageOpaque) PageGetSpecialPointer(page); @@ -882,7 +885,7 @@ btree_xlog_unlink_page(uint8 info, XLogReaderState *record) IndexTupleData trunctuple; buffer = XLogInitBufferForRedo(record, 3); - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); _bt_pageinit(page, BufferGetPageSize(buffer)); pageop = (BTPageOpaque) PageGetSpecialPointer(page); @@ -926,7 +929,7 @@ btree_xlog_newroot(XLogReaderState *record) Size len; buffer = XLogInitBufferForRedo(record, 0); - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); _bt_pageinit(page, BufferGetPageSize(buffer)); pageop = (BTPageOpaque) PageGetSpecialPointer(page); diff --git a/src/backend/access/spgist/spgdoinsert.c b/src/backend/access/spgist/spgdoinsert.c index f090ca528b..b780bfea44 100644 --- a/src/backend/access/spgist/spgdoinsert.c +++ b/src/backend/access/spgist/spgdoinsert.c @@ -451,7 +451,7 @@ moveLeafs(Relation index, SpGistState *state, /* Find a leaf page that will hold them */ nbuf = SpGistGetBuffer(index, GBUF_LEAF | (isNulls ? GBUF_NULLS : 0), size, &xlrec.newPage); - npage = BufferGetPage(nbuf); + npage = BufferGetPage(nbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); nblkno = BufferGetBlockNumber(nbuf); Assert(nblkno != current->blkno); @@ -1037,7 +1037,8 @@ doPickSplit(Relation index, SpGistState *state, nodePageSelect = (uint8 *) palloc(sizeof(uint8) * out.nNodes); curspace = currentFreeSpace; - newspace = PageGetExactFreeSpace(BufferGetPage(newLeafBuffer)); + newspace = PageGetExactFreeSpace + (BufferGetPage(newLeafBuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST)); for (i = 0; i < out.nNodes; i++) { if (leafSizes[i] <= curspace) @@ -1070,7 +1071,9 @@ doPickSplit(Relation index, SpGistState *state, /* Repeat the node assignment process --- should succeed now */ curspace = currentFreeSpace; - newspace = PageGetExactFreeSpace(BufferGetPage(newLeafBuffer)); + newspace = PageGetExactFreeSpace + (BufferGetPage(newLeafBuffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST)); for (i = 0; i < out.nNodes; i++) { if (leafSizes[i] <= curspace) @@ -1201,7 +1204,9 @@ doPickSplit(Relation index, SpGistState *state, it->nextOffset = InvalidOffsetNumber; /* Insert it on page */ - newoffset = SpGistPageAddNewItem(state, BufferGetPage(leafBuffer), + newoffset = SpGistPageAddNewItem(state, + BufferGetPage(leafBuffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), (Item) it, it->size, &startOffsets[leafPageSelect[i]], false); @@ -1275,7 +1280,8 @@ doPickSplit(Relation index, SpGistState *state, /* Repoint "current" at the new inner tuple */ current->buffer = newInnerBuffer; current->blkno = BufferGetBlockNumber(current->buffer); - current->page = BufferGetPage(current->buffer); + current->page = BufferGetPage(current->buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); xlrec.offnumInner = current->offnum = SpGistPageAddNewItem(state, current->page, (Item) innerTuple, innerTuple->size, @@ -1391,24 +1397,22 @@ doPickSplit(Relation index, SpGistState *state, /* Update page LSNs on all affected pages */ if (newLeafBuffer != InvalidBuffer) { - Page page = BufferGetPage(newLeafBuffer); - + Page page = BufferGetPage(newLeafBuffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); PageSetLSN(page, recptr); } if (saveCurrent.buffer != InvalidBuffer) { - Page page = BufferGetPage(saveCurrent.buffer); - + Page page = BufferGetPage(saveCurrent.buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); PageSetLSN(page, recptr); } PageSetLSN(current->page, recptr); if (parent->buffer != InvalidBuffer) - { PageSetLSN(parent->page, recptr); - } } END_CRIT_SECTION(); @@ -1578,7 +1582,8 @@ spgAddNodeAction(Relation index, SpGistState *state, newInnerTuple->size + sizeof(ItemIdData), &xlrec.newPage); current->blkno = BufferGetBlockNumber(current->buffer); - current->page = BufferGetPage(current->buffer); + current->page = BufferGetPage(current->buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); /* * Let's just make real sure new current isn't same as old. Right now @@ -1793,7 +1798,9 @@ spgSplitNodeAction(Relation index, SpGistState *state, { postfixBlkno = BufferGetBlockNumber(newBuffer); xlrec.offnumPostfix = postfixOffset = - SpGistPageAddNewItem(state, BufferGetPage(newBuffer), + SpGistPageAddNewItem(state, + BufferGetPage(newBuffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), (Item) postfixTuple, postfixTuple->size, NULL, false); MarkBufferDirty(newBuffer); @@ -1840,7 +1847,8 @@ spgSplitNodeAction(Relation index, SpGistState *state, if (newBuffer != InvalidBuffer) { - PageSetLSN(BufferGetPage(newBuffer), recptr); + PageSetLSN(BufferGetPage(newBuffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), recptr); } } @@ -1984,7 +1992,8 @@ spgdoinsert(Relation index, SpGistState *state, /* inner tuple can be stored on the same page as parent one */ current.buffer = parent.buffer; } - current.page = BufferGetPage(current.buffer); + current.page = BufferGetPage(current.buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); /* should not arrive at a page of the wrong type */ if (isnull ? !SpGistPageStoresNulls(current.page) : diff --git a/src/backend/access/spgist/spginsert.c b/src/backend/access/spgist/spginsert.c index 44fd644e42..3e16b511ac 100644 --- a/src/backend/access/spgist/spginsert.c +++ b/src/backend/access/spgist/spginsert.c @@ -92,7 +92,8 @@ spgbuild(Relation heap, Relation index, IndexInfo *indexInfo) START_CRIT_SECTION(); - SpGistInitMetapage(BufferGetPage(metabuffer)); + SpGistInitMetapage(BufferGetPage(metabuffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST)); MarkBufferDirty(metabuffer); SpGistInitBuffer(rootbuffer, SPGIST_LEAF); MarkBufferDirty(rootbuffer); @@ -115,9 +116,12 @@ spgbuild(Relation heap, Relation index, IndexInfo *indexInfo) recptr = XLogInsert(RM_SPGIST_ID, XLOG_SPGIST_CREATE_INDEX); - PageSetLSN(BufferGetPage(metabuffer), recptr); - PageSetLSN(BufferGetPage(rootbuffer), recptr); - PageSetLSN(BufferGetPage(nullbuffer), recptr); + PageSetLSN(BufferGetPage(metabuffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), recptr); + PageSetLSN(BufferGetPage(rootbuffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), recptr); + PageSetLSN(BufferGetPage(nullbuffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), recptr); } END_CRIT_SECTION(); diff --git a/src/backend/access/spgist/spgscan.c b/src/backend/access/spgist/spgscan.c index 8aa28ecbc3..fafdca31f3 100644 --- a/src/backend/access/spgist/spgscan.c +++ b/src/backend/access/spgist/spgscan.c @@ -301,7 +301,7 @@ spgLeafTest(Relation index, SpGistScanOpaque so, */ static void spgWalk(Relation index, SpGistScanOpaque so, bool scanWholeIndex, - storeRes_func storeRes) + storeRes_func storeRes, Snapshot snapshot) { Buffer buffer = InvalidBuffer; bool reportedSome = false; @@ -341,7 +341,7 @@ redirect: } /* else new pointer points to the same page, no work needed */ - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); isnull = SpGistPageStoresNulls(page) ? true : false; @@ -576,7 +576,7 @@ spggetbitmap(IndexScanDesc scan, TIDBitmap *tbm) so->tbm = tbm; so->ntids = 0; - spgWalk(scan->indexRelation, so, true, storeBitmap); + spgWalk(scan->indexRelation, so, true, storeBitmap, scan->xs_snapshot); return so->ntids; } @@ -635,7 +635,8 @@ spggettuple(IndexScanDesc scan, ScanDirection dir) } so->iPtr = so->nPtrs = 0; - spgWalk(scan->indexRelation, so, false, storeGettuple); + spgWalk(scan->indexRelation, so, false, storeGettuple, + scan->xs_snapshot); if (so->nPtrs == 0) break; /* must have completed scan */ diff --git a/src/backend/access/spgist/spgutils.c b/src/backend/access/spgist/spgutils.c index 201203f91a..f4bcbeeb4a 100644 --- a/src/backend/access/spgist/spgutils.c +++ b/src/backend/access/spgist/spgutils.c @@ -126,7 +126,8 @@ spgGetCache(Relation index) metabuffer = ReadBuffer(index, SPGIST_METAPAGE_BLKNO); LockBuffer(metabuffer, BUFFER_LOCK_SHARE); - metadata = SpGistPageGetMeta(BufferGetPage(metabuffer)); + metadata = SpGistPageGetMeta + (BufferGetPage(metabuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST)); if (metadata->magicNumber != SPGIST_MAGIC_NUMBER) elog(ERROR, "index \"%s\" is not an SP-GiST index", @@ -206,7 +207,8 @@ SpGistNewBuffer(Relation index) */ if (ConditionalLockBuffer(buffer)) { - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); if (PageIsNew(page)) return buffer; /* OK to use, if never initialized */ @@ -256,7 +258,8 @@ SpGistUpdateMetaPage(Relation index) if (ConditionalLockBuffer(metabuffer)) { - metadata = SpGistPageGetMeta(BufferGetPage(metabuffer)); + metadata = SpGistPageGetMeta + (BufferGetPage(metabuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST)); metadata->lastUsedPages = cache->lastUsedPages; MarkBufferDirty(metabuffer); @@ -333,7 +336,9 @@ allocNewBuffer(Relation index, int flags) blkFlags |= GBUF_NULLS; cache->lastUsedPages.cachedPage[blkFlags].blkno = blkno; cache->lastUsedPages.cachedPage[blkFlags].freeSpace = - PageGetExactFreeSpace(BufferGetPage(buffer)); + PageGetExactFreeSpace + (BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST)); UnlockReleaseBuffer(buffer); } } @@ -401,7 +406,7 @@ SpGistGetBuffer(Relation index, int flags, int needSpace, bool *isNew) return allocNewBuffer(index, flags); } - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (PageIsNew(page) || SpGistPageIsDeleted(page) || PageIsEmpty(page)) { @@ -460,7 +465,7 @@ SpGistSetLastUsedPage(Relation index, Buffer buffer) SpGistCache *cache = spgGetCache(index); SpGistLastUsedPage *lup; int freeSpace; - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); BlockNumber blkno = BufferGetBlockNumber(buffer); int flags; @@ -508,7 +513,7 @@ void SpGistInitBuffer(Buffer b, uint16 f) { Assert(BufferGetPageSize(b) == BLCKSZ); - SpGistInitPage(BufferGetPage(b), f); + SpGistInitPage(BufferGetPage(b, NULL, NULL, BGP_NO_SNAPSHOT_TEST), f); } /* diff --git a/src/backend/access/spgist/spgvacuum.c b/src/backend/access/spgist/spgvacuum.c index 15b867f24c..6b57790a6a 100644 --- a/src/backend/access/spgist/spgvacuum.c +++ b/src/backend/access/spgist/spgvacuum.c @@ -125,7 +125,8 @@ static void vacuumLeafPage(spgBulkDeleteState *bds, Relation index, Buffer buffer, bool forPending) { - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); spgxlogVacuumLeaf xlrec; OffsetNumber toDead[MaxIndexTuplesPerPage]; OffsetNumber toPlaceholder[MaxIndexTuplesPerPage]; @@ -405,7 +406,8 @@ vacuumLeafPage(spgBulkDeleteState *bds, Relation index, Buffer buffer, static void vacuumLeafRoot(spgBulkDeleteState *bds, Relation index, Buffer buffer) { - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); spgxlogVacuumRoot xlrec; OffsetNumber toDelete[MaxIndexTuplesPerPage]; OffsetNumber i, @@ -490,7 +492,8 @@ vacuumLeafRoot(spgBulkDeleteState *bds, Relation index, Buffer buffer) static void vacuumRedirectAndPlaceholder(Relation index, Buffer buffer) { - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); SpGistPageOpaque opaque = SpGistPageGetOpaque(page); OffsetNumber i, max = PageGetMaxOffsetNumber(page), @@ -615,7 +618,7 @@ spgvacuumpage(spgBulkDeleteState *bds, BlockNumber blkno) buffer = ReadBufferExtended(index, MAIN_FORKNUM, blkno, RBM_NORMAL, bds->info->strategy); LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE); - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (PageIsNew(page)) { @@ -696,7 +699,7 @@ spgprocesspending(spgBulkDeleteState *bds) buffer = ReadBufferExtended(index, MAIN_FORKNUM, blkno, RBM_NORMAL, bds->info->strategy); LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE); - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (PageIsNew(page) || SpGistPageIsDeleted(page)) { diff --git a/src/backend/access/spgist/spgxlog.c b/src/backend/access/spgist/spgxlog.c index 01a4e0f252..b5fc2663f0 100644 --- a/src/backend/access/spgist/spgxlog.c +++ b/src/backend/access/spgist/spgxlog.c @@ -79,7 +79,7 @@ spgRedoCreateIndex(XLogReaderState *record) buffer = XLogInitBufferForRedo(record, 0); Assert(BufferGetBlockNumber(buffer) == SPGIST_METAPAGE_BLKNO); - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); SpGistInitMetapage(page); PageSetLSN(page, lsn); MarkBufferDirty(buffer); @@ -88,7 +88,7 @@ spgRedoCreateIndex(XLogReaderState *record) buffer = XLogInitBufferForRedo(record, 1); Assert(BufferGetBlockNumber(buffer) == SPGIST_ROOT_BLKNO); SpGistInitBuffer(buffer, SPGIST_LEAF); - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); PageSetLSN(page, lsn); MarkBufferDirty(buffer); UnlockReleaseBuffer(buffer); @@ -96,7 +96,7 @@ spgRedoCreateIndex(XLogReaderState *record) buffer = XLogInitBufferForRedo(record, 2); Assert(BufferGetBlockNumber(buffer) == SPGIST_NULL_BLKNO); SpGistInitBuffer(buffer, SPGIST_LEAF | SPGIST_NULLS); - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); PageSetLSN(page, lsn); MarkBufferDirty(buffer); UnlockReleaseBuffer(buffer); @@ -136,7 +136,7 @@ spgRedoAddLeaf(XLogReaderState *record) if (action == BLK_NEEDS_REDO) { - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* insert new tuple */ if (xldata->offnumLeaf != xldata->offnumHeadLeaf) @@ -183,7 +183,7 @@ spgRedoAddLeaf(XLogReaderState *record) XLogRecGetBlockTag(record, 0, NULL, NULL, &blknoLeaf); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); tuple = (SpGistInnerTuple) PageGetItem(page, PageGetItemId(page, xldata->offnumParent)); @@ -249,7 +249,7 @@ spgRedoMoveLeafs(XLogReaderState *record) { int i; - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); for (i = 0; i < nInsert; i++) { @@ -278,7 +278,7 @@ spgRedoMoveLeafs(XLogReaderState *record) /* Delete tuples from the source page, inserting a redirection pointer */ if (XLogReadBufferForRedo(record, 0, &buffer) == BLK_NEEDS_REDO) { - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); spgPageIndexMultiDelete(&state, page, toDelete, xldata->nMoves, state.isBuild ? SPGIST_PLACEHOLDER : SPGIST_REDIRECT, @@ -297,7 +297,7 @@ spgRedoMoveLeafs(XLogReaderState *record) { SpGistInnerTuple tuple; - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); tuple = (SpGistInnerTuple) PageGetItem(page, PageGetItemId(page, xldata->offnumParent)); @@ -338,7 +338,7 @@ spgRedoAddNode(XLogReaderState *record) Assert(xldata->parentBlk == -1); if (XLogReadBufferForRedo(record, 0, &buffer) == BLK_NEEDS_REDO) { - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); PageIndexTupleDelete(page, xldata->offnum); if (PageAddItem(page, (Item) innerTuple, innerTupleHdr.size, @@ -381,7 +381,7 @@ spgRedoAddNode(XLogReaderState *record) action = XLogReadBufferForRedo(record, 1, &buffer); if (action == BLK_NEEDS_REDO) { - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); addOrReplaceTuple(page, (Item) innerTuple, innerTupleHdr.size, xldata->offnumNew); @@ -410,7 +410,7 @@ spgRedoAddNode(XLogReaderState *record) { SpGistDeadTuple dt; - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (state.isBuild) dt = spgFormDeadTuple(&state, SPGIST_PLACEHOLDER, @@ -462,7 +462,7 @@ spgRedoAddNode(XLogReaderState *record) { SpGistInnerTuple parentTuple; - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); parentTuple = (SpGistInnerTuple) PageGetItem(page, PageGetItemId(page, xldata->offnumParent)); @@ -522,7 +522,7 @@ spgRedoSplitTuple(XLogReaderState *record) action = XLogReadBufferForRedo(record, 1, &buffer); if (action == BLK_NEEDS_REDO) { - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); addOrReplaceTuple(page, (Item) postfixTuple, postfixTupleHdr.size, xldata->offnumPostfix); @@ -537,7 +537,7 @@ spgRedoSplitTuple(XLogReaderState *record) /* now handle the original page */ if (XLogReadBufferForRedo(record, 0, &buffer) == BLK_NEEDS_REDO) { - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); PageIndexTupleDelete(page, xldata->offnumPrefix); if (PageAddItem(page, (Item) prefixTuple, prefixTupleHdr.size, @@ -608,7 +608,7 @@ spgRedoPickSplit(XLogReaderState *record) { /* just re-init the source page */ srcBuffer = XLogInitBufferForRedo(record, 0); - srcPage = (Page) BufferGetPage(srcBuffer); + srcPage = BufferGetPage(srcBuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); SpGistInitBuffer(srcBuffer, SPGIST_LEAF | (xldata->storesNulls ? SPGIST_NULLS : 0)); @@ -625,7 +625,7 @@ spgRedoPickSplit(XLogReaderState *record) srcPage = NULL; if (XLogReadBufferForRedo(record, 0, &srcBuffer) == BLK_NEEDS_REDO) { - srcPage = BufferGetPage(srcBuffer); + srcPage = BufferGetPage(srcBuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* * We have it a bit easier here than in doPickSplit(), because we @@ -661,7 +661,8 @@ spgRedoPickSplit(XLogReaderState *record) { /* just re-init the dest page */ destBuffer = XLogInitBufferForRedo(record, 1); - destPage = (Page) BufferGetPage(destBuffer); + destPage = BufferGetPage(destBuffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); SpGistInitBuffer(destBuffer, SPGIST_LEAF | (xldata->storesNulls ? SPGIST_NULLS : 0)); @@ -674,7 +675,8 @@ spgRedoPickSplit(XLogReaderState *record) * full-page-image case, but for safety let's hold it till later. */ if (XLogReadBufferForRedo(record, 1, &destBuffer) == BLK_NEEDS_REDO) - destPage = (Page) BufferGetPage(destBuffer); + destPage = BufferGetPage(destBuffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); else destPage = NULL; /* don't do any page updates */ } @@ -722,7 +724,7 @@ spgRedoPickSplit(XLogReaderState *record) if (action == BLK_NEEDS_REDO) { - page = BufferGetPage(innerBuffer); + page = BufferGetPage(innerBuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); addOrReplaceTuple(page, (Item) innerTuple, innerTupleHdr.size, xldata->offnumInner); @@ -762,7 +764,8 @@ spgRedoPickSplit(XLogReaderState *record) { SpGistInnerTuple parent; - page = BufferGetPage(parentBuffer); + page = BufferGetPage(parentBuffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); parent = (SpGistInnerTuple) PageGetItem(page, PageGetItemId(page, xldata->offnumParent)); @@ -813,7 +816,7 @@ spgRedoVacuumLeaf(XLogReaderState *record) if (XLogReadBufferForRedo(record, 0, &buffer) == BLK_NEEDS_REDO) { - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); spgPageIndexMultiDelete(&state, page, toDead, xldata->nDead, @@ -876,7 +879,7 @@ spgRedoVacuumRoot(XLogReaderState *record) if (XLogReadBufferForRedo(record, 0, &buffer) == BLK_NEEDS_REDO) { - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* The tuple numbers are in order */ PageIndexMultiDelete(page, toDelete, xldata->nDelete); @@ -917,7 +920,8 @@ spgRedoVacuumRedirect(XLogReaderState *record) if (XLogReadBufferForRedo(record, 0, &buffer) == BLK_NEEDS_REDO) { - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); SpGistPageOpaque opaque = SpGistPageGetOpaque(page); int i; diff --git a/src/backend/access/transam/generic_xlog.c b/src/backend/access/transam/generic_xlog.c index e62179d2fb..4118d7bb08 100644 --- a/src/backend/access/transam/generic_xlog.c +++ b/src/backend/access/transam/generic_xlog.c @@ -95,7 +95,8 @@ writeFragment(PageData *pageData, OffsetNumber offset, OffsetNumber length, static void writeDelta(PageData *pageData) { - Page page = BufferGetPage(pageData->buffer), + Page page = BufferGetPage(pageData->buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), image = (Page) pageData->image; int i, fragmentBegin = -1, @@ -220,7 +221,8 @@ GenericXLogRegister(GenericXLogState *state, Buffer buffer, bool isNew) if (BufferIsInvalid(page->buffer)) { page->buffer = buffer; - memcpy(page->image, BufferGetPage(buffer), BLCKSZ); + memcpy(page->image, BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), BLCKSZ); page->dataLen = 0; page->fullImage = isNew; return (Page)page->image; @@ -295,8 +297,10 @@ GenericXLogFinish(GenericXLogState *state) /* Swap current and saved page image. */ memcpy(tmp, page->image, BLCKSZ); - memcpy(page->image, BufferGetPage(page->buffer), BLCKSZ); - memcpy(BufferGetPage(page->buffer), tmp, BLCKSZ); + memcpy(page->image, BufferGetPage(page->buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), BLCKSZ); + memcpy(BufferGetPage(page->buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), tmp, BLCKSZ); if (page->fullImage) { @@ -325,7 +329,8 @@ GenericXLogFinish(GenericXLogState *state) if (BufferIsInvalid(page->buffer)) continue; - PageSetLSN(BufferGetPage(page->buffer), lsn); + PageSetLSN(BufferGetPage(page->buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), lsn); MarkBufferDirty(page->buffer); } END_CRIT_SECTION(); @@ -340,7 +345,8 @@ GenericXLogFinish(GenericXLogState *state) if (BufferIsInvalid(page->buffer)) continue; - memcpy(BufferGetPage(page->buffer), page->image, BLCKSZ); + memcpy(BufferGetPage(page->buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), page->image, BLCKSZ); MarkBufferDirty(page->buffer); } END_CRIT_SECTION(); @@ -413,7 +419,7 @@ generic_redo(XLogReaderState *record) Size blockDataSize; Page page; - page = BufferGetPage(buffers[block_id]); + page = BufferGetPage(buffers[block_id], NULL, NULL, BGP_NO_SNAPSHOT_TEST); blockData = XLogRecGetBlockData(record, block_id, &blockDataSize); applyPageRedo(page, blockData, blockDataSize); diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index c37003a24c..1e336edfb5 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -228,7 +228,7 @@ XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags) regbuf = ®istered_buffers[block_id]; BufferGetTag(buffer, ®buf->rnode, ®buf->forkno, ®buf->block); - regbuf->page = BufferGetPage(buffer); + regbuf->page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); regbuf->flags = flags; regbuf->rdata_tail = (XLogRecData *) ®buf->rdata_head; regbuf->rdata_len = 0; @@ -825,7 +825,7 @@ XLogCheckBufferNeedsBackup(Buffer buffer) GetFullPageWriteInfo(&RedoRecPtr, &doPageWrites); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (doPageWrites && PageGetLSN(page) <= RedoRecPtr) return true; /* buffer requires backup */ @@ -896,7 +896,7 @@ XLogSaveBufferForHint(Buffer buffer, bool buffer_std) if (buffer_std) { /* Assume we can omit data between pd_lower and pd_upper */ - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); uint16 lower = ((PageHeader) page)->pd_lower; uint16 upper = ((PageHeader) page)->pd_upper; @@ -973,7 +973,7 @@ log_newpage(RelFileNode *rnode, ForkNumber forkNum, BlockNumber blkno, XLogRecPtr log_newpage_buffer(Buffer buffer, bool page_std) { - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); RelFileNode rnode; ForkNumber forkNum; BlockNumber blkno; diff --git a/src/backend/access/transam/xlogutils.c b/src/backend/access/transam/xlogutils.c index f6ca2b95e5..c3213ac0b6 100644 --- a/src/backend/access/transam/xlogutils.c +++ b/src/backend/access/transam/xlogutils.c @@ -358,7 +358,7 @@ XLogReadBufferForRedoExtended(XLogReaderState *record, { *buf = XLogReadBufferExtended(rnode, forknum, blkno, get_cleanup_lock ? RBM_ZERO_AND_CLEANUP_LOCK : RBM_ZERO_AND_LOCK); - page = BufferGetPage(*buf); + page = BufferGetPage(*buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (!RestoreBlockImage(record, block_id, page)) elog(ERROR, "failed to restore block image"); @@ -396,7 +396,8 @@ XLogReadBufferForRedoExtended(XLogReaderState *record, else LockBuffer(*buf, BUFFER_LOCK_EXCLUSIVE); } - if (lsn <= PageGetLSN(BufferGetPage(*buf))) + if (lsn <= PageGetLSN(BufferGetPage(*buf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST))) return BLK_DONE; else return BLK_NEEDS_REDO; @@ -502,7 +503,8 @@ XLogReadBufferExtended(RelFileNode rnode, ForkNumber forknum, if (mode == RBM_NORMAL) { /* check that page has been initialized */ - Page page = (Page) BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, + BGP_NO_SNAPSHOT_TEST); /* * We assume that PageIsNew is safe without a lock. During recovery, diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index 31a1438d4a..f8398dd16c 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -2306,7 +2306,7 @@ IndexBuildHeapRangeScan(Relation heapRelation, */ if (scan->rs_cblock != root_blkno) { - Page page = BufferGetPage(scan->rs_cbuf); + Page page = BufferGetPage(scan->rs_cbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); LockBuffer(scan->rs_cbuf, BUFFER_LOCK_SHARE); heap_get_root_tuples(page, root_offsets); @@ -3016,7 +3016,7 @@ validate_index_heapscan(Relation heapRelation, */ if (scan->rs_cblock != root_blkno) { - Page page = BufferGetPage(scan->rs_cbuf); + Page page = BufferGetPage(scan->rs_cbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); LockBuffer(scan->rs_cbuf, BUFFER_LOCK_SHARE); heap_get_root_tuples(page, root_offsets); diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index cf8c8164b7..8b41ab0828 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -1025,7 +1025,7 @@ acquire_sample_rows(Relation onerel, int elevel, targbuffer = ReadBufferExtended(onerel, MAIN_FORKNUM, targblock, RBM_NORMAL, vac_strategy); LockBuffer(targbuffer, BUFFER_LOCK_SHARE); - targpage = BufferGetPage(targbuffer); + targpage = BufferGetPage(targbuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); maxoffset = PageGetMaxOffsetNumber(targpage); /* Inner loop over all tuples on the selected page */ diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c index c98f981111..f38126f4f9 100644 --- a/src/backend/commands/sequence.c +++ b/src/backend/commands/sequence.c @@ -337,7 +337,7 @@ fill_seq_with_data(Relation rel, HeapTuple tuple) buf = ReadBuffer(rel, P_NEW); Assert(BufferGetBlockNumber(buf) == 0); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); PageInit(page, BufferGetPageSize(buf), sizeof(sequence_magic)); sm = (sequence_magic *) PageGetSpecialPointer(page); @@ -462,7 +462,7 @@ AlterSequence(AlterSeqStmt *stmt) { xl_seq_rec xlrec; XLogRecPtr recptr; - Page page = BufferGetPage(buf); + Page page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); XLogBeginInsert(); XLogRegisterBuffer(0, buf, REGBUF_WILL_INIT); @@ -584,7 +584,7 @@ nextval_internal(Oid relid) /* lock page' buffer and read tuple */ seq = read_seq_tuple(elm, seqrel, &buf, &seqtuple); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); last = next = result = seq->last_value; incby = seq->increment_by; @@ -923,7 +923,7 @@ do_setval(Oid relid, int64 next, bool iscalled) { xl_seq_rec xlrec; XLogRecPtr recptr; - Page page = BufferGetPage(buf); + Page page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); XLogBeginInsert(); XLogRegisterBuffer(0, buf, REGBUF_WILL_INIT); @@ -1115,7 +1115,7 @@ read_seq_tuple(SeqTable elm, Relation rel, Buffer *buf, HeapTuple seqtuple) *buf = ReadBuffer(rel, 0); LockBuffer(*buf, BUFFER_LOCK_EXCLUSIVE); - page = BufferGetPage(*buf); + page = BufferGetPage(*buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); sm = (sequence_magic *) PageGetSpecialPointer(page); if (sm->magic != SEQ_MAGIC) @@ -1591,7 +1591,7 @@ seq_redo(XLogReaderState *record) elog(PANIC, "seq_redo: unknown op code %u", info); buffer = XLogInitBufferForRedo(record, 0); - page = (Page) BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* * We always reinit the page. However, since this WAL record type is also diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index 6f728ff0fc..33107e02a9 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -2798,7 +2798,7 @@ ltrmark:; */ LockBuffer(buffer, BUFFER_LOCK_SHARE); - page = BufferGetPage(buffer); + page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); lp = PageGetItemId(page, ItemPointerGetOffsetNumber(tid)); Assert(ItemIdIsNormal(lp)); diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c index 52e19b3061..3f48ef4070 100644 --- a/src/backend/commands/vacuumlazy.c +++ b/src/backend/commands/vacuumlazy.c @@ -803,7 +803,7 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, vacrelstats->scanned_pages++; - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (PageIsNew(page)) { @@ -1378,7 +1378,7 @@ lazy_vacuum_heap(Relation onerel, LVRelStats *vacrelstats) &vmbuffer); /* Now that we've compacted the page, record its available space */ - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); freespace = PageGetHeapFreeSpace(page); UnlockReleaseBuffer(buf); @@ -1414,7 +1414,7 @@ static int lazy_vacuum_page(Relation onerel, BlockNumber blkno, Buffer buffer, int tupindex, LVRelStats *vacrelstats, Buffer *vmbuffer) { - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); OffsetNumber unused[MaxOffsetNumber]; int uncnt = 0; TransactionId visibility_cutoff_xid; @@ -1511,7 +1511,7 @@ lazy_vacuum_page(Relation onerel, BlockNumber blkno, Buffer buffer, static bool lazy_check_needs_freeze(Buffer buf, bool *hastup) { - Page page = BufferGetPage(buf); + Page page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); OffsetNumber offnum, maxoff; HeapTupleHeader tupleheader; @@ -1863,7 +1863,7 @@ count_nondeletable_pages(Relation onerel, LVRelStats *vacrelstats) /* In this phase we only need shared access to the buffer */ LockBuffer(buf, BUFFER_LOCK_SHARE); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (PageIsNew(page) || PageIsEmpty(page)) { @@ -2031,7 +2031,7 @@ heap_page_is_all_visible(Relation rel, Buffer buf, TransactionId *visibility_cutoff_xid, bool *all_frozen) { - Page page = BufferGetPage(buf); + Page page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); BlockNumber blockno = BufferGetBlockNumber(buf); OffsetNumber offnum, maxoff; diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c index 449aacb6e7..b7a2ca7fc6 100644 --- a/src/backend/executor/nodeBitmapHeapscan.c +++ b/src/backend/executor/nodeBitmapHeapscan.c @@ -257,7 +257,7 @@ BitmapHeapNext(BitmapHeapScanState *node) * Okay to fetch the tuple */ targoffset = scan->rs_vistuples[scan->rs_cindex]; - dp = (Page) BufferGetPage(scan->rs_cbuf); + dp = BufferGetPage(scan->rs_cbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); lp = PageGetItemId(dp, targoffset); Assert(ItemIdIsNormal(lp)); @@ -375,7 +375,7 @@ bitgetpage(HeapScanDesc scan, TBMIterateResult *tbmres) * Bitmap is lossy, so we must examine each item pointer on the page. * But we can ignore HOT chains, since we'll check each tuple anyway. */ - Page dp = (Page) BufferGetPage(buffer); + Page dp = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); OffsetNumber maxoff = PageGetMaxOffsetNumber(dp); OffsetNumber offnum; diff --git a/src/backend/executor/nodeSamplescan.c b/src/backend/executor/nodeSamplescan.c index 9ce7c02aff..e12b424bce 100644 --- a/src/backend/executor/nodeSamplescan.c +++ b/src/backend/executor/nodeSamplescan.c @@ -435,7 +435,7 @@ tablesample_getnext(SampleScanState *scanstate) if (!pagemode) LockBuffer(scan->rs_cbuf, BUFFER_LOCK_SHARE); - page = (Page) BufferGetPage(scan->rs_cbuf); + page = BufferGetPage(scan->rs_cbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); all_visible = PageIsAllVisible(page) && !snapshot->takenDuringRecovery; maxoffset = PageGetMaxOffsetNumber(page); @@ -546,7 +546,7 @@ tablesample_getnext(SampleScanState *scanstate) if (!pagemode) LockBuffer(scan->rs_cbuf, BUFFER_LOCK_SHARE); - page = (Page) BufferGetPage(scan->rs_cbuf); + page = BufferGetPage(scan->rs_cbuf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); all_visible = PageIsAllVisible(page) && !snapshot->takenDuringRecovery; maxoffset = PageGetMaxOffsetNumber(page); } diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index 42aa2f9df9..9874c3eaa0 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -2734,7 +2734,7 @@ XLogRecPtr BufferGetLSNAtomic(Buffer buffer) { BufferDesc *bufHdr = GetBufferDescriptor(buffer - 1); - char *page = BufferGetPage(buffer); + char *page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); XLogRecPtr lsn; /* @@ -3269,7 +3269,7 @@ void MarkBufferDirtyHint(Buffer buffer, bool buffer_std) { BufferDesc *bufHdr; - Page page = BufferGetPage(buffer); + Page page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (!BufferIsValid(buffer)) elog(ERROR, "bad buffer ID: %d", buffer); diff --git a/src/backend/storage/freespace/freespace.c b/src/backend/storage/freespace/freespace.c index 2ffa8ff24d..25aeb3b7b8 100644 --- a/src/backend/storage/freespace/freespace.c +++ b/src/backend/storage/freespace/freespace.c @@ -253,7 +253,7 @@ XLogRecordPageWithFreeSpace(RelFileNode rnode, BlockNumber heapBlk, buf = XLogReadBufferExtended(rnode, FSM_FORKNUM, blkno, RBM_ZERO_ON_ERROR); LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (PageIsNew(page)) PageInit(page, BLCKSZ, 0); @@ -280,7 +280,8 @@ GetRecordedFreeSpace(Relation rel, BlockNumber heapBlk) buf = fsm_readbuf(rel, addr, false); if (!BufferIsValid(buf)) return 0; - cat = fsm_get_avail(BufferGetPage(buf), slot); + cat = fsm_get_avail(BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST), + slot); ReleaseBuffer(buf); return fsm_space_cat_to_avail(cat); @@ -327,7 +328,9 @@ FreeSpaceMapTruncateRel(Relation rel, BlockNumber nblocks) if (!BufferIsValid(buf)) return; /* nothing to do; the FSM was already smaller */ LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE); - fsm_truncate_avail(BufferGetPage(buf), first_removed_slot); + fsm_truncate_avail(BufferGetPage(buf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), + first_removed_slot); MarkBufferDirtyHint(buf, false); UnlockReleaseBuffer(buf); @@ -577,8 +580,9 @@ fsm_readbuf(Relation rel, FSMAddress addr, bool extend) * headers, for example. */ buf = ReadBufferExtended(rel, FSM_FORKNUM, blkno, RBM_ZERO_ON_ERROR, NULL); - if (PageIsNew(BufferGetPage(buf))) - PageInit(BufferGetPage(buf), BLCKSZ, 0); + if (PageIsNew(BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST))) + PageInit(BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST), + BLCKSZ, 0); return buf; } @@ -657,7 +661,7 @@ fsm_set_and_search(Relation rel, FSMAddress addr, uint16 slot, buf = fsm_readbuf(rel, addr, true); LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE); - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); if (fsm_set_avail(page, slot, newValue)) MarkBufferDirtyHint(buf, false); @@ -701,7 +705,9 @@ fsm_search(Relation rel, uint8 min_cat) (addr.level == FSM_BOTTOM_LEVEL), false); if (slot == -1) - max_avail = fsm_get_max_avail(BufferGetPage(buf)); + max_avail = + fsm_get_max_avail(BufferGetPage(buf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST)); UnlockReleaseBuffer(buf); } else @@ -783,7 +789,7 @@ fsm_vacuum_page(Relation rel, FSMAddress addr, bool *eof_p) else *eof_p = false; - page = BufferGetPage(buf); + page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); /* * Recurse into children, and fix the information stored about them at @@ -810,14 +816,17 @@ fsm_vacuum_page(Relation rel, FSMAddress addr, bool *eof_p) if (fsm_get_avail(page, slot) != child_avail) { LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE); - fsm_set_avail(BufferGetPage(buf), slot, child_avail); + fsm_set_avail(BufferGetPage(buf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST), + slot, child_avail); MarkBufferDirtyHint(buf, false); LockBuffer(buf, BUFFER_LOCK_UNLOCK); } } } - max_avail = fsm_get_max_avail(BufferGetPage(buf)); + max_avail = fsm_get_max_avail(BufferGetPage(buf, NULL, NULL, + BGP_NO_SNAPSHOT_TEST)); /* * Reset the next slot pointer. This encourages the use of low-numbered diff --git a/src/backend/storage/freespace/fsmpage.c b/src/backend/storage/freespace/fsmpage.c index 535a4711eb..baceee798d 100644 --- a/src/backend/storage/freespace/fsmpage.c +++ b/src/backend/storage/freespace/fsmpage.c @@ -158,7 +158,7 @@ int fsm_search_avail(Buffer buf, uint8 minvalue, bool advancenext, bool exclusive_lock_held) { - Page page = BufferGetPage(buf); + Page page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); FSMPage fsmpage = (FSMPage) PageGetContents(page); int nodeno; int target; diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h index 7d57c04871..4c15934f36 100644 --- a/src/include/storage/bufmgr.h +++ b/src/include/storage/bufmgr.h @@ -14,11 +14,14 @@ #ifndef BUFMGR_H #define BUFMGR_H +#include "catalog/catalog.h" #include "storage/block.h" #include "storage/buf.h" #include "storage/bufpage.h" #include "storage/relfilenode.h" #include "utils/relcache.h" +#include "utils/snapmgr.h" +#include "utils/tqual.h" typedef void *Block; @@ -45,6 +48,19 @@ typedef enum * replay; otherwise same as RBM_NORMAL */ } ReadBufferMode; +/* + * Forced choice for whether BufferGetPage() must check snapshot age + * + * A scan must test for old snapshot, unless the test would be redundant (for + * example, to tests already made at a lower level on all code paths). + * Positioning for DML or vacuuming does not need this sort of test. + */ +typedef enum +{ + BGP_NO_SNAPSHOT_TEST, /* Not used for scan, or is redundant */ + BGP_TEST_FOR_OLD_SNAPSHOT /* Test for old snapshot is needed */ +} BufferGetPageAgeTest; + /* forward declared, to avoid having to expose buf_internals.h here */ struct WritebackContext; @@ -165,7 +181,11 @@ extern PGDLLIMPORT int32 *LocalRefCount; * BufferGetPage * Returns the page associated with a buffer. */ -#define BufferGetPage(buffer) ((Page)BufferGetBlock(buffer)) +#define BufferGetPage(buffer, snapshot, relation, agetest) \ +( \ + AssertMacro((agetest) == BGP_NO_SNAPSHOT_TEST), \ + ((Page)BufferGetBlock(buffer)) \ +) /* * prototypes for functions in bufmgr.c @@ -233,6 +253,8 @@ extern bool BgBufferSync(struct WritebackContext *wb_context); extern void AtProcExit_LocalBuffers(void); +extern Page TestForOldSnapshot(Snapshot snapshot, Relation relation, Page page); + /* in freelist.c */ extern BufferAccessStrategy GetAccessStrategy(BufferAccessStrategyType btype); extern void FreeAccessStrategy(BufferAccessStrategy strategy); -- 2.40.0