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#ifdef CATALOG_VARLEN /* variable-length fields start here */
99 /* Connection string to the publisher */
100 text subconninfo; /* Set if connecting with connection string */
101
102 /* Slot name on publisher */
103 NameData subslotname BKI_FORCE_NULL;
104
105 /* Synchronous commit setting for worker */
106 text subsynccommit BKI_FORCE_NOT_NULL;
107
108 /* wal_receiver_timeout setting for worker */
109 text subwalrcvtimeout BKI_FORCE_NOT_NULL;
110
111 /* List of publications subscribed to */
112 text subpublications[1] BKI_FORCE_NOT_NULL;
113
114 /* Only publish data originating from the specified origin */
116#endif
118
120
122
124
127
130
131typedef struct Subscription
132{
133 MemoryContext cxt; /* mem cxt containing this subscription */
134
135 Oid oid; /* Oid of the subscription */
136 Oid dbid; /* Oid of the database which subscription is
137 * in */
138 XLogRecPtr skiplsn; /* All changes finished at this LSN are
139 * skipped */
140 char *name; /* Name of the subscription */
141 Oid owner; /* Oid of the subscription owner */
142 bool ownersuperuser; /* Is the subscription owner a superuser? */
143 bool enabled; /* Indicates if the subscription is enabled */
144 bool binary; /* Indicates if the subscription wants data in
145 * binary format */
146 char stream; /* Allow streaming in-progress transactions.
147 * See LOGICALREP_STREAM_xxx constants. */
148 char twophasestate; /* Allow streaming two-phase transactions */
149 bool disableonerr; /* Indicates if the subscription should be
150 * automatically disabled if a worker error
151 * occurs */
152 bool passwordrequired; /* Must connection use a password? */
153 bool runasowner; /* Run replication as subscription owner */
154 bool failover; /* True if the associated replication slots
155 * (i.e. the main slot and the table sync
156 * slots) in the upstream database are enabled
157 * to be synchronized to the standbys. */
158 bool retaindeadtuples; /* True if dead tuples useful for conflict
159 * detection are retained */
160 int32 maxretention; /* The maximum duration (in milliseconds) for
161 * which information useful for conflict
162 * detection can be retained */
163 bool retentionactive; /* True if retain_dead_tuples is enabled
164 * and the retention duration has not
165 * exceeded max_retention_duration, when
166 * defined */
167 char *conninfo; /* Connection string to the publisher */
168 char *slotname; /* Name of the replication slot */
169 char *synccommit; /* Synchronous commit setting for worker */
170 char *walrcvtimeout; /* wal_receiver_timeout setting for worker */
171 List *publications; /* List of publication names to subscribe to */
172 char *origin; /* Only publish data originating from the
173 * specified origin */
175
176#ifdef EXPOSE_TO_CLIENT_CODE
177
178/*
179 * two_phase tri-state values. See comments atop worker.c to know more about
180 * these states.
181 */
182#define LOGICALREP_TWOPHASE_STATE_DISABLED 'd'
183#define LOGICALREP_TWOPHASE_STATE_PENDING 'p'
184#define LOGICALREP_TWOPHASE_STATE_ENABLED 'e'
185
186/*
187 * The subscription will request the publisher to only send changes that do not
188 * have any origin.
189 */
190#define LOGICALREP_ORIGIN_NONE "none"
191
192/*
193 * The subscription will request the publisher to send changes regardless
194 * of their origin.
195 */
196#define LOGICALREP_ORIGIN_ANY "any"
197
198/* Disallow streaming in-progress transactions. */
199#define LOGICALREP_STREAM_OFF 'f'
200
201/*
202 * Streaming in-progress transactions are written to a temporary file and
203 * applied only after the transaction is committed on upstream.
204 */
205#define LOGICALREP_STREAM_ON 't'
206
207/*
208 * Streaming in-progress transactions are applied immediately via a parallel
209 * apply worker.
210 */
211#define LOGICALREP_STREAM_PARALLEL 'p'
212
213#endif /* EXPOSE_TO_CLIENT_CODE */
214
215extern Subscription *GetSubscription(Oid subid, bool missing_ok,
216 bool aclcheck);
217extern void DisableSubscription(Oid subid);
218
219extern int CountDBSubscriptions(Oid dbid);
220
221extern void GetPublicationsStr(List *publications, StringInfo dest,
222 bool quote_literal);
223
224#endif /* PG_SUBSCRIPTION_H */
int32_t int32
Definition c.h:620
#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
Subscription * GetSubscription(Oid subid, bool missing_ok, bool aclcheck)
char substream
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
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:830
Definition c.h:776
uint64 XLogRecPtr
Definition xlogdefs.h:21