PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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
41  * (the worker should be running) */
42 
43 #ifdef CATALOG_VARLEN /* variable-length fields start here */
44  text subconninfo; /* Connection string to the publisher */
45  NameData subslotname; /* Slot name on publisher */
46 
47  text subpublications[1]; /* List of publications subscribed to */
48 #endif
50 
52 
53 /* ----------------
54  * compiler constants for pg_subscription
55  * ----------------
56  */
57 #define Natts_pg_subscription 7
58 #define Anum_pg_subscription_subdbid 1
59 #define Anum_pg_subscription_subname 2
60 #define Anum_pg_subscription_subowner 3
61 #define Anum_pg_subscription_subenabled 4
62 #define Anum_pg_subscription_subconninfo 5
63 #define Anum_pg_subscription_subslotname 6
64 #define Anum_pg_subscription_subpublications 7
65 
66 
67 typedef struct Subscription
68 {
69  Oid oid; /* Oid of the subscription */
70  Oid dbid; /* Oid of the database which subscription is in */
71  char *name; /* Name of the subscription */
72  Oid owner; /* Oid of the subscription owner */
73  bool enabled; /* Indicates if the subscription is enabled */
74  char *conninfo; /* Connection string to the publisher */
75  char *slotname; /* Name of the replication slot */
76  List *publications; /* List of publication names to subscribe to */
77 } Subscription;
78 
79 extern Subscription *GetSubscription(Oid subid, bool missing_ok);
80 extern void FreeSubscription(Subscription *sub);
81 extern Oid get_subscription_oid(const char *subname, bool missing_ok);
82 extern char *get_subscription_name(Oid subid);
83 
84 extern int CountDBSubscriptions(Oid dbid);
85 
86 #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)
char * get_subscription_name(Oid subid)
Definition: c.h:493
#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:439
Definition: pg_list.h:45