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  bool need_full_snapshot);
59 extern void FreeSnapshotBuilder(SnapBuild *cache);
60 
61 extern void SnapBuildSnapDecRefcount(Snapshot snap);
62 
64 extern const char *SnapBuildExportSnapshot(SnapBuild *snapstate);
65 extern void SnapBuildClearExportedSnapshot(void);
66 
69  TransactionId xid);
70 
71 extern bool SnapBuildXactNeedsSkip(SnapBuild *snapstate, XLogRecPtr ptr);
72 
73 extern void SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn,
74  TransactionId xid, int nsubxacts,
75  TransactionId *subxacts);
76 extern void SnapBuildAbortTxn(SnapBuild *builder, XLogRecPtr lsn,
77  TransactionId xid, int nsubxacts,
78  TransactionId *subxacts);
79 extern bool SnapBuildProcessChange(SnapBuild *builder, TransactionId xid,
80  XLogRecPtr lsn);
81 extern void SnapBuildProcessNewCid(SnapBuild *builder, TransactionId xid,
82  XLogRecPtr lsn, struct xl_heap_new_cid *cid);
83 extern void SnapBuildProcessRunningXacts(SnapBuild *builder, XLogRecPtr lsn,
84  struct xl_running_xacts *running);
85 extern void SnapBuildSerializationPoint(SnapBuild *builder, XLogRecPtr lsn);
86 
87 #endif /* SNAPBUILD_H */
bool SnapBuildXactNeedsSkip(SnapBuild *snapstate, XLogRecPtr ptr)
Definition: snapbuild.c:379
void SnapBuildClearExportedSnapshot(void)
Definition: snapbuild.c:665
uint32 TransactionId
Definition: c.h:397
SnapBuild * AllocateSnapshotBuilder(struct ReorderBuffer *cache, TransactionId xmin_horizon, XLogRecPtr start_lsn, bool need_full_snapshot)
Definition: snapbuild.c:285
void SnapBuildProcessNewCid(SnapBuild *builder, TransactionId xid, XLogRecPtr lsn, struct xl_heap_new_cid *cid)
Definition: snapbuild.c:738
void SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid, int nsubxacts, TransactionId *subxacts)
Definition: snapbuild.c:985
bool SnapBuildProcessChange(SnapBuild *builder, TransactionId xid, XLogRecPtr lsn)
Definition: snapbuild.c:688
Snapshot SnapBuildInitialSnapshot(SnapBuild *builder)
Definition: snapbuild.c:514
void SnapBuildAbortTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid, int nsubxacts, TransactionId *subxacts)
Definition: snapbuild.c:965
SnapBuildState
Definition: snapbuild.h:18
void CheckPointSnapBuild(void)
Definition: snapbuild.c:1886
SnapBuildState SnapBuildCurrentState(SnapBuild *snapstate)
Definition: snapbuild.c:370
void SnapBuildProcessRunningXacts(SnapBuild *builder, XLogRecPtr lsn, struct xl_running_xacts *running)
Definition: snapbuild.c:1150
uint64 XLogRecPtr
Definition: xlogdefs.h:21
void FreeSnapshotBuilder(SnapBuild *cache)
Definition: snapbuild.c:326
Snapshot SnapBuildGetOrBuildSnapshot(SnapBuild *builder, TransactionId xid)
Definition: snapbuild.c:644
const char * SnapBuildExportSnapshot(SnapBuild *snapstate)
Definition: snapbuild.c:604
void SnapBuildSnapDecRefcount(Snapshot snap)
Definition: snapbuild.c:403
void SnapBuildSerializationPoint(SnapBuild *builder, XLogRecPtr lsn)
Definition: snapbuild.c:1476