pg_subscription_rel.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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-2022, 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. #include "access/xlogdefs.h"
  21. #include "catalog/genbki.h"
  22. #include "catalog/pg_subscription_rel_d.h"
  23. #include "nodes/pg_list.h"
  24. /* ----------------
  25. * pg_subscription_rel definition. cpp turns this into
  26. * typedef struct FormData_pg_subscription_rel
  27. * ----------------
  28. */
  29. CATALOG(pg_subscription_rel,6102,SubscriptionRelRelationId)
  30. {
  31. Oid srsubid BKI_LOOKUP(pg_subscription); /* Oid of subscription */
  32. Oid srrelid BKI_LOOKUP(pg_class); /* Oid of relation */
  33. char srsubstate; /* state of the relation in subscription */
  34. /*
  35. * Although srsublsn is a fixed-width type, it is allowed to be NULL, so
  36. * we prevent direct C code access to it just as for a varlena field.
  37. */
  38. #ifdef CATALOG_VARLEN /* variable-length fields start here */
  39. XLogRecPtr srsublsn BKI_FORCE_NULL; /* remote LSN of the state change
  40. * used for synchronization
  41. * coordination, or NULL if not
  42. * valid */
  43. #endif
  44. } FormData_pg_subscription_rel;
  45. typedef FormData_pg_subscription_rel *Form_pg_subscription_rel;
  46. DECLARE_UNIQUE_INDEX_PKEY(pg_subscription_rel_srrelid_srsubid_index, 6117, SubscriptionRelSrrelidSrsubidIndexId, on pg_subscription_rel using btree(srrelid oid_ops, srsubid oid_ops));
  47. #ifdef EXPOSE_TO_CLIENT_CODE
  48. /* ----------------
  49. * substate constants
  50. * ----------------
  51. */
  52. #define SUBREL_STATE_INIT 'i' /* initializing (sublsn NULL) */
  53. #define SUBREL_STATE_DATASYNC 'd' /* data is being synchronized (sublsn
  54. * NULL) */
  55. #define SUBREL_STATE_FINISHEDCOPY 'f' /* tablesync copy phase is completed
  56. * (sublsn NULL) */
  57. #define SUBREL_STATE_SYNCDONE 's' /* synchronization finished in front of
  58. * apply (sublsn set) */
  59. #define SUBREL_STATE_READY 'r' /* ready (sublsn set) */
  60. /* These are never stored in the catalog, we only use them for IPC. */
  61. #define SUBREL_STATE_UNKNOWN '\0' /* unknown state */
  62. #define SUBREL_STATE_SYNCWAIT 'w' /* waiting for sync */
  63. #define SUBREL_STATE_CATCHUP 'c' /* catching up with apply */
  64. #endif /* EXPOSE_TO_CLIENT_CODE */
  65. typedef struct SubscriptionRelState
  66. {
  67. Oid relid;
  68. XLogRecPtr lsn;
  69. char state;
  70. } SubscriptionRelState;
  71. extern void AddSubscriptionRelState(Oid subid, Oid relid, char state,
  72. XLogRecPtr sublsn);
  73. extern void UpdateSubscriptionRelState(Oid subid, Oid relid, char state,
  74. XLogRecPtr sublsn);
  75. extern char GetSubscriptionRelState(Oid subid, Oid relid, XLogRecPtr *sublsn);
  76. extern void RemoveSubscriptionRel(Oid subid, Oid relid);
  77. extern bool HasSubscriptionRelations(Oid subid);
  78. extern List *GetSubscriptionRelations(Oid subid);
  79. extern List *GetSubscriptionNotReadyRelations(Oid subid);
  80. #endif /* PG_SUBSCRIPTION_REL_H */