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-2025, 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" /* IWYU pragma: export */
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 */
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, so
39 * 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 change
44 * used for synchronization
45 * coordination, or NULL if not
46 * valid */
47#endif
49
51
52DECLARE_UNIQUE_INDEX_PKEY(pg_subscription_rel_srrelid_srsubid_index, 6117, SubscriptionRelSrrelidSrsubidIndexId, pg_subscription_rel, btree(srrelid oid_ops, srsubid oid_ops));
53
54MAKE_SYSCACHE(SUBSCRIPTIONRELMAP, pg_subscription_rel_srrelid_srsubid_index, 64);
55
56#ifdef EXPOSE_TO_CLIENT_CODE
57
58/* ----------------
59 * substate constants
60 * ----------------
61 */
62#define SUBREL_STATE_INIT 'i' /* initializing (sublsn NULL) */
63#define SUBREL_STATE_DATASYNC 'd' /* data is being synchronized (sublsn
64 * NULL) */
65#define SUBREL_STATE_FINISHEDCOPY 'f' /* tablesync copy phase is completed
66 * (sublsn NULL) */
67#define SUBREL_STATE_SYNCDONE 's' /* synchronization finished in front of
68 * apply (sublsn set) */
69#define SUBREL_STATE_READY 'r' /* ready (sublsn set) */
70
71/* These are never stored in the catalog, we only use them for IPC. */
72#define SUBREL_STATE_UNKNOWN '\0' /* unknown state */
73#define SUBREL_STATE_SYNCWAIT 'w' /* waiting for sync */
74#define SUBREL_STATE_CATCHUP 'c' /* catching up with apply */
75
76#endif /* EXPOSE_TO_CLIENT_CODE */
77
79{
82 char state;
84
85extern void AddSubscriptionRelState(Oid subid, Oid relid, char state,
86 XLogRecPtr sublsn, bool retain_lock);
87extern void UpdateSubscriptionRelState(Oid subid, Oid relid, char state,
88 XLogRecPtr sublsn);
89extern char GetSubscriptionRelState(Oid subid, Oid relid, XLogRecPtr *sublsn);
90extern void RemoveSubscriptionRel(Oid subid, Oid relid);
91
92extern bool HasSubscriptionRelations(Oid subid);
93extern List *GetSubscriptionRelations(Oid subid, bool not_ready);
94
95#endif /* PG_SUBSCRIPTION_REL_H */
#define BKI_LOOKUP(catalog)
Definition: genbki.h:46
#define BKI_FORCE_NULL
Definition: genbki.h:32
FormData_pg_subscription_rel * Form_pg_subscription_rel
List * GetSubscriptionRelations(Oid subid, bool not_ready)
FormData_pg_subscription_rel
struct SubscriptionRelState SubscriptionRelState
void RemoveSubscriptionRel(Oid subid, Oid relid)
char GetSubscriptionRelState(Oid subid, Oid relid, XLogRecPtr *sublsn)
void AddSubscriptionRelState(Oid subid, Oid relid, char state, XLogRecPtr sublsn, bool retain_lock)
void UpdateSubscriptionRelState(Oid subid, Oid relid, char state, XLogRecPtr sublsn)
DECLARE_UNIQUE_INDEX_PKEY(pg_subscription_rel_srrelid_srsubid_index, 6117, SubscriptionRelSrrelidSrsubidIndexId, pg_subscription_rel, btree(srrelid oid_ops, srsubid oid_ops))
bool HasSubscriptionRelations(Oid subid)
MAKE_SYSCACHE(SUBSCRIPTIONRELMAP, pg_subscription_rel_srrelid_srsubid_index, 64)
CATALOG(pg_subscription_rel, 6102, SubscriptionRelRelationId)
unsigned int Oid
Definition: postgres_ext.h:32
Definition: pg_list.h:54
Definition: regguts.h:323
uint64 XLogRecPtr
Definition: xlogdefs.h:21