| 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-2019, 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 "catalog/genbki.h" |
| 22 | #include "catalog/pg_subscription_rel_d.h" |
| 23 | |
| 24 | #include "access/xlogdefs.h" |
| 25 | #include "nodes/pg_list.h" |
| 26 | |
| 27 | /* ---------------- |
| 28 | * pg_subscription_rel definition. cpp turns this into |
| 29 | * typedef struct FormData_pg_subscription_rel |
| 30 | * ---------------- |
| 31 | */ |
| 32 | CATALOG(pg_subscription_rel,6102,SubscriptionRelRelationId) |
| 33 | { |
| 34 | Oid srsubid; /* Oid of subscription */ |
| 35 | Oid srrelid; /* Oid of relation */ |
| 36 | char srsubstate; /* state of the relation in subscription */ |
| 37 | XLogRecPtr srsublsn; /* remote lsn of the state change used for |
| 38 | * synchronization coordination */ |
| 39 | } FormData_pg_subscription_rel; |
| 40 | |
| 41 | typedef FormData_pg_subscription_rel *Form_pg_subscription_rel; |
| 42 | |
| 43 | #ifdef EXPOSE_TO_CLIENT_CODE |
| 44 | |
| 45 | /* ---------------- |
| 46 | * substate constants |
| 47 | * ---------------- |
| 48 | */ |
| 49 | #define SUBREL_STATE_INIT 'i' /* initializing (sublsn NULL) */ |
| 50 | #define SUBREL_STATE_DATASYNC 'd' /* data is being synchronized (sublsn |
| 51 | * NULL) */ |
| 52 | #define SUBREL_STATE_SYNCDONE 's' /* synchronization finished in front of |
| 53 | * apply (sublsn set) */ |
| 54 | #define SUBREL_STATE_READY 'r' /* ready (sublsn set) */ |
| 55 | |
| 56 | /* These are never stored in the catalog, we only use them for IPC. */ |
| 57 | #define SUBREL_STATE_UNKNOWN '\0' /* unknown state */ |
| 58 | #define SUBREL_STATE_SYNCWAIT 'w' /* waiting for sync */ |
| 59 | #define SUBREL_STATE_CATCHUP 'c' /* catching up with apply */ |
| 60 | |
| 61 | #endif /* EXPOSE_TO_CLIENT_CODE */ |
| 62 | |
| 63 | typedef struct SubscriptionRelState |
| 64 | { |
| 65 | Oid relid; |
| 66 | XLogRecPtr lsn; |
| 67 | char state; |
| 68 | } SubscriptionRelState; |
| 69 | |
| 70 | extern void AddSubscriptionRelState(Oid subid, Oid relid, char state, |
| 71 | XLogRecPtr sublsn); |
| 72 | extern void UpdateSubscriptionRelState(Oid subid, Oid relid, char state, |
| 73 | XLogRecPtr sublsn); |
| 74 | extern char GetSubscriptionRelState(Oid subid, Oid relid, |
| 75 | XLogRecPtr *sublsn, bool missing_ok); |
| 76 | extern void RemoveSubscriptionRel(Oid subid, Oid relid); |
| 77 | |
| 78 | extern List *GetSubscriptionRelations(Oid subid); |
| 79 | extern List *GetSubscriptionNotReadyRelations(Oid subid); |
| 80 | |
| 81 | #endif /* PG_SUBSCRIPTION_REL_H */ |
| 82 | |