forked from 2ndQuadrant/bdr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bdr_internal.h
101 lines (80 loc) · 2.6 KB
/
bdr_internal.h
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
/*
* bdr_internal.h
*
* BiDirectionalReplication
*
* Copyright (c) 2012-2015, PostgreSQL Global Development Group
*
* bdr_internal.h
*/
#ifndef BDR_INTERNAL_H
#define BDR_INTERNAL_H
#include <signal.h>
#include "lib/ilist.h"
#define EMPTY_REPLICATION_NAME ""
/*
* The format used for slot names
*
* params: local_dboid, remote_sysid, remote_timeline, remote_dboid, replname
*/
#define BDR_SLOT_NAME_FORMAT "bdr_%u_"UINT64_FORMAT"_%u_%u__%s"
/*
* The format used for replication identifiers (riident, replident)
*
* params: remote_sysid, remote_timeline, remote_dboid, local_dboid, replname
*/
#define BDR_NODE_ID_FORMAT "bdr_"UINT64_FORMAT"_%u_%u_%u_%s"
#ifdef __GNUC__
#define BDR_WARN_UNUSED __attribute__((warn_unused_result))
#define BDR_NORETURN __attribute__((noreturn))
#else
#define BDR_WARN_UNUSED
#define BDR_NORETURN
#endif
/* A configured BDR connection from bdr_connections */
typedef struct BdrConnectionConfig
{
uint64 sysid;
TimeLineID timeline;
Oid dboid;
/*
* If the origin_ id fields are set then they must refer to our node,
* otherwise we wouldn't load the configuration entry. So if origin_is_set
* is false the origin was zero, and if true the origin is the local node
* id.
*/
bool origin_is_my_id;
char *dsn;
int apply_delay;
/* Quoted identifier-list of replication sets */
char *replication_sets;
} BdrConnectionConfig;
typedef struct BdrFlushPosition
{
dlist_node node;
XLogRecPtr local_end;
XLogRecPtr remote_end;
} BdrFlushPosition;
extern volatile sig_atomic_t got_SIGTERM;
extern volatile sig_atomic_t got_SIGHUP;
extern void bdr_error_nodeids_must_differ(uint64 sysid, TimeLineID timeline,
Oid dboid);
extern List* bdr_read_connection_configs(void);
extern BdrConnectionConfig* bdr_get_connection_config(uint64 sysid,
TimeLineID timeline,
Oid dboid,
bool missing_ok);
extern void bdr_free_connection_config(BdrConnectionConfig *cfg);
extern void bdr_slot_name(Name slot_name, uint64 sysid, TimeLineID tlid,
Oid dboid, Oid local_dboid);
extern char* bdr_replident_name(uint64 remote_sysid,
TimeLineID remote_timeline, Oid remote_dboid, Oid local_dboid);
extern void bdr_parse_slot_name(const char *name, uint64 *remote_sysid,
Oid *remote_dboid, TimeLineID *remote_tli,
Oid *local_dboid);
extern void bdr_parse_replident_name(const char *name, uint64 *remote_sysid,
Oid *remote_dboid, TimeLineID *remote_tli,
Oid *local_dboid);
extern int bdr_find_other_exec(const char *argv0, const char *target,
uint32 *version, char *retpath);
#endif /* BDR_INTERNAL_H */