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-2023, 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 *reorder,
63  TransactionId xmin_horizon, XLogRecPtr start_lsn,
64  bool need_full_snapshot,
65  XLogRecPtr two_phase_at);
66 extern void FreeSnapshotBuilder(SnapBuild *builder);
67 
68 extern void SnapBuildSnapDecRefcount(Snapshot snap);
69 
71 extern const char *SnapBuildExportSnapshot(SnapBuild *builder);
72 extern void SnapBuildClearExportedSnapshot(void);
73 extern void SnapBuildResetExportedSnapshotState(void);
74 
77 
78 extern bool SnapBuildXactNeedsSkip(SnapBuild *builder, 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, uint32 xinfo);
85 extern bool SnapBuildProcessChange(SnapBuild *builder, TransactionId xid,
86  XLogRecPtr lsn);
87 extern void SnapBuildProcessNewCid(SnapBuild *builder, TransactionId xid,
88  XLogRecPtr lsn,
89  struct xl_heap_new_cid *xlrec);
90 extern void SnapBuildProcessRunningXacts(SnapBuild *builder, XLogRecPtr lsn,
91  struct xl_running_xacts *running);
92 extern void SnapBuildSerializationPoint(SnapBuild *builder, XLogRecPtr lsn);
93 
94 #endif /* SNAPBUILD_H */
unsigned int uint32
Definition: c.h:495
uint32 TransactionId
Definition: c.h:641
void SnapBuildProcessNewCid(SnapBuild *builder, TransactionId xid, XLogRecPtr lsn, struct xl_heap_new_cid *xlrec)
Definition: snapbuild.c:819
void SnapBuildSnapDecRefcount(Snapshot snap)
Definition: snapbuild.c:458
bool SnapBuildXactNeedsSkip(SnapBuild *builder, XLogRecPtr ptr)
Definition: snapbuild.c:434
void SnapBuildResetExportedSnapshotState(void)
Definition: snapbuild.c:757
void SnapBuildSetTwoPhaseAt(SnapBuild *builder, XLogRecPtr ptr)
Definition: snapbuild.c:425
bool SnapBuildProcessChange(SnapBuild *builder, TransactionId xid, XLogRecPtr lsn)
Definition: snapbuild.c:769
const char * SnapBuildExportSnapshot(SnapBuild *builder)
Definition: snapbuild.c:669
XLogRecPtr SnapBuildGetTwoPhaseAt(SnapBuild *builder)
Definition: snapbuild.c:416
SnapBuildState SnapBuildCurrentState(SnapBuild *builder)
Definition: snapbuild.c:407
void FreeSnapshotBuilder(SnapBuild *builder)
Definition: snapbuild.c:363
void CheckPointSnapBuild(void)
Definition: snapbuild.c:2055
Snapshot SnapBuildGetOrBuildSnapshot(SnapBuild *builder)
Definition: snapbuild.c:709
Snapshot SnapBuildInitialSnapshot(SnapBuild *builder)
Definition: snapbuild.c:570
SnapBuildState
Definition: snapbuild.h:19
@ SNAPBUILD_START
Definition: snapbuild.h:23
@ SNAPBUILD_BUILDING_SNAPSHOT
Definition: snapbuild.h:29
@ SNAPBUILD_FULL_SNAPSHOT
Definition: snapbuild.h:39
@ SNAPBUILD_CONSISTENT
Definition: snapbuild.h:46
void SnapBuildSerializationPoint(SnapBuild *builder, XLogRecPtr lsn)
Definition: snapbuild.c:1593
void SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid, int nsubxacts, TransactionId *subxacts, uint32 xinfo)
Definition: snapbuild.c:1025
void SnapBuildClearExportedSnapshot(void)
Definition: snapbuild.c:730
SnapBuild * AllocateSnapshotBuilder(struct ReorderBuffer *reorder, TransactionId xmin_horizon, XLogRecPtr start_lsn, bool need_full_snapshot, XLogRecPtr two_phase_at)
Definition: snapbuild.c:317
void SnapBuildProcessRunningXacts(SnapBuild *builder, XLogRecPtr lsn, struct xl_running_xacts *running)
Definition: snapbuild.c:1218
uint64 XLogRecPtr
Definition: xlogdefs.h:21