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