codekingpro/portable-devtools
114k
1/* -------------------------------------------------------------------------2 *3 * pg_subscription_rel.h4 * definition of the system catalog containing the state for each5 * replicated table in each subscription (pg_subscription_rel)6 *7 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group8 * Portions Copyright (c) 1994, Regents of the University of California9 *10 * src/include/catalog/pg_subscription_rel.h11 *12 * NOTES13 * The Catalog.pm module reads this file and derives schema14 * information.15 *16 * -------------------------------------------------------------------------17 */18#ifndef PG_SUBSCRIPTION_REL_H19#define PG_SUBSCRIPTION_REL_H20 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 into28 * typedef struct FormData_pg_subscription_rel29 * ----------------30 */31CATALOG(pg_subscription_rel,6102,SubscriptionRelRelationId)32{33 Oid srsubid BKI_LOOKUP(pg_subscription); /* Oid of subscription */34 Oid srrelid BKI_LOOKUP(pg_class); /* Oid of relation */35 char srsubstate; /* state of the relation in subscription */36 37 /*38 * Although srsublsn is a fixed-width type, it is allowed to be NULL, so39 * we prevent direct C code access to it just as for a varlena field.40 */41#ifdef CATALOG_VARLEN /* variable-length fields start here */42 43 XLogRecPtr srsublsn BKI_FORCE_NULL; /* remote LSN of the state change44 * used for synchronization45 * coordination, or NULL if not46 * valid */47#endif48} FormData_pg_subscription_rel;49 50typedef FormData_pg_subscription_rel *Form_pg_subscription_rel;51 52DECLARE_UNIQUE_INDEX_PKEY(pg_subscription_rel_srrelid_srsubid_index, 6117, SubscriptionRelSrrelidSrsubidIndexId, on pg_subscription_rel using btree(srrelid oid_ops, srsubid oid_ops));53 54#ifdef EXPOSE_TO_CLIENT_CODE55 56/* ----------------57 * substate constants58 * ----------------59 */60#define SUBREL_STATE_INIT 'i' /* initializing (sublsn NULL) */61#define SUBREL_STATE_DATASYNC 'd' /* data is being synchronized (sublsn62 * NULL) */63#define SUBREL_STATE_FINISHEDCOPY 'f' /* tablesync copy phase is completed64 * (sublsn NULL) */65#define SUBREL_STATE_SYNCDONE 's' /* synchronization finished in front of66 * apply (sublsn set) */67#define SUBREL_STATE_READY 'r' /* ready (sublsn set) */68 69/* These are never stored in the catalog, we only use them for IPC. */70#define SUBREL_STATE_UNKNOWN '\0' /* unknown state */71#define SUBREL_STATE_SYNCWAIT 'w' /* waiting for sync */72#define SUBREL_STATE_CATCHUP 'c' /* catching up with apply */73 74#endif /* EXPOSE_TO_CLIENT_CODE */75 76typedef struct SubscriptionRelState77{78 Oid relid;79 XLogRecPtr lsn;80 char state;81} SubscriptionRelState;82 83extern void AddSubscriptionRelState(Oid subid, Oid relid, char state,84 XLogRecPtr sublsn);85extern void UpdateSubscriptionRelState(Oid subid, Oid relid, char state,86 XLogRecPtr sublsn);87extern char GetSubscriptionRelState(Oid subid, Oid relid, XLogRecPtr *sublsn);88extern void RemoveSubscriptionRel(Oid subid, Oid relid);89 90extern bool HasSubscriptionRelations(Oid subid);91extern List *GetSubscriptionRelations(Oid subid, bool not_ready);92 93#endif /* PG_SUBSCRIPTION_REL_H */94 