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 catalog (pg_subscription).
5  *
6  * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  * -------------------------------------------------------------------------
10  */
11 #ifndef PG_SUBSCRIPTION_H
12 #define PG_SUBSCRIPTION_H
13 
14 #include "catalog/genbki.h"
15 #include "nodes/pg_list.h"
16 
17 /* ----------------
18  * pg_subscription definition. cpp turns this into
19  * typedef struct FormData_pg_subscription
20  * ----------------
21  */
22 #define SubscriptionRelationId 6100
23 #define SubscriptionRelation_Rowtype_Id 6101
24 
25 /*
26  * Technically, the subscriptions live inside the database, so a shared catalog
27  * seems weird, but the replication launcher process needs to access all of
28  * them to be able to start the workers, so we have to put them in a shared,
29  * nailed catalog.
30  *
31  * NOTE: When adding a column, also update system_views.sql.
32  */
34 {
35  Oid subdbid; /* Database the subscription is in. */
36  NameData subname; /* Name of the subscription */
37 
38  Oid subowner; /* Owner of the subscription */
39 
40  bool subenabled; /* True if the subscription is enabled (the
41  * worker should be running) */
42 
43 #ifdef CATALOG_VARLEN /* variable-length fields start here */
44  /* Connection string to the publisher */
45  text subconninfo BKI_FORCE_NOT_NULL;
46 
47  /* Slot name on publisher */
48  NameData subslotname;
49 
50  /* Synchronous commit setting for worker */
51  text subsynccommit BKI_FORCE_NOT_NULL;
52 
53  /* List of publications subscribed to */
54  text subpublications[1] BKI_FORCE_NOT_NULL;
55 #endif
57 
59 
60 /* ----------------
61  * compiler constants for pg_subscription
62  * ----------------
63  */
64 #define Natts_pg_subscription 8
65 #define Anum_pg_subscription_subdbid 1
66 #define Anum_pg_subscription_subname 2
67 #define Anum_pg_subscription_subowner 3
68 #define Anum_pg_subscription_subenabled 4
69 #define Anum_pg_subscription_subconninfo 5
70 #define Anum_pg_subscription_subslotname 6
71 #define Anum_pg_subscription_subsynccommit 7
72 #define Anum_pg_subscription_subpublications 8
73 
74 
75 typedef struct Subscription
76 {
77  Oid oid; /* Oid of the subscription */
78  Oid dbid; /* Oid of the database which subscription is
79  * in */
80  char *name; /* Name of the subscription */
81  Oid owner; /* Oid of the subscription owner */
82  bool enabled; /* Indicates if the subscription is enabled */
83  char *conninfo; /* Connection string to the publisher */
84  char *slotname; /* Name of the replication slot */
85  char *synccommit; /* Synchronous commit setting for worker */
86  List *publications; /* List of publication names to subscribe to */
87 } Subscription;
88 
89 extern Subscription *GetSubscription(Oid subid, bool missing_ok);
90 extern void FreeSubscription(Subscription *sub);
91 extern Oid get_subscription_oid(const char *subname, bool missing_ok);
92 extern char *get_subscription_name(Oid subid);
93 
94 extern int CountDBSubscriptions(Oid dbid);
95 
96 #endif /* PG_SUBSCRIPTION_H */
#define BKI_SCHEMA_MACRO
Definition: genbki.h:30
FormData_pg_subscription
#define BKI_SHARED_RELATION
Definition: genbki.h:27
FormData_pg_subscription * Form_pg_subscription
unsigned int Oid
Definition: postgres_ext.h:31
Subscription * GetSubscription(Oid subid, bool missing_ok)
int CountDBSubscriptions(Oid dbid)
#define BKI_FORCE_NOT_NULL
Definition: genbki.h:32
char * get_subscription_name(Oid subid)
Definition: c.h:541
#define BKI_ROWTYPE_OID(oid)
Definition: genbki.h:29
List * publications
CATALOG(pg_subscription, 6100) BKI_SHARED_RELATION BKI_ROWTYPE_OID(6101) BKI_SCHEMA_MACRO
void FreeSubscription(Subscription *sub)
struct Subscription Subscription
Oid get_subscription_oid(const char *subname, bool missing_ok)
Definition: c.h:487
Definition: pg_list.h:45