PostgreSQL Source Code git master
Loading...
Searching...
No Matches
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-2026, 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 * forward declarations in this file
20 */
22typedef struct SnapBuild SnapBuild;
25
26/*
27 * Please keep get_snapbuild_state_desc() (located in the pg_logicalinspect
28 * module) updated if a change needs to be made to SnapBuildState.
29 */
30typedef enum
31{
32 /*
33 * Initial state, we can't do much yet.
34 */
36
37 /*
38 * Collecting committed transactions, to build the initial catalog
39 * snapshot.
40 */
42
43 /*
44 * We have collected enough information to decode tuples in transactions
45 * that started after this.
46 *
47 * Once we reached this we start to collect changes. We cannot apply them
48 * yet, because they might be based on transactions that were still
49 * running when FULL_SNAPSHOT was reached.
50 */
52
53 /*
54 * Found a point after SNAPBUILD_FULL_SNAPSHOT where all transactions that
55 * were running at that point finished. Till we reach that we hold off
56 * calling any commit callbacks.
57 */
60
61
62
63extern void CheckPointSnapBuild(void);
64
68 bool in_slot_creation,
69 XLogRecPtr two_phase_at);
70extern void FreeSnapshotBuilder(SnapBuild *builder);
71
73
75extern const char *SnapBuildExportSnapshot(SnapBuild *builder);
76extern void SnapBuildClearExportedSnapshot(void);
78
81
82extern bool SnapBuildXactNeedsSkip(SnapBuild *builder, XLogRecPtr ptr);
84extern void SnapBuildSetTwoPhaseAt(SnapBuild *builder, XLogRecPtr ptr);
85
86extern void SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn,
87 TransactionId xid, int nsubxacts,
88 TransactionId *subxacts, uint32 xinfo);
89extern bool SnapBuildProcessChange(SnapBuild *builder, TransactionId xid,
90 XLogRecPtr lsn);
91extern void SnapBuildProcessNewCid(SnapBuild *builder, TransactionId xid,
92 XLogRecPtr lsn,
94extern void SnapBuildProcessRunningXacts(SnapBuild *builder, XLogRecPtr lsn,
95 xl_running_xacts *running,
96 bool db_specific);
97extern void SnapBuildSerializationPoint(SnapBuild *builder, XLogRecPtr lsn);
98
99extern bool SnapBuildSnapshotExists(XLogRecPtr lsn);
100
101#endif /* SNAPBUILD_H */
uint32_t uint32
Definition c.h:624
uint32 TransactionId
Definition c.h:736
static int fb(int x)
void SnapBuildSnapDecRefcount(Snapshot snap)
Definition snapbuild.c:346
bool SnapBuildXactNeedsSkip(SnapBuild *builder, XLogRecPtr ptr)
Definition snapbuild.c:322
void SnapBuildResetExportedSnapshotState(void)
Definition snapbuild.c:644
void SnapBuildSetTwoPhaseAt(SnapBuild *builder, XLogRecPtr ptr)
Definition snapbuild.c:313
bool SnapBuildProcessChange(SnapBuild *builder, TransactionId xid, XLogRecPtr lsn)
Definition snapbuild.c:656
XLogRecPtr SnapBuildGetTwoPhaseAt(SnapBuild *builder)
Definition snapbuild.c:304
SnapBuildState SnapBuildCurrentState(SnapBuild *builder)
Definition snapbuild.c:295
SnapBuild * AllocateSnapshotBuilder(ReorderBuffer *reorder, TransactionId xmin_horizon, XLogRecPtr start_lsn, bool need_full_snapshot, bool in_slot_creation, XLogRecPtr two_phase_at)
Definition snapbuild.c:197
void SnapBuildProcessRunningXacts(SnapBuild *builder, XLogRecPtr lsn, xl_running_xacts *running, bool db_specific)
Definition snapbuild.c:1154
void FreeSnapshotBuilder(SnapBuild *builder)
Definition snapbuild.c:248
bool SnapBuildSnapshotExists(XLogRecPtr lsn)
Definition snapbuild.c:2118
void CheckPointSnapBuild(void)
Definition snapbuild.c:2030
Snapshot SnapBuildGetOrBuildSnapshot(SnapBuild *builder)
Definition snapbuild.c:596
Snapshot SnapBuildInitialSnapshot(SnapBuild *builder)
Definition snapbuild.c:458
SnapBuildState
Definition snapbuild.h:31
@ SNAPBUILD_START
Definition snapbuild.h:35
@ SNAPBUILD_BUILDING_SNAPSHOT
Definition snapbuild.h:41
@ SNAPBUILD_FULL_SNAPSHOT
Definition snapbuild.h:51
@ SNAPBUILD_CONSISTENT
Definition snapbuild.h:58
const char * SnapBuildExportSnapshot(SnapBuild *builder)
Definition snapbuild.c:556
void SnapBuildSerializationPoint(SnapBuild *builder, XLogRecPtr lsn)
Definition snapbuild.c:1544
void SnapBuildCommitTxn(SnapBuild *builder, XLogRecPtr lsn, TransactionId xid, int nsubxacts, TransactionId *subxacts, uint32 xinfo)
Definition snapbuild.c:958
void SnapBuildProcessNewCid(SnapBuild *builder, TransactionId xid, XLogRecPtr lsn, xl_heap_new_cid *xlrec)
Definition snapbuild.c:706
void SnapBuildClearExportedSnapshot(void)
Definition snapbuild.c:617
uint64 XLogRecPtr
Definition xlogdefs.h:21