diff options
author | Kevin Grittner <kgrittn@postgresql.org> | 2016-04-08 14:30:10 -0500 |
---|---|---|
committer | Kevin Grittner <kgrittn@postgresql.org> | 2016-04-08 14:30:10 -0500 |
commit | 8b65cf4c5edabdcae45ceaef7b9ac236879aae50 (patch) | |
tree | f4412d3e9bc0db823ac32e08fac8e3124b42ff02 /src/include/storage/bufmgr.h | |
parent | 689f9a058854a1a32e994818dd6d79f49d8f8a1b (diff) | |
download | postgresql-8b65cf4c5edabdcae45ceaef7b9ac236879aae50.tar.gz postgresql-8b65cf4c5edabdcae45ceaef7b9ac236879aae50.zip |
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.
Diffstat (limited to 'src/include/storage/bufmgr.h')
-rw-r--r-- | src/include/storage/bufmgr.h | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h index 7d57c048714..4c15934f36b 100644 --- a/src/include/storage/bufmgr.h +++ b/src/include/storage/bufmgr.h @@ -14,11 +14,14 @@ #ifndef BUFMGR_H #define BUFMGR_H +#include "catalog/catalog.h" #include "storage/block.h" #include "storage/buf.h" #include "storage/bufpage.h" #include "storage/relfilenode.h" #include "utils/relcache.h" +#include "utils/snapmgr.h" +#include "utils/tqual.h" typedef void *Block; @@ -45,6 +48,19 @@ 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; @@ -165,7 +181,11 @@ extern PGDLLIMPORT int32 *LocalRefCount; * BufferGetPage * Returns the page associated with a buffer. */ -#define BufferGetPage(buffer) ((Page)BufferGetBlock(buffer)) +#define BufferGetPage(buffer, snapshot, relation, agetest) \ +( \ + AssertMacro((agetest) == BGP_NO_SNAPSHOT_TEST), \ + ((Page)BufferGetBlock(buffer)) \ +) /* * prototypes for functions in bufmgr.c @@ -233,6 +253,8 @@ extern bool BgBufferSync(struct WritebackContext *wb_context); extern void AtProcExit_LocalBuffers(void); +extern Page TestForOldSnapshot(Snapshot snapshot, Relation relation, Page page); + /* in freelist.c */ extern BufferAccessStrategy GetAccessStrategy(BufferAccessStrategyType btype); extern void FreeAccessStrategy(BufferAccessStrategy strategy); |