-
Notifications
You must be signed in to change notification settings - Fork 15
/
spock.h
119 lines (94 loc) · 3.72 KB
/
spock.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*-------------------------------------------------------------------------
*
* spock.h
* spock replication extension
*
* Copyright (c) 2022-2024, pgEdge, Inc.
* Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, The Regents of the University of California
*
*-------------------------------------------------------------------------
*/
#ifndef SPOCK_H
#define SPOCK_H
#include "storage/s_lock.h"
#include "postmaster/bgworker.h"
#include "utils/array.h"
#include "access/xlogdefs.h"
#include "executor/executor.h"
#include "libpq-fe.h"
#include "spock_fe.h"
#include "spock_node.h"
#include "spock_compat.h"
#define SPOCK_VERSION "3.3"
#define SPOCK_VERSION_NUM 30306
#define SPOCK_MIN_PROTO_VERSION_NUM 1
#define SPOCK_MAX_PROTO_VERSION_NUM 1
#define EXTENSION_NAME "spock"
#define REPLICATION_ORIGIN_ALL "all"
#define HAVE_REPLICATION_ORIGINS
extern bool spock_synchronous_commit;
extern char *spock_temp_directory;
extern bool spock_use_spi;
extern int spock_ctt_prune_interval;
extern bool spock_batch_inserts;
extern char *spock_extra_connection_options;
extern bool spock_ch_stats;
extern bool spock_deny_ddl;
extern bool spock_enable_ddl_replication;
extern bool spock_include_ddl_repset;
extern bool allow_ddl_from_functions;
extern char *shorten_hash(const char *str, int maxlen);
extern List *textarray_to_list(ArrayType *textarray);
extern bool parsePGArray(const char *atext, char ***itemarray, int *nitems);
extern Oid get_spock_table_oid(const char *table);
extern void spock_execute_sql_command(char *cmdstr, char *role,
bool isTopLevel);
extern PGconn *spock_connect(const char *connstring, const char *connname,
const char *suffix);
extern PGconn *spock_connect_replica(const char *connstring,
const char *connname,
const char *suffix);
extern void spock_identify_system(PGconn *streamConn, uint64* sysid,
TimeLineID *timeline, XLogRecPtr *xlogpos,
Name *dbname);
extern void spock_start_replication(PGconn *streamConn,
const char *slot_name,
XLogRecPtr start_pos,
const char *forward_origins,
const char *replication_sets,
const char *replicate_only_table,
bool force_text_transfer);
extern void spock_manage_extension(void);
extern void apply_work(PGconn *streamConn);
extern bool synchronize_sequences(void);
extern void synchronize_sequence(Oid seqoid);
extern void spock_create_sequence_state_record(Oid seqoid);
extern void spock_drop_sequence_state_record(Oid seqoid);
extern int64 sequence_get_last_value(Oid seqoid);
extern bool in_spock_replicate_ddl_command;
extern bool in_spock_queue_ddl_command;
extern void spock_auto_replicate_ddl(const char *query, List *replication_sets,
Oid roleoid, Node *stmt);
#include "utils/memdebug.h"
/*
* PostgreSQL exposes stubs for some Valgrind macros, but there are some
* others we use that aren't supported by Pg proper yet.
*/
#ifndef USE_VALGRIND
#define VALGRIND_CHECK_VALUE_IS_DEFINED(v) do{} while(0)
#define VALGRIND_DO_LEAK_CHECK do{} while(0)
#define VALGRIND_DO_ADDED_LEAK_CHECK do{} while(0)
#define VALGRIND_DO_CHANGED_LEAK_CHECK do{} while(0)
#define VALGRIND_DO_QUICK_LEAK_CHECK do{} while(0)
#define VALGRIND_DISABLE_ERROR_REPORTING do {} while (0)
#define VALGRIND_ENABLE_ERROR_REPORTING do {} while (0)
/*
* Gives us some error checking when no-op'd. spock uses this to report
* the worker type, etc, prefixed by SPOCK:, in the Valgrind logs. We
* need to stub it out if we aren't using valgrind.
*/
pg_attribute_printf(1, 2) pg_attribute_unused() static inline void VALGRIND_PRINTF(const char *format, ...) {}
#endif
extern void spock_init_failover_slot(void);
#endif /* SPOCK_H */