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 
62 extern const char *SnapBuildExportSnapshot(SnapBuild *snapstate);
63 extern void SnapBuildClearExportedSnapshot(void);
64 
67  TransactionId xid);
68 
69 extern bool SnapBuildXactNeedsSkip(SnapBuild *snapstate, XLogRecPtr ptr);
70 
71 extern void SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn,
72  TransactionId xid, int nsubxacts,
73  TransactionId *subxacts);
74 extern void SnapBuildAbortTxn(SnapBuild *builder, XLogRecPtr lsn,
75  TransactionId xid, int nsubxacts,
76  TransactionId *subxacts);
77 extern bool SnapBuildProcessChange(SnapBuild *builder, TransactionId xid,
78  XLogRecPtr lsn);
79 extern void SnapBuildProcessNewCid(SnapBuild *builder, TransactionId xid,
80  XLogRecPtr lsn, struct xl_heap_new_cid *cid);
81 extern void SnapBuildProcessRunningXacts(SnapBuild *builder, XLogRecPtr lsn,
82  struct xl_running_xacts *running);
83 extern void SnapBuildSerializationPoint(SnapBuild *builder, XLogRecPtr lsn);
84 
85 #endif /* SNAPBUILD_H */
bool SnapBuildXactNeedsSkip(SnapBuild *snapstate, XLogRecPtr ptr)
Definition: snapbuild.c:373
void SnapBuildClearExportedSnapshot(void)
Definition: snapbuild.c:630
uint32 TransactionId
Definition: c.h:393
void SnapBuildProcessNewCid(SnapBuild *builder, TransactionId xid, XLogRecPtr lsn, struct xl_heap_new_cid *cid)
Definition: snapbuild.c:703
void SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid, int nsubxacts, TransactionId *subxacts)
Definition: snapbuild.c:950
SnapBuild * AllocateSnapshotBuilder(struct ReorderBuffer *cache, TransactionId xmin_horizon, XLogRecPtr start_lsn)
Definition: snapbuild.c:281
bool SnapBuildProcessChange(SnapBuild *builder, TransactionId xid, XLogRecPtr lsn)
Definition: snapbuild.c:653
void SnapBuildAbortTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid, int nsubxacts, TransactionId *subxacts)
Definition: snapbuild.c:930
SnapBuildState
Definition: snapbuild.h:18
void CheckPointSnapBuild(void)
Definition: snapbuild.c:1835
SnapBuildState SnapBuildCurrentState(SnapBuild *snapstate)
Definition: snapbuild.c:364
void SnapBuildProcessRunningXacts(SnapBuild *builder, XLogRecPtr lsn, struct xl_running_xacts *running)
Definition: snapbuild.c:1115
uint64 XLogRecPtr
Definition: xlogdefs.h:21
void FreeSnapshotBuilder(SnapBuild *cache)
Definition: snapbuild.c:320
Snapshot SnapBuildGetOrBuildSnapshot(SnapBuild *builder, TransactionId xid)
Definition: snapbuild.c:609
const char * SnapBuildExportSnapshot(SnapBuild *snapstate)
Definition: snapbuild.c:512
void SnapBuildSnapDecRefcount(Snapshot snap)
Definition: snapbuild.c:397
void SnapBuildSerializationPoint(SnapBuild *builder, XLogRecPtr lsn)
Definition: snapbuild.c:1437