1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-25 12:03:53 +03:00

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.
This commit is contained in:
Kevin Grittner
2016-04-08 14:30:10 -05:00
parent 689f9a0588
commit 8b65cf4c5e
65 changed files with 735 additions and 522 deletions

View File

@@ -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);