1/* -------------------------------------------------------------------------
4 * definition of the "subscription" system catalog (pg_subscription)
6 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
9 * src/include/catalog/pg_subscription.h
12 * The Catalog.pm module reads this file and derives schema
15 * -------------------------------------------------------------------------
17#ifndef PG_SUBSCRIPTION_H
18#define PG_SUBSCRIPTION_H
22#include "catalog/pg_subscription_d.h" /* IWYU pragma: export */
27 * pg_subscription definition. cpp turns this into
28 * typedef struct FormData_pg_subscription
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,
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).
48 * subscription is in. */
57 bool subenabled;
/* True if the subscription is enabled (the
58 * worker should be running) */
60 bool subbinary;
/* True if the subscription wants the
61 * publisher to send data in binary */
63 char substream;
/* Stream in-progress transactions. See
64 * LOGICALREP_STREAM_xxx constants. */
69 * subscription to be disabled */
74 * subscription owner */
77 * (i.e. the main slot and the table sync
78 * slots) in the upstream database are enabled
79 * to be synchronized to the standbys. */
82 * conflict detection are retained */
85 * for which information useful for
86 * conflict detection can be retained */
89 * and the retention duration has not
90 * exceeded max_retention_duration, when
93#ifdef CATALOG_VARLEN /* variable-length fields start here */
94 /* Connection string to the publisher */
97 /* Slot name on publisher */
100 /* Synchronous commit setting for worker */
103 /* List of publications subscribed to */
106 /* Only publish data originating from the specified origin */
124 Oid dbid;
/* Oid of the database which subscription is
128 char *
name;
/* Name of the subscription */
131 bool enabled;
/* Indicates if the subscription is enabled */
132 bool binary;
/* Indicates if the subscription wants data in
134 char stream;
/* Allow streaming in-progress transactions.
135 * See LOGICALREP_STREAM_xxx constants. */
138 * automatically disabled if a worker error
142 bool failover;
/* True if the associated replication slots
143 * (i.e. the main slot and the table sync
144 * slots) in the upstream database are enabled
145 * to be synchronized to the standbys. */
147 * detection are retained */
149 * which information useful for conflict
150 * detection can be retained */
152 * and the retention duration has not
153 * exceeded max_retention_duration, when
155 char *
conninfo;
/* Connection string to the publisher */
157 char *
synccommit;
/* Synchronous commit setting for worker */
159 char *
origin;
/* Only publish data originating from the
160 * specified origin */
163#ifdef EXPOSE_TO_CLIENT_CODE
166 * two_phase tri-state values. See comments atop worker.c to know more about
169#define LOGICALREP_TWOPHASE_STATE_DISABLED 'd'
170#define LOGICALREP_TWOPHASE_STATE_PENDING 'p'
171#define LOGICALREP_TWOPHASE_STATE_ENABLED 'e'
174 * The subscription will request the publisher to only send changes that do not
177#define LOGICALREP_ORIGIN_NONE "none"
180 * The subscription will request the publisher to send changes regardless
183#define LOGICALREP_ORIGIN_ANY "any"
185/* Disallow streaming in-progress transactions. */
186#define LOGICALREP_STREAM_OFF 'f'
189 * Streaming in-progress transactions are written to a temporary file and
190 * applied only after the transaction is committed on upstream.
192#define LOGICALREP_STREAM_ON 't'
195 * Streaming in-progress transactions are applied immediately via a parallel
198#define LOGICALREP_STREAM_PARALLEL 'p'
200#endif /* EXPOSE_TO_CLIENT_CODE */
211#endif /* PG_SUBSCRIPTION_H */
#define BKI_DEFAULT(value)
#define BKI_FORCE_NOT_NULL
#define BKI_SHARED_RELATION
#define BKI_ROWTYPE_OID(oid, oidmacro)
CATALOG(pg_subscription, 6100, SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(6101
int CountDBSubscriptions(Oid dbid)
DECLARE_TOAST_WITH_MACRO(pg_subscription, 4183, 4184, PgSubscriptionToastTable, PgSubscriptionToastIndex)
void FreeSubscription(Subscription *sub)
void DisableSubscription(Oid subid)
void GetPublicationsStr(List *publications, StringInfo dest, bool quote_literal)
DECLARE_UNIQUE_INDEX_PKEY(pg_subscription_oid_index, 6114, SubscriptionObjectIndexId, pg_subscription, btree(oid oid_ops))
struct Subscription Subscription
Oid subdbid BKI_LOOKUP(pg_database)
MAKE_SYSCACHE(SUBSCRIPTIONOID, pg_subscription_oid_index, 4)
Subscription * GetSubscription(Oid subid, bool missing_ok)
FormData_pg_subscription * Form_pg_subscription
DECLARE_UNIQUE_INDEX(pg_subscription_subname_index, 6115, SubscriptionNameIndexId, pg_subscription, btree(subdbid oid_ops, subname name_ops))
SubscriptionRelation_Rowtype_Id BKI_SCHEMA_MACRO
Datum quote_literal(PG_FUNCTION_ARGS)