PostgreSQL Source Code git master
Loading...
Searching...
No Matches
pg_subscription.h
Go to the documentation of this file.
1/* -------------------------------------------------------------------------
2 *
3 * pg_subscription.h
4 * definition of the "subscription" system catalog (pg_subscription)
5 *
6 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
8 *
9 * src/include/catalog/pg_subscription.h
10 *
11 * NOTES
12 * The Catalog.pm module reads this file and derives schema
13 * information.
14 *
15 * -------------------------------------------------------------------------
16 */
17#ifndef PG_SUBSCRIPTION_H
18#define PG_SUBSCRIPTION_H
19
20#include "access/xlogdefs.h"
21#include "catalog/genbki.h"
22#include "catalog/pg_subscription_d.h" /* IWYU pragma: export */
23#include "lib/stringinfo.h"
24#include "nodes/pg_list.h"
25
26/* ----------------
27 * pg_subscription definition. cpp turns this into
28 * typedef struct FormData_pg_subscription
29 * ----------------
30 */
31
32/*
33 * Technically, the subscriptions live inside the database, so a shared catalog
34 * seems weird, but the replication launcher process needs to access all of
35 * them to be able to start the workers, so we have to put them in a shared,
36 * nailed catalog.
37 *
38 * CAUTION: There is a GRANT in system_views.sql to grant public select
39 * access on all columns except subconninfo. When you add a new column
40 * here, be sure to update that (or, if the new column is not to be publicly
41 * readable, update associated comments and catalogs.sgml instead).
42 */
44
46{
47 Oid oid; /* oid */
48
50 * subscription is in. */
51
52 XLogRecPtr subskiplsn; /* All changes finished at this LSN are
53 * skipped */
54
55 NameData subname; /* Name of the subscription */
56
57 Oid subowner BKI_LOOKUP(pg_authid); /* Owner of the subscription */
58
59 bool subenabled; /* True if the subscription is enabled (the
60 * worker should be running) */
61
62 bool subbinary; /* True if the subscription wants the
63 * publisher to send data in binary */
64
65 char substream; /* Stream in-progress transactions. See
66 * LOGICALREP_STREAM_xxx constants. */
67
68 char subtwophasestate; /* Stream two-phase transactions */
69
70 bool subdisableonerr; /* True if a worker error should cause the
71 * subscription to be disabled */
72
73 bool subpasswordrequired; /* Must connection use a password? */
74
75 bool subrunasowner; /* True if replication should execute as the
76 * subscription owner */
77
78 bool subfailover; /* True if the associated replication slots
79 * (i.e. the main slot and the table sync
80 * slots) in the upstream database are enabled
81 * to be synchronized to the standbys. */
82
83 bool subretaindeadtuples; /* True if dead tuples useful for
84 * conflict detection are retained */
85
86 int32 submaxretention; /* The maximum duration (in milliseconds)
87 * for which information useful for
88 * conflict detection can be retained */
89
90 bool subretentionactive; /* True if retain_dead_tuples is enabled
91 * and the retention duration has not
92 * exceeded max_retention_duration, when
93 * defined */
94
96 * server */
97
98 Oid subconflictlogrelid; /* Relid of the conflict log table. */
99#ifdef CATALOG_VARLEN /* variable-length fields start here */
100
101 /*
102 * Strategy for logging replication conflicts: 'log' - server log only,
103 * 'table' - conflict log table only, 'all' - both log and table.
104 */
106
107 /* Connection string to the publisher */
108 text subconninfo; /* Set if connecting with connection string */
109
110 /* Slot name on publisher */
111 NameData subslotname BKI_FORCE_NULL;
112
113 /* Synchronous commit setting for worker */
114 text subsynccommit BKI_FORCE_NOT_NULL;
115
116 /* wal_receiver_timeout setting for worker */
117 text subwalrcvtimeout BKI_FORCE_NOT_NULL;
118
119 /* List of publications subscribed to */
120 text subpublications[1] BKI_FORCE_NOT_NULL;
121
122 /* Only publish data originating from the specified origin */
124#endif
126
128
130
132
135
138
139typedef struct Subscription
140{
141 MemoryContext cxt; /* mem cxt containing this subscription */
142
143 Oid oid; /* Oid of the subscription */
144 Oid dbid; /* Oid of the database which subscription is
145 * in */
146 XLogRecPtr skiplsn; /* All changes finished at this LSN are
147 * skipped */
148 char *name; /* Name of the subscription */
149 Oid owner; /* Oid of the subscription owner */
150 bool ownersuperuser; /* Is the subscription owner a superuser? */
151 bool enabled; /* Indicates if the subscription is enabled */
152 bool binary; /* Indicates if the subscription wants data in
153 * binary format */
154 char stream; /* Allow streaming in-progress transactions.
155 * See LOGICALREP_STREAM_xxx constants. */
156 char twophasestate; /* Allow streaming two-phase transactions */
157 bool disableonerr; /* Indicates if the subscription should be
158 * automatically disabled if a worker error
159 * occurs */
160 bool passwordrequired; /* Must connection use a password? */
161 bool runasowner; /* Run replication as subscription owner */
162 bool failover; /* True if the associated replication slots
163 * (i.e. the main slot and the table sync
164 * slots) in the upstream database are enabled
165 * to be synchronized to the standbys. */
166 bool retaindeadtuples; /* True if dead tuples useful for conflict
167 * detection are retained */
168 int32 maxretention; /* The maximum duration (in milliseconds) for
169 * which information useful for conflict
170 * detection can be retained */
171 bool retentionactive; /* True if retain_dead_tuples is enabled
172 * and the retention duration has not
173 * exceeded max_retention_duration, when
174 * defined */
175 Oid conflictlogrelid; /* conflict log table Oid */
176 char *conninfo; /* Connection string to the publisher */
177 char *slotname; /* Name of the replication slot */
178 char *synccommit; /* Synchronous commit setting for worker */
179 char *walrcvtimeout; /* wal_receiver_timeout setting for worker */
180 List *publications; /* List of publication names to subscribe to */
181 char *origin; /* Only publish data originating from the
182 * specified origin */
183 char *conflictlogdest; /* Conflict log destination */
185
186#ifdef EXPOSE_TO_CLIENT_CODE
187
188/*
189 * two_phase tri-state values. See comments atop worker.c to know more about
190 * these states.
191 */
192#define LOGICALREP_TWOPHASE_STATE_DISABLED 'd'
193#define LOGICALREP_TWOPHASE_STATE_PENDING 'p'
194#define LOGICALREP_TWOPHASE_STATE_ENABLED 'e'
195
196/*
197 * The subscription will request the publisher to only send changes that do not
198 * have any origin.
199 */
200#define LOGICALREP_ORIGIN_NONE "none"
201
202/*
203 * The subscription will request the publisher to send changes regardless
204 * of their origin.
205 */
206#define LOGICALREP_ORIGIN_ANY "any"
207
208/* Disallow streaming in-progress transactions. */
209#define LOGICALREP_STREAM_OFF 'f'
210
211/*
212 * Streaming in-progress transactions are written to a temporary file and
213 * applied only after the transaction is committed on upstream.
214 */
215#define LOGICALREP_STREAM_ON 't'
216
217/*
218 * Streaming in-progress transactions are applied immediately via a parallel
219 * apply worker.
220 */
221#define LOGICALREP_STREAM_PARALLEL 'p'
222
223#endif /* EXPOSE_TO_CLIENT_CODE */
224
225extern Subscription *GetSubscription(Oid subid, bool missing_ok,
226 bool conninfo_needed,
227 bool conninfo_aclcheck);
228extern void DisableSubscription(Oid subid);
229
230extern int CountDBSubscriptions(Oid dbid);
231
232extern void GetPublicationsStr(List *publications, StringInfo dest,
233 bool quote_literal);
234
235#endif /* PG_SUBSCRIPTION_H */
int32_t int32
Definition c.h:679
#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_DEFAULT(value)
Definition genbki.h:54
#define BKI_LOOKUP_OPT(catalog)
Definition genbki.h:66
#define DECLARE_TOAST_WITH_MACRO(name, toastoid, indexoid, toastoidmacro, indexoidmacro)
Definition genbki.h:83
#define DECLARE_UNIQUE_INDEX(name, oid, oidmacro, tblname, decl)
Definition genbki.h:104
#define BKI_FORCE_NOT_NULL
Definition genbki.h:52
#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
#define BKI_SHARED_RELATION
Definition genbki.h:46
#define BKI_ROWTYPE_OID(oid, oidmacro)
Definition genbki.h:47
bool subdisableonerr
int CountDBSubscriptions(Oid dbid)
bool subrunasowner
bool subenabled
char subtwophasestate
char substream
Subscription * GetSubscription(Oid subid, bool missing_ok, bool conninfo_needed, bool conninfo_aclcheck)
bool subpasswordrequired
void DisableSubscription(Oid subid)
NameData subname
void GetPublicationsStr(List *publications, StringInfo dest, bool quote_literal)
XLogRecPtr subskiplsn
FormData_pg_subscription
int32 submaxretention
bool subretaindeadtuples
bool subbinary
END_CATALOG_STRUCT typedef FormData_pg_subscription * Form_pg_subscription
Oid subconflictlogrelid
BEGIN_CATALOG_STRUCT SubscriptionRelation_Rowtype_Id BKI_SCHEMA_MACRO
bool subfailover
bool subretentionactive
unsigned int Oid
static int fb(int x)
Datum quote_literal(PG_FUNCTION_ARGS)
Definition quote.c:76
Definition pg_list.h:54
MemoryContext cxt
XLogRecPtr skiplsn
Definition c.h:889
Definition c.h:835
uint64 XLogRecPtr
Definition xlogdefs.h:21