mirror of
https://github.com/postgres/postgres.git
synced 2025-11-28 11:44:57 +03:00
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
This commit is contained in:
@@ -2815,7 +2815,7 @@ XLogRecPtr
|
||||
BufferGetLSNAtomic(Buffer buffer)
|
||||
{
|
||||
BufferDesc *bufHdr = GetBufferDescriptor(buffer - 1);
|
||||
char *page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST);
|
||||
char *page = BufferGetPage(buffer);
|
||||
XLogRecPtr lsn;
|
||||
uint32 buf_state;
|
||||
|
||||
@@ -3362,7 +3362,7 @@ void
|
||||
MarkBufferDirtyHint(Buffer buffer, bool buffer_std)
|
||||
{
|
||||
BufferDesc *bufHdr;
|
||||
Page page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST);
|
||||
Page page = BufferGetPage(buffer);
|
||||
|
||||
if (!BufferIsValid(buffer))
|
||||
elog(ERROR, "bad buffer ID: %d", buffer);
|
||||
@@ -4288,10 +4288,8 @@ IssuePendingWritebacks(WritebackContext *context)
|
||||
* This test generally needs to be performed after every BufferGetPage() call
|
||||
* that is executed as part of a scan. It is not needed for calls made for
|
||||
* modifying the page (for example, to position to the right place to insert a
|
||||
* new index tuple or for vacuuming). To minimize errors of omission, the
|
||||
* BufferGetPage() macro accepts parameters to specify whether the test should
|
||||
* be run, and supply the necessary snapshot and relation parameters. See the
|
||||
* declaration of BufferGetPage() for more details.
|
||||
* new index tuple or for vacuuming). It may also be omitted where calls to
|
||||
* lower-level functions will have already performed the test.
|
||||
*
|
||||
* Note that a NULL snapshot argument is allowed and causes a fast return
|
||||
* without error; this is to support call sites which can be called from
|
||||
|
||||
@@ -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, NULL, NULL, BGP_NO_SNAPSHOT_TEST);
|
||||
page = BufferGetPage(buf);
|
||||
if (PageIsNew(page))
|
||||
PageInit(page, BLCKSZ, 0);
|
||||
|
||||
@@ -280,8 +280,7 @@ GetRecordedFreeSpace(Relation rel, BlockNumber heapBlk)
|
||||
buf = fsm_readbuf(rel, addr, false);
|
||||
if (!BufferIsValid(buf))
|
||||
return 0;
|
||||
cat = fsm_get_avail(BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST),
|
||||
slot);
|
||||
cat = fsm_get_avail(BufferGetPage(buf), slot);
|
||||
ReleaseBuffer(buf);
|
||||
|
||||
return fsm_space_cat_to_avail(cat);
|
||||
@@ -328,9 +327,7 @@ 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, NULL, NULL,
|
||||
BGP_NO_SNAPSHOT_TEST),
|
||||
first_removed_slot);
|
||||
fsm_truncate_avail(BufferGetPage(buf), first_removed_slot);
|
||||
MarkBufferDirtyHint(buf, false);
|
||||
UnlockReleaseBuffer(buf);
|
||||
|
||||
@@ -580,9 +577,8 @@ 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, NULL, NULL, BGP_NO_SNAPSHOT_TEST)))
|
||||
PageInit(BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST),
|
||||
BLCKSZ, 0);
|
||||
if (PageIsNew(BufferGetPage(buf)))
|
||||
PageInit(BufferGetPage(buf), BLCKSZ, 0);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -661,7 +657,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, NULL, NULL, BGP_NO_SNAPSHOT_TEST);
|
||||
page = BufferGetPage(buf);
|
||||
|
||||
if (fsm_set_avail(page, slot, newValue))
|
||||
MarkBufferDirtyHint(buf, false);
|
||||
@@ -705,9 +701,7 @@ fsm_search(Relation rel, uint8 min_cat)
|
||||
(addr.level == FSM_BOTTOM_LEVEL),
|
||||
false);
|
||||
if (slot == -1)
|
||||
max_avail =
|
||||
fsm_get_max_avail(BufferGetPage(buf, NULL, NULL,
|
||||
BGP_NO_SNAPSHOT_TEST));
|
||||
max_avail = fsm_get_max_avail(BufferGetPage(buf));
|
||||
UnlockReleaseBuffer(buf);
|
||||
}
|
||||
else
|
||||
@@ -789,7 +783,7 @@ fsm_vacuum_page(Relation rel, FSMAddress addr, bool *eof_p)
|
||||
else
|
||||
*eof_p = false;
|
||||
|
||||
page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST);
|
||||
page = BufferGetPage(buf);
|
||||
|
||||
/*
|
||||
* Recurse into children, and fix the information stored about them at
|
||||
@@ -816,17 +810,14 @@ 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, NULL, NULL,
|
||||
BGP_NO_SNAPSHOT_TEST),
|
||||
slot, child_avail);
|
||||
fsm_set_avail(BufferGetPage(buf), slot, child_avail);
|
||||
MarkBufferDirtyHint(buf, false);
|
||||
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
max_avail = fsm_get_max_avail(BufferGetPage(buf, NULL, NULL,
|
||||
BGP_NO_SNAPSHOT_TEST));
|
||||
max_avail = fsm_get_max_avail(BufferGetPage(buf));
|
||||
|
||||
/*
|
||||
* Reset the next slot pointer. This encourages the use of low-numbered
|
||||
|
||||
@@ -158,7 +158,7 @@ int
|
||||
fsm_search_avail(Buffer buf, uint8 minvalue, bool advancenext,
|
||||
bool exclusive_lock_held)
|
||||
{
|
||||
Page page = BufferGetPage(buf, NULL, NULL, BGP_NO_SNAPSHOT_TEST);
|
||||
Page page = BufferGetPage(buf);
|
||||
FSMPage fsmpage = (FSMPage) PageGetContents(page);
|
||||
int nodeno;
|
||||
int target;
|
||||
|
||||
Reference in New Issue
Block a user