1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-03 20:02:46 +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:
Kevin Grittner
2016-04-08 14:30:10 -05:00
parent 689f9a0588
commit 8b65cf4c5e
65 changed files with 735 additions and 522 deletions

View File

@ -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);