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  */
32 {
33  Oid subdbid; /* Database the subscription is in. */
34  NameData subname; /* Name of the subscription */
35 
36  Oid subowner; /* Owner of the subscription */
37 
38  bool subenabled; /* True if the subscription is enabled
39  * (the worker should be running) */
40 
41 #ifdef CATALOG_VARLEN /* variable-length fields start here */
42  text subconninfo; /* Connection string to the publisher */
43  NameData subslotname; /* Slot name on publisher */
44 
45  text subpublications[1]; /* List of publications subscribed to */
46 #endif
48 
50 
51 /* ----------------
52  * compiler constants for pg_subscription
53  * ----------------
54  */
55 #define Natts_pg_subscription 7
56 #define Anum_pg_subscription_subdbid 1
57 #define Anum_pg_subscription_subname 2
58 #define Anum_pg_subscription_subowner 3
59 #define Anum_pg_subscription_subenabled 4
60 #define Anum_pg_subscription_subconninfo 5
61 #define Anum_pg_subscription_subslotname 6
62 #define Anum_pg_subscription_subpublications 7
63 
64 
65 typedef struct Subscription
66 {
67  Oid oid; /* Oid of the subscription */
68  Oid dbid; /* Oid of the database which subscription is in */
69  char *name; /* Name of the subscription */
70  Oid owner; /* Oid of the subscription owner */
71  bool enabled; /* Indicates if the subscription is enabled */
72  char *conninfo; /* Connection string to the publisher */
73  char *slotname; /* Name of the replication slot */
74  List *publications; /* List of publication names to subscribe to */
75 } Subscription;
76 
77 extern Subscription *GetSubscription(Oid subid, bool missing_ok);
78 extern void FreeSubscription(Subscription *sub);
79 extern Oid get_subscription_oid(const char *subname, bool missing_ok);
80 extern char *get_subscription_name(Oid subid);
81 
82 extern int CountDBSubscriptions(Oid dbid);
83 
84 #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:489
#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:435
Definition: pg_list.h:45