sql_parser.cc 中处理语句
case COM_BINLOG_DUMP_GTID:
// TODO: access of protocol_classic should be removed
error=
com_binlog_dump_gtid(thd,
(char *)thd->get_protocol_classic()->get_raw_packet(),
thd->get_protocol_classic()->get_packet_length());
break;
case COM_BINLOG_DUMP:
// TODO: access of protocol_classic should be removed
error=
com_binlog_dump(thd,
(char*)thd->get_protocol_classic()->get_raw_packet(),
thd->get_protocol_classic()->get_packet_length());
break;
普通复制调用com_binlog_dump
kill_zombie_dump_threads(thd);
query_logger.general_log_print(thd, thd->get_command(), "Log: '%s' Pos: %ld",
packet + 10, (long) pos);
mysql_binlog_send(thd, thd->mem_strdup(packet + 10), (my_off_t) pos, NULL, flags);--只要复制没被kill 就一直发送
unregister_slave(thd, true, true/*need_lock_slave_list=true*/);
void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos,
Gtid_set* slave_gtid_executed, uint32 flags)
{
Binlog_sender sender(thd, log_ident, pos, slave_gtid_executed, flags);
sender.run();
}
void Binlog_sender::run()
{
DBUG_ENTER("Binlog_sender::run");
File file= -1;
IO_CACHE log_cache;
my_off_t start_pos= m_start_pos;
const char *log_file= m_linfo.log_file_name;
bool is_index_file_reopened_on_binlog_disable= false;
init();
while (!has_error() && !m_thd->killed)
{
/*
Faked rotate event is only required in a few cases(see comment of the
function). But even so, a faked rotate event is always sent before sending
event log file, even if a rotate log event exists in last binlog and
was already sent. The slave then gets an extra rotation and records
two Rotate_log_events.
The main issue here are some dependencies on mysqlbinlog, that should be
solved in the future.
*/