]> granicus.if.org Git - postgresql/blob - src/include/replication/snapbuild.h
Centralize definition of integer limits.
[postgresql] / src / include / replication / snapbuild.h
1 /*-------------------------------------------------------------------------
2  *
3  * snapbuild.h
4  *        Exports from replication/logical/snapbuild.c.
5  *
6  * Copyright (c) 2012-2015, 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          */
23         SNAPBUILD_START,
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          */
33         SNAPBUILD_FULL_SNAPSHOT,
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          */
40         SNAPBUILD_CONSISTENT
41 } SnapBuildState;
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
65 extern SnapBuildState SnapBuildCurrentState(SnapBuild *snapstate);
66
67 extern bool SnapBuildXactNeedsSkip(SnapBuild *snapstate, XLogRecPtr ptr);
68
69 extern void SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn,
70                                    TransactionId xid, int nsubxacts,
71                                    TransactionId *subxacts);
72 extern void SnapBuildAbortTxn(SnapBuild *builder, XLogRecPtr lsn,
73                                   TransactionId xid, int nsubxacts,
74                                   TransactionId *subxacts);
75 extern bool SnapBuildProcessChange(SnapBuild *builder, TransactionId xid,
76                                            XLogRecPtr lsn);
77 extern void SnapBuildProcessNewCid(SnapBuild *builder, TransactionId xid,
78                                            XLogRecPtr lsn, struct xl_heap_new_cid *cid);
79 extern void SnapBuildProcessRunningXacts(SnapBuild *builder, XLogRecPtr lsn,
80                                                          struct xl_running_xacts *running);
81 extern void SnapBuildSerializationPoint(SnapBuild *builder, XLogRecPtr lsn);
82
83 #endif   /* SNAPBUILD_H */