Commit 274a47a5 authored by Sergei Golubchik's avatar Sergei Golubchik

cleanup: remove Slave_log_event (unused since 2002)

parent 2d2286fa
......@@ -1560,11 +1560,6 @@ Log_event* Log_event::read_log_event(const char* buf, uint event_len,
case GTID_LIST_EVENT:
ev = new Gtid_list_log_event(buf, event_len, description_event);
break;
#ifdef HAVE_REPLICATION
case SLAVE_EVENT: /* can never happen (unused event) */
ev = new Slave_log_event(buf, event_len, description_event);
break;
#endif /* HAVE_REPLICATION */
case CREATE_FILE_EVENT:
ev = new Create_file_log_event(buf, event_len, description_event);
break;
......@@ -7874,11 +7869,6 @@ User_var_log_event::do_shall_skip(rpl_group_info *rgi)
}
#endif /* !MYSQL_CLIENT */
/**************************************************************************
Slave_log_event methods
**************************************************************************/
#ifdef HAVE_REPLICATION
#ifdef MYSQL_CLIENT
void Unknown_log_event::print(FILE* file_arg, PRINT_EVENT_INFO* print_event_info)
......@@ -7892,152 +7882,6 @@ void Unknown_log_event::print(FILE* file_arg, PRINT_EVENT_INFO* print_event_info
}
#endif
#ifndef MYSQL_CLIENT
void Slave_log_event::pack_info(THD *thd, Protocol *protocol)
{
char buf[256+HOSTNAME_LENGTH], *pos;
pos= strmov(buf, "host=");
pos= strnmov(pos, master_host, HOSTNAME_LENGTH);
pos= strmov(pos, ",port=");
pos= int10_to_str((long) master_port, pos, 10);
pos= strmov(pos, ",log=");
pos= strmov(pos, master_log);
pos= strmov(pos, ",pos=");
pos= longlong10_to_str(master_pos, pos, 10);
protocol->store(buf, pos-buf, &my_charset_bin);
}
#endif /* !MYSQL_CLIENT */
#ifndef MYSQL_CLIENT
/**
@todo
re-write this better without holding both locks at the same time
*/
Slave_log_event::Slave_log_event(THD* thd_arg,
Relay_log_info* rli)
:Log_event(thd_arg, 0, 0) , mem_pool(0), master_host(0)
{
DBUG_ENTER("Slave_log_event");
if (!rli->inited) // QQ When can this happen ?
DBUG_VOID_RETURN;
Master_info* mi = rli->mi;
// TODO: re-write this better without holding both locks at the same time
mysql_mutex_lock(&mi->data_lock);
mysql_mutex_lock(&rli->data_lock);
master_host_len = strlen(mi->host);
master_log_len = strlen(rli->group_master_log_name);
// on OOM, just do not initialize the structure and print the error
if ((mem_pool = (char*)my_malloc(get_data_size() + 1,
MYF(MY_WME))))
{
master_host = mem_pool + SL_MASTER_HOST_OFFSET ;
memcpy(master_host, mi->host, master_host_len + 1);
master_log = master_host + master_host_len + 1;
memcpy(master_log, rli->group_master_log_name, master_log_len + 1);
master_port = mi->port;
master_pos = rli->group_master_log_pos;
DBUG_PRINT("info", ("master_log: %s pos: %lu", master_log,
(ulong) master_pos));
}
else
sql_print_error("Out of memory while recording slave event");
mysql_mutex_unlock(&rli->data_lock);
mysql_mutex_unlock(&mi->data_lock);
DBUG_VOID_RETURN;
}
#endif /* !MYSQL_CLIENT */
Slave_log_event::~Slave_log_event()
{
my_free(mem_pool);
}
#ifdef MYSQL_CLIENT
void Slave_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
{
Write_on_release_cache cache(&print_event_info->head_cache, file);
char llbuff[22];
if (print_event_info->short_form)
return;
print_header(&cache, print_event_info, FALSE);
my_b_printf(&cache, "\n\
Slave: master_host: '%s' master_port: %d master_log: '%s' master_pos: %s\n",
master_host, master_port, master_log, llstr(master_pos, llbuff));
}
#endif /* MYSQL_CLIENT */
int Slave_log_event::get_data_size()
{
return master_host_len + master_log_len + 1 + SL_MASTER_HOST_OFFSET;
}
#ifndef MYSQL_CLIENT
bool Slave_log_event::write(IO_CACHE* file)
{
ulong event_length= get_data_size();
int8store(mem_pool + SL_MASTER_POS_OFFSET, master_pos);
int2store(mem_pool + SL_MASTER_PORT_OFFSET, master_port);
// log and host are already there
return (write_header(file, event_length) ||
my_b_safe_write(file, (uchar*) mem_pool, event_length));
}
#endif
void Slave_log_event::init_from_mem_pool(int data_size)
{
master_pos = uint8korr(mem_pool + SL_MASTER_POS_OFFSET);
master_port = uint2korr(mem_pool + SL_MASTER_PORT_OFFSET);
master_host = mem_pool + SL_MASTER_HOST_OFFSET;
master_host_len = (uint) strlen(master_host);
// safety
master_log = master_host + master_host_len + 1;
if (master_log > mem_pool + data_size)
{
master_host = 0;
return;
}
master_log_len = (uint) strlen(master_log);
}
/** This code is not used, so has not been updated to be format-tolerant. */
/* We are using description_event so that slave does not crash on Log_event
constructor */
Slave_log_event::Slave_log_event(const char* buf,
uint event_len,
const Format_description_log_event* description_event)
:Log_event(buf,description_event),mem_pool(0),master_host(0)
{
if (event_len < LOG_EVENT_HEADER_LEN)
return;
event_len -= LOG_EVENT_HEADER_LEN;
if (!(mem_pool = (char*) my_malloc(event_len + 1, MYF(MY_WME))))
return;
memcpy(mem_pool, buf + LOG_EVENT_HEADER_LEN, event_len);
mem_pool[event_len] = 0;
init_from_mem_pool(event_len);
}
#ifndef MYSQL_CLIENT
int Slave_log_event::do_apply_event(rpl_group_info *rgi)
{
if (mysql_bin_log.is_open())
return mysql_bin_log.write(this);
return 0;
}
#endif /* !MYSQL_CLIENT */
/**************************************************************************
Stop_log_event methods
**************************************************************************/
......
......@@ -2040,96 +2040,6 @@ public: /* !!! Public in this patch to allow old usage */
};
#ifdef HAVE_REPLICATION
/**
@class Slave_log_event
Note that this class is currently not used at all; no code writes a
@c Slave_log_event (though some code in @c repl_failsafe.cc reads @c
Slave_log_event). So it's not a problem if this code is not
maintained.
@section Slave_log_event_binary_format Binary Format
This event type has no Post-Header. The Body has the following
four components.
<table>
<caption>Body for Slave_log_event</caption>
<tr>
<th>Name</th>
<th>Format</th>
<th>Description</th>
</tr>
<tr>
<td>master_pos</td>
<td>8 byte integer</td>
<td>???TODO
</td>
</tr>
<tr>
<td>master_port</td>
<td>2 byte integer</td>
<td>???TODO</td>
</tr>
<tr>
<td>master_host</td>
<td>null-terminated string</td>
<td>???TODO</td>
</tr>
<tr>
<td>master_log</td>
<td>null-terminated string</td>
<td>???TODO</td>
</tr>
</table>
*/
class Slave_log_event: public Log_event
{
protected:
char* mem_pool;
void init_from_mem_pool(int data_size);
public:
my_off_t master_pos;
char* master_host;
char* master_log;
int master_host_len;
int master_log_len;
uint16 master_port;
#ifdef MYSQL_SERVER
Slave_log_event(THD* thd_arg, Relay_log_info* rli);
void pack_info(THD *thd, Protocol* protocol);
#else
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
#endif
Slave_log_event(const char* buf,
uint event_len,
const Format_description_log_event *description_event);
~Slave_log_event();
int get_data_size();
bool is_valid() const { return master_host != 0; }
Log_event_type get_type_code() { return SLAVE_EVENT; }
#ifdef MYSQL_SERVER
bool write(IO_CACHE* file);
#endif
private:
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
virtual int do_apply_event(rpl_group_info *rgi);
#endif
};
#endif /* HAVE_REPLICATION */
/**
@class Load_log_event
......
......@@ -68,7 +68,6 @@ struct rpl_group_info;
class Rpl_filter;
class Query_log_event;
class Load_log_event;
class Slave_log_event;
class sp_rcontext;
class sp_cache;
class Lex_input_stream;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment