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-2020, 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; /* Database the subscription is in. */
44  NameData subname; /* Name of the subscription */
45 
46  Oid subowner; /* Owner of the subscription */
47 
48  bool subenabled; /* True if the subscription is enabled (the
49  * worker should be running) */
50 
51  bool subbinary; /* True if the subscription wants the
52  * publisher to send data in binary */
53 
54  bool substream; /* Stream in-progress transactions. */
55 
56 #ifdef CATALOG_VARLEN /* variable-length fields start here */
57  /* Connection string to the publisher */
58  text subconninfo BKI_FORCE_NOT_NULL;
59 
60  /* Slot name on publisher */
61  NameData subslotname BKI_FORCE_NULL;
62 
63  /* Synchronous commit setting for worker */
64  text subsynccommit BKI_FORCE_NOT_NULL;
65 
66  /* List of publications subscribed to */
67  text subpublications[1] BKI_FORCE_NOT_NULL;
68 #endif
70 
72 
73 typedef struct Subscription
74 {
75  Oid oid; /* Oid of the subscription */
76  Oid dbid; /* Oid of the database which subscription is
77  * in */
78  char *name; /* Name of the subscription */
79  Oid owner; /* Oid of the subscription owner */
80  bool enabled; /* Indicates if the subscription is enabled */
81  bool binary; /* Indicates if the subscription wants data in
82  * binary format */
83  bool stream; /* Allow streaming in-progress transactions. */
84  char *conninfo; /* Connection string to the publisher */
85  char *slotname; /* Name of the replication slot */
86  char *synccommit; /* Synchronous commit setting for worker */
87  List *publications; /* List of publication names to subscribe to */
88 } Subscription;
89 
90 extern Subscription *GetSubscription(Oid subid, bool missing_ok);
91 extern void FreeSubscription(Subscription *sub);
92 extern Oid get_subscription_oid(const char *subname, bool missing_ok);
93 extern char *get_subscription_name(Oid subid, bool missing_ok);
94 
95 extern int CountDBSubscriptions(Oid dbid);
96 
97 #endif /* PG_SUBSCRIPTION_H */
FormData_pg_subscription
Oid subdbid
#define BKI_SHARED_RELATION
Definition: genbki.h:27
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:617
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 subowner
Oid get_subscription_oid(const char *subname, bool missing_ok)
Definition: c.h:563
bool subenabled
Definition: pg_list.h:50