summaryrefslogtreecommitdiff
path: root/sql/sql_repl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_repl.cc')
-rw-r--r--sql/sql_repl.cc220
1 files changed, 132 insertions, 88 deletions
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 59a3f686e45..6a95a68864f 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -14,7 +14,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
-#include <my_global.h>
+#include "mariadb.h"
#include "sql_priv.h"
#include "unireg.h"
#include "sql_base.h"
@@ -28,9 +28,9 @@
#include "log_event.h"
#include "rpl_filter.h"
#include <my_dir.h>
-#include "rpl_handler.h"
#include "debug_sync.h"
-#include "log.h" // get_gtid_list_event
+#include "semisync_master.h"
+#include "semisync_slave.h"
enum enum_gtid_until_state {
GTID_UNTIL_NOT_DONE,
@@ -160,6 +160,7 @@ struct binlog_send_info {
bool clear_initial_log_pos;
bool should_stop;
+ size_t dirlen;
binlog_send_info(THD *thd_arg, String *packet_arg, ushort flags_arg,
char *lfn)
@@ -313,16 +314,43 @@ static int reset_transmit_packet(binlog_send_info *info, ushort flags,
packet->length(0);
packet->set("\0", 1, &my_charset_bin);
- if (RUN_HOOK(binlog_transmit, reserve_header, (info->thd, flags, packet)))
+ if (info->thd->semi_sync_slave)
{
- info->error= ER_UNKNOWN_ERROR;
- *errmsg= "Failed to run hook 'reserve_header'";
- ret= 1;
+ if (repl_semisync_master.reserve_sync_header(packet))
+ {
+ info->error= ER_UNKNOWN_ERROR;
+ *errmsg= "Failed to run hook 'reserve_header'";
+ ret= 1;
+ }
}
+
*ev_offset= packet->length();
return ret;
}
+int get_user_var_int(const char *name,
+ long long int *value, int *null_value)
+{
+ bool null_val;
+ user_var_entry *entry=
+ (user_var_entry*) my_hash_search(&current_thd->user_vars,
+ (uchar*) name, strlen(name));
+ if (!entry)
+ return 1;
+ *value= entry->val_int(&null_val);
+ if (null_value)
+ *null_value= null_val;
+ return 0;
+}
+
+inline bool is_semi_sync_slave()
+{
+ int null_value;
+ long long val= 0;
+ get_user_var_int("rpl_semi_sync_slave", &val, &null_value);
+ return val;
+}
+
static int send_file(THD *thd)
{
NET* net = &thd->net;
@@ -346,11 +374,15 @@ static int send_file(THD *thd)
We need net_flush here because the client will not know it needs to send
us the file name until it has processed the load event entry
*/
- if (net_flush(net) || (packet_len = my_net_read(net)) == packet_error)
+ if (unlikely(net_flush(net)))
{
+ read_error:
errmsg = "while reading file name";
goto err;
}
+ packet_len= my_net_read(net);
+ if (unlikely(packet_len == packet_error))
+ goto read_error;
// terminate with \0 for fn_format
*((char*)net->read_pos + packet_len) = 0;
@@ -428,7 +460,7 @@ inline void fix_checksum(enum_binlog_checksum_alg checksum_alg, String *packet,
static user_var_entry * get_binlog_checksum_uservar(THD * thd)
{
- LEX_STRING name= { C_STRING_WITH_LEN("master_binlog_checksum")};
+ LEX_CSTRING name= { STRING_WITH_LEN("master_binlog_checksum")};
user_var_entry *entry=
(user_var_entry*) my_hash_search(&thd->user_vars, (uchar*) name.str,
name.length);
@@ -678,7 +710,7 @@ void set_read_error(binlog_send_info *info, int error)
static ulonglong get_heartbeat_period(THD * thd)
{
bool null_value;
- LEX_STRING name= { C_STRING_WITH_LEN("master_heartbeat_period")};
+ LEX_CSTRING name= { STRING_WITH_LEN("master_heartbeat_period")};
user_var_entry *entry=
(user_var_entry*) my_hash_search(&thd->user_vars, (uchar*) name.str,
name.length);
@@ -697,7 +729,7 @@ static int
get_mariadb_slave_capability(THD *thd)
{
bool null_value;
- const LEX_STRING name= { C_STRING_WITH_LEN("mariadb_slave_capability") };
+ const LEX_CSTRING name= { STRING_WITH_LEN("mariadb_slave_capability") };
const user_var_entry *entry=
(user_var_entry*) my_hash_search(&thd->user_vars, (uchar*) name.str,
name.length);
@@ -718,7 +750,7 @@ get_slave_connect_state(THD *thd, String *out_str)
{
bool null_value;
- const LEX_STRING name= { C_STRING_WITH_LEN("slave_connect_state") };
+ const LEX_CSTRING name= { STRING_WITH_LEN("slave_connect_state") };
user_var_entry *entry=
(user_var_entry*) my_hash_search(&thd->user_vars, (uchar*) name.str,
name.length);
@@ -731,7 +763,7 @@ get_slave_gtid_strict_mode(THD *thd)
{
bool null_value;
- const LEX_STRING name= { C_STRING_WITH_LEN("slave_gtid_strict_mode") };
+ const LEX_CSTRING name= { STRING_WITH_LEN("slave_gtid_strict_mode") };
user_var_entry *entry=
(user_var_entry*) my_hash_search(&thd->user_vars, (uchar*) name.str,
name.length);
@@ -744,7 +776,7 @@ get_slave_gtid_ignore_duplicates(THD *thd)
{
bool null_value;
- const LEX_STRING name= { C_STRING_WITH_LEN("slave_gtid_ignore_duplicates") };
+ const LEX_CSTRING name= { STRING_WITH_LEN("slave_gtid_ignore_duplicates") };
user_var_entry *entry=
(user_var_entry*) my_hash_search(&thd->user_vars, (uchar*) name.str,
name.length);
@@ -765,7 +797,7 @@ get_slave_until_gtid(THD *thd, String *out_str)
{
bool null_value;
- const LEX_STRING name= { C_STRING_WITH_LEN("slave_until_gtid") };
+ const LEX_CSTRING name= { STRING_WITH_LEN("slave_until_gtid") };
user_var_entry *entry=
(user_var_entry*) my_hash_search(&thd->user_vars, (uchar*) name.str,
name.length);
@@ -811,8 +843,8 @@ static int send_heartbeat_event(binlog_send_info *info,
char* p= coord->file_name + dirname_length(coord->file_name);
- uint ident_len = strlen(p);
- ulong event_len = ident_len + LOG_EVENT_HEADER_LEN +
+ size_t ident_len = strlen(p);
+ size_t event_len = ident_len + LOG_EVENT_HEADER_LEN +
(do_checksum ? BINLOG_CHECKSUM_LEN : 0);
int4store(header + SERVER_ID_OFFSET, global_system_variables.server_id);
int4store(header + EVENT_LEN_OFFSET, event_len);
@@ -1207,8 +1239,9 @@ gtid_find_binlog_file(slave_connection_state *state, char *out_name,
const char *errormsg= NULL;
char buf[FN_REFLEN];
- init_alloc_root(&memroot, 10*(FN_REFLEN+sizeof(binlog_file_entry)), 0,
- MYF(MY_THREAD_SPECIFIC));
+ init_alloc_root(&memroot, "gtid_find_binlog_file",
+ 10*(FN_REFLEN+sizeof(binlog_file_entry)),
+ 0, MYF(MY_THREAD_SPECIFIC));
if (!(list= get_binlog_list(&memroot)))
{
errormsg= "Out of memory while looking for GTID position in binlog";
@@ -1241,12 +1274,12 @@ gtid_find_binlog_file(slave_connection_state *state, char *out_name,
goto end;
}
bzero((char*) &cache, sizeof(cache));
- if ((file= open_binlog(&cache, buf, &errormsg)) == (File)-1)
+ if (unlikely((file= open_binlog(&cache, buf, &errormsg)) == (File)-1))
goto end;
errormsg= get_gtid_list_event(&cache, &glev);
end_io_cache(&cache);
mysql_file_close(file, MYF(MY_WME));
- if (errormsg)
+ if (unlikely(errormsg))
goto end;
if (!glev || contains_all_slave_gtid(state, glev))
@@ -1353,14 +1386,14 @@ gtid_state_from_pos(const char *name, uint32 offset,
String packet;
Format_description_log_event *fdev= NULL;
- if (gtid_state->load((const rpl_gtid *)NULL, 0))
+ if (unlikely(gtid_state->load((const rpl_gtid *)NULL, 0)))
{
errormsg= "Internal error (out of memory?) initializing slave state "
"while scanning binlog to find start position";
return errormsg;
}
- if ((file= open_binlog(&cache, name, &errormsg)) == (File)-1)
+ if (unlikely((file= open_binlog(&cache, name, &errormsg)) == (File)-1))
return errormsg;
if (!(fdev= new Format_description_log_event(3)))
@@ -1393,7 +1426,7 @@ gtid_state_from_pos(const char *name, uint32 offset,
err= Log_event::read_log_event(&cache, &packet, fdev,
opt_master_verify_checksum ? current_checksum_alg
: BINLOG_CHECKSUM_ALG_OFF);
- if (err)
+ if (unlikely(err))
{
errormsg= "Could not read binlog while searching for slave start "
"position on master";
@@ -1408,7 +1441,7 @@ gtid_state_from_pos(const char *name, uint32 offset,
{
Format_description_log_event *tmp;
- if (found_format_description_event)
+ if (unlikely(found_format_description_event))
{
errormsg= "Duplicate format description log event found while "
"searching for old-style position in binlog";
@@ -1417,8 +1450,9 @@ gtid_state_from_pos(const char *name, uint32 offset,
current_checksum_alg= get_checksum_alg(packet.ptr(), packet.length());
found_format_description_event= true;
- if (!(tmp= new Format_description_log_event(packet.ptr(), packet.length(),
- fdev)))
+ if (unlikely(!(tmp= new Format_description_log_event(packet.ptr(),
+ packet.length(),
+ fdev))))
{
errormsg= "Corrupt Format_description event found or out-of-memory "
"while searching for old-style position in binlog";
@@ -1441,7 +1475,8 @@ gtid_state_from_pos(const char *name, uint32 offset,
goto end;
}
}
- else if (typ != FORMAT_DESCRIPTION_EVENT && !found_format_description_event)
+ else if (unlikely(typ != FORMAT_DESCRIPTION_EVENT &&
+ !found_format_description_event))
{
errormsg= "Did not find format description log event while searching "
"for old-style position in binlog";
@@ -1456,7 +1491,7 @@ gtid_state_from_pos(const char *name, uint32 offset,
bool status;
uint32 list_len;
- if (found_gtid_list_event)
+ if (unlikely(found_gtid_list_event))
{
errormsg= "Found duplicate Gtid_list_log_event while scanning binlog "
"to find slave start position";
@@ -1465,7 +1500,7 @@ gtid_state_from_pos(const char *name, uint32 offset,
status= Gtid_list_log_event::peek(packet.ptr(), packet.length(),
current_checksum_alg,
&gtid_list, &list_len, fdev);
- if (status)
+ if (unlikely(status))
{
errormsg= "Error reading Gtid_list_log_event while searching "
"for old-style position in binlog";
@@ -1473,7 +1508,7 @@ gtid_state_from_pos(const char *name, uint32 offset,
}
err= gtid_state->load(gtid_list, list_len);
my_free(gtid_list);
- if (err)
+ if (unlikely(err))
{
errormsg= "Internal error (out of memory?) initialising slave state "
"while scanning binlog to find start position";
@@ -1481,7 +1516,7 @@ gtid_state_from_pos(const char *name, uint32 offset,
}
found_gtid_list_event= true;
}
- else if (!found_gtid_list_event)
+ else if (unlikely(!found_gtid_list_event))
{
/* We did not find any Gtid_list_log_event, must be old binlog. */
goto end;
@@ -1490,15 +1525,16 @@ gtid_state_from_pos(const char *name, uint32 offset,
{
rpl_gtid gtid;
uchar flags2;
- if (Gtid_log_event::peek(packet.ptr(), packet.length(),
- current_checksum_alg, &gtid.domain_id,
- &gtid.server_id, &gtid.seq_no, &flags2, fdev))
+ if (unlikely(Gtid_log_event::peek(packet.ptr(), packet.length(),
+ current_checksum_alg, &gtid.domain_id,
+ &gtid.server_id, &gtid.seq_no, &flags2,
+ fdev)))
{
errormsg= "Corrupt gtid_log_event found while scanning binlog to find "
"initial slave position";
goto end;
}
- if (gtid_state->update(&gtid))
+ if (unlikely(gtid_state->update(&gtid)))
{
errormsg= "Internal error (out of memory?) updating slave state while "
"scanning binlog to find start position";
@@ -1507,7 +1543,7 @@ gtid_state_from_pos(const char *name, uint32 offset,
}
}
- if (!valid_pos)
+ if (unlikely(!valid_pos))
{
errormsg= "Slave requested incorrect position in master binlog. "
"Requested position %u in file '%s', but this position does not "
@@ -1617,6 +1653,7 @@ send_event_to_slave(binlog_send_info *info, Log_event_type event_type,
enum enum_binlog_checksum_alg current_checksum_alg= info->current_checksum_alg;
slave_connection_state *gtid_state= &info->gtid_state;
slave_connection_state *until_gtid_state= info->until_gtid_state;
+ bool need_sync= false;
if (event_type == GTID_LIST_EVENT &&
info->using_gtid_state && until_gtid_state)
@@ -1924,8 +1961,10 @@ send_event_to_slave(binlog_send_info *info, Log_event_type event_type,
THD_STAGE_INFO(info->thd, stage_sending_binlog_event_to_slave);
pos= my_b_tell(log);
- if (RUN_HOOK(binlog_transmit, before_send_event,
- (info->thd, info->flags, packet, info->log_file_name, pos)))
+ if (repl_semisync_master.update_sync_header(info->thd,
+ (uchar*) packet->c_ptr_safe(),
+ info->log_file_name + info->dirlen,
+ pos, &need_sync))
{
info->error= ER_UNKNOWN_ERROR;
return "run 'before_send_event' hook failed";
@@ -1947,8 +1986,8 @@ send_event_to_slave(binlog_send_info *info, Log_event_type event_type,
}
}
- if (RUN_HOOK(binlog_transmit, after_send_event,
- (info->thd, info->flags, packet)))
+ if (need_sync && repl_semisync_master.flush_net(info->thd,
+ packet->c_ptr_safe()))
{
info->error= ER_UNKNOWN_ERROR;
return "Failed to run hook 'after_send_event'";
@@ -2083,8 +2122,8 @@ static int init_binlog_sender(binlog_send_info *info,
info->error= ER_UNKNOWN_ERROR;
return 1;
}
- if ((error= check_slave_start_position(info, &info->errmsg,
- &info->error_gtid)))
+ if (unlikely((error= check_slave_start_position(info, &info->errmsg,
+ &info->error_gtid))))
{
info->error= error;
return 1;
@@ -2184,7 +2223,7 @@ static int send_format_descriptor_event(binlog_send_info *info, IO_CACHE *log,
: BINLOG_CHECKSUM_ALG_OFF);
linfo->pos= my_b_tell(log);
- if (error)
+ if (unlikely(error))
{
set_read_error(info, error);
DBUG_RETURN(1);
@@ -2318,7 +2357,7 @@ static int send_format_descriptor_event(binlog_send_info *info, IO_CACHE *log,
: BINLOG_CHECKSUM_ALG_OFF);
linfo->pos= my_b_tell(log);
- if (error)
+ if (unlikely(error))
{
set_read_error(info, error);
DBUG_RETURN(1);
@@ -2396,7 +2435,7 @@ static int wait_new_events(binlog_send_info *info, /* in */
PSI_stage_info old_stage;
mysql_bin_log.lock_binlog_end_pos();
- info->thd->ENTER_COND(mysql_bin_log.get_log_cond(),
+ info->thd->ENTER_COND(mysql_bin_log.get_bin_log_cond(),
mysql_bin_log.get_binlog_end_pos_lock(),
&stage_master_has_sent_all_binlog_to_slave,
&old_stage);
@@ -2584,7 +2623,7 @@ static int send_events(binlog_send_info *info, IO_CACHE* log, LOG_INFO* linfo,
: BINLOG_CHECKSUM_ALG_OFF);
linfo->pos= my_b_tell(log);
- if (error)
+ if (unlikely(error))
{
set_read_error(info, error);
return 1;
@@ -2708,7 +2747,7 @@ static int send_one_binlog_file(binlog_send_info *info,
/** end of file or error */
return (int)end_pos;
}
-
+ info->dirlen= dirname_length(info->log_file_name);
/**
* send events from current position up to end_pos
*/
@@ -2730,6 +2769,7 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos,
binlog_send_info infoobj(thd, packet, flags, linfo.log_file_name);
binlog_send_info *info= &infoobj;
+ bool has_transmit_started= false;
int old_max_allowed_packet= thd->variables.max_allowed_packet;
thd->variables.max_allowed_packet= MAX_MAX_ALLOWED_PACKET;
@@ -2742,15 +2782,14 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos,
if (init_binlog_sender(info, &linfo, log_ident, &pos))
goto err;
- /*
- run hook first when all check has been made that slave seems to
- be requesting a reasonable position. i.e when transmit actually starts
- */
+ has_transmit_started= true;
+
+ /* Check if the dump thread is created by a slave with semisync enabled. */
+ thd->semi_sync_slave = is_semi_sync_slave();
DBUG_ASSERT(pos == linfo.pos);
- if (RUN_HOOK(binlog_transmit, transmit_start,
- (thd, flags, linfo.log_file_name, linfo.pos)))
+ if (repl_semisync_master.dump_start(thd, linfo.log_file_name, linfo.pos))
{
info->errmsg= "Failed to run hook 'transmit_start'";
info->error= ER_UNKNOWN_ERROR;
@@ -2872,7 +2911,10 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos,
err:
THD_STAGE_INFO(thd, stage_waiting_to_finalize_termination);
- RUN_HOOK(binlog_transmit, transmit_stop, (thd, flags));
+ if (has_transmit_started)
+ {
+ repl_semisync_master.dump_end(thd);
+ }
if (info->thd->killed == KILL_SLAVE_SAME_ID)
{
@@ -2892,6 +2934,12 @@ err:
thd->variables.max_allowed_packet= old_max_allowed_packet;
delete info->fdev;
+ if (likely(info->error == 0))
+ {
+ my_eof(thd);
+ DBUG_VOID_RETURN;
+ }
+
if ((info->error == ER_MASTER_FATAL_ERROR_READING_BINLOG ||
info->error == ER_SLAVE_SAME_ID) && binlog_open)
{
@@ -2953,17 +3001,10 @@ err:
"mysql", rpl_gtid_slave_state_table_name.str);
info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG;
}
- else if (info->error != 0 && info->errmsg != NULL)
+ else if (info->errmsg != NULL)
strcpy(info->error_text, info->errmsg);
- if (info->error == 0)
- {
- my_eof(thd);
- }
- else
- {
- my_message(info->error, info->error_text, MYF(0));
- }
+ my_message(info->error, info->error_text, MYF(0));
DBUG_VOID_RETURN;
}
@@ -3257,7 +3298,7 @@ int reset_slave(THD *thd, Master_info* mi)
char fname[FN_REFLEN];
int thread_mask= 0, error= 0;
uint sql_errno=ER_UNKNOWN_ERROR;
- const char* errmsg= "Unknown error occurred while reseting slave";
+ const char* errmsg= "Unknown error occurred while resetting slave";
char master_info_file_tmp[FN_REFLEN];
char relay_log_info_file_tmp[FN_REFLEN];
DBUG_ENTER("reset_slave");
@@ -3282,9 +3323,9 @@ int reset_slave(THD *thd, Master_info* mi)
}
// delete relay logs, clear relay log coordinates
- if ((error= purge_relay_logs(&mi->rli, thd,
+ if (unlikely((error= purge_relay_logs(&mi->rli, thd,
1 /* just reset */,
- &errmsg)))
+ &errmsg))))
{
sql_errno= ER_RELAY_LOG_FAIL;
goto err;
@@ -3338,10 +3379,11 @@ int reset_slave(THD *thd, Master_info* mi)
else if (global_system_variables.log_warnings > 1)
sql_print_information("Deleted Master_info file '%s'.", fname);
- RUN_HOOK(binlog_relay_io, after_reset_slave, (thd, mi));
+ if (rpl_semi_sync_slave_enabled)
+ repl_semisync_slave.reset_slave(mi);
err:
mi->unlock_slave_threads();
- if (error)
+ if (unlikely(error))
my_error(sql_errno, MYF(0), errmsg);
DBUG_RETURN(error);
}
@@ -3375,7 +3417,7 @@ void kill_zombie_dump_threads(uint32 slave_server_id)
if (tmp->get_command() == COM_BINLOG_DUMP &&
tmp->variables.server_id == slave_server_id)
{
- mysql_mutex_lock(&tmp->LOCK_thd_data); // Lock from delete
+ mysql_mutex_lock(&tmp->LOCK_thd_kill); // Lock from delete
break;
}
}
@@ -3387,8 +3429,8 @@ void kill_zombie_dump_threads(uint32 slave_server_id)
it will be slow because it will iterate through the list
again. We just to do kill the thread ourselves.
*/
- tmp->awake(KILL_SLAVE_SAME_ID);
- mysql_mutex_unlock(&tmp->LOCK_thd_data);
+ tmp->awake_no_mutex(KILL_SLAVE_SAME_ID);
+ mysql_mutex_unlock(&tmp->LOCK_thd_kill);
}
}
@@ -3407,7 +3449,7 @@ static bool get_string_parameter(char *to, const char *from, size_t length,
if (from) // Empty paramaters allowed
{
size_t from_length= strlen(from);
- uint from_numchars= cs->cset->numchars(cs, from, from + from_length);
+ size_t from_numchars= cs->cset->numchars(cs, from, from + from_length);
if (from_numchars > length / cs->mbmaxlen)
{
my_error(ER_WRONG_STRING_LENGTH, MYF(0), from, name,
@@ -3841,11 +3883,13 @@ int reset_master(THD* thd, rpl_gtid *init_state, uint32 init_state_len,
return 1;
}
- if (mysql_bin_log.reset_logs(thd, 1, init_state, init_state_len,
- next_log_number))
- return 1;
- RUN_HOOK(binlog_transmit, after_reset_master, (thd, 0 /* flags */));
- return 0;
+ bool ret= 0;
+ /* Temporarily disable master semisync before resetting master. */
+ repl_semisync_master.before_reset_master();
+ ret= mysql_bin_log.reset_logs(thd, 1, init_state, init_state_len,
+ next_log_number);
+ repl_semisync_master.after_reset_master();
+ return ret;
}
@@ -3982,7 +4026,7 @@ bool mysql_show_binlog_events(THD* thd)
my_off_t scan_pos = BIN_LOG_HEADER_SIZE;
while (scan_pos < pos)
{
- ev= Log_event::read_log_event(&log, (mysql_mutex_t*)0, description_event,
+ ev= Log_event::read_log_event(&log, description_event,
opt_master_verify_checksum);
scan_pos = my_b_tell(&log);
if (ev == NULL || !ev->is_valid())
@@ -4052,7 +4096,7 @@ bool mysql_show_binlog_events(THD* thd)
}
for (event_count = 0;
- (ev = Log_event::read_log_event(&log, (mysql_mutex_t*) 0,
+ (ev = Log_event::read_log_event(&log,
description_event,
(opt_master_verify_checksum ||
verify_checksum_once))); )
@@ -4096,7 +4140,7 @@ bool mysql_show_binlog_events(THD* thd)
break;
}
- if (event_count < limit_end && log.error)
+ if (unlikely(event_count < limit_end && log.error))
{
errmsg = "Wrong offset or I/O error";
mysql_mutex_unlock(log_lock);
@@ -4178,7 +4222,7 @@ bool show_binlog_info(THD* thd)
{
LOG_INFO li;
mysql_bin_log.get_current_log(&li);
- int dir_len = dirname_length(li.log_file_name);
+ size_t dir_len = dirname_length(li.log_file_name);
protocol->store(li.log_file_name + dir_len, &my_charset_bin);
protocol->store((ulonglong) li.pos);
protocol->store(binlog_filter->get_do_db());
@@ -4220,8 +4264,8 @@ bool show_binlogs(THD* thd)
File file;
char fname[FN_REFLEN];
List<Item> field_list;
- uint length;
- int cur_dir_len;
+ size_t length;
+ size_t cur_dir_len;
Protocol *protocol= thd->protocol;
DBUG_ENTER("show_binlogs");
@@ -4251,7 +4295,7 @@ bool show_binlogs(THD* thd)
/* The file ends with EOF or empty line */
while ((length=my_b_gets(index_file, fname, sizeof(fname))) > 1)
{
- int dir_len;
+ size_t dir_len;
ulonglong file_length= 0; // Length if open fails
fname[--length] = '\0'; // remove the newline
@@ -4277,7 +4321,7 @@ bool show_binlogs(THD* thd)
if (protocol->write())
goto err;
}
- if(index_file->error == -1)
+ if (unlikely(index_file->error == -1))
goto err;
mysql_bin_log.unlock_index();
my_eof(thd);
@@ -4320,7 +4364,7 @@ int log_loaded_block(IO_CACHE* file, uchar *Buffer, size_t Count)
lf_info->last_pos_in_file= my_b_get_pos_in_file(file);
if (lf_info->wrote_create_file)
{
- Append_block_log_event a(lf_info->thd, lf_info->thd->db, buffer,
+ Append_block_log_event a(lf_info->thd, lf_info->thd->db.str, buffer,
MY_MIN(block_len, max_event_size),
lf_info->log_delayed);
if (mysql_bin_log.write(&a))
@@ -4328,7 +4372,7 @@ int log_loaded_block(IO_CACHE* file, uchar *Buffer, size_t Count)
}
else
{
- Begin_load_query_log_event b(lf_info->thd, lf_info->thd->db,
+ Begin_load_query_log_event b(lf_info->thd, lf_info->thd->db.str,
buffer,
MY_MIN(block_len, max_event_size),
lf_info->log_delayed);