diff options
| author | Kevin Grittner | 2016-04-20 13:31:19 +0000 |
|---|---|---|
| committer | Kevin Grittner | 2016-04-20 13:31:19 +0000 |
| commit | a343e223a5c33a7283a6d8b255c9dbc48dbc5061 (patch) | |
| tree | f02f3de305180170d8d5e51120861ae6770b31e8 /src/backend/access/brin | |
| parent | 4db0d2d2fe935e086dfd26c00f707dab298b443c (diff) | |
Revert no-op changes to BufferGetPage()
The reverted changes were intended to force a choice of whether any
newly-added BufferGetPage() calls needed to be accompanied by a
test of the snapshot age, to support the "snapshot too old"
feature. Such an accompanying test is needed in about 7% of the
cases, where the page is being used as part of a scan rather than
positioning for other purposes (such as DML or vacuuming). The
additional effort required for back-patching, and the doubt whether
the intended benefit would really be there, have indicated it is
best just to rely on developers to do the right thing based on
comments and existing usage, as we do with many other conventions.
This change should have little or no effect on generated executable
code.
Motivated by the back-patching pain of Tom Lane and Robert Haas
Diffstat (limited to 'src/backend/access/brin')
| -rw-r--r-- | src/backend/access/brin/brin.c | 15 | ||||
| -rw-r--r-- | src/backend/access/brin/brin_pageops.c | 52 | ||||
| -rw-r--r-- | src/backend/access/brin/brin_revmap.c | 19 | ||||
| -rw-r--r-- | src/backend/access/brin/brin_xlog.c | 16 |
4 files changed, 40 insertions, 62 deletions
diff --git a/src/backend/access/brin/brin.c b/src/backend/access/brin/brin.c index e64c94d3569..89bad0521b6 100644 --- a/src/backend/access/brin/brin.c +++ b/src/backend/access/brin/brin.c @@ -208,8 +208,7 @@ brininsert(Relation idxRel, Datum *values, bool *nulls, } else { - Page page = BufferGetPage(buf, NULL, NULL, - BGP_NO_SNAPSHOT_TEST); + Page page = BufferGetPage(buf); ItemId lp = PageGetItemId(page, off); Size origsz; BrinTuple *origtup; @@ -620,8 +619,7 @@ brinbuild(Relation heap, Relation index, IndexInfo *indexInfo) Assert(BufferGetBlockNumber(meta) == BRIN_METAPAGE_BLKNO); LockBuffer(meta, BUFFER_LOCK_EXCLUSIVE); - brin_metapage_init(BufferGetPage(meta, NULL, NULL, BGP_NO_SNAPSHOT_TEST), - BrinGetPagesPerRange(index), + brin_metapage_init(BufferGetPage(meta), BrinGetPagesPerRange(index), BRIN_CURRENT_VERSION); MarkBufferDirty(meta); @@ -640,7 +638,7 @@ brinbuild(Relation heap, Relation index, IndexInfo *indexInfo) recptr = XLogInsert(RM_BRIN_ID, XLOG_BRIN_CREATE_INDEX); - page = BufferGetPage(meta, NULL, NULL, BGP_NO_SNAPSHOT_TEST); + page = BufferGetPage(meta); PageSetLSN(page, recptr); } @@ -690,9 +688,7 @@ brinbuildempty(Relation index) /* Initialize and xlog metabuffer. */ START_CRIT_SECTION(); - brin_metapage_init(BufferGetPage(metabuf, NULL, NULL, - BGP_NO_SNAPSHOT_TEST), - BrinGetPagesPerRange(index), + brin_metapage_init(BufferGetPage(metabuf), BrinGetPagesPerRange(index), BRIN_CURRENT_VERSION); MarkBufferDirty(metabuf); log_newpage_buffer(metabuf, false); @@ -947,8 +943,7 @@ terminate_brin_buildstate(BrinBuildState *state) { Page page; - page = BufferGetPage(state->bs_currentInsertBuf, NULL, NULL, - BGP_NO_SNAPSHOT_TEST); + page = BufferGetPage(state->bs_currentInsertBuf); 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 a522b0b5dce..d0ca485caa6 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, NULL, NULL, BGP_NO_SNAPSHOT_TEST); + oldpage = BufferGetPage(oldbuf); oldlp = PageGetItemId(oldpage, oldoff); /* @@ -228,8 +228,7 @@ 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, NULL, NULL, - BGP_NO_SNAPSHOT_TEST); + Page newpage = BufferGetPage(newbuf); Buffer revmapbuf; ItemPointerData newtid; OffsetNumber newoff; @@ -246,9 +245,7 @@ brin_doupdate(Relation idxrel, BlockNumber pagesPerRange, * need to do that here. */ if (extended) - brin_page_init(BufferGetPage(newbuf, NULL, NULL, - BGP_NO_SNAPSHOT_TEST), - BRIN_PAGETYPE_REGULAR); + brin_page_init(BufferGetPage(newbuf), BRIN_PAGETYPE_REGULAR); PageIndexDeleteNoCompact(oldpage, &oldoff, 1); newoff = PageAddItem(newpage, (Item) newtup, newsz, @@ -301,9 +298,7 @@ brin_doupdate(Relation idxrel, BlockNumber pagesPerRange, PageSetLSN(oldpage, recptr); PageSetLSN(newpage, recptr); - PageSetLSN(BufferGetPage(revmapbuf, NULL, NULL, - BGP_NO_SNAPSHOT_TEST), - recptr); + PageSetLSN(BufferGetPage(revmapbuf), recptr); } END_CRIT_SECTION(); @@ -331,9 +326,7 @@ brin_can_do_samepage_update(Buffer buffer, Size origsz, Size newsz) { return ((newsz <= origsz) || - PageGetExactFreeSpace(BufferGetPage(buffer, NULL, NULL, - BGP_NO_SNAPSHOT_TEST)) - >= (newsz - origsz)); + PageGetExactFreeSpace(BufferGetPage(buffer)) >= (newsz - origsz)); } /* @@ -388,9 +381,7 @@ brin_doinsert(Relation idxrel, BlockNumber pagesPerRange, * it's still a regular page. */ LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE); - if (br_page_get_freespace(BufferGetPage(*buffer, NULL, NULL, - BGP_NO_SNAPSHOT_TEST)) - < itemsz) + if (br_page_get_freespace(BufferGetPage(*buffer)) < itemsz) { UnlockReleaseBuffer(*buffer); *buffer = InvalidBuffer; @@ -413,15 +404,13 @@ brin_doinsert(Relation idxrel, BlockNumber pagesPerRange, /* Now obtain lock on revmap buffer */ revmapbuf = brinLockRevmapPageForUpdate(revmap, heapBlk); - page = BufferGetPage(*buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); + page = BufferGetPage(*buffer); blk = BufferGetBlockNumber(*buffer); /* Execute the actual insertion */ START_CRIT_SECTION(); if (extended) - brin_page_init(BufferGetPage(*buffer, NULL, NULL, - BGP_NO_SNAPSHOT_TEST), - BRIN_PAGETYPE_REGULAR); + brin_page_init(BufferGetPage(*buffer), BRIN_PAGETYPE_REGULAR); off = PageAddItem(page, (Item) tup, itemsz, InvalidOffsetNumber, false, false); if (off == InvalidOffsetNumber) @@ -458,8 +447,7 @@ brin_doinsert(Relation idxrel, BlockNumber pagesPerRange, recptr = XLogInsert(RM_BRIN_ID, info); PageSetLSN(page, recptr); - PageSetLSN(BufferGetPage(revmapbuf, NULL, NULL, - BGP_NO_SNAPSHOT_TEST), recptr); + PageSetLSN(BufferGetPage(revmapbuf), recptr); } END_CRIT_SECTION(); @@ -527,7 +515,7 @@ brin_start_evacuating_page(Relation idxRel, Buffer buf) OffsetNumber maxoff; Page page; - page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); + page = BufferGetPage(buf); if (PageIsNew(page)) return false; @@ -563,7 +551,7 @@ brin_evacuate_page(Relation idxRel, BlockNumber pagesPerRange, OffsetNumber maxoff; Page page; - page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); + page = BufferGetPage(buf); Assert(BrinPageFlags(page) & BRIN_EVACUATE_PAGE); @@ -610,7 +598,7 @@ brin_evacuate_page(Relation idxRel, BlockNumber pagesPerRange, bool brin_page_cleanup(Relation idxrel, Buffer buf) { - Page page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); + Page page = BufferGetPage(buf); Size freespace; /* @@ -639,10 +627,8 @@ brin_page_cleanup(Relation idxrel, Buffer buf) } /* Nothing to be done for non-regular index pages */ - 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))) + if (BRIN_IS_META_PAGE(BufferGetPage(buf)) || + BRIN_IS_REVMAP_PAGE(BufferGetPage(buf))) return false; /* Measure free space and record it */ @@ -752,8 +738,7 @@ 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, NULL, NULL, - BGP_NO_SNAPSHOT_TEST))) + if (!BRIN_IS_REGULAR_PAGE(BufferGetPage(oldbuf))) { LockBuffer(oldbuf, BUFFER_LOCK_UNLOCK); @@ -785,7 +770,7 @@ brin_getinsertbuffer(Relation irel, Buffer oldbuf, Size itemsz, if (extensionLockHeld) UnlockRelationForExtension(irel, ExclusiveLock); - page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); + page = BufferGetPage(buf); /* * We have a new buffer to insert into. Check that the new page has @@ -820,8 +805,7 @@ 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, NULL, NULL, - BGP_NO_SNAPSHOT_TEST))); + Assert(BRIN_IS_REGULAR_PAGE(BufferGetPage(oldbuf))); } return buf; @@ -878,7 +862,7 @@ brin_initialize_empty_new_buffer(Relation idxrel, Buffer buffer) BufferGetBlockNumber(buffer))); START_CRIT_SECTION(); - page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); + page = BufferGetPage(buffer); 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 5ed867cf30b..812f76c71b8 100644 --- a/src/backend/access/brin/brin_revmap.c +++ b/src/backend/access/brin/brin_revmap.c @@ -78,7 +78,8 @@ brinRevmapInitialize(Relation idxrel, BlockNumber *pagesPerRange, meta = ReadBuffer(idxrel, BRIN_METAPAGE_BLKNO); LockBuffer(meta, BUFFER_LOCK_SHARE); - page = BufferGetPage(meta, snapshot, idxrel, BGP_TEST_FOR_OLD_SNAPSHOT); + page = BufferGetPage(meta); + TestForOldSnapshot(snapshot, idxrel, page); metadata = (BrinMetaPageData *) PageGetContents(page); revmap = palloc(sizeof(BrinRevmap)); @@ -162,7 +163,7 @@ brinSetHeapBlockItemptr(Buffer buf, BlockNumber pagesPerRange, Page page; /* The correct page should already be pinned and locked */ - page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); + page = BufferGetPage(buf); contents = (RevmapContents *) PageGetContents(page); iptr = (ItemPointerData *) contents->rm_tids; iptr += HEAPBLK_TO_REVMAP_INDEX(pagesPerRange, heapBlk); @@ -230,8 +231,7 @@ brinGetTupleForHeapBlock(BrinRevmap *revmap, BlockNumber heapBlk, LockBuffer(revmap->rm_currBuf, BUFFER_LOCK_SHARE); contents = (RevmapContents *) - PageGetContents(BufferGetPage(revmap->rm_currBuf, NULL, NULL, - BGP_NO_SNAPSHOT_TEST)); + PageGetContents(BufferGetPage(revmap->rm_currBuf)); iptr = contents->rm_tids; iptr += HEAPBLK_TO_REVMAP_INDEX(revmap->rm_pagesPerRange, heapBlk); @@ -266,8 +266,8 @@ brinGetTupleForHeapBlock(BrinRevmap *revmap, BlockNumber heapBlk, *buf = ReadBuffer(idxRel, blk); } LockBuffer(*buf, mode); - page = BufferGetPage(*buf, snapshot, idxRel, - BGP_TEST_FOR_OLD_SNAPSHOT); + page = BufferGetPage(*buf); + TestForOldSnapshot(snapshot, idxRel, page); /* If we land on a revmap page, start over */ if (BRIN_IS_REGULAR_PAGE(page)) @@ -399,8 +399,7 @@ 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, NULL, NULL, - BGP_NO_SNAPSHOT_TEST); + metapage = BufferGetPage(revmap->rm_metaBuf); metadata = (BrinMetaPageData *) PageGetContents(metapage); /* @@ -420,7 +419,7 @@ revmap_physical_extend(BrinRevmap *revmap) { buf = ReadBuffer(irel, mapBlk); LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE); - page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); + page = BufferGetPage(buf); } else { @@ -443,7 +442,7 @@ revmap_physical_extend(BrinRevmap *revmap) return; } LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE); - page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); + page = BufferGetPage(buf); if (needLock) UnlockRelationForExtension(irel, ExclusiveLock); diff --git a/src/backend/access/brin/brin_xlog.c b/src/backend/access/brin/brin_xlog.c index 36e4a99fc10..deb7af4ca6e 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 = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); + page = (Page) BufferGetPage(buf); 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, NULL, NULL, BGP_NO_SNAPSHOT_TEST); + page = BufferGetPage(buffer); 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 = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); + page = (Page) BufferGetPage(buffer); 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 = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); + page = (Page) BufferGetPage(buffer); brinSetHeapBlockItemptr(buffer, xlrec->pagesPerRange, xlrec->heapBlk, tid); @@ -145,7 +145,7 @@ brin_xlog_update(XLogReaderState *record) Page page; OffsetNumber offnum; - page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); + page = (Page) BufferGetPage(buffer); 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 = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST); + page = (Page) BufferGetPage(buffer); 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, NULL, NULL, BGP_NO_SNAPSHOT_TEST); + metapg = BufferGetPage(metabuf); 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 = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST); + page = (Page) BufferGetPage(buf); brin_page_init(page, BRIN_PAGETYPE_REVMAP); PageSetLSN(page, lsn); |
