Update copyright for 2022
[pgsql.git] / src / include / catalog / pg_subscription.h
blob18c291289f634b3cd83390fa4f3c1405a54f6d57
1 /* -------------------------------------------------------------------------
3 * pg_subscription.h
4 * definition of the "subscription" system catalog (pg_subscription)
6 * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
9 * src/include/catalog/pg_subscription.h
11 * NOTES
12 * The Catalog.pm module reads this file and derives schema
13 * information.
15 * -------------------------------------------------------------------------
17 #ifndef PG_SUBSCRIPTION_H
18 #define PG_SUBSCRIPTION_H
20 #include "catalog/genbki.h"
21 #include "catalog/pg_subscription_d.h"
23 #include "nodes/pg_list.h"
26 * two_phase tri-state values. See comments atop worker.c to know more about
27 * these states.
29 #define LOGICALREP_TWOPHASE_STATE_DISABLED 'd'
30 #define LOGICALREP_TWOPHASE_STATE_PENDING 'p'
31 #define LOGICALREP_TWOPHASE_STATE_ENABLED 'e'
33 /* ----------------
34 * pg_subscription definition. cpp turns this into
35 * typedef struct FormData_pg_subscription
36 * ----------------
40 * Technically, the subscriptions live inside the database, so a shared catalog
41 * seems weird, but the replication launcher process needs to access all of
42 * them to be able to start the workers, so we have to put them in a shared,
43 * nailed catalog.
45 * CAUTION: There is a GRANT in system_views.sql to grant public select
46 * access on all columns except subconninfo. When you add a new column
47 * here, be sure to update that (or, if the new column is not to be publicly
48 * readable, update associated comments and catalogs.sgml instead).
50 CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(6101,SubscriptionRelation_Rowtype_Id) BKI_SCHEMA_MACRO
52 Oid oid; /* oid */
54 Oid subdbid BKI_LOOKUP(pg_database); /* Database the
55 * subscription is in. */
56 NameData subname; /* Name of the subscription */
58 Oid subowner BKI_LOOKUP(pg_authid); /* Owner of the subscription */
60 bool subenabled; /* True if the subscription is enabled (the
61 * worker should be running) */
63 bool subbinary; /* True if the subscription wants the
64 * publisher to send data in binary */
66 bool substream; /* Stream in-progress transactions. */
68 char subtwophasestate; /* Stream two-phase transactions */
70 #ifdef CATALOG_VARLEN /* variable-length fields start here */
71 /* Connection string to the publisher */
72 text subconninfo BKI_FORCE_NOT_NULL;
74 /* Slot name on publisher */
75 NameData subslotname BKI_FORCE_NULL;
77 /* Synchronous commit setting for worker */
78 text subsynccommit BKI_FORCE_NOT_NULL;
80 /* List of publications subscribed to */
81 text subpublications[1] BKI_FORCE_NOT_NULL;
82 #endif
83 } FormData_pg_subscription;
85 typedef FormData_pg_subscription *Form_pg_subscription;
87 DECLARE_TOAST(pg_subscription, 4183, 4184);
88 #define PgSubscriptionToastTable 4183
89 #define PgSubscriptionToastIndex 4184
91 DECLARE_UNIQUE_INDEX_PKEY(pg_subscription_oid_index, 6114, SubscriptionObjectIndexId, on pg_subscription using btree(oid oid_ops));
92 DECLARE_UNIQUE_INDEX(pg_subscription_subname_index, 6115, SubscriptionNameIndexId, on pg_subscription using btree(subdbid oid_ops, subname name_ops));
94 typedef struct Subscription
96 Oid oid; /* Oid of the subscription */
97 Oid dbid; /* Oid of the database which subscription is
98 * in */
99 char *name; /* Name of the subscription */
100 Oid owner; /* Oid of the subscription owner */
101 bool enabled; /* Indicates if the subscription is enabled */
102 bool binary; /* Indicates if the subscription wants data in
103 * binary format */
104 bool stream; /* Allow streaming in-progress transactions. */
105 char twophasestate; /* Allow streaming two-phase transactions */
106 char *conninfo; /* Connection string to the publisher */
107 char *slotname; /* Name of the replication slot */
108 char *synccommit; /* Synchronous commit setting for worker */
109 List *publications; /* List of publication names to subscribe to */
110 } Subscription;
112 extern Subscription *GetSubscription(Oid subid, bool missing_ok);
113 extern void FreeSubscription(Subscription *sub);
114 extern Oid get_subscription_oid(const char *subname, bool missing_ok);
115 extern char *get_subscription_name(Oid subid, bool missing_ok);
117 extern int CountDBSubscriptions(Oid dbid);
119 #endif /* PG_SUBSCRIPTION_H */