summaryrefslogtreecommitdiffstats
path: root/sql/rpl_gtid.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sql/rpl_gtid.h39
1 files changed, 32 insertions, 7 deletions
diff --git a/sql/rpl_gtid.h b/sql/rpl_gtid.h
index 7d25ee6e..8b697c79 100644
--- a/sql/rpl_gtid.h
+++ b/sql/rpl_gtid.h
@@ -26,6 +26,11 @@
extern const LEX_CSTRING rpl_gtid_slave_state_table_name;
class String;
+#ifdef MYSQL_SERVER
+struct TABLE;
+#endif
+struct slave_connection_state;
+
#define PARAM_GTID(G) G.domain_id, G.server_id, G.seq_no
#define GTID_MAX_STR_LENGTH (10+1+10+1+20)
@@ -296,8 +301,13 @@ struct rpl_slave_state
to know where to start when a master is changed to a slave. As a side
effect, it also allows to skip a hash lookup in the very common case of
logging a new GTID with same server id as last GTID.
+
+ The base class rpl_binlog_state_base contains just be basic data operations
+ to insert/update GTIDs, and is used eg. from Gtid_index_*. The main class
+ rpl_binlog_state builds server logic on top of that like mutex locking,
+ gtid_strict_mode handling, etc.
*/
-struct rpl_binlog_state
+struct rpl_binlog_state_base
{
struct element {
uint32 domain_id;
@@ -309,29 +319,45 @@ struct rpl_binlog_state
int update_element(const rpl_gtid *gtid);
};
+
/* Mapping from domain_id to collection of elements. */
HASH hash;
+ my_bool initialized;
+
+ rpl_binlog_state_base() : initialized(0) {}
+ ~rpl_binlog_state_base();
+ void init();
+ void reset_nolock();
+ void free();
+ bool load_nolock(struct rpl_gtid *list, uint32 count);
+ bool load_nolock(rpl_binlog_state_base *orig_state);
+ int update_nolock(const struct rpl_gtid *gtid);
+ int alloc_element_nolock(const rpl_gtid *gtid);
+ uint32 count_nolock();
+ int get_gtid_list_nolock(rpl_gtid *gtid_list, uint32 list_size);
+ rpl_gtid *find_nolock(uint32 domain_id, uint32 server_id);
+ bool is_before_pos(slave_connection_state *pos);
+};
+
+struct rpl_binlog_state : public rpl_binlog_state_base
+{
/* Mutex protecting access to the state. */
mysql_mutex_t LOCK_binlog_state;
- my_bool initialized;
/* Auxiliary buffer to sort gtid list. */
DYNAMIC_ARRAY gtid_sort_array;
- rpl_binlog_state() :initialized(0) {}
+ rpl_binlog_state() {}
~rpl_binlog_state();
void init();
- void reset_nolock();
void reset();
void free();
bool load(struct rpl_gtid *list, uint32 count);
bool load(rpl_slave_state *slave_pos);
- int update_nolock(const struct rpl_gtid *gtid, bool strict);
int update(const struct rpl_gtid *gtid, bool strict);
int update_with_next_gtid(uint32 domain_id, uint32 server_id,
rpl_gtid *gtid);
- int alloc_element_nolock(const rpl_gtid *gtid);
bool check_strict_sequence(uint32 domain_id, uint32 server_id, uint64 seq_no,
bool no_error= false);
int bump_seq_no_if_needed(uint32 domain_id, uint64 seq_no);
@@ -342,7 +368,6 @@ struct rpl_binlog_state
int get_most_recent_gtid_list(rpl_gtid **list, uint32 *size);
bool append_pos(String *str);
bool append_state(String *str);
- rpl_gtid *find_nolock(uint32 domain_id, uint32 server_id);
rpl_gtid *find(uint32 domain_id, uint32 server_id);
rpl_gtid *find_most_recent(uint32 domain_id);
const char* drop_domain(DYNAMIC_ARRAY *ids, Gtid_list_log_event *glev, char*);