From 8b65cf4c5edabdcae45ceaef7b9ac236879aae50 Mon Sep 17 00:00:00 2001 From: Kevin Grittner Date: Fri, 8 Apr 2016 14:30:10 -0500 Subject: 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. --- src/backend/access/heap/visibilitymap.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/backend/access/heap/visibilitymap.c') diff --git a/src/backend/access/heap/visibilitymap.c b/src/backend/access/heap/visibilitymap.c index eaab4beccbc..694d78406f3 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; } -- cgit v1.2.3