21 #include "mysqld_error.h"
27 DBUG_ENTER(
"Sid_map::Sid_map");
28 my_init_dynamic_array(&_sidno_to_sid,
sizeof(Node *), 8, 8);
29 my_init_dynamic_array(&_sorted,
sizeof(rpl_sidno), 8, 8);
30 my_hash_init(&_sid_to_sidno, &my_charset_bin, 20,
39 DBUG_ENTER(
"Sid_map::~Sid_map");
40 delete_dynamic(&_sidno_to_sid);
41 delete_dynamic(&_sorted);
42 my_hash_free(&_sid_to_sidno);
53 #ifdef NON_DISABLED_GTID
54 enum_return_status Sid_map::clear()
56 DBUG_ENTER(
"Sid_map::clear");
57 my_hash_free(&_sid_to_sidno);
58 my_hash_init(&_sid_to_sidno, &my_charset_bin, 20,
61 reset_dynamic(&_sidno_to_sid);
62 reset_dynamic(&_sorted);
70 DBUG_ENTER(
"Sid_map::add_sid(const rpl_sid *)");
74 DBUG_PRINT(
"info", (
"SID=%s", buf));
78 Node *node= (Node *)my_hash_search(&_sid_to_sidno, sid.
bytes,
82 DBUG_PRINT(
"info", (
"existed as sidno=%d", node->sidno));
83 DBUG_RETURN(node->sidno);
86 bool is_wrlock=
false;
96 DBUG_PRINT(
"info", (
"is_wrlock=%d sid_lock=%p", is_wrlock, sid_lock));
98 node= (Node *)my_hash_search(&_sid_to_sidno, sid.
bytes,
105 if (add_node(sidno, sid) != RETURN_STATUS_OK)
120 enum_return_status Sid_map::add_node(rpl_sidno sidno,
const rpl_sid &sid)
122 DBUG_ENTER(
"Sid_map::add_node(rpl_sidno, const rpl_sid *)");
125 Node *node= (Node *)my_malloc(
sizeof(Node), MYF(MY_WME));
127 RETURN_REPORTED_ERROR;
131 if (insert_dynamic(&_sidno_to_sid, &node) == 0)
133 if (insert_dynamic(&_sorted, &sidno) == 0)
135 if (my_hash_insert(&_sid_to_sidno, (uchar *)node) == 0)
142 if (
this != global_sid_map ||
148 int sorted_i= sidno - 1;
149 rpl_sidno *prev_sorted_p= dynamic_element(&_sorted, sorted_i,
152 while (sorted_i >= 0)
154 rpl_sidno *sorted_p= dynamic_element(&_sorted, sorted_i,
160 memcpy(prev_sorted_p, sorted_p,
sizeof(rpl_sidno));
162 prev_sorted_p= sorted_p;
164 memcpy(prev_sorted_p, &sidno,
sizeof(rpl_sidno));
168 pop_dynamic(&_sorted);
170 pop_dynamic(&_sidno_to_sid);
174 BINLOG_ERROR((
"Out of memory."), (ER_OUT_OF_RESOURCES, MYF(0)));
175 RETURN_REPORTED_ERROR;