PostgreSQL Source Code git master
Loading...
Searching...
No Matches
pg_subscription_rel.h
Go to the documentation of this file.
1/* -------------------------------------------------------------------------
2 *
3 * pg_subscription_rel.h
4 * definition of the system catalog containing the state for each
5 * replicated table in each subscription (pg_subscription_rel)
6 *
7 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
9 *
10 * src/include/catalog/pg_subscription_rel.h
11 *
12 * NOTES
13 * The Catalog.pm module reads this file and derives schema
14 * information.
15 *
16 * -------------------------------------------------------------------------
17 */
18#ifndef PG_SUBSCRIPTION_REL_H
19#define PG_SUBSCRIPTION_REL_H
20
21#include "access/xlogdefs.h"
22#include "catalog/genbki.h"
23#include "catalog/pg_subscription_rel_d.h" /* IWYU pragma: export */
24#include "nodes/pg_list.h"
25
26/* ----------------
27 * pg_subscription_rel definition. cpp turns this into
28 * typedef struct FormData_pg_subscription_rel
29 * ----------------
30 */
32
34{
35 Oid srsubid BKI_LOOKUP(pg_subscription); /* Oid of subscription */
36 Oid srrelid BKI_LOOKUP(pg_class); /* Oid of relation */
37 char srsubstate; /* state of the relation in subscription */
38
39 /*
40 * Although srsublsn is a fixed-width type, it is allowed to be NULL, so
41 * we prevent direct C code access to it just as for a varlena field.
42 */
43#ifdef CATALOG_VARLEN /* variable-length fields start here */
44
45 XLogRecPtr srsublsn BKI_FORCE_NULL; /* remote LSN of the state change
46 * used for synchronization
47 * coordination, or NULL if not
48 * valid */
49#endif
51
53
55
57
59
60#ifdef EXPOSE_TO_CLIENT_CODE
61
62/* ----------------
63 * substate constants
64 * ----------------
65 */
66#define SUBREL_STATE_INIT 'i' /* initializing (sublsn NULL) */
67#define SUBREL_STATE_DATASYNC 'd' /* data is being synchronized (sublsn
68 * NULL) */
69#define SUBREL_STATE_FINISHEDCOPY 'f' /* tablesync copy phase is completed
70 * (sublsn NULL) */
71#define SUBREL_STATE_SYNCDONE 's' /* synchronization finished in front of
72 * apply (sublsn set) */
73#define SUBREL_STATE_READY 'r' /* ready (sublsn set) */
74
75/* These are never stored in the catalog, we only use them for IPC. */
76#define SUBREL_STATE_UNKNOWN '\0' /* unknown state */
77#define SUBREL_STATE_SYNCWAIT 'w' /* waiting for sync */
78#define SUBREL_STATE_CATCHUP 'c' /* catching up with apply */
79
80#endif /* EXPOSE_TO_CLIENT_CODE */
81
88
89/*
90 * Holds local sequence identity and corresponding publisher values used during
91 * sequence synchronization.
92 */
94{
95 /* Sequence information retrieved from the local node */
96 char *seqname;
97 char *nspname;
99
100 /* Sequence information retrieved from the publisher node */
104
105 /*
106 * True if the sequence identified by nspname + seqname exists on the
107 * publisher.
108 */
111
112extern void AddSubscriptionRelState(Oid subid, Oid relid, char state,
114extern void UpdateSubscriptionRelState(Oid subid, Oid relid, char state,
116extern char GetSubscriptionRelState(Oid subid, Oid relid, XLogRecPtr *sublsn);
117extern void RemoveSubscriptionRel(Oid subid, Oid relid);
118
119extern bool HasSubscriptionTables(Oid subid);
120extern List *GetSubscriptionRelations(Oid subid, bool tables, bool sequences,
121 bool not_ready);
122
123extern void UpdateDeadTupleRetentionStatus(Oid subid, bool active);
124
125#endif /* PG_SUBSCRIPTION_REL_H */
int64_t int64
Definition c.h:576
#define BEGIN_CATALOG_STRUCT
Definition genbki.h:37
#define DECLARE_UNIQUE_INDEX_PKEY(name, oid, oidmacro, tblname, decl)
Definition genbki.h:105
#define BKI_LOOKUP(catalog)
Definition genbki.h:65
#define END_CATALOG_STRUCT
Definition genbki.h:38
#define BKI_FORCE_NULL
Definition genbki.h:51
#define CATALOG(name, oid, oidmacro)
Definition genbki.h:42
#define MAKE_SYSCACHE(name, idxname, nbuckets)
Definition genbki.h:146
static SequenceItem * sequences
Definition pg_dump.c:214
void UpdateSubscriptionRelState(Oid subid, Oid relid, char state, XLogRecPtr sublsn, bool already_locked)
FormData_pg_subscription_rel
void RemoveSubscriptionRel(Oid subid, Oid relid)
char GetSubscriptionRelState(Oid subid, Oid relid, XLogRecPtr *sublsn)
void AddSubscriptionRelState(Oid subid, Oid relid, char state, XLogRecPtr sublsn, bool retain_lock)
bool HasSubscriptionTables(Oid subid)
void UpdateDeadTupleRetentionStatus(Oid subid, bool active)
END_CATALOG_STRUCT typedef FormData_pg_subscription_rel * Form_pg_subscription_rel
List * GetSubscriptionRelations(Oid subid, bool tables, bool sequences, bool not_ready)
unsigned int Oid
static int fb(int x)
Definition pg_list.h:54
uint64 XLogRecPtr
Definition xlogdefs.h:21