Commit edb70453 authored by mats@romeo.(none)'s avatar mats@romeo.(none)

Merge romeo.(none):/home/bkroot/mysql-5.1-new-rpl

into  romeo.(none):/home/bk/b23171-mysql-5.1-new-rpl
parents efaa0f40 9372c38c
......@@ -2423,7 +2423,7 @@ bool MYSQL_BIN_LOG::open(const char *log_name,
/*
Set 'created' to 0, so that in next relay logs this event does not
trigger cleaning actions on the slave in
Format_description_log_event::exec_event().
Format_description_log_event::apply_event_impl().
*/
description_event_for_queue->created= 0;
/* Don't set log_pos in event header */
......
......@@ -532,24 +532,22 @@ Log_event::Log_event(const char* buf,
#ifdef HAVE_REPLICATION
/*
Log_event::exec_event()
Log_event::apply_event_impl()
*/
int Log_event::exec_event(struct st_relay_log_info* rli)
int Log_event::apply_event_impl(RELAY_LOG_INFO* rli)
{
DBUG_ENTER("Log_event::exec_event");
DBUG_ENTER("Log_event::apply_event_impl");
/*
rli is null when (as far as I (Guilhem) know)
the caller is
Load_log_event::exec_event *and* that one is called from
Execute_load_log_event::exec_event.
In this case, we don't do anything here ;
Execute_load_log_event::exec_event will call Log_event::exec_event
again later with the proper rli.
Strictly speaking, if we were sure that rli is null
only in the case discussed above, 'if (rli)' is useless here.
But as we are not 100% sure, keep it for now.
rli is null when (as far as I (Guilhem) know) the caller is
Load_log_event::apply_event_impl *and* that one is called from
Execute_load_log_event::apply_event_impl. In this case, we don't
do anything here ; Execute_load_log_event::apply_event_impl will
call Log_event::apply_event_impl again later with the proper rli.
Strictly speaking, if we were sure that rli is null only in the
case discussed above, 'if (rli)' is useless here. But as we are
not 100% sure, keep it for now.
*/
if (rli)
{
......@@ -584,13 +582,13 @@ int Log_event::exec_event(struct st_relay_log_info* rli)
{
rli->inc_group_relay_log_pos(log_pos);
flush_relay_log_info(rli);
/*
Note that Rotate_log_event::exec_event() does not call this
function, so there is no chance that a fake rotate event resets
last_master_timestamp.
Note that we update without mutex (probably ok - except in some very
rare cases, only consequence is that value may take some time to
display in Seconds_Behind_Master - not critical).
/*
Note that Rotate_log_event::apply_event_impl() does not call
this function, so there is no chance that a fake rotate event
resets last_master_timestamp. Note that we update without
mutex (probably ok - except in some very rare cases, only
consequence is that value may take some time to display in
Seconds_Behind_Master - not critical).
*/
rli->last_master_timestamp= when;
}
......@@ -1821,27 +1819,28 @@ void Query_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
/*
Query_log_event::exec_event()
Query_log_event::apply_event_impl()
*/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
int Query_log_event::exec_event(struct st_relay_log_info* rli)
int Query_log_event::apply_event_impl(RELAY_LOG_INFO* rli)
{
return exec_event(rli, query, q_len);
return apply_event_impl(rli, query, q_len);
}
int Query_log_event::exec_event(struct st_relay_log_info* rli,
const char *query_arg, uint32 q_len_arg)
int Query_log_event::apply_event_impl(RELAY_LOG_INFO* rli,
const char *query_arg, uint32 q_len_arg)
{
LEX_STRING new_db;
int expected_error,actual_error= 0;
/*
Colleagues: please never free(thd->catalog) in MySQL. This would lead to
bugs as here thd->catalog is a part of an alloced block, not an entire
alloced block (see Query_log_event::exec_event()). Same for thd->db.
Thank you.
Colleagues: please never free(thd->catalog) in MySQL. This would
lead to bugs as here thd->catalog is a part of an alloced block,
not an entire alloced block (see
Query_log_event::apply_event_impl()). Same for thd->db. Thank
you.
*/
thd->catalog= catalog_len ? (char *) catalog : (char *)"";
new_db.length= db_len;
......@@ -1873,8 +1872,8 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli,
its companion query. If the SET is ignored because of
db_ok(), the companion query will also be ignored, and if
the companion query is ignored in the db_ok() test of
::exec_event(), then the companion SET also have so we
don't need to reset_one_shot_variables().
::apply_event_impl(), then the companion SET also have so
we don't need to reset_one_shot_variables().
*/
if (rpl_filter->db_ok(thd->db))
{
......@@ -2089,7 +2088,7 @@ Default database: '%s'. Query: '%s'",
*/
return (thd->query_error ? thd->query_error :
(thd->one_shot_set ? (rli->inc_event_relay_log_pos(),0) :
Log_event::exec_event(rli)));
Log_event::apply_event_impl(rli)));
}
#endif
......@@ -2217,7 +2216,7 @@ bool Start_log_event_v3::write(IO_CACHE* file)
/*
Start_log_event_v3::exec_event()
Start_log_event_v3::apply_event_impl()
The master started
......@@ -2236,9 +2235,9 @@ bool Start_log_event_v3::write(IO_CACHE* file)
*/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
int Start_log_event_v3::exec_event(struct st_relay_log_info* rli)
int Start_log_event_v3::apply_event_impl(RELAY_LOG_INFO* rli)
{
DBUG_ENTER("Start_log_event_v3::exec_event");
DBUG_ENTER("Start_log_event_v3::apply_event_impl");
switch (binlog_version)
{
case 3:
......@@ -2280,7 +2279,7 @@ int Start_log_event_v3::exec_event(struct st_relay_log_info* rli)
/* this case is impossible */
DBUG_RETURN(1);
}
DBUG_RETURN(Log_event::exec_event(rli));
DBUG_RETURN(Log_event::apply_event_impl(rli));
}
#endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
......@@ -2469,18 +2468,18 @@ bool Format_description_log_event::write(IO_CACHE* file)
/*
SYNOPSIS
Format_description_log_event::exec_event()
Format_description_log_event::apply_event_impl()
IMPLEMENTATION
Save the information which describes the binlog's format, to be able to
read all coming events.
Call Start_log_event_v3::exec_event().
Save the information which describes the binlog's format, to be
able to read all coming events. Call
Start_log_event_v3::apply_event_impl().
*/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
int Format_description_log_event::exec_event(struct st_relay_log_info* rli)
int Format_description_log_event::apply_event_impl(RELAY_LOG_INFO* rli)
{
DBUG_ENTER("Format_description_log_event::exec_event");
DBUG_ENTER("Format_description_log_event::apply_event_impl");
/* save the information describing this binlog */
delete rli->relay_log.description_event_for_exec;
......@@ -2510,9 +2509,9 @@ int Format_description_log_event::exec_event(struct st_relay_log_info* rli)
}
#endif
/*
If this event comes from ourselves, there is no cleaning task to perform,
we don't call Start_log_event_v3::exec_event() (this was just to update the
log's description event).
If this event comes from ourselves, there is no cleaning task to
perform, we don't call Start_log_event_v3::apply_event_impl()
(this was just to update the log's description event).
*/
if (server_id == (uint32) ::server_id)
{
......@@ -2541,7 +2540,7 @@ int Format_description_log_event::exec_event(struct st_relay_log_info* rli)
replication rli->group_master_log_pos will be 0, then 96, then jump to
first really asked event (which is >96). So this is ok.
*/
DBUG_RETURN(Start_log_event_v3::exec_event(rli));
DBUG_RETURN(Start_log_event_v3::apply_event_impl(rli));
}
#endif
......@@ -3024,29 +3023,31 @@ void Load_log_event::set_fields(const char* affected_db,
Does the data loading job when executing a LOAD DATA on the slave
SYNOPSIS
Load_log_event::exec_event
net
rli
use_rli_only_for_errors - if set to 1, rli is provided to
Load_log_event::exec_event only for this
function to have RPL_LOG_NAME and
rli->last_slave_error, both being used by
error reports. rli's position advancing
is skipped (done by the caller which is
Execute_load_log_event::exec_event).
- if set to 0, rli is provided for full use,
i.e. for error reports and position
advancing.
Load_log_event::apply_event_impl
net
rli
use_rli_only_for_errors - if set to 1, rli is provided to
Load_log_event::apply_event_impl
only for this function to have
RPL_LOG_NAME and
rli->last_slave_error, both being
used by error reports. rli's
position advancing is skipped (done
by the caller which is
Execute_load_log_event::apply_event_impl).
- if set to 0, rli is provided for
full use, i.e. for error reports and
position advancing.
DESCRIPTION
Does the data loading job when executing a LOAD DATA on the slave
RETURN VALUE
0 Success
0 Success
1 Failure
*/
int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
int Load_log_event::apply_event_impl(NET* net, RELAY_LOG_INFO* rli,
bool use_rli_only_for_errors)
{
LEX_STRING new_db;
......@@ -3058,7 +3059,7 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
thd->query_error= 0;
clear_all_errors(thd, rli);
/* see Query_log_event::exec_event() and BUG#13360 */
/* see Query_log_event::apply_event_impl() and BUG#13360 */
DBUG_ASSERT(!rli->m_table_map.count());
/*
Usually mysql_init_query() is called by mysql_parse(), but we need it here
......@@ -3067,22 +3068,26 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
mysql_init_query(thd, 0, 0);
if (!use_rli_only_for_errors)
{
/* Saved for InnoDB, see comment in Query_log_event::exec_event() */
/*
Saved for InnoDB, see comment in
Query_log_event::apply_event_impl()
*/
rli->future_group_master_log_pos= log_pos;
DBUG_PRINT("info", ("log_pos: %lu", (ulong) log_pos));
}
/*
We test replicate_*_db rules. Note that we have already prepared the file
to load, even if we are going to ignore and delete it now. So it is
possible that we did a lot of disk writes for nothing. In other words, a
big LOAD DATA INFILE on the master will still consume a lot of space on
the slave (space in the relay log + space of temp files: twice the space
of the file to load...) even if it will finally be ignored.
TODO: fix this; this can be done by testing rules in
Create_file_log_event::exec_event() and then discarding Append_block and
al. Another way is do the filtering in the I/O thread (more efficient: no
disk writes at all).
We test replicate_*_db rules. Note that we have already prepared
the file to load, even if we are going to ignore and delete it
now. So it is possible that we did a lot of disk writes for
nothing. In other words, a big LOAD DATA INFILE on the master will
still consume a lot of space on the slave (space in the relay log
+ space of temp files: twice the space of the file to load...)
even if it will finally be ignored. TODO: fix this; this can be
done by testing rules in Create_file_log_event::apply_event_impl()
and then discarding Append_block and al. Another way is do the
filtering in the I/O thread (more efficient: no disk writes at
all).
Note: We do not need to execute reset_one_shot_variables() if this
......@@ -3091,8 +3096,8 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
its companion query. If the SET is ignored because of
db_ok(), the companion query will also be ignored, and if
the companion query is ignored in the db_ok() test of
::exec_event(), then the companion SET also have so we
don't need to reset_one_shot_variables().
::apply_event_impl(), then the companion SET also have so
we don't need to reset_one_shot_variables().
*/
if (rpl_filter->db_ok(thd->db))
{
......@@ -3288,7 +3293,7 @@ Fatal error running LOAD DATA INFILE on table '%s'. Default database: '%s'",
return 1;
}
return ( use_rli_only_for_errors ? 0 : Log_event::exec_event(rli) );
return ( use_rli_only_for_errors ? 0 : Log_event::apply_event_impl(rli) );
}
#endif
......@@ -3402,7 +3407,7 @@ bool Rotate_log_event::write(IO_CACHE* file)
#endif
/*
Rotate_log_event::exec_event()
Rotate_log_event::apply_event_impl()
Got a rotate log event from the master
......@@ -3419,9 +3424,9 @@ bool Rotate_log_event::write(IO_CACHE* file)
*/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
int Rotate_log_event::exec_event(struct st_relay_log_info* rli)
int Rotate_log_event::apply_event_impl(RELAY_LOG_INFO* rli)
{
DBUG_ENTER("Rotate_log_event::exec_event");
DBUG_ENTER("Rotate_log_event::apply_event_impl");
pthread_mutex_lock(&rli->data_lock);
rli->event_relay_log_pos= my_b_tell(rli->cur_log);
......@@ -3572,11 +3577,11 @@ void Intvar_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
/*
Intvar_log_event::exec_event()
Intvar_log_event::apply_event_impl()
*/
#if defined(HAVE_REPLICATION)&& !defined(MYSQL_CLIENT)
int Intvar_log_event::exec_event(struct st_relay_log_info* rli)
int Intvar_log_event::apply_event_impl(RELAY_LOG_INFO* rli)
{
switch (type) {
case LAST_INSERT_ID_EVENT:
......@@ -3651,7 +3656,7 @@ void Rand_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
int Rand_log_event::exec_event(struct st_relay_log_info* rli)
int Rand_log_event::apply_event_impl(RELAY_LOG_INFO* rli)
{
thd->rand.seed1= (ulong) seed1;
thd->rand.seed2= (ulong) seed2;
......@@ -3724,12 +3729,12 @@ void Xid_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
int Xid_log_event::exec_event(struct st_relay_log_info* rli)
int Xid_log_event::apply_event_impl(RELAY_LOG_INFO* rli)
{
/* For a slave Xid_log_event is COMMIT */
general_log_print(thd, COM_QUERY,
"COMMIT /* implicit, from Xid_log_event */");
return end_trans(thd, COMMIT) || Log_event::exec_event(rli);
return end_trans(thd, COMMIT) || Log_event::apply_event_impl(rli);
}
#endif /* !MYSQL_CLIENT */
......@@ -4005,11 +4010,11 @@ void User_var_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
/*
User_var_log_event::exec_event()
User_var_log_event::apply_event_impl()
*/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
int User_var_log_event::exec_event(struct st_relay_log_info* rli)
int User_var_log_event::apply_event_impl(RELAY_LOG_INFO* rli)
{
Item *it= 0;
CHARSET_INFO *charset;
......@@ -4113,7 +4118,7 @@ void Slave_log_event::pack_info(Protocol *protocol)
#ifndef MYSQL_CLIENT
Slave_log_event::Slave_log_event(THD* thd_arg,
struct st_relay_log_info* rli)
RELAY_LOG_INFO* rli)
:Log_event(thd_arg, 0, 0) , mem_pool(0), master_host(0)
{
DBUG_ENTER("Slave_log_event");
......@@ -4223,11 +4228,11 @@ Slave_log_event::Slave_log_event(const char* buf, uint event_len)
#ifndef MYSQL_CLIENT
int Slave_log_event::exec_event(struct st_relay_log_info* rli)
int Slave_log_event::apply_event_impl(RELAY_LOG_INFO* rli)
{
if (mysql_bin_log.is_open())
mysql_bin_log.write(this);
return Log_event::exec_event(rli);
return Log_event::apply_event_impl(rli);
}
#endif /* !MYSQL_CLIENT */
......@@ -4256,21 +4261,21 @@ void Stop_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
/*
Stop_log_event::exec_event()
The master stopped.
We used to clean up all temporary tables but this is useless as, as the
master has shut down properly, it has written all DROP TEMPORARY TABLE
(prepared statements' deletion is TODO only when we binlog prep stmts).
We used to clean up slave_load_tmpdir, but this is useless as it has been
cleared at the end of LOAD DATA INFILE.
So we have nothing to do here.
The place were we must do this cleaning is in Start_log_event_v3::exec_event(),
not here. Because if we come here, the master was sane.
Stop_log_event::apply_event_impl()
The master stopped. We used to clean up all temporary tables but
this is useless as, as the master has shut down properly, it has
written all DROP TEMPORARY TABLE (prepared statements' deletion is
TODO only when we binlog prep stmts). We used to clean up
slave_load_tmpdir, but this is useless as it has been cleared at the
end of LOAD DATA INFILE. So we have nothing to do here. The place
were we must do this cleaning is in
Start_log_event_v3::apply_event_impl(), not here. Because if we come
here, the master was sane.
*/
#ifndef MYSQL_CLIENT
int Stop_log_event::exec_event(struct st_relay_log_info* rli)
int Stop_log_event::apply_event_impl(RELAY_LOG_INFO* rli)
{
/*
We do not want to update master_log pos because we get a rotate event
......@@ -4478,11 +4483,11 @@ void Create_file_log_event::pack_info(Protocol *protocol)
/*
Create_file_log_event::exec_event()
Create_file_log_event::apply_event_impl()
*/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
int Create_file_log_event::exec_event(struct st_relay_log_info* rli)
int Create_file_log_event::apply_event_impl(RELAY_LOG_INFO* rli)
{
char proc_info[17+FN_REFLEN+10], *fname_buf;
char *ext;
......@@ -4544,7 +4549,7 @@ int Create_file_log_event::exec_event(struct st_relay_log_info* rli)
if (fd >= 0)
my_close(fd, MYF(0));
thd->proc_info= 0;
return error ? 1 : Log_event::exec_event(rli);
return error ? 1 : Log_event::apply_event_impl(rli);
}
#endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
......@@ -4652,15 +4657,15 @@ int Append_block_log_event::get_create_or_append() const
}
/*
Append_block_log_event::exec_event()
Append_block_log_event::apply_event_impl()
*/
int Append_block_log_event::exec_event(struct st_relay_log_info* rli)
int Append_block_log_event::apply_event_impl(RELAY_LOG_INFO* rli)
{
char proc_info[17+FN_REFLEN+10], *fname= proc_info+17;
int fd;
int error = 1;
DBUG_ENTER("Append_block_log_event::exec_event");
DBUG_ENTER("Append_block_log_event::apply_event_impl");
fname= strmov(proc_info, "Making temp file ");
slave_load_file_stem(fname, file_id, server_id, ".data");
......@@ -4699,7 +4704,7 @@ int Append_block_log_event::exec_event(struct st_relay_log_info* rli)
if (fd >= 0)
my_close(fd, MYF(0));
thd->proc_info= 0;
DBUG_RETURN(error ? error : Log_event::exec_event(rli));
DBUG_RETURN(error ? error : Log_event::apply_event_impl(rli));
}
#endif
......@@ -4783,18 +4788,18 @@ void Delete_file_log_event::pack_info(Protocol *protocol)
#endif
/*
Delete_file_log_event::exec_event()
Delete_file_log_event::apply_event_impl()
*/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
int Delete_file_log_event::exec_event(struct st_relay_log_info* rli)
int Delete_file_log_event::apply_event_impl(RELAY_LOG_INFO* rli)
{
char fname[FN_REFLEN+10];
char *ext= slave_load_file_stem(fname, file_id, server_id, ".data");
(void) my_delete(fname, MYF(MY_WME));
strmov(ext, ".info");
(void) my_delete(fname, MYF(MY_WME));
return Log_event::exec_event(rli);
return Log_event::apply_event_impl(rli);
}
#endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
......@@ -4880,10 +4885,10 @@ void Execute_load_log_event::pack_info(Protocol *protocol)
/*
Execute_load_log_event::exec_event()
Execute_load_log_event::apply_event_impl()
*/
int Execute_load_log_event::exec_event(struct st_relay_log_info* rli)
int Execute_load_log_event::apply_event_impl(RELAY_LOG_INFO* rli)
{
char fname[FN_REFLEN+10];
char *ext;
......@@ -4914,14 +4919,15 @@ int Execute_load_log_event::exec_event(struct st_relay_log_info* rli)
lev->thd = thd;
/*
lev->exec_event should use rli only for errors
i.e. should not advance rli's position.
lev->exec_event is the place where the table is loaded (it calls
mysql_load()).
lev->apply_event_impl should use rli only for errors i.e. should
not advance rli's position.
lev->apply_event_impl is the place where the table is loaded (it
calls mysql_load()).
*/
rli->future_group_master_log_pos= log_pos;
if (lev->exec_event(0,rli,1))
if (lev->apply_event_impl(0,rli,1))
{
/*
We want to indicate the name of the file that could not be loaded
......@@ -4964,7 +4970,7 @@ int Execute_load_log_event::exec_event(struct st_relay_log_info* rli)
my_close(fd, MYF(0));
end_io_cache(&file);
}
return error ? error : Log_event::exec_event(rli);
return error ? error : Log_event::apply_event_impl(rli);
}
#endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
......@@ -5132,7 +5138,7 @@ void Execute_load_query_log_event::pack_info(Protocol *protocol)
int
Execute_load_query_log_event::exec_event(struct st_relay_log_info* rli)
Execute_load_query_log_event::apply_event_impl(RELAY_LOG_INFO* rli)
{
char *p;
char *buf;
......@@ -5169,7 +5175,7 @@ Execute_load_query_log_event::exec_event(struct st_relay_log_info* rli)
p= strmake(p, STRING_WITH_LEN(" INTO"));
p= strmake(p, query+fn_pos_end, q_len-fn_pos_end);
error= Query_log_event::exec_event(rli, buf, p-buf);
error= Query_log_event::apply_event_impl(rli, buf, p-buf);
/* Forging file name for deletion in same buffer */
*fname_end= 0;
......@@ -5584,9 +5590,9 @@ unpack_row(RELAY_LOG_INFO *rli,
return error;
}
int Rows_log_event::exec_event(st_relay_log_info *rli)
int Rows_log_event::apply_event_impl(st_relay_log_info *rli)
{
DBUG_ENTER("Rows_log_event::exec_event(st_relay_log_info*)");
DBUG_ENTER("Rows_log_event::apply_event_impl(st_relay_log_info*)");
int error= 0;
char const *row_start= (char const *)m_rows_buf;
......@@ -5613,7 +5619,8 @@ int Rows_log_event::exec_event(st_relay_log_info *rli)
/*
'thd' has been set by exec_relay_log_event(), just before calling
exec_event(). We still check here to prevent future coding errors.
apply_event_impl(). We still check here to prevent future coding
errors.
*/
DBUG_ASSERT(rli->sql_thd == thd);
......@@ -5629,8 +5636,9 @@ int Rows_log_event::exec_event(st_relay_log_info *rli)
/*
lock_tables() reads the contents of thd->lex, so they must be
initialized. Contrary to in Table_map_log_event::exec_event() we don't
call mysql_init_query() as that may reset the binlog format.
initialized. Contrary to in
Table_map_log_event::apply_event_impl() we don't call
mysql_init_query() as that may reset the binlog format.
*/
lex_start(thd, NULL, 0);
......@@ -5709,8 +5717,8 @@ int Rows_log_event::exec_event(st_relay_log_info *rli)
{
/*
table == NULL means that this table should not be replicated
(this was set up by Table_map_log_event::exec_event() which
tested replicate-* rules).
(this was set up by Table_map_log_event::apply_event_impl()
which tested replicate-* rules).
*/
/*
......@@ -5862,7 +5870,7 @@ int Rows_log_event::exec_event(st_relay_log_info *rli)
do not become visible. We still prefer to wipe them out.
*/
thd->clear_error();
error= Log_event::exec_event(rli);
error= Log_event::apply_event_impl(rli);
}
else
slave_print_msg(ERROR_LEVEL, rli, error,
......@@ -6126,9 +6134,9 @@ Table_map_log_event::~Table_map_log_event()
*/
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
int Table_map_log_event::exec_event(st_relay_log_info *rli)
int Table_map_log_event::apply_event_impl(st_relay_log_info *rli)
{
DBUG_ENTER("Table_map_log_event::exec_event(st_relay_log_info*)");
DBUG_ENTER("Table_map_log_event::apply_event_impl(st_relay_log_info*)");
DBUG_ASSERT(rli->sql_thd == thd);
......@@ -6238,10 +6246,10 @@ int Table_map_log_event::exec_event(st_relay_log_info *rli)
}
/*
We explicitly do not call Log_event::exec_event() here since we do not
want the relay log position to be flushed to disk. The flushing will be
done by the last Rows_log_event that either ends a statement (outside a
transaction) or a transaction.
We explicitly do not call Log_event::apply_event_impl() here since
we do not want the relay log position to be flushed to disk. The
flushing will be done by the last Rows_log_event that either ends
a statement (outside a transaction) or a transaction.
A table map event can *never* end a transaction or a statement, so we
just step the relay log position.
......
......@@ -477,6 +477,7 @@ class THD;
class Format_description_log_event;
struct st_relay_log_info;
typedef st_relay_log_info RELAY_LOG_INFO;
#ifdef MYSQL_CLIENT
/*
......@@ -631,16 +632,48 @@ class Log_event
static void init_show_field_list(List<Item>* field_list);
#ifdef HAVE_REPLICATION
int net_send(Protocol *protocol, const char* log_name, my_off_t pos);
/**
Execute the event to change the database and update the binary
log coordinates.
@param rli Pointer to relay log information
@retval 0 The event was successfully executed.
@retval errno Error code when the execution failed
*/
int exec_event(RELAY_LOG_INFO *rli)
{
// !!! Just chaining the calls in this first patch
return apply_event_impl(rli);
}
/**
Skip the event by just updating the binary log coordinates.
@param rli Pointer to relay log information
@retval 0 The event was successfully executed.
@retval errno Error code when the execution failed
*/
int skip_event(RELAY_LOG_INFO *rli)
{
// !!! Nothing yet. This is just the reorgainization patch.
return 0;
}
/*
pack_info() is used by SHOW BINLOG EVENTS; as print() it prepares and sends
a string to display to the user, so it resembles print().
*/
virtual void pack_info(Protocol *protocol);
/*
The SQL slave thread calls exec_event() to execute the event; this is where
the slave's data is modified.
*/
virtual int exec_event(struct st_relay_log_info* rli);
#endif /* HAVE_REPLICATION */
virtual const char* get_db()
{
......@@ -713,6 +746,38 @@ class Log_event
*description_event);
/* returns the human readable name of the event's type */
const char* get_type_str();
protected: /* !!! Protected in this patch to allow old usage */
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
/**
Primitive to apply an event to the database.
This is where the change to the database is made.
@param rli Pointer to relay log info structure
@retval 0 Event applied successfully
@retval errno Error code if event application failed
*/
virtual int apply_event_impl(RELAY_LOG_INFO *rli);
/**
Advance binary log coordinates.
This function is called to advance the binary log or relay log
coordinates to just after the event.
@param rli Pointer to relay log info structure
@retval 0 Coordinates changed successfully
@retval errno Error code if advancing failed
*/
virtual int advance_coord_impl(RELAY_LOG_INFO *rli)
{
// !!! Dummy implementation for this patch only
return 0;
}
#endif
};
/*
......@@ -753,10 +818,10 @@ class Query_log_event: public Log_event
uint16 error_code;
ulong thread_id;
/*
For events created by Query_log_event::exec_event (and
Load_log_event::exec_event()) we need the *original* thread id, to be able
to log the event with the original (=master's) thread id (fix for
BUG#1686).
For events created by Query_log_event::apply_event_impl (and
Load_log_event::apply_event_impl()) we need the *original* thread
id, to be able to log the event with the original (=master's)
thread id (fix for BUG#1686).
*/
ulong slave_proxy_id;
......@@ -817,9 +882,6 @@ class Query_log_event: public Log_event
const char* get_db() { return db; }
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
int exec_event(struct st_relay_log_info* rli);
int exec_event(struct st_relay_log_info* rli, const char *query_arg,
uint32 q_len_arg);
#endif /* HAVE_REPLICATION */
#else
void print_query_header(IO_CACHE* file, PRINT_EVENT_INFO* print_event_info);
......@@ -848,6 +910,14 @@ class Query_log_event: public Log_event
*/
virtual ulong get_post_header_size_for_derived() { return 0; }
/* Writes derived event-specific part of post header. */
public: /* !!! Public in this patch to allow old usage */
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
virtual int apply_event_impl(RELAY_LOG_INFO* rli);
int apply_event_impl(RELAY_LOG_INFO* rli,
const char *query_arg,
uint32 q_len_arg);
#endif /* HAVE_REPLICATION */
};
......@@ -894,9 +964,8 @@ class Slave_log_event: public Log_event
uint16 master_port;
#ifndef MYSQL_CLIENT
Slave_log_event(THD* thd_arg, struct st_relay_log_info* rli);
Slave_log_event(THD* thd_arg, RELAY_LOG_INFO* rli);
void pack_info(Protocol* protocol);
int exec_event(struct st_relay_log_info* rli);
#else
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
#endif
......@@ -909,6 +978,11 @@ class Slave_log_event: public Log_event
#ifndef MYSQL_CLIENT
bool write(IO_CACHE* file);
#endif
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
virtual int apply_event_impl(RELAY_LOG_INFO* rli);
#endif
};
#endif /* HAVE_REPLICATION */
......@@ -978,12 +1052,6 @@ class Load_log_event: public Log_event
const char* get_db() { return db; }
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
int exec_event(struct st_relay_log_info* rli)
{
return exec_event(thd->slave_net,rli,0);
}
int exec_event(NET* net, struct st_relay_log_info* rli,
bool use_rli_only_for_errors);
#endif /* HAVE_REPLICATION */
#else
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
......@@ -1015,6 +1083,17 @@ class Load_log_event: public Log_event
+ LOAD_HEADER_LEN
+ sql_ex.data_size() + field_block_len + num_fields);
}
public: /* !!! Public in this patch to allow old usage */
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
virtual int apply_event_impl(RELAY_LOG_INFO* rli)
{
return apply_event_impl(thd->slave_net,rli,0);
}
int apply_event_impl(NET* net, RELAY_LOG_INFO* rli,
bool use_rli_only_for_errors);
#endif
};
extern char server_version[SERVER_VERSION_LENGTH];
......@@ -1072,7 +1151,6 @@ class Start_log_event_v3: public Log_event
Start_log_event_v3();
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
int exec_event(struct st_relay_log_info* rli);
#endif /* HAVE_REPLICATION */
#else
Start_log_event_v3() {}
......@@ -1092,6 +1170,11 @@ class Start_log_event_v3: public Log_event
return START_V3_HEADER_LEN; //no variable-sized part
}
virtual bool is_artificial_event() { return artificial_event; }
protected: /* !!! Protected in this patch to allow old usage */
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
virtual int apply_event_impl(RELAY_LOG_INFO* rli);
#endif
};
......@@ -1116,13 +1199,6 @@ class Format_description_log_event: public Start_log_event_v3
uint8 *post_header_len;
Format_description_log_event(uint8 binlog_ver, const char* server_ver=0);
#ifndef MYSQL_CLIENT
#ifdef HAVE_REPLICATION
int exec_event(struct st_relay_log_info* rli);
#endif /* HAVE_REPLICATION */
#endif
Format_description_log_event(const char* buf, uint event_len,
const Format_description_log_event* description_event);
~Format_description_log_event() { my_free((gptr)post_header_len, MYF(0)); }
......@@ -1145,6 +1221,11 @@ class Format_description_log_event: public Start_log_event_v3
*/
return FORMAT_DESCRIPTION_HEADER_LEN;
}
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
virtual int apply_event_impl(RELAY_LOG_INFO* rli);
#endif
};
......@@ -1168,7 +1249,6 @@ class Intvar_log_event: public Log_event
{}
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
int exec_event(struct st_relay_log_info* rli);
#endif /* HAVE_REPLICATION */
#else
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
......@@ -1183,6 +1263,11 @@ class Intvar_log_event: public Log_event
bool write(IO_CACHE* file);
#endif
bool is_valid() const { return 1; }
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
virtual int apply_event_impl(RELAY_LOG_INFO* rli);
#endif
};
......@@ -1209,7 +1294,6 @@ class Rand_log_event: public Log_event
{}
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
int exec_event(struct st_relay_log_info* rli);
#endif /* HAVE_REPLICATION */
#else
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
......@@ -1223,6 +1307,11 @@ class Rand_log_event: public Log_event
bool write(IO_CACHE* file);
#endif
bool is_valid() const { return 1; }
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
virtual int apply_event_impl(RELAY_LOG_INFO* rli);
#endif
};
/*****************************************************************************
......@@ -1246,7 +1335,6 @@ class Xid_log_event: public Log_event
Xid_log_event(THD* thd_arg, my_xid x): Log_event(thd_arg,0,0), xid(x) {}
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
int exec_event(struct st_relay_log_info* rli);
#endif /* HAVE_REPLICATION */
#else
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
......@@ -1260,6 +1348,11 @@ class Xid_log_event: public Log_event
bool write(IO_CACHE* file);
#endif
bool is_valid() const { return 1; }
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
virtual int apply_event_impl(RELAY_LOG_INFO* rli);
#endif
};
/*****************************************************************************
......@@ -1289,7 +1382,6 @@ class User_var_log_event: public Log_event
val_len(val_len_arg), type(type_arg), charset_number(charset_number_arg)
{ is_null= !val; }
void pack_info(Protocol* protocol);
int exec_event(struct st_relay_log_info* rli);
#else
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
#endif
......@@ -1301,6 +1393,11 @@ class User_var_log_event: public Log_event
bool write(IO_CACHE* file);
#endif
bool is_valid() const { return 1; }
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
virtual int apply_event_impl(RELAY_LOG_INFO* rli);
#endif
};
......@@ -1315,7 +1412,6 @@ class Stop_log_event: public Log_event
#ifndef MYSQL_CLIENT
Stop_log_event() :Log_event()
{}
int exec_event(struct st_relay_log_info* rli);
#else
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
#endif
......@@ -1326,6 +1422,11 @@ class Stop_log_event: public Log_event
~Stop_log_event() {}
Log_event_type get_type_code() { return STOP_EVENT;}
bool is_valid() const { return 1; }
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
virtual int apply_event_impl(RELAY_LOG_INFO* rli);
#endif
};
/*****************************************************************************
......@@ -1352,7 +1453,6 @@ class Rotate_log_event: public Log_event
ulonglong pos_arg, uint flags);
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
int exec_event(struct st_relay_log_info* rli);
#endif /* HAVE_REPLICATION */
#else
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
......@@ -1371,6 +1471,11 @@ class Rotate_log_event: public Log_event
#ifndef MYSQL_CLIENT
bool write(IO_CACHE* file);
#endif
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
virtual int apply_event_impl(RELAY_LOG_INFO* rli);
#endif
};
......@@ -1405,7 +1510,6 @@ class Create_file_log_event: public Load_log_event
bool using_trans);
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
int exec_event(struct st_relay_log_info* rli);
#endif /* HAVE_REPLICATION */
#else
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
......@@ -1439,6 +1543,11 @@ class Create_file_log_event: public Load_log_event
*/
bool write_base(IO_CACHE* file);
#endif
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
virtual int apply_event_impl(RELAY_LOG_INFO* rli);
#endif
};
......@@ -1471,7 +1580,6 @@ class Append_block_log_event: public Log_event
Append_block_log_event(THD* thd, const char* db_arg, char* block_arg,
uint block_len_arg, bool using_trans);
#ifdef HAVE_REPLICATION
int exec_event(struct st_relay_log_info* rli);
void pack_info(Protocol* protocol);
virtual int get_create_or_append() const;
#endif /* HAVE_REPLICATION */
......@@ -1489,6 +1597,11 @@ class Append_block_log_event: public Log_event
bool write(IO_CACHE* file);
const char* get_db() { return db; }
#endif
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
virtual int apply_event_impl(RELAY_LOG_INFO* rli);
#endif
};
......@@ -1508,7 +1621,6 @@ class Delete_file_log_event: public Log_event
Delete_file_log_event(THD* thd, const char* db_arg, bool using_trans);
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
int exec_event(struct st_relay_log_info* rli);
#endif /* HAVE_REPLICATION */
#else
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
......@@ -1525,6 +1637,11 @@ class Delete_file_log_event: public Log_event
bool write(IO_CACHE* file);
const char* get_db() { return db; }
#endif
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
virtual int apply_event_impl(RELAY_LOG_INFO* rli);
#endif
};
......@@ -1544,7 +1661,6 @@ class Execute_load_log_event: public Log_event
Execute_load_log_event(THD* thd, const char* db_arg, bool using_trans);
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
int exec_event(struct st_relay_log_info* rli);
#endif /* HAVE_REPLICATION */
#else
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
......@@ -1560,6 +1676,11 @@ class Execute_load_log_event: public Log_event
bool write(IO_CACHE* file);
const char* get_db() { return db; }
#endif
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
virtual int apply_event_impl(RELAY_LOG_INFO* rli);
#endif
};
......@@ -1629,7 +1750,6 @@ class Execute_load_query_log_event: public Query_log_event
bool using_trans, bool suppress_use);
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
int exec_event(struct st_relay_log_info* rli);
#endif /* HAVE_REPLICATION */
#else
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
......@@ -1648,7 +1768,12 @@ class Execute_load_query_log_event: public Query_log_event
#ifndef MYSQL_CLIENT
bool write_post_header_for_derived(IO_CACHE* file);
#endif
};
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
virtual int apply_event_impl(RELAY_LOG_INFO* rli);
#endif
};
#ifdef MYSQL_CLIENT
......@@ -1745,7 +1870,6 @@ class Table_map_log_event : public Log_event
#endif
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
virtual int exec_event(struct st_relay_log_info *rli);
virtual void pack_info(Protocol *protocol);
#endif
......@@ -1755,6 +1879,10 @@ class Table_map_log_event : public Log_event
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
virtual int apply_event_impl(RELAY_LOG_INFO* rli);
#endif
#ifndef MYSQL_CLIENT
TABLE *m_table;
#endif
......@@ -1826,7 +1954,6 @@ class Rows_log_event : public Log_event
flag_set get_flags(flag_set flags) const { return m_flags & flags; }
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
virtual int exec_event(struct st_relay_log_info *rli);
virtual void pack_info(Protocol *protocol);
#endif
......@@ -1910,6 +2037,8 @@ class Rows_log_event : public Log_event
private:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
virtual int apply_event_impl(RELAY_LOG_INFO* rli);
/*
Primitive to prepare for a sequence of row executions.
......
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