PostgreSQL Source Code  git master
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-2021, 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  * Collecting committed transactions, to build the initial catalog
27  * snapshot.
28  */
30 
31  /*
32  * We have collected enough information to decode tuples in transactions
33  * that started after this.
34  *
35  * Once we reached this we start to collect changes. We cannot apply them
36  * yet, because they might be based on transactions that were still
37  * running when FULL_SNAPSHOT was reached.
38  */
40 
41  /*
42  * Found a point after SNAPBUILD_FULL_SNAPSHOT where all transactions that
43  * were running at that point finished. Till we reach that we hold off
44  * calling any commit callbacks.
45  */
48 
49 /* forward declare so we don't have to expose the struct to the public */
50 struct SnapBuild;
51 typedef struct SnapBuild SnapBuild;
52 
53 /* forward declare so we don't have to include reorderbuffer.h */
54 struct ReorderBuffer;
55 
56 /* forward declare so we don't have to include heapam_xlog.h */
57 struct xl_heap_new_cid;
58 struct xl_running_xacts;
59 
60 extern void CheckPointSnapBuild(void);
61 
62 extern SnapBuild *AllocateSnapshotBuilder(struct ReorderBuffer *cache,
63  TransactionId xmin_horizon, XLogRecPtr start_lsn,
64  bool need_full_snapshot,
65  XLogRecPtr two_phase_at);
66 extern void FreeSnapshotBuilder(SnapBuild *cache);
67 
68 extern void SnapBuildSnapDecRefcount(Snapshot snap);
69 
71 extern const char *SnapBuildExportSnapshot(SnapBuild *snapstate);
72 extern void SnapBuildClearExportedSnapshot(void);
73 
76  TransactionId xid);
77 
78 extern bool SnapBuildXactNeedsSkip(SnapBuild *snapstate, XLogRecPtr ptr);
80 extern void SnapBuildSetTwoPhaseAt(SnapBuild *builder, XLogRecPtr ptr);
81 
82 extern void SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn,
83  TransactionId xid, int nsubxacts,
84  TransactionId *subxacts);
85 extern bool SnapBuildProcessChange(SnapBuild *builder, TransactionId xid,
86  XLogRecPtr lsn);
87 extern void SnapBuildProcessNewCid(SnapBuild *builder, TransactionId xid,
88  XLogRecPtr lsn, struct xl_heap_new_cid *cid);
89 extern void SnapBuildProcessRunningXacts(SnapBuild *builder, XLogRecPtr lsn,
90  struct xl_running_xacts *running);
91 extern void SnapBuildSerializationPoint(SnapBuild *builder, XLogRecPtr lsn);
92 
93 #endif /* SNAPBUILD_H */
bool SnapBuildXactNeedsSkip(SnapBuild *snapstate, XLogRecPtr ptr)
Definition: snapbuild.c:394
void SnapBuildClearExportedSnapshot(void)
Definition: snapbuild.c:683
uint32 TransactionId
Definition: c.h:587
void SnapBuildProcessNewCid(SnapBuild *builder, TransactionId xid, XLogRecPtr lsn, struct xl_heap_new_cid *cid)
Definition: snapbuild.c:756
void SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid, int nsubxacts, TransactionId *subxacts)
Definition: snapbuild.c:921
bool SnapBuildProcessChange(SnapBuild *builder, TransactionId xid, XLogRecPtr lsn)
Definition: snapbuild.c:706
Snapshot SnapBuildInitialSnapshot(SnapBuild *builder)
Definition: snapbuild.c:530
SnapBuildState
Definition: snapbuild.h:18
void CheckPointSnapBuild(void)
Definition: snapbuild.c:1907
void SnapBuildSetTwoPhaseAt(SnapBuild *builder, XLogRecPtr ptr)
Definition: snapbuild.c:385
SnapBuild * AllocateSnapshotBuilder(struct ReorderBuffer *cache, TransactionId xmin_horizon, XLogRecPtr start_lsn, bool need_full_snapshot, XLogRecPtr two_phase_at)
Definition: snapbuild.c:280
SnapBuildState SnapBuildCurrentState(SnapBuild *snapstate)
Definition: snapbuild.c:367
void SnapBuildProcessRunningXacts(SnapBuild *builder, XLogRecPtr lsn, struct xl_running_xacts *running)
Definition: snapbuild.c:1088
XLogRecPtr SnapBuildGetTwoPhaseAt(SnapBuild *builder)
Definition: snapbuild.c:376
uint64 XLogRecPtr
Definition: xlogdefs.h:21
void FreeSnapshotBuilder(SnapBuild *cache)
Definition: snapbuild.c:323
Snapshot SnapBuildGetOrBuildSnapshot(SnapBuild *builder, TransactionId xid)
Definition: snapbuild.c:662
const char * SnapBuildExportSnapshot(SnapBuild *snapstate)
Definition: snapbuild.c:622
void SnapBuildSnapDecRefcount(Snapshot snap)
Definition: snapbuild.c:418
void SnapBuildSerializationPoint(SnapBuild *builder, XLogRecPtr lsn)
Definition: snapbuild.c:1465