Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/* -------------------------------------------------------------------------
 *
 * pg_subscription_rel.h
 *    definition of the system catalog containing the state for each
 *    replicated table in each subscription (pg_subscription_rel)
 *
 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
 * Portions Copyright (c) 1994, Regents of the University of California
 *
 * src/include/catalog/pg_subscription_rel.h
 *
 * NOTES
 *    The Catalog.pm module reads this file and derives schema
 *    information.
 *
 * -------------------------------------------------------------------------
 */
#ifndef PG_SUBSCRIPTION_REL_H
#define PG_SUBSCRIPTION_REL_H
 
#include "access/xlogdefs.h"
#include "catalog/genbki.h"
#include "catalog/pg_subscription_rel_d.h"  /* IWYU pragma: export */
#include "nodes/pg_list.h"
 
/* ----------------
 *      pg_subscription_rel definition. cpp turns this into
 *      typedef struct FormData_pg_subscription_rel
 * ----------------
 */
BEGIN_CATALOG_STRUCT
 
CATALOG(pg_subscription_rel,6102,SubscriptionRelRelationId)
{
    Oid         srsubid BKI_LOOKUP(pg_subscription);    /* Oid of subscription */
    Oid         srrelid BKI_LOOKUP(pg_class);   /* Oid of relation */
    char        srsubstate;     /* state of the relation in subscription */
 
    /*
     * Although srsublsn is a fixed-width type, it is allowed to be NULL, so
     * we prevent direct C code access to it just as for a varlena field.
     */
#ifdef CATALOG_VARLEN           /* variable-length fields start here */
 
    XLogRecPtr  srsublsn BKI_FORCE_NULL;    /* remote LSN of the state change
                                             * used for synchronization
                                             * coordination, or NULL if not
                                             * valid */
#endif
} FormData_pg_subscription_rel;
 
END_CATALOG_STRUCT
 
typedef FormData_pg_subscription_rel *Form_pg_subscription_rel;
 
DECLARE_UNIQUE_INDEX_PKEY(pg_subscription_rel_srrelid_srsubid_index, 6117, SubscriptionRelSrrelidSrsubidIndexId, pg_subscription_rel, btree(srrelid oid_ops, srsubid oid_ops));
 
MAKE_SYSCACHE(SUBSCRIPTIONRELMAP, pg_subscription_rel_srrelid_srsubid_index, 64);
 
#ifdef EXPOSE_TO_CLIENT_CODE
 
/* ----------------
 *      substate constants
 * ----------------
 */
#define SUBREL_STATE_INIT       'i' /* initializing (sublsn NULL) */
#define SUBREL_STATE_DATASYNC   'd' /* data is being synchronized (sublsn
                                     * NULL) */
#define SUBREL_STATE_FINISHEDCOPY 'f'   /* tablesync copy phase is completed
                                         * (sublsn NULL) */
#define SUBREL_STATE_SYNCDONE   's' /* synchronization finished in front of
                                     * apply (sublsn set) */
#define SUBREL_STATE_READY      'r' /* ready (sublsn set) */
 
/* These are never stored in the catalog, we only use them for IPC. */
#define SUBREL_STATE_UNKNOWN    '\0'    /* unknown state */
#define SUBREL_STATE_SYNCWAIT   'w' /* waiting for sync */
#define SUBREL_STATE_CATCHUP    'c' /* catching up with apply */
 
#endif                          /* EXPOSE_TO_CLIENT_CODE */
 
typedef struct SubscriptionRelState
{
    Oid         relid;
    XLogRecPtr  lsn;
    char        state;
} SubscriptionRelState;
 
/*
 * Holds local sequence identity and corresponding publisher values used during
 * sequence synchronization.
 */
typedef struct LogicalRepSequenceInfo
{
    /* Sequence information retrieved from the local node */
    char       *seqname;
    char       *nspname;
    Oid         localrelid;
 
    /* Sequence information retrieved from the publisher node */
    XLogRecPtr  page_lsn;
    int64       last_value;
    bool        is_called;
 
    /*
     * True if the sequence identified by nspname + seqname exists on the
     * publisher.
     */
    bool        found_on_pub;
} LogicalRepSequenceInfo;
 
extern void AddSubscriptionRelState(Oid subid, Oid relid, char state,
                                    XLogRecPtr sublsn, bool retain_lock);
extern void UpdateSubscriptionRelState(Oid subid, Oid relid, char state,
                                       XLogRecPtr sublsn, bool already_locked);
extern char GetSubscriptionRelState(Oid subid, Oid relid, XLogRecPtr *sublsn);
extern void RemoveSubscriptionRel(Oid subid, Oid relid);
 
extern bool HasSubscriptionTables(Oid subid);
extern List *GetSubscriptionRelations(Oid subid, bool tables, bool sequences,
                                      bool not_ready);
 
extern void UpdateDeadTupleRetentionStatus(Oid subid, bool active);
 
#endif                          /* PG_SUBSCRIPTION_REL_H */