diff --git a/mysql-test/include/check-testcase.test b/mysql-test/include/check-testcase.test index e9efc6c8907..b25c6945023 100644 --- a/mysql-test/include/check-testcase.test +++ b/mysql-test/include/check-testcase.test @@ -60,7 +60,7 @@ if ($tmp) --echo Last_SQL_Error --echo Replicate_Ignore_Server_Ids --echo Master_Server_Id # - --echo Gtid_Pos_Auto 0 + --echo Using_Gtid 0 } if (!$tmp) { # Note: after WL#5177, fields 13-18 shall not be filtered-out. diff --git a/mysql-test/include/rpl_end.inc b/mysql-test/include/rpl_end.inc index b6535f00283..3fdd91ba319 100644 --- a/mysql-test/include/rpl_end.inc +++ b/mysql-test/include/rpl_end.inc @@ -89,7 +89,7 @@ while ($_rpl_server) --let $rpl_connection_name= server_$_rpl_server --source include/rpl_connection.inc - # Clear Gtid_Pos_Auto in SHOW SLAVE STATUS to keep check_testcase happy. + # Clear Using_Gtid in SHOW SLAVE STATUS to keep check_testcase happy. CHANGE MASTER TO master_log_file=''; --dec $_rpl_server diff --git a/sql/log.cc b/sql/log.cc index 33e10acba8f..fc9a651bfab 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -3270,12 +3270,9 @@ bool MYSQL_BIN_LOG::open(const char *log_name, there had been an entry (domain_id, server_id, 0). */ - if (rpl_global_gtid_binlog_state.count()) - { - Gtid_list_log_event gl_ev(&rpl_global_gtid_binlog_state); - if (gl_ev.write(&log_file)) - goto err; - } + Gtid_list_log_event gl_ev(&rpl_global_gtid_binlog_state); + if (gl_ev.write(&log_file)) + goto err; /* Output a binlog checkpoint event at the start of the binlog file. */ diff --git a/sql/log_event.cc b/sql/log_event.cc index 9a0fd375be1..d406aeae778 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -7220,9 +7220,9 @@ Gtid_list_log_event::Gtid_list_log_event(const char *buf, uint event_len, buf+= header_size; count= uint4korr(buf) & ((1<<28)-1); buf+= 4; - if (count == 0 || - event_len - (header_size + post_header_len) < count*element_size || - (!(list= (rpl_gtid *)my_malloc(count*sizeof(*list), MYF(MY_WME))))) + if (event_len - (header_size + post_header_len) < count*element_size || + (!(list= (rpl_gtid *)my_malloc(count*sizeof(*list) + (count == 0), + MYF(MY_WME))))) return; for (i= 0; i < count; ++i) @@ -7314,11 +7314,10 @@ rpl_binlog_state::get_most_recent_gtid_list(rpl_gtid **list, uint32 *size) Gtid_list_log_event::Gtid_list_log_event(rpl_binlog_state *gtid_set) : count(gtid_set->count()), list(0) { - DBUG_ASSERT(count != 0); - /* Failure to allocate memory will be caught by is_valid() returning false. */ - if (count != 0 && count < (1<<28) && - (list = (rpl_gtid *)my_malloc(count * sizeof(*list), MYF(MY_WME)))) + if (count < (1<<28) && + (list = (rpl_gtid *)my_malloc(count * sizeof(*list) + (count == 0), + MYF(MY_WME)))) gtid_set->get_gtid_list(list, count); } @@ -7356,17 +7355,13 @@ Gtid_list_log_event::pack_info(THD *thd, Protocol *protocol) uint32 i; buf.length(0); + buf.append(STRING_WITH_LEN("[")); for (i= 0; i < count; ++i) { if (i) buf.append(STRING_WITH_LEN(", ")); - else - buf.append(STRING_WITH_LEN("[")); - if (list[i].domain_id) - { - buf.append_ulonglong((ulonglong)list[i].domain_id); - buf.append(STRING_WITH_LEN("-")); - } + buf.append_ulonglong((ulonglong)list[i].domain_id); + buf.append(STRING_WITH_LEN("-")); buf.append_ulonglong((ulonglong)list[i].server_id); buf.append(STRING_WITH_LEN("-")); buf.append_ulonglong(list[i].seq_no); @@ -7392,8 +7387,7 @@ Gtid_list_log_event::print(FILE *file, PRINT_EVENT_INFO *print_event_info) print_header(&cache, print_event_info, FALSE); for (i= 0; i < count; ++i) { - if (list[i].domain_id) - my_b_printf(&cache, "%u-", list[i].domain_id); + my_b_printf(&cache, "%u-", list[i].domain_id); longlong10_to_str(list[i].seq_no, buf, 10); my_b_printf(&cache, "%u-%s", list[i].server_id, buf); if (i < count-1) @@ -7428,7 +7422,8 @@ Gtid_list_log_event::peek(const char *event_start, uint32 event_len, if (event_len < LOG_EVENT_HEADER_LEN + GTID_LIST_HEADER_LEN + 16 * count) return true; - if (!(gtid_list= (rpl_gtid *)my_malloc(sizeof(rpl_gtid)*count, MYF(MY_WME)))) + if (!(gtid_list= (rpl_gtid *)my_malloc(sizeof(rpl_gtid)*count + (count == 0), + MYF(MY_WME)))) return true; *out_gtid_list= gtid_list; *out_list_len= count; diff --git a/sql/slave.cc b/sql/slave.cc index a97599b7e19..9ceeee13480 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2256,7 +2256,7 @@ static bool send_show_master_info_header(THD *thd, bool full, FN_REFLEN)); field_list.push_back(new Item_return_int("Master_Server_Id", sizeof(ulong), MYSQL_TYPE_LONG)); - field_list.push_back(new Item_return_int("Gtid_Pos_Auto", sizeof(ulong), + field_list.push_back(new Item_return_int("Using_Gtid", sizeof(ulong), MYSQL_TYPE_LONG)); if (full) { diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 62b7135641d..f4c902c5954 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -735,7 +735,7 @@ gtid_find_binlog_file(slave_connection_state *state, char *out_name) { MEM_ROOT memroot; binlog_file_entry *list; - Gtid_list_log_event *glev; + Gtid_list_log_event *glev= NULL; const char *errormsg= NULL; IO_CACHE cache; File file = (File)-1; @@ -780,6 +780,8 @@ gtid_find_binlog_file(slave_connection_state *state, char *out_name) strmake(out_name, buf, FN_REFLEN); goto end; } + delete glev; + glev= NULL; list= list->next; } @@ -789,6 +791,8 @@ gtid_find_binlog_file(slave_connection_state *state, char *out_name) "have been purged."; end: + if (glev) + delete glev; if (file != (File)-1) { end_io_cache(&cache);