PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
snapbuild.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * snapbuild.h
4  * Exports from replication/logical/snapbuild.c.
5  *
6  * Copyright (c) 2012-2017, PostgreSQL Global Development Group
7  *
8  * src/include/replication/snapbuild.h
9  *
10  *-------------------------------------------------------------------------
11  */
12 #ifndef SNAPBUILD_H
13 #define SNAPBUILD_H
14 
15 #include "access/xlogdefs.h"
16 #include "utils/snapmgr.h"
17 
18 typedef enum
19 {
20  /*
21  * Initial state, we can't do much yet.
22  */
24 
25  /*
26  * We have collected enough information to decode tuples in transactions
27  * that started after this.
28  *
29  * Once we reached this we start to collect changes. We cannot apply them
30  * yet because the might be based on transactions that were still running
31  * when we reached them yet.
32  */
34 
35  /*
36  * Found a point after hitting built_full_snapshot where all transactions
37  * that were running at that point finished. Till we reach that we hold
38  * off calling any commit callbacks.
39  */
42 
43 /* forward declare so we don't have to expose the struct to the public */
44 struct SnapBuild;
45 typedef struct SnapBuild SnapBuild;
46 
47 /* forward declare so we don't have to include reorderbuffer.h */
48 struct ReorderBuffer;
49 
50 /* forward declare so we don't have to include heapam_xlog.h */
51 struct xl_heap_new_cid;
52 struct xl_running_xacts;
53 
54 extern void CheckPointSnapBuild(void);
55 
56 extern SnapBuild *AllocateSnapshotBuilder(struct ReorderBuffer *cache,
57  TransactionId xmin_horizon, XLogRecPtr start_lsn);
58 extern void FreeSnapshotBuilder(SnapBuild *cache);
59 
60 extern void SnapBuildSnapDecRefcount(Snapshot snap);
61 
63 extern const char *SnapBuildExportSnapshot(SnapBuild *snapstate);
64 extern void SnapBuildClearExportedSnapshot(void);
65 
68  TransactionId xid);
69 
70 extern bool SnapBuildXactNeedsSkip(SnapBuild *snapstate, XLogRecPtr ptr);
71 
72 extern void SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn,
73  TransactionId xid, int nsubxacts,
74  TransactionId *subxacts);
75 extern void SnapBuildAbortTxn(SnapBuild *builder, XLogRecPtr lsn,
76  TransactionId xid, int nsubxacts,
77  TransactionId *subxacts);
78 extern bool SnapBuildProcessChange(SnapBuild *builder, TransactionId xid,
79  XLogRecPtr lsn);
80 extern void SnapBuildProcessNewCid(SnapBuild *builder, TransactionId xid,
81  XLogRecPtr lsn, struct xl_heap_new_cid *cid);
82 extern void SnapBuildProcessRunningXacts(SnapBuild *builder, XLogRecPtr lsn,
83  struct xl_running_xacts *running);
84 extern void SnapBuildSerializationPoint(SnapBuild *builder, XLogRecPtr lsn);
85 
86 #endif /* SNAPBUILD_H */
bool SnapBuildXactNeedsSkip(SnapBuild *snapstate, XLogRecPtr ptr)
Definition: snapbuild.c:374
void SnapBuildClearExportedSnapshot(void)
Definition: snapbuild.c:648
uint32 TransactionId
Definition: c.h:397
void SnapBuildProcessNewCid(SnapBuild *builder, TransactionId xid, XLogRecPtr lsn, struct xl_heap_new_cid *cid)
Definition: snapbuild.c:721
void SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid, int nsubxacts, TransactionId *subxacts)
Definition: snapbuild.c:968
SnapBuild * AllocateSnapshotBuilder(struct ReorderBuffer *cache, TransactionId xmin_horizon, XLogRecPtr start_lsn)
Definition: snapbuild.c:282
bool SnapBuildProcessChange(SnapBuild *builder, TransactionId xid, XLogRecPtr lsn)
Definition: snapbuild.c:671
Snapshot SnapBuildInitalSnapshot(SnapBuild *builder)
Definition: snapbuild.c:509
void SnapBuildAbortTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid, int nsubxacts, TransactionId *subxacts)
Definition: snapbuild.c:948
SnapBuildState
Definition: snapbuild.h:18
void CheckPointSnapBuild(void)
Definition: snapbuild.c:1865
SnapBuildState SnapBuildCurrentState(SnapBuild *snapstate)
Definition: snapbuild.c:365
void SnapBuildProcessRunningXacts(SnapBuild *builder, XLogRecPtr lsn, struct xl_running_xacts *running)
Definition: snapbuild.c:1133
uint64 XLogRecPtr
Definition: xlogdefs.h:21
void FreeSnapshotBuilder(SnapBuild *cache)
Definition: snapbuild.c:321
Snapshot SnapBuildGetOrBuildSnapshot(SnapBuild *builder, TransactionId xid)
Definition: snapbuild.c:627
const char * SnapBuildExportSnapshot(SnapBuild *snapstate)
Definition: snapbuild.c:587
void SnapBuildSnapDecRefcount(Snapshot snap)
Definition: snapbuild.c:398
void SnapBuildSerializationPoint(SnapBuild *builder, XLogRecPtr lsn)
Definition: snapbuild.c:1455