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