1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-25 12:03:53 +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:
Kevin Grittner
2016-04-20 08:31:19 -05:00
parent 4db0d2d2fe
commit a343e223a5
65 changed files with 550 additions and 736 deletions

View File

@@ -48,19 +48,6 @@ typedef enum
* replay; otherwise same as RBM_NORMAL */
} ReadBufferMode;
/*
* Forced choice for whether BufferGetPage() must check snapshot age
*
* A scan must test for old snapshot, unless the test would be redundant (for
* example, to tests already made at a lower level on all code paths).
* Positioning for DML or vacuuming does not need this sort of test.
*/
typedef enum
{
BGP_NO_SNAPSHOT_TEST, /* Not used for scan, or is redundant */
BGP_TEST_FOR_OLD_SNAPSHOT /* Test for old snapshot is needed */
} BufferGetPageAgeTest;
/* forward declared, to avoid having to expose buf_internals.h here */
struct WritebackContext;
@@ -177,6 +164,15 @@ extern PGDLLIMPORT int32 *LocalRefCount;
(Size)BLCKSZ \
)
/*
* BufferGetPage
* Returns the page associated with a buffer.
*
* When this is called as part of a scan, there may be a need for a nearby
* call to TestForOldSnapshot(). See the definition of that for details.
*/
#define BufferGetPage(buffer) ((Page)BufferGetBlock(buffer))
/*
* prototypes for functions in bufmgr.c
*/
@@ -261,26 +257,6 @@ extern void FreeAccessStrategy(BufferAccessStrategy strategy);
#ifndef FRONTEND
/*
* BufferGetPage
* Returns the page associated with a buffer.
*
* For call sites where the check is not needed (which is the vast majority of
* them), the snapshot and relation parameters can, and generally should, be
* NULL.
*/
static inline Page
BufferGetPage(Buffer buffer, Snapshot snapshot, Relation relation,
BufferGetPageAgeTest agetest)
{
Page page = (Page) BufferGetBlock(buffer);
if (agetest == BGP_TEST_FOR_OLD_SNAPSHOT)
TestForOldSnapshot(snapshot, relation, page);
return page;
}
#endif /* FRONTEND */
#endif /* BUFMGR_H */