mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +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:
@ -126,8 +126,7 @@ spgGetCache(Relation index)
|
||||
metabuffer = ReadBuffer(index, SPGIST_METAPAGE_BLKNO);
|
||||
LockBuffer(metabuffer, BUFFER_LOCK_SHARE);
|
||||
|
||||
metadata = SpGistPageGetMeta
|
||||
(BufferGetPage(metabuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST));
|
||||
metadata = SpGistPageGetMeta(BufferGetPage(metabuffer));
|
||||
|
||||
if (metadata->magicNumber != SPGIST_MAGIC_NUMBER)
|
||||
elog(ERROR, "index \"%s\" is not an SP-GiST index",
|
||||
@ -207,8 +206,7 @@ SpGistNewBuffer(Relation index)
|
||||
*/
|
||||
if (ConditionalLockBuffer(buffer))
|
||||
{
|
||||
Page page = BufferGetPage(buffer, NULL, NULL,
|
||||
BGP_NO_SNAPSHOT_TEST);
|
||||
Page page = BufferGetPage(buffer);
|
||||
|
||||
if (PageIsNew(page))
|
||||
return buffer; /* OK to use, if never initialized */
|
||||
@ -258,8 +256,7 @@ SpGistUpdateMetaPage(Relation index)
|
||||
|
||||
if (ConditionalLockBuffer(metabuffer))
|
||||
{
|
||||
metadata = SpGistPageGetMeta
|
||||
(BufferGetPage(metabuffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST));
|
||||
metadata = SpGistPageGetMeta(BufferGetPage(metabuffer));
|
||||
metadata->lastUsedPages = cache->lastUsedPages;
|
||||
|
||||
MarkBufferDirty(metabuffer);
|
||||
@ -336,9 +333,7 @@ allocNewBuffer(Relation index, int flags)
|
||||
blkFlags |= GBUF_NULLS;
|
||||
cache->lastUsedPages.cachedPage[blkFlags].blkno = blkno;
|
||||
cache->lastUsedPages.cachedPage[blkFlags].freeSpace =
|
||||
PageGetExactFreeSpace
|
||||
(BufferGetPage(buffer, NULL, NULL,
|
||||
BGP_NO_SNAPSHOT_TEST));
|
||||
PageGetExactFreeSpace(BufferGetPage(buffer));
|
||||
UnlockReleaseBuffer(buffer);
|
||||
}
|
||||
}
|
||||
@ -406,7 +401,7 @@ SpGistGetBuffer(Relation index, int flags, int needSpace, bool *isNew)
|
||||
return allocNewBuffer(index, flags);
|
||||
}
|
||||
|
||||
page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST);
|
||||
page = BufferGetPage(buffer);
|
||||
|
||||
if (PageIsNew(page) || SpGistPageIsDeleted(page) || PageIsEmpty(page))
|
||||
{
|
||||
@ -465,7 +460,7 @@ SpGistSetLastUsedPage(Relation index, Buffer buffer)
|
||||
SpGistCache *cache = spgGetCache(index);
|
||||
SpGistLastUsedPage *lup;
|
||||
int freeSpace;
|
||||
Page page = BufferGetPage(buffer, NULL, NULL, BGP_NO_SNAPSHOT_TEST);
|
||||
Page page = BufferGetPage(buffer);
|
||||
BlockNumber blkno = BufferGetBlockNumber(buffer);
|
||||
int flags;
|
||||
|
||||
@ -513,7 +508,7 @@ void
|
||||
SpGistInitBuffer(Buffer b, uint16 f)
|
||||
{
|
||||
Assert(BufferGetPageSize(b) == BLCKSZ);
|
||||
SpGistInitPage(BufferGetPage(b, NULL, NULL, BGP_NO_SNAPSHOT_TEST), f);
|
||||
SpGistInitPage(BufferGetPage(b), f);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user