Исходный код СУБД 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
/*-------------------------------------------------------------------------
 * origin.h
 *     Exports from replication/logical/origin.c
 *
 * Copyright (c) 2013-2026, PostgreSQL Global Development Group
 *
 * src/include/replication/origin.h
 *-------------------------------------------------------------------------
 */
#ifndef PG_ORIGIN_H
#define PG_ORIGIN_H
 
#include "access/xlog.h"
#include "access/xlogdefs.h"
#include "access/xlogreader.h"
#include "catalog/pg_replication_origin.h"
 
typedef struct xl_replorigin_set
{
    XLogRecPtr  remote_lsn;
    ReplOriginId node_id;
    bool        force;
} xl_replorigin_set;
 
typedef struct xl_replorigin_drop
{
    ReplOriginId node_id;
} xl_replorigin_drop;
 
#define XLOG_REPLORIGIN_SET     0x00
#define XLOG_REPLORIGIN_DROP        0x10
 
#define InvalidReplOriginId 0
#define DoNotReplicateId PG_UINT16_MAX
 
/*
 * To avoid needing a TOAST table for pg_replication_origin, we limit
 * replication origin names to 512 bytes.  This should be more than enough for
 * all practical use.
 */
#define MAX_RONAME_LEN  512
 
typedef struct ReplOriginXactState
{
    ReplOriginId origin;
    XLogRecPtr  origin_lsn;
    TimestampTz origin_timestamp;
} ReplOriginXactState;
 
extern PGDLLIMPORT ReplOriginXactState replorigin_xact_state;
 
/* GUCs */
extern PGDLLIMPORT int max_active_replication_origins;
 
/* API for querying & manipulating replication origins */
extern ReplOriginId replorigin_by_name(const char *roname, bool missing_ok);
extern ReplOriginId replorigin_create(const char *roname);
extern void replorigin_drop_by_name(const char *name, bool missing_ok, bool nowait);
extern bool replorigin_by_oid(ReplOriginId roident, bool missing_ok,
                              char **roname);
 
/* API for querying & manipulating replication progress tracking */
extern void replorigin_advance(ReplOriginId node,
                               XLogRecPtr remote_commit,
                               XLogRecPtr local_commit,
                               bool go_backward, bool wal_log);
extern XLogRecPtr replorigin_get_progress(ReplOriginId node, bool flush);
 
extern void replorigin_session_advance(XLogRecPtr remote_commit,
                                       XLogRecPtr local_commit);
extern void replorigin_session_setup(ReplOriginId node, int acquired_by);
extern void replorigin_session_reset(void);
extern XLogRecPtr replorigin_session_get_progress(bool flush);
 
/* Per-transaction replication origin state manipulation */
extern void replorigin_xact_clear(bool clear_origin);
 
/* Checkpoint/Startup integration */
extern void CheckPointReplicationOrigin(void);
extern void StartupReplicationOrigin(void);
 
/* WAL logging */
extern void replorigin_redo(XLogReaderState *record);
extern void replorigin_desc(StringInfo buf, XLogReaderState *record);
extern const char *replorigin_identify(uint8 info);
 
#endif                          /* PG_ORIGIN_H */