mirror of
https://github.com/postgres/postgres.git
synced 2025-08-21 10:42:50 +03:00
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.
This commit is contained in:
@@ -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
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user