PostgreSQL Source Code  git master
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-2021, 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 "catalog/genbki.h"
21 #include "catalog/pg_subscription_d.h"
22 
23 #include "nodes/pg_list.h"
24 
25 /* ----------------
26  * pg_subscription definition. cpp turns this into
27  * typedef struct FormData_pg_subscription
28  * ----------------
29  */
30 
31 /*
32  * Technically, the subscriptions live inside the database, so a shared catalog
33  * seems weird, but the replication launcher process needs to access all of
34  * them to be able to start the workers, so we have to put them in a shared,
35  * nailed catalog.
36  *
37  * NOTE: When adding a column, also update system_views.sql.
38  */
39 CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(6101,SubscriptionRelation_Rowtype_Id) BKI_SCHEMA_MACRO
40 {
41  Oid oid; /* oid */
42 
43  Oid subdbid BKI_LOOKUP(pg_database); /* Database the
44  * subscription is in. */
45  NameData subname; /* Name of the subscription */
46 
47  Oid subowner BKI_LOOKUP(pg_authid); /* Owner of the subscription */
48 
49  bool subenabled; /* True if the subscription is enabled (the
50  * worker should be running) */
51 
52  bool subbinary; /* True if the subscription wants the
53  * publisher to send data in binary */
54 
55  bool substream; /* Stream in-progress transactions. */
56 
57 #ifdef CATALOG_VARLEN /* variable-length fields start here */
58  /* Connection string to the publisher */
59  text subconninfo BKI_FORCE_NOT_NULL;
60 
61  /* Slot name on publisher */
62  NameData subslotname BKI_FORCE_NULL;
63 
64  /* Synchronous commit setting for worker */
65  text subsynccommit BKI_FORCE_NOT_NULL;
66 
67  /* List of publications subscribed to */
68  text subpublications[1] BKI_FORCE_NOT_NULL;
69 #endif
71 
73 
74 DECLARE_TOAST(pg_subscription, 4183, 4184);
75 #define PgSubscriptionToastTable 4183
76 #define PgSubscriptionToastIndex 4184
77 
78 DECLARE_UNIQUE_INDEX_PKEY(pg_subscription_oid_index, 6114, on pg_subscription using btree(oid oid_ops));
79 #define SubscriptionObjectIndexId 6114
80 DECLARE_UNIQUE_INDEX(pg_subscription_subname_index, 6115, on pg_subscription using btree(subdbid oid_ops, subname name_ops));
81 #define SubscriptionNameIndexId 6115
82 
83 typedef struct Subscription
84 {
85  Oid oid; /* Oid of the subscription */
86  Oid dbid; /* Oid of the database which subscription is
87  * in */
88  char *name; /* Name of the subscription */
89  Oid owner; /* Oid of the subscription owner */
90  bool enabled; /* Indicates if the subscription is enabled */
91  bool binary; /* Indicates if the subscription wants data in
92  * binary format */
93  bool stream; /* Allow streaming in-progress transactions. */
94  char *conninfo; /* Connection string to the publisher */
95  char *slotname; /* Name of the replication slot */
96  char *synccommit; /* Synchronous commit setting for worker */
97  List *publications; /* List of publication names to subscribe to */
98 } Subscription;
99 
100 extern Subscription *GetSubscription(Oid subid, bool missing_ok);
101 extern void FreeSubscription(Subscription *sub);
102 extern Oid get_subscription_oid(const char *subname, bool missing_ok);
103 extern char *get_subscription_name(Oid subid, bool missing_ok);
104 
105 extern int CountDBSubscriptions(Oid dbid);
106 
107 #endif /* PG_SUBSCRIPTION_H */
FormData_pg_subscription
#define BKI_SHARED_RELATION
Definition: genbki.h:27
DECLARE_UNIQUE_INDEX_PKEY(pg_subscription_oid_index, 6114, on pg_subscription using btree(oid oid_ops))
FormData_pg_subscription * Form_pg_subscription
unsigned int Oid
Definition: postgres_ext.h:31
NameData subname
bool substream
Subscription * GetSubscription(Oid subid, bool missing_ok)
int CountDBSubscriptions(Oid dbid)
#define BKI_FORCE_NOT_NULL
Definition: genbki.h:33
CATALOG(pg_subscription, 6100, SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(6101
#define BKI_FORCE_NULL
Definition: genbki.h:32
Definition: c.h:675
DECLARE_TOAST(pg_subscription, 4183, 4184)
SubscriptionRelation_Rowtype_Id BKI_SCHEMA_MACRO
List * publications
char * get_subscription_name(Oid subid, bool missing_ok)
#define BKI_ROWTYPE_OID(oid, oidmacro)
Definition: genbki.h:28
void FreeSubscription(Subscription *sub)
struct Subscription Subscription
bool subbinary
Oid get_subscription_oid(const char *subname, bool missing_ok)
Definition: c.h:621
bool subenabled
DECLARE_UNIQUE_INDEX(pg_subscription_subname_index, 6115, on pg_subscription using btree(subdbid oid_ops, subname name_ops))
Oid subdbid BKI_LOOKUP(pg_database)
Definition: pg_list.h:50