PostgreSQL Source Code  git master
pg_subscription_rel.h
Go to the documentation of this file.
1 /* -------------------------------------------------------------------------
2  *
3  * pg_subscription_rel.h
4  * definition of the system catalog containing the state for each
5  * replicated table in each subscription (pg_subscription_rel)
6  *
7  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/catalog/pg_subscription_rel.h
11  *
12  * NOTES
13  * The Catalog.pm module reads this file and derives schema
14  * information.
15  *
16  * -------------------------------------------------------------------------
17  */
18 #ifndef PG_SUBSCRIPTION_REL_H
19 #define PG_SUBSCRIPTION_REL_H
20 
21 #include "access/xlogdefs.h"
22 #include "catalog/genbki.h"
23 #include "catalog/pg_subscription_rel_d.h"
24 #include "nodes/pg_list.h"
25 
26 /* ----------------
27  * pg_subscription_rel definition. cpp turns this into
28  * typedef struct FormData_pg_subscription_rel
29  * ----------------
30  */
31 CATALOG(pg_subscription_rel,6102,SubscriptionRelRelationId)
32 {
33  Oid srsubid; /* Oid of subscription */
34  Oid srrelid; /* Oid of relation */
35  char srsubstate; /* state of the relation in subscription */
36  XLogRecPtr srsublsn; /* remote lsn of the state change used for
37  * synchronization coordination */
39 
41 
42 #ifdef EXPOSE_TO_CLIENT_CODE
43 
44 /* ----------------
45  * substate constants
46  * ----------------
47  */
48 #define SUBREL_STATE_INIT 'i' /* initializing (sublsn NULL) */
49 #define SUBREL_STATE_DATASYNC 'd' /* data is being synchronized (sublsn
50  * NULL) */
51 #define SUBREL_STATE_SYNCDONE 's' /* synchronization finished in front of
52  * apply (sublsn set) */
53 #define SUBREL_STATE_READY 'r' /* ready (sublsn set) */
54 
55 /* These are never stored in the catalog, we only use them for IPC. */
56 #define SUBREL_STATE_UNKNOWN '\0' /* unknown state */
57 #define SUBREL_STATE_SYNCWAIT 'w' /* waiting for sync */
58 #define SUBREL_STATE_CATCHUP 'c' /* catching up with apply */
59 
60 #endif /* EXPOSE_TO_CLIENT_CODE */
61 
62 typedef struct SubscriptionRelState
63 {
66  char state;
68 
69 extern void AddSubscriptionRelState(Oid subid, Oid relid, char state,
70  XLogRecPtr sublsn);
71 extern void UpdateSubscriptionRelState(Oid subid, Oid relid, char state,
72  XLogRecPtr sublsn);
73 extern char GetSubscriptionRelState(Oid subid, Oid relid,
74  XLogRecPtr *sublsn, bool missing_ok);
75 extern void RemoveSubscriptionRel(Oid subid, Oid relid);
76 
77 extern List *GetSubscriptionRelations(Oid subid);
79 
80 #endif /* PG_SUBSCRIPTION_REL_H */
CATALOG(pg_subscription_rel, 6102, SubscriptionRelRelationId)
struct SubscriptionRelState SubscriptionRelState
List * GetSubscriptionRelations(Oid subid)
unsigned int Oid
Definition: postgres_ext.h:31
FormData_pg_subscription_rel
List * GetSubscriptionNotReadyRelations(Oid subid)
char GetSubscriptionRelState(Oid subid, Oid relid, XLogRecPtr *sublsn, bool missing_ok)
void UpdateSubscriptionRelState(Oid subid, Oid relid, char state, XLogRecPtr sublsn)
void RemoveSubscriptionRel(Oid subid, Oid relid)
FormData_pg_subscription_rel * Form_pg_subscription_rel
uint64 XLogRecPtr
Definition: xlogdefs.h:21
Definition: regguts.h:298
Definition: pg_list.h:50
void AddSubscriptionRelState(Oid subid, Oid relid, char state, XLogRecPtr sublsn)