PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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-2024, 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/*
19 * Please keep get_snapbuild_state_desc() (located in the pg_logicalinspect
20 * module) updated if a change needs to be made to SnapBuildState.
21 */
22typedef enum
23{
24 /*
25 * Initial state, we can't do much yet.
26 */
28
29 /*
30 * Collecting committed transactions, to build the initial catalog
31 * snapshot.
32 */
34
35 /*
36 * We have collected enough information to decode tuples in transactions
37 * that started after this.
38 *
39 * Once we reached this we start to collect changes. We cannot apply them
40 * yet, because they might be based on transactions that were still
41 * running when FULL_SNAPSHOT was reached.
42 */
44
45 /*
46 * Found a point after SNAPBUILD_FULL_SNAPSHOT where all transactions that
47 * were running at that point finished. Till we reach that we hold off
48 * calling any commit callbacks.
49 */
52
53/* forward declare so we don't have to include snapbuild_internal.h */
54struct SnapBuild;
55typedef struct SnapBuild SnapBuild;
56
57/* forward declare so we don't have to include reorderbuffer.h */
58struct ReorderBuffer;
59
60/* forward declare so we don't have to include heapam_xlog.h */
61struct xl_heap_new_cid;
62struct xl_running_xacts;
63
64extern void CheckPointSnapBuild(void);
65
66extern SnapBuild *AllocateSnapshotBuilder(struct ReorderBuffer *reorder,
67 TransactionId xmin_horizon, XLogRecPtr start_lsn,
68 bool need_full_snapshot,
69 bool in_slot_creation,
70 XLogRecPtr two_phase_at);
71extern void FreeSnapshotBuilder(SnapBuild *builder);
72
73extern void SnapBuildSnapDecRefcount(Snapshot snap);
74
76extern const char *SnapBuildExportSnapshot(SnapBuild *builder);
77extern void SnapBuildClearExportedSnapshot(void);
79
82
83extern bool SnapBuildXactNeedsSkip(SnapBuild *builder, XLogRecPtr ptr);
85extern void SnapBuildSetTwoPhaseAt(SnapBuild *builder, XLogRecPtr ptr);
86
87extern void SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn,
88 TransactionId xid, int nsubxacts,
89 TransactionId *subxacts, uint32 xinfo);
90extern bool SnapBuildProcessChange(SnapBuild *builder, TransactionId xid,
91 XLogRecPtr lsn);
92extern void SnapBuildProcessNewCid(SnapBuild *builder, TransactionId xid,
93 XLogRecPtr lsn,
94 struct xl_heap_new_cid *xlrec);
95extern void SnapBuildProcessRunningXacts(SnapBuild *builder, XLogRecPtr lsn,
96 struct xl_running_xacts *running);
97extern void SnapBuildSerializationPoint(SnapBuild *builder, XLogRecPtr lsn);
98
99extern bool SnapBuildSnapshotExists(XLogRecPtr lsn);
100
101#endif /* SNAPBUILD_H */
uint32_t uint32
Definition: c.h:485
uint32 TransactionId
Definition: c.h:606
void SnapBuildProcessNewCid(SnapBuild *builder, TransactionId xid, XLogRecPtr lsn, struct xl_heap_new_cid *xlrec)
Definition: snapbuild.c:689
void SnapBuildSnapDecRefcount(Snapshot snap)
Definition: snapbuild.c:328
bool SnapBuildXactNeedsSkip(SnapBuild *builder, XLogRecPtr ptr)
Definition: snapbuild.c:304
void SnapBuildResetExportedSnapshotState(void)
Definition: snapbuild.c:627
void SnapBuildSetTwoPhaseAt(SnapBuild *builder, XLogRecPtr ptr)
Definition: snapbuild.c:295
bool SnapBuildProcessChange(SnapBuild *builder, TransactionId xid, XLogRecPtr lsn)
Definition: snapbuild.c:639
XLogRecPtr SnapBuildGetTwoPhaseAt(SnapBuild *builder)
Definition: snapbuild.c:286
SnapBuildState SnapBuildCurrentState(SnapBuild *builder)
Definition: snapbuild.c:277
void FreeSnapshotBuilder(SnapBuild *builder)
Definition: snapbuild.c:233
bool SnapBuildSnapshotExists(XLogRecPtr lsn)
Definition: snapbuild.c:2010
void CheckPointSnapBuild(void)
Definition: snapbuild.c:1922
Snapshot SnapBuildGetOrBuildSnapshot(SnapBuild *builder)
Definition: snapbuild.c:579
Snapshot SnapBuildInitialSnapshot(SnapBuild *builder)
Definition: snapbuild.c:440
SnapBuildState
Definition: snapbuild.h:23
@ SNAPBUILD_START
Definition: snapbuild.h:27
@ SNAPBUILD_BUILDING_SNAPSHOT
Definition: snapbuild.h:33
@ SNAPBUILD_FULL_SNAPSHOT
Definition: snapbuild.h:43
@ SNAPBUILD_CONSISTENT
Definition: snapbuild.h:50
const char * SnapBuildExportSnapshot(SnapBuild *builder)
Definition: snapbuild.c:539
SnapBuild * AllocateSnapshotBuilder(struct ReorderBuffer *reorder, TransactionId xmin_horizon, XLogRecPtr start_lsn, bool need_full_snapshot, bool in_slot_creation, XLogRecPtr two_phase_at)
Definition: snapbuild.c:185
void SnapBuildSerializationPoint(SnapBuild *builder, XLogRecPtr lsn)
Definition: snapbuild.c:1436
void SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid, int nsubxacts, TransactionId *subxacts, uint32 xinfo)
Definition: snapbuild.c:895
void SnapBuildClearExportedSnapshot(void)
Definition: snapbuild.c:600
void SnapBuildProcessRunningXacts(SnapBuild *builder, XLogRecPtr lsn, struct xl_running_xacts *running)
Definition: snapbuild.c:1088
uint64 XLogRecPtr
Definition: xlogdefs.h:21