From 8b65cf4c5edabdcae45ceaef7b9ac236879aae50 Mon Sep 17 00:00:00 2001 From: Kevin Grittner Date: Fri, 8 Apr 2016 14:30:10 -0500 Subject: 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. --- src/include/storage/bufmgr.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/include/storage') 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); -- cgit v1.2.3