diff options
| author | Kevin Grittner | 2016-04-20 13:31:19 +0000 |
|---|---|---|
| committer | Kevin Grittner | 2016-04-20 13:31:19 +0000 |
| commit | a343e223a5c33a7283a6d8b255c9dbc48dbc5061 (patch) | |
| tree | f02f3de305180170d8d5e51120861ae6770b31e8 /src/include | |
| parent | 4db0d2d2fe935e086dfd26c00f707dab298b443c (diff) | |
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
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/storage/bufmgr.h | 42 |
1 files changed, 9 insertions, 33 deletions
diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h index 86040610e7..b514b4696d 100644 --- a/src/include/storage/bufmgr.h +++ b/src/include/storage/bufmgr.h @@ -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; @@ -178,6 +165,15 @@ extern PGDLLIMPORT int32 *LocalRefCount; ) /* + * 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 */ extern bool ComputeIoConcurrency(int io_concurrency, double *target); @@ -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 */ |
