From 9372c38c6b75dfc62a6eca6b2bf7bc3ccdd00f29 Mon Sep 17 00:00:00 2001 From: "mats@romeo.(none)" <> Date: Wed, 1 Nov 2006 15:35:37 +0100 Subject: [PATCH 01/22] BUG#23171 (Illegal slave restart group position): First patch preparing for restructuring the event execution and event skipping. This patch renames the existing (virtual) function exec_event() to be a primitive for implementing the real patch. Also, the virtual function advance_coord_impl() is added to advance the binary/relay log coordinates, and two non-virtual functions exec_event() [sic] and skip_event() is added that will contain the business logic for executing and skipping events respectively. --- sql/log.cc | 2 +- sql/log_event.cc | 278 ++++++++++++++++++++++++----------------------- sql/log_event.h | 213 +++++++++++++++++++++++++++++------- 3 files changed, 315 insertions(+), 178 deletions(-) diff --git a/sql/log.cc b/sql/log.cc index a1ed9bd6df3..83530883fdc 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2411,7 +2411,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 */ diff --git a/sql/log_event.cc b/sql/log_event.cc index 4a6346bf57c..93650561028 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -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 @@ end: */ 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() + 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::exec_event(), - not here. Because if we come here, the master was sane. + 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 @@ err: 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 @@ err: 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 @@ err: 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); @@ -5710,8 +5718,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). */ /* @@ -5863,7 +5871,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, @@ -6127,9 +6135,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); @@ -6240,10 +6248,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. diff --git a/sql/log_event.h b/sql/log_event.h index 81ce2f18b4d..794cf410841 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -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 @@ public: static void init_show_field_list(List* 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 @@ public: *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 @@ public: 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 @@ public: 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 @@ public: */ 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 @@ public: 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 @@ public: #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 @@ public: 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 @@ public: + 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: */ 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 @@ public: {} #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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: #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 @@ public: ~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 @@ public: 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 @@ public: #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 @@ public: 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 @@ public: */ 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: #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 @@ public: #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 @@ public: 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 @@ public: 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 @@ protected: 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. From 1fb9105ebd647be9d4b4c582d1e8354f0ea38414 Mon Sep 17 00:00:00 2001 From: "mats@romeo.(none)" <> Date: Fri, 10 Nov 2006 15:10:41 +0100 Subject: [PATCH 02/22] BUG#23171 (Illegal slave restart group position): Second patch to fix skipping code. Moving relay and binary log position changing code from do_apply_event [old exec_event()] into do_update_pos() and doing other changes necessary to support that. Fixing a bug that can cause deadlock if rotating binary log when committing a changes to a transactional table that is not inside a transaction and cause a rotate log. --- sql/log.cc | 20 ++- sql/log_event.cc | 344 +++++++++++++++++++++++++-------------------- sql/rpl_rli.cc | 15 +- sql/rpl_rli.h | 4 +- sql/rpl_utility.cc | 3 +- sql/rpl_utility.h | 2 +- sql/slave.cc | 20 ++- sql/slave.h | 6 +- 8 files changed, 226 insertions(+), 188 deletions(-) diff --git a/sql/log.cc b/sql/log.cc index 3db51c9cb2f..1cf89fad042 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1453,7 +1453,7 @@ static int binlog_prepare(handlerton *hton, THD *thd, bool all) do nothing. just pretend we can do 2pc, so that MySQL won't switch to 1pc. - real work will be done in MYSQL_BIN_LOG::log() + real work will be done in TC_LOG_BINLOG::log() */ return 0; } @@ -1467,9 +1467,15 @@ static int binlog_commit(handlerton *hton, THD *thd, bool all) IO_CACHE *trans_log= &trx_data->trans_log; DBUG_ASSERT(mysql_bin_log.is_open()); - if (all && trx_data->empty()) + /* + The condition here has to be identical to the one inside + binlog_end_trans(), guarding the write of the transaction cache to + the binary log. + */ + if ((all || !(thd->options & (OPTION_BEGIN | OPTION_NOT_AUTOCOMMIT))) && + trx_data->empty()) { - // we're here because trans_log was flushed in MYSQL_BIN_LOG::log() + // we're here because trans_log was flushed in TC_LOG_BINLOG::log() trx_data->reset(); DBUG_RETURN(0); } @@ -3117,8 +3123,10 @@ void MYSQL_BIN_LOG::new_file_impl(bool need_lock) { tc_log_page_waits++; pthread_mutex_lock(&LOCK_prep_xids); - while (prepared_xids) + while (prepared_xids) { + DBUG_PRINT("info", ("prepared_xids=%lu", prepared_xids)); pthread_cond_wait(&COND_prep_xids, &LOCK_prep_xids); + } pthread_mutex_unlock(&LOCK_prep_xids); } @@ -4905,8 +4913,10 @@ void TC_LOG_BINLOG::unlog(ulong cookie, my_xid xid) { pthread_mutex_lock(&LOCK_prep_xids); DBUG_ASSERT(prepared_xids > 0); - if (--prepared_xids == 0) + if (--prepared_xids == 0) { + DBUG_PRINT("info", ("prepared_xids=%lu", prepared_xids)); pthread_cond_signal(&COND_prep_xids); + } pthread_mutex_unlock(&LOCK_prep_xids); rotate_and_purge(0); // as ::write() did not rotate } diff --git a/sql/log_event.cc b/sql/log_event.cc index 3b8a953539b..3bdc6412dc6 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -531,23 +531,19 @@ Log_event::Log_event(const char* buf, #ifndef MYSQL_CLIENT #ifdef HAVE_REPLICATION -/* - Log_event::apply_event_impl() -*/ - -int Log_event::apply_event_impl(RELAY_LOG_INFO* rli) +int Log_event::do_update_pos(RELAY_LOG_INFO *rli) { - DBUG_ENTER("Log_event::apply_event_impl"); - /* 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. + Load_log_event::do_apply_event *and* that one is called from + Execute_load_log_event::do_apply_event. In this case, we don't + do anything here ; Execute_load_log_event::do_apply_event will + call Log_event::do_apply_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. + + Matz: I don't think we will need this check with this refactoring. */ if (rli) { @@ -583,7 +579,7 @@ int Log_event::apply_event_impl(RELAY_LOG_INFO* rli) rli->inc_group_relay_log_pos(log_pos); flush_relay_log_info(rli); /* - Note that Rotate_log_event::apply_event_impl() does not call + Note that Rotate_log_event::do_apply_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 @@ -593,9 +589,9 @@ int Log_event::apply_event_impl(RELAY_LOG_INFO* rli) rli->last_master_timestamp= when; } } - DBUG_RETURN(0); -} + return 0; // Cannot fail currently +} /* Log_event::pack_info() @@ -1819,18 +1815,18 @@ void Query_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info) /* - Query_log_event::apply_event_impl() + Query_log_event::do_apply_event() */ #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) -int Query_log_event::apply_event_impl(RELAY_LOG_INFO* rli) +int Query_log_event::do_apply_event(RELAY_LOG_INFO const *rli) { - return apply_event_impl(rli, query, q_len); + return do_apply_event(rli, query, q_len); } -int Query_log_event::apply_event_impl(RELAY_LOG_INFO* rli, +int Query_log_event::do_apply_event(RELAY_LOG_INFO const *rli, const char *query_arg, uint32 q_len_arg) { LEX_STRING new_db; @@ -1839,7 +1835,7 @@ int Query_log_event::apply_event_impl(RELAY_LOG_INFO* rli, 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 + Query_log_event::do_apply_event()). Same for thd->db. Thank you. */ thd->catalog= catalog_len ? (char *) catalog : (char *)""; @@ -1859,11 +1855,11 @@ int Query_log_event::apply_event_impl(RELAY_LOG_INFO* rli, END of the current log event (COMMIT). We save it in rli so that InnoDB can access it. */ - rli->future_group_master_log_pos= log_pos; + const_cast(rli)->future_group_master_log_pos= log_pos; DBUG_PRINT("info", ("log_pos: %lu", (ulong) log_pos)); - clear_all_errors(thd, rli); - rli->clear_tables_to_lock(); + clear_all_errors(thd, const_cast(rli)); + const_cast(rli)->clear_tables_to_lock(); /* Note: We do not need to execute reset_one_shot_variables() if this @@ -1872,7 +1868,7 @@ int Query_log_event::apply_event_impl(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 - ::apply_event_impl(), then the companion SET also have so + ::do_apply_event(), then the companion SET also have so we don't need to reset_one_shot_variables(). */ if (rpl_filter->db_ok(thd->db)) @@ -1962,7 +1958,7 @@ int Query_log_event::apply_event_impl(RELAY_LOG_INFO* rli, to check/fix it. */ if (mysql_test_parse_for_slave(thd, thd->query, thd->query_length)) - clear_all_errors(thd, rli); /* Can ignore query */ + clear_all_errors(thd, const_cast(rli)); /* Can ignore query */ else { slave_print_msg(ERROR_LEVEL, rli, expected_error, @@ -2013,7 +2009,7 @@ Default database: '%s'. Query: '%s'", ignored_error_code(actual_error)) { DBUG_PRINT("info",("error ignored")); - clear_all_errors(thd, rli); + clear_all_errors(thd, const_cast(rli)); } /* Other cases: mostly we expected no error and get one. @@ -2080,16 +2076,26 @@ end: thd->first_successful_insert_id_in_prev_stmt= 0; thd->stmt_depends_on_first_successful_insert_id_in_prev_stmt= 0; free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC)); - /* - If there was an error we stop. Otherwise we increment positions. Note that - we will not increment group* positions if we are just after a SET - ONE_SHOT, because SET ONE_SHOT should not be separated from its following - updating query. - */ - return (thd->query_error ? thd->query_error : - (thd->one_shot_set ? (rli->inc_event_relay_log_pos(),0) : - Log_event::apply_event_impl(rli))); + return thd->query_error; } + +int Query_log_event::do_update_pos(RELAY_LOG_INFO *rli) +{ + /* + Note that we will not increment group* positions if we are just + after a SET ONE_SHOT, because SET ONE_SHOT should not be separated + from its following updating query. + */ + if (thd->one_shot_set) + { + rli->inc_event_relay_log_pos(); + return 0; + } + else + return Log_event::do_update_pos(rli); +} + + #endif @@ -2216,7 +2222,7 @@ bool Start_log_event_v3::write(IO_CACHE* file) /* - Start_log_event_v3::apply_event_impl() + Start_log_event_v3::do_apply_event() The master started @@ -2235,9 +2241,9 @@ bool Start_log_event_v3::write(IO_CACHE* file) */ #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) -int Start_log_event_v3::apply_event_impl(RELAY_LOG_INFO* rli) +int Start_log_event_v3::do_apply_event(RELAY_LOG_INFO const *rli) { - DBUG_ENTER("Start_log_event_v3::apply_event_impl"); + DBUG_ENTER("Start_log_event_v3::do_apply_event"); switch (binlog_version) { case 3: @@ -2279,7 +2285,7 @@ int Start_log_event_v3::apply_event_impl(RELAY_LOG_INFO* rli) /* this case is impossible */ DBUG_RETURN(1); } - DBUG_RETURN(Log_event::apply_event_impl(rli)); + DBUG_RETURN(0); } #endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */ @@ -2468,22 +2474,18 @@ bool Format_description_log_event::write(IO_CACHE* file) /* SYNOPSIS - Format_description_log_event::apply_event_impl() + Format_description_log_event::do_apply_event() IMPLEMENTATION 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(). + Start_log_event_v3::do_apply_event(). */ #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) -int Format_description_log_event::apply_event_impl(RELAY_LOG_INFO* rli) +int Format_description_log_event::do_apply_event(RELAY_LOG_INFO const *rli) { - DBUG_ENTER("Format_description_log_event::apply_event_impl"); - - /* save the information describing this binlog */ - delete rli->relay_log.description_event_for_exec; - rli->relay_log.description_event_for_exec= this; + DBUG_ENTER("Format_description_log_event::do_apply_event"); #ifdef USING_TRANSACTIONS /* @@ -2505,14 +2507,36 @@ int Format_description_log_event::apply_event_impl(RELAY_LOG_INFO* rli) "or ROLLBACK in relay log). A probable cause is that " "the master died while writing the transaction to " "its binary log, thus rolled back too."); - rli->cleanup_context(thd, 1); + const_cast(rli)->cleanup_context(thd, 1); } #endif /* If this event comes from ourselves, there is no cleaning task to - perform, we don't call Start_log_event_v3::apply_event_impl() + perform, we don't call Start_log_event_v3::do_apply_event() (this was just to update the log's description event). */ + if (server_id != (uint32) ::server_id) + { + /* + If the event was not requested by the slave i.e. the master sent + it while the slave asked for a position >4, the event will make + rli->group_master_log_pos advance. Say that the slave asked for + position 1000, and the Format_desc event's end is 96. Then in + the beginning of 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::do_apply_event(rli)); + } + DBUG_RETURN(0); +} + +int Format_description_log_event::do_update_pos(RELAY_LOG_INFO *rli) +{ + /* save the information describing this binlog */ + delete rli->relay_log.description_event_for_exec; + rli->relay_log.description_event_for_exec= this; + if (server_id == (uint32) ::server_id) { /* @@ -2529,19 +2553,14 @@ int Format_description_log_event::apply_event_impl(RELAY_LOG_INFO* rli) the Intvar_log_event respectively. */ rli->inc_event_relay_log_pos(); - DBUG_RETURN(0); + return 0; + } + else + { + return Log_event::do_update_pos(rli); } - - /* - If the event was not requested by the slave i.e. the master sent it while - the slave asked for a position >4, the event will make - rli->group_master_log_pos advance. Say that the slave asked for position - 1000, and the Format_desc event's end is 96. Then in the beginning of - 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::apply_event_impl(rli)); } + #endif /************************************************************************** @@ -3023,18 +3042,18 @@ 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::apply_event_impl + Load_log_event::do_apply_event net rli use_rli_only_for_errors - if set to 1, rli is provided to - Load_log_event::apply_event_impl + Load_log_event::do_apply_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::apply_event_impl). + Execute_load_log_event::do_apply_event). - if set to 0, rli is provided for full use, i.e. for error reports and position advancing. @@ -3047,8 +3066,8 @@ void Load_log_event::set_fields(const char* affected_db, 1 Failure */ -int Load_log_event::apply_event_impl(NET* net, RELAY_LOG_INFO* rli, - bool use_rli_only_for_errors) +int Load_log_event::do_apply_event(NET* net, RELAY_LOG_INFO const *rli, + bool use_rli_only_for_errors) { LEX_STRING new_db; new_db.length= db_len; @@ -3057,9 +3076,9 @@ int Load_log_event::apply_event_impl(NET* net, RELAY_LOG_INFO* rli, DBUG_ASSERT(thd->query == 0); thd->query_length= 0; // Should not be needed thd->query_error= 0; - clear_all_errors(thd, rli); + clear_all_errors(thd, const_cast(rli)); - /* see Query_log_event::apply_event_impl() and BUG#13360 */ + /* see Query_log_event::do_apply_event() and BUG#13360 */ DBUG_ASSERT(!rli->m_table_map.count()); /* Usually mysql_init_query() is called by mysql_parse(), but we need it here @@ -3070,9 +3089,9 @@ int Load_log_event::apply_event_impl(NET* net, RELAY_LOG_INFO* rli, { /* Saved for InnoDB, see comment in - Query_log_event::apply_event_impl() + Query_log_event::do_apply_event() */ - rli->future_group_master_log_pos= log_pos; + const_cast(rli)->future_group_master_log_pos= log_pos; DBUG_PRINT("info", ("log_pos: %lu", (ulong) log_pos)); } @@ -3084,7 +3103,7 @@ int Load_log_event::apply_event_impl(NET* net, RELAY_LOG_INFO* rli, 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() + done by testing rules in Create_file_log_event::do_apply_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). @@ -3096,7 +3115,7 @@ int Load_log_event::apply_event_impl(NET* net, 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 - ::apply_event_impl(), then the companion SET also have so + ::do_apply_event(), then the companion SET also have so we don't need to reset_one_shot_variables(). */ if (rpl_filter->db_ok(thd->db)) @@ -3293,7 +3312,7 @@ Fatal error running LOAD DATA INFILE on table '%s'. Default database: '%s'", return 1; } - return ( use_rli_only_for_errors ? 0 : Log_event::apply_event_impl(rli) ); + return ( use_rli_only_for_errors ? 0 : Log_event::do_apply_event(rli) ); } #endif @@ -3407,7 +3426,7 @@ bool Rotate_log_event::write(IO_CACHE* file) #endif /* - Rotate_log_event::apply_event_impl() + Rotate_log_event::do_apply_event() Got a rotate log event from the master @@ -3424,10 +3443,9 @@ bool Rotate_log_event::write(IO_CACHE* file) */ #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) -int Rotate_log_event::apply_event_impl(RELAY_LOG_INFO* rli) +int Rotate_log_event::do_update_pos(RELAY_LOG_INFO *rli) { - DBUG_ENTER("Rotate_log_event::apply_event_impl"); - + DBUG_ENTER("Rotate_log_event::do_update_pos"); pthread_mutex_lock(&rli->data_lock); rli->event_relay_log_pos= my_b_tell(rli->cur_log); /* @@ -3470,8 +3488,10 @@ int Rotate_log_event::apply_event_impl(RELAY_LOG_INFO* rli) pthread_mutex_unlock(&rli->data_lock); pthread_cond_broadcast(&rli->data_cond); flush_relay_log_info(rli); + DBUG_RETURN(0); } + #endif @@ -3577,11 +3597,11 @@ void Intvar_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info) /* - Intvar_log_event::apply_event_impl() + Intvar_log_event::do_apply_event() */ #if defined(HAVE_REPLICATION)&& !defined(MYSQL_CLIENT) -int Intvar_log_event::apply_event_impl(RELAY_LOG_INFO* rli) +int Intvar_log_event::do_apply_event(RELAY_LOG_INFO const *rli) { switch (type) { case LAST_INSERT_ID_EVENT: @@ -3592,6 +3612,11 @@ int Intvar_log_event::apply_event_impl(RELAY_LOG_INFO* rli) thd->force_one_auto_inc_interval(val); break; } + return 0; +} + +int Intvar_log_event::do_update_pos(RELAY_LOG_INFO *rli) +{ rli->inc_event_relay_log_pos(); return 0; } @@ -3656,13 +3681,19 @@ void Rand_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info) #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) -int Rand_log_event::apply_event_impl(RELAY_LOG_INFO* rli) +int Rand_log_event::do_apply_event(RELAY_LOG_INFO const *rli) { thd->rand.seed1= (ulong) seed1; thd->rand.seed2= (ulong) seed2; + return 0; +} + +int Rand_log_event::do_update_pos(RELAY_LOG_INFO *rli) +{ rli->inc_event_relay_log_pos(); return 0; } + #endif /* !MYSQL_CLIENT */ @@ -3729,12 +3760,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::apply_event_impl(RELAY_LOG_INFO* rli) +int Xid_log_event::do_apply_event(RELAY_LOG_INFO const *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::apply_event_impl(rli); + return end_trans(thd, COMMIT); } #endif /* !MYSQL_CLIENT */ @@ -4010,11 +4041,11 @@ void User_var_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info) /* - User_var_log_event::apply_event_impl() + User_var_log_event::do_apply_event() */ #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) -int User_var_log_event::apply_event_impl(RELAY_LOG_INFO* rli) +int User_var_log_event::do_apply_event(RELAY_LOG_INFO const *rli) { Item *it= 0; CHARSET_INFO *charset; @@ -4076,9 +4107,15 @@ int User_var_log_event::apply_event_impl(RELAY_LOG_INFO* rli) e.update_hash(val, val_len, type, charset, DERIVATION_IMPLICIT, 0); free_root(thd->mem_root,0); + return 0; +} + +int User_var_log_event::do_update_pos(RELAY_LOG_INFO *rli) +{ rli->inc_event_relay_log_pos(); return 0; } + #endif /* !MYSQL_CLIENT */ @@ -4228,11 +4265,11 @@ Slave_log_event::Slave_log_event(const char* buf, uint event_len) #ifndef MYSQL_CLIENT -int Slave_log_event::apply_event_impl(RELAY_LOG_INFO* rli) +int Slave_log_event::do_apply_event(RELAY_LOG_INFO const *rli) { if (mysql_bin_log.is_open()) mysql_bin_log.write(this); - return Log_event::apply_event_impl(rli); + return 0; } #endif /* !MYSQL_CLIENT */ @@ -4261,7 +4298,7 @@ void Stop_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info) /* - Stop_log_event::apply_event_impl() + Stop_log_event::do_apply_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 @@ -4270,12 +4307,12 @@ void Stop_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info) 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 + Start_log_event_v3::do_apply_event(), not here. Because if we come here, the master was sane. */ #ifndef MYSQL_CLIENT -int Stop_log_event::apply_event_impl(RELAY_LOG_INFO* rli) +int Stop_log_event::do_update_pos(RELAY_LOG_INFO *rli) { /* We do not want to update master_log pos because we get a rotate event @@ -4293,6 +4330,7 @@ int Stop_log_event::apply_event_impl(RELAY_LOG_INFO* rli) } return 0; } + #endif /* !MYSQL_CLIENT */ #endif /* HAVE_REPLICATION */ @@ -4483,11 +4521,11 @@ void Create_file_log_event::pack_info(Protocol *protocol) /* - Create_file_log_event::apply_event_impl() + Create_file_log_event::do_apply_event() */ #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) -int Create_file_log_event::apply_event_impl(RELAY_LOG_INFO* rli) +int Create_file_log_event::do_apply_event(RELAY_LOG_INFO const *rli) { char proc_info[17+FN_REFLEN+10], *fname_buf; char *ext; @@ -4549,7 +4587,7 @@ err: if (fd >= 0) my_close(fd, MYF(0)); thd->proc_info= 0; - return error ? 1 : Log_event::apply_event_impl(rli); + return error == 0; } #endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */ @@ -4657,15 +4695,15 @@ int Append_block_log_event::get_create_or_append() const } /* - Append_block_log_event::apply_event_impl() + Append_block_log_event::do_apply_event() */ -int Append_block_log_event::apply_event_impl(RELAY_LOG_INFO* rli) +int Append_block_log_event::do_apply_event(RELAY_LOG_INFO const *rli) { char proc_info[17+FN_REFLEN+10], *fname= proc_info+17; int fd; int error = 1; - DBUG_ENTER("Append_block_log_event::apply_event_impl"); + DBUG_ENTER("Append_block_log_event::do_apply_event"); fname= strmov(proc_info, "Making temp file "); slave_load_file_stem(fname, file_id, server_id, ".data"); @@ -4704,7 +4742,7 @@ err: if (fd >= 0) my_close(fd, MYF(0)); thd->proc_info= 0; - DBUG_RETURN(error ? error : Log_event::apply_event_impl(rli)); + DBUG_RETURN(error); } #endif @@ -4788,18 +4826,18 @@ void Delete_file_log_event::pack_info(Protocol *protocol) #endif /* - Delete_file_log_event::apply_event_impl() + Delete_file_log_event::do_apply_event() */ #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) -int Delete_file_log_event::apply_event_impl(RELAY_LOG_INFO* rli) +int Delete_file_log_event::do_apply_event(RELAY_LOG_INFO const *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::apply_event_impl(rli); + return 0; } #endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */ @@ -4885,10 +4923,10 @@ void Execute_load_log_event::pack_info(Protocol *protocol) /* - Execute_load_log_event::apply_event_impl() + Execute_load_log_event::do_apply_event() */ -int Execute_load_log_event::apply_event_impl(RELAY_LOG_INFO* rli) +int Execute_load_log_event::do_apply_event(RELAY_LOG_INFO const *rli) { char fname[FN_REFLEN+10]; char *ext; @@ -4919,15 +4957,15 @@ int Execute_load_log_event::apply_event_impl(RELAY_LOG_INFO* rli) lev->thd = thd; /* - lev->apply_event_impl should use rli only for errors i.e. should + lev->do_apply_event 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 + lev->do_apply_event is the place where the table is loaded (it calls mysql_load()). */ - rli->future_group_master_log_pos= log_pos; - if (lev->apply_event_impl(0,rli,1)) + const_cast(rli)->future_group_master_log_pos= log_pos; + if (lev->do_apply_event(0,rli,1)) { /* We want to indicate the name of the file that could not be loaded @@ -4970,7 +5008,7 @@ err: my_close(fd, MYF(0)); end_io_cache(&file); } - return error ? error : Log_event::apply_event_impl(rli); + return error; } #endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */ @@ -5138,7 +5176,7 @@ void Execute_load_query_log_event::pack_info(Protocol *protocol) int -Execute_load_query_log_event::apply_event_impl(RELAY_LOG_INFO* rli) +Execute_load_query_log_event::do_apply_event(RELAY_LOG_INFO const *rli) { char *p; char *buf; @@ -5175,7 +5213,7 @@ Execute_load_query_log_event::apply_event_impl(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::apply_event_impl(rli, buf, p-buf); + error= Query_log_event::do_apply_event(rli, buf, p-buf); /* Forging file name for deletion in same buffer */ *fname_end= 0; @@ -5488,7 +5526,7 @@ int Rows_log_event::do_add_row_data(byte *const row_data, the master does not have a default value (and isn't nullable) */ static int -unpack_row(RELAY_LOG_INFO *rli, +unpack_row(RELAY_LOG_INFO const *rli, TABLE *table, uint const colcnt, byte *record, char const *row, MY_BITMAP const *cols, char const **row_end, ulong *master_reclength, @@ -5590,17 +5628,17 @@ unpack_row(RELAY_LOG_INFO *rli, return error; } -int Rows_log_event::apply_event_impl(st_relay_log_info *rli) +int Rows_log_event::do_apply_event(RELAY_LOG_INFO const *rli) { - DBUG_ENTER("Rows_log_event::apply_event_impl(st_relay_log_info*)"); + DBUG_ENTER("Rows_log_event::do_apply_event(st_relay_log_info*)"); int error= 0; char const *row_start= (char const *)m_rows_buf; /* - If m_table_id == ~0UL, then we have a dummy event that does - not contain any data. In that case, we just remove all tables in - the tables_to_lock list, close the thread tables, step the relay - log position, and return with success. + If m_table_id == ~0UL, then we have a dummy event that does not + contain any data. In that case, we just remove all tables in the + tables_to_lock list, close the thread tables, and return with + success. The relay log position will be stepped in */ if (m_table_id == ~0UL) { @@ -5610,16 +5648,15 @@ int Rows_log_event::apply_event_impl(st_relay_log_info *rli) */ DBUG_ASSERT(get_flags(STMT_END_F)); - rli->clear_tables_to_lock(); + const_cast(rli)->clear_tables_to_lock(); close_thread_tables(thd); thd->clear_error(); - rli->inc_event_relay_log_pos(); DBUG_RETURN(0); } /* 'thd' has been set by exec_relay_log_event(), just before calling - apply_event_impl(). We still check here to prevent future coding + do_apply_event(). We still check here to prevent future coding errors. */ DBUG_ASSERT(rli->sql_thd == thd); @@ -5637,7 +5674,7 @@ int Rows_log_event::apply_event_impl(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::apply_event_impl() we don't call + Table_map_log_event::do_apply_event() we don't call mysql_init_query() as that may reset the binlog format. */ lex_start(thd, NULL, 0); @@ -5650,7 +5687,7 @@ int Rows_log_event::apply_event_impl(st_relay_log_info *rli) slave_print_msg(ERROR_LEVEL, rli, error, "Error in %s event: when locking tables", get_type_str()); - rli->clear_tables_to_lock(); + const_cast(rli)->clear_tables_to_lock(); DBUG_RETURN(error); } @@ -5668,10 +5705,12 @@ int Rows_log_event::apply_event_impl(st_relay_log_info *rli) need to add code to assert that is the case. */ thd->binlog_flush_pending_rows_event(false); - close_tables_for_reopen(thd, &rli->tables_to_lock); + close_tables_for_reopen(thd, &const_cast(rli)->tables_to_lock); - if ((error= open_tables(thd, &rli->tables_to_lock, - &rli->tables_to_lock_count, 0))) + if ((error= open_tables(thd, + &const_cast(rli)->tables_to_lock, + &const_cast(rli)->tables_to_lock_count, + 0))) { if (thd->query_error || thd->is_fatal_error) { @@ -5686,7 +5725,7 @@ int Rows_log_event::apply_event_impl(st_relay_log_info *rli) "unexpected success or fatal error")); thd->query_error= 1; } - rli->clear_tables_to_lock(); + const_cast(rli)->clear_tables_to_lock(); DBUG_RETURN(error); } } @@ -5701,23 +5740,23 @@ int Rows_log_event::apply_event_impl(st_relay_log_info *rli) TABLE_LIST *ptr; for (ptr= rli->tables_to_lock ; ptr ; ptr= ptr->next_global) { - rli->m_table_map.set_table(ptr->table_id, ptr->table); + const_cast(rli)->m_table_map.set_table(ptr->table_id, ptr->table); } #ifdef HAVE_QUERY_CACHE query_cache.invalidate_locked_for_write(rli->tables_to_lock); #endif - rli->clear_tables_to_lock(); + const_cast(rli)->clear_tables_to_lock(); } DBUG_ASSERT(rli->tables_to_lock == NULL && rli->tables_to_lock_count == 0); - TABLE* table= rli->m_table_map.get_table(m_table_id); + TABLE* table= const_cast(rli)->m_table_map.get_table(m_table_id); if (table) { /* table == NULL means that this table should not be replicated - (this was set up by Table_map_log_event::apply_event_impl() + (this was set up by Table_map_log_event::do_apply_event() which tested replicate-* rules). */ @@ -5785,7 +5824,7 @@ int Rows_log_event::apply_event_impl(st_relay_log_info *rli) row_start= row_end; } DBUG_EXECUTE_IF("STOP_SLAVE_after_first_Rows_event", - rli->abort_slave=1;); + const_cast(rli)->abort_slave= 1;); error= do_after_row_operations(table, error); if (!cache_stmt) { @@ -5812,7 +5851,7 @@ int Rows_log_event::apply_event_impl(st_relay_log_info *rli) thread is certainly going to stop. */ thd->reset_current_stmt_binlog_row_based(); - rli->cleanup_context(thd, 1); + const_cast(rli)->cleanup_context(thd, 1); thd->query_error= 1; DBUG_RETURN(error); } @@ -5856,8 +5895,7 @@ int Rows_log_event::apply_event_impl(st_relay_log_info *rli) */ thd->reset_current_stmt_binlog_row_based(); - rli->cleanup_context(thd, 0); - rli->transaction_end(thd); + const_cast(rli)->cleanup_context(thd, 0); if (error == 0) { @@ -5870,7 +5908,6 @@ int Rows_log_event::apply_event_impl(st_relay_log_info *rli) do not become visible. We still prefer to wipe them out. */ thd->clear_error(); - error= Log_event::apply_event_impl(rli); } else slave_print_msg(ERROR_LEVEL, rli, error, @@ -5899,15 +5936,15 @@ int Rows_log_event::apply_event_impl(st_relay_log_info *rli) problem. When WL#2975 is implemented, just remove the member st_relay_log_info::unsafe_to_stop_at and all its occurences. */ - rli->unsafe_to_stop_at= time(0); + const_cast(rli)->unsafe_to_stop_at= time(0); } DBUG_ASSERT(error == 0); thd->clear_error(); - rli->inc_event_relay_log_pos(); - + DBUG_RETURN(0); } + #endif /* !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) */ #ifndef MYSQL_CLIENT @@ -6081,15 +6118,15 @@ Table_map_log_event::Table_map_log_event(const char *buf, uint event_len, const char *const vpart= buf + common_header_len + post_header_len; /* Extract the length of the various parts from the buffer */ - byte const* const ptr_dblen= (byte const*)vpart + 0; + byte const *const ptr_dblen= (byte const*)vpart + 0; m_dblen= *(uchar*) ptr_dblen; /* Length of database name + counter + terminating null */ - byte const* const ptr_tbllen= ptr_dblen + m_dblen + 2; + byte const *const ptr_tbllen= ptr_dblen + m_dblen + 2; m_tbllen= *(uchar*) ptr_tbllen; /* Length of table name + counter + terminating null */ - byte const* const ptr_colcnt= ptr_tbllen + m_tbllen + 2; + byte const *const ptr_colcnt= ptr_tbllen + m_tbllen + 2; uchar *ptr_after_colcnt= (uchar*) ptr_colcnt; m_colcnt= net_field_length(&ptr_after_colcnt); @@ -6134,9 +6171,9 @@ Table_map_log_event::~Table_map_log_event() */ #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) -int Table_map_log_event::apply_event_impl(st_relay_log_info *rli) +int Table_map_log_event::do_apply_event(RELAY_LOG_INFO const *rli) { - DBUG_ENTER("Table_map_log_event::apply_event_impl(st_relay_log_info*)"); + DBUG_ENTER("Table_map_log_event::do_apply_event(st_relay_log_info*)"); DBUG_ASSERT(rli->sql_thd == thd); @@ -6240,29 +6277,24 @@ int Table_map_log_event::apply_event_impl(st_relay_log_info *rli) locked by linking the table into the list of tables to lock. */ table_list->next_global= table_list->next_local= rli->tables_to_lock; - rli->tables_to_lock= table_list; - rli->tables_to_lock_count++; + const_cast(rli)->tables_to_lock= table_list; + const_cast(rli)->tables_to_lock_count++; /* 'memory' is freed in clear_tables_to_lock */ } - /* - 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. - */ - - if (likely(!error)) - rli->inc_event_relay_log_pos(); DBUG_RETURN(error); err: my_free((gptr) memory, MYF(MY_WME)); DBUG_RETURN(error); } + +int Table_map_log_event::do_update_pos(RELAY_LOG_INFO *rli) +{ + rli->inc_event_relay_log_pos(); + return 0; +} + #endif /* !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) */ #ifndef MYSQL_CLIENT @@ -6427,7 +6459,7 @@ int Write_rows_log_event::do_after_row_operations(TABLE *table, int error) return error; } -int Write_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO *rli, +int Write_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli, TABLE *table, char const *row_start, char const **row_end) @@ -6973,7 +7005,7 @@ int Delete_rows_log_event::do_after_row_operations(TABLE *table, int error) return error; } -int Delete_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO *rli, +int Delete_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli, TABLE *table, char const *row_start, char const **row_end) @@ -7110,7 +7142,7 @@ int Update_rows_log_event::do_after_row_operations(TABLE *table, int error) return error; } -int Update_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO *rli, +int Update_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli, TABLE *table, char const *row_start, char const **row_end) diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc index f01fc5d1c9e..75e4bd168ee 100644 --- a/sql/rpl_rli.cc +++ b/sql/rpl_rli.cc @@ -1056,30 +1056,19 @@ void st_relay_log_info::cached_charset_invalidate() } -bool st_relay_log_info::cached_charset_compare(char *charset) +bool st_relay_log_info::cached_charset_compare(char *charset) const { DBUG_ENTER("st_relay_log_info::cached_charset_compare"); if (bcmp(cached_charset, charset, sizeof(cached_charset))) { - memcpy(cached_charset, charset, sizeof(cached_charset)); + memcpy(const_cast(cached_charset), charset, sizeof(cached_charset)); DBUG_RETURN(1); } DBUG_RETURN(0); } -void st_relay_log_info::transaction_end(THD* thd) -{ - DBUG_ENTER("st_relay_log_info::transaction_end"); - - /* - Nothing to do here right now. - */ - - DBUG_VOID_RETURN; -} - #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) void st_relay_log_info::cleanup_context(THD *thd, bool error) { diff --git a/sql/rpl_rli.h b/sql/rpl_rli.h index d737055baf2..cecf351fd88 100644 --- a/sql/rpl_rli.h +++ b/sql/rpl_rli.h @@ -291,9 +291,7 @@ typedef struct st_relay_log_info When the 6 bytes are equal to 0 is used to mean "cache is invalidated". */ void cached_charset_invalidate(); - bool cached_charset_compare(char *charset); - - void transaction_end(THD*); + bool cached_charset_compare(char *charset) const; void cleanup_context(THD *, bool); void clear_tables_to_lock() { diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc index c80b6dc3f69..fb3d689f2f7 100644 --- a/sql/rpl_utility.cc +++ b/sql/rpl_utility.cc @@ -109,7 +109,7 @@ field_length_from_packed(enum_field_types const field_type, */ int -table_def::compatible_with(RELAY_LOG_INFO *rli, TABLE *table) +table_def::compatible_with(RELAY_LOG_INFO const *rli_arg, TABLE *table) const { /* @@ -117,6 +117,7 @@ table_def::compatible_with(RELAY_LOG_INFO *rli, TABLE *table) */ uint const cols_to_check= min(table->s->fields, size()); int error= 0; + RELAY_LOG_INFO const *rli= const_cast(rli_arg); TABLE_SHARE const *const tsh= table->s; diff --git a/sql/rpl_utility.h b/sql/rpl_utility.h index df0b0cd2ee1..a45a16f1ca8 100644 --- a/sql/rpl_utility.h +++ b/sql/rpl_utility.h @@ -116,7 +116,7 @@ public: 1 if the table definition is not compatible with 'table' 0 if the table definition is compatible with 'table' */ - int compatible_with(RELAY_LOG_INFO *rli, TABLE *table) const; + int compatible_with(RELAY_LOG_INFO const *rli, TABLE *table) const; private: my_size_t m_size; // Number of elements in the types array diff --git a/sql/slave.cc b/sql/slave.cc index 87f11417fcc..ed5f2aa5c44 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -555,7 +555,7 @@ static bool sql_slave_killed(THD* thd, RELAY_LOG_INFO* rli) void */ -void slave_print_msg(enum loglevel level, RELAY_LOG_INFO* rli, +void slave_print_msg(enum loglevel level, RELAY_LOG_INFO const *rli, int err_code, const char* msg, ...) { void (*report_function)(const char *, ...); @@ -577,9 +577,9 @@ void slave_print_msg(enum loglevel level, RELAY_LOG_INFO* rli, It's an error, it must be reported in Last_error and Last_errno in SHOW SLAVE STATUS. */ - pbuff= rli->last_slave_error; + pbuff= const_cast(rli)->last_slave_error; pbuffsize= sizeof(rli->last_slave_error); - rli->last_slave_errno = err_code; + const_cast(rli)->last_slave_errno = err_code; report_function= sql_print_error; break; case WARNING_LEVEL: @@ -1376,7 +1376,7 @@ void set_slave_thread_options(THD* thd) DBUG_VOID_RETURN; } -void set_slave_thread_default_charset(THD* thd, RELAY_LOG_INFO *rli) +void set_slave_thread_default_charset(THD* thd, RELAY_LOG_INFO const *rli) { DBUG_ENTER("set_slave_thread_default_charset"); @@ -1387,7 +1387,14 @@ void set_slave_thread_default_charset(THD* thd, RELAY_LOG_INFO *rli) thd->variables.collation_server= global_system_variables.collation_server; thd->update_charset(); - rli->cached_charset_invalidate(); + + /* + We use a const cast here since the conceptual (and externally + visible) behavior of the function is to set the default charset of + the thread. That the cache has to be invalidated is a secondary + effect. + */ + const_cast(rli)->cached_charset_invalidate(); DBUG_VOID_RETURN; } @@ -1607,7 +1614,8 @@ static ulong read_event(MYSQL* mysql, MASTER_INFO *mi, bool* suppress_warnings) } -int check_expected_error(THD* thd, RELAY_LOG_INFO* rli, int expected_error) +int check_expected_error(THD* thd, RELAY_LOG_INFO const *rli, + int expected_error) { DBUG_ENTER("check_expected_error"); diff --git a/sql/slave.h b/sql/slave.h index 24ba09d78d3..1e5be3ab8bd 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -164,9 +164,9 @@ bool show_master_info(THD* thd, MASTER_INFO* mi); bool show_binlog_info(THD* thd); const char *print_slave_db_safe(const char *db); -int check_expected_error(THD* thd, RELAY_LOG_INFO* rli, int error_code); +int check_expected_error(THD* thd, RELAY_LOG_INFO const *rli, int error_code); void skip_load_data_infile(NET* net); -void slave_print_msg(enum loglevel level, RELAY_LOG_INFO* rli, +void slave_print_msg(enum loglevel level, RELAY_LOG_INFO const *rli, int err_code, const char* msg, ...) ATTRIBUTE_FORMAT(printf, 4, 5); @@ -184,7 +184,7 @@ int init_relay_log_pos(RELAY_LOG_INFO* rli,const char* log,ulonglong pos, int purge_relay_logs(RELAY_LOG_INFO* rli, THD *thd, bool just_reset, const char** errmsg); void set_slave_thread_options(THD* thd); -void set_slave_thread_default_charset(THD* thd, RELAY_LOG_INFO *rli); +void set_slave_thread_default_charset(THD *thd, RELAY_LOG_INFO const *rli); void rotate_relay_log(MASTER_INFO* mi); pthread_handler_t handle_slave_io(void *arg); From 3920f529eaed9f358bfe722082aa17b424442995 Mon Sep 17 00:00:00 2001 From: "mats@romeo.(none)" <> Date: Wed, 17 Jan 2007 15:06:37 +0100 Subject: [PATCH 03/22] BUG#23171 (Illegal slave restart position): Third patch of the bug fix where the code for skipping events and for executing events is factored out into three functions: - shall_skip() to decide if the event shall be skipped and the reason for it; - do_apply_event(), where the event is applied to the database; and - do_update_pos(), which updates the actual relay log position and group positions. --- mysql-test/r/rpl_row_tabledefs_2myisam.result | 2 +- mysql-test/r/rpl_row_tabledefs_3innodb.result | 2 +- sql/log_event.cc | 214 +++++++++++++++--- sql/rpl_rli.cc | 20 +- sql/rpl_rli.h | 9 +- sql/slave.cc | 75 ++---- 6 files changed, 226 insertions(+), 96 deletions(-) diff --git a/mysql-test/r/rpl_row_tabledefs_2myisam.result b/mysql-test/r/rpl_row_tabledefs_2myisam.result index ae792a5dc2a..b3a55ec2447 100644 --- a/mysql-test/r/rpl_row_tabledefs_2myisam.result +++ b/mysql-test/r/rpl_row_tabledefs_2myisam.result @@ -121,7 +121,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1364 +Last_Errno 1105 Last_Error Error in Write_rows event: error during transaction execution on table test.t1_nodef Skip_Counter 0 Exec_Master_Log_Pos # diff --git a/mysql-test/r/rpl_row_tabledefs_3innodb.result b/mysql-test/r/rpl_row_tabledefs_3innodb.result index b7f0b7b15e2..a7f3cd3db9a 100644 --- a/mysql-test/r/rpl_row_tabledefs_3innodb.result +++ b/mysql-test/r/rpl_row_tabledefs_3innodb.result @@ -121,7 +121,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1364 +Last_Errno 1105 Last_Error Error in Write_rows event: error during transaction execution on table test.t1_nodef Skip_Counter 0 Exec_Master_Log_Pos # diff --git a/sql/log_event.cc b/sql/log_event.cc index 3bdc6412dc6..ec7136b5d58 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -89,9 +89,10 @@ public: operator&() DESCRIPTION - Function to return a pointer to the internal, so that the object - can be treated as a IO_CACHE and used with the my_b_* IO_CACHE - functions + + Function to return a pointer to the internal cache, so that the + object can be treated as a IO_CACHE and used with the my_b_* + IO_CACHE functions RETURN VALUE A pointer to the internal IO_CACHE. @@ -593,6 +594,19 @@ int Log_event::do_update_pos(RELAY_LOG_INFO *rli) return 0; // Cannot fail currently } + +Log_event::enum_skip_reason +Log_event::shall_skip(RELAY_LOG_INFO *rli) +{ + if (this->server_id == ::server_id && !replicate_same_server_id) + return EVENT_SKIP_SAME_SID; + else if (rli->slave_skip_counter > 0) + return EVENT_SKIP_COUNT; + else + return EVENT_NOT_SKIPPED; +} + + /* Log_event::pack_info() */ @@ -736,7 +750,7 @@ int Log_event::read_log_event(IO_CACHE* file, String* packet, ulong data_len; int result=0; char buf[LOG_EVENT_MINIMAL_HEADER_LEN]; - DBUG_ENTER("read_log_event"); + DBUG_ENTER("Log_event::read_log_event"); if (log_lock) pthread_mutex_lock(log_lock); @@ -811,7 +825,7 @@ Log_event* Log_event::read_log_event(IO_CACHE* file, const Format_description_log_event *description_event) #endif { - DBUG_ENTER("Log_event::read_log_event(IO_CACHE *, Format_description_log_event *"); + DBUG_ENTER("Log_event::read_log_event"); DBUG_ASSERT(description_event != 0); char head[LOG_EVENT_MINIMAL_HEADER_LEN]; /* @@ -2472,16 +2486,6 @@ bool Format_description_log_event::write(IO_CACHE* file) } #endif -/* - SYNOPSIS - Format_description_log_event::do_apply_event() - - IMPLEMENTATION - Save the information which describes the binlog's format, to be - able to read all coming events. Call - Start_log_event_v3::do_apply_event(). -*/ - #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) int Format_description_log_event::do_apply_event(RELAY_LOG_INFO const *rli) { @@ -2561,6 +2565,12 @@ int Format_description_log_event::do_update_pos(RELAY_LOG_INFO *rli) } } +Log_event::enum_skip_reason +Format_description_log_event::shall_skip(RELAY_LOG_INFO *rli) +{ + return Log_event::EVENT_NOT_SKIPPED; +} + #endif /************************************************************************** @@ -3425,6 +3435,16 @@ bool Rotate_log_event::write(IO_CACHE* file) } #endif +/** + Helper function to detect if the event is inside a group. + */ +static bool is_in_group(THD *const thd, RELAY_LOG_INFO *const rli) +{ + return (thd->options & OPTION_BEGIN) != 0 || + (rli->last_event_start_time > 0); +} + + /* Rotate_log_event::do_apply_event() @@ -3446,30 +3466,40 @@ bool Rotate_log_event::write(IO_CACHE* file) int Rotate_log_event::do_update_pos(RELAY_LOG_INFO *rli) { DBUG_ENTER("Rotate_log_event::do_update_pos"); +#ifndef DBUG_OFF + char buf[32]; +#endif + + DBUG_PRINT("info", ("server_id=%lu; ::server_id=%lu", this->server_id, ::server_id)); + DBUG_PRINT("info", ("new_log_ident: %s", this->new_log_ident)); + DBUG_PRINT("info", ("pos: %s", llstr(this->pos, buf))); + pthread_mutex_lock(&rli->data_lock); rli->event_relay_log_pos= my_b_tell(rli->cur_log); /* - If we are in a transaction: the only normal case is when the I/O thread was - copying a big transaction, then it was stopped and restarted: we have this - in the relay log: + If we are in a transaction or in a group: the only normal case is + when the I/O thread was copying a big transaction, then it was + stopped and restarted: we have this in the relay log: + BEGIN ... ROTATE (a fake one) ... COMMIT or ROLLBACK - In that case, we don't want to touch the coordinates which correspond to - the beginning of the transaction. - Starting from 5.0.0, there also are some rotates from the slave itself, in - the relay log. + + In that case, we don't want to touch the coordinates which + correspond to the beginning of the transaction. Starting from + 5.0.0, there also are some rotates from the slave itself, in the + relay log. */ - if (!(thd->options & OPTION_BEGIN)) + if (!is_in_group(thd, rli)) { memcpy(rli->group_master_log_name, new_log_ident, ident_len+1); rli->notify_group_master_log_name_update(); rli->group_master_log_pos= pos; rli->group_relay_log_pos= rli->event_relay_log_pos; - DBUG_PRINT("info", ("group_master_log_name: '%s' " - "group_master_log_pos: %lu", + DBUG_PRINT("info", ("new group_master_log_name: '%s' " + "new group_master_log_pos: %lu", rli->group_master_log_name, (ulong) rli->group_master_log_pos)); /* @@ -3492,6 +3522,24 @@ int Rotate_log_event::do_update_pos(RELAY_LOG_INFO *rli) DBUG_RETURN(0); } + +Log_event::enum_skip_reason +Rotate_log_event::shall_skip(RELAY_LOG_INFO *rli) +{ + + enum_skip_reason reason= Log_event::shall_skip(rli); + + switch (reason) { + case Log_event::EVENT_NOT_SKIPPED: + case Log_event::EVENT_SKIP_COUNT: + return Log_event::EVENT_NOT_SKIPPED; + + case Log_event::EVENT_SKIP_SAME_SID: + return Log_event::EVENT_SKIP_SAME_SID; + } + DBUG_ASSERT(0); +} + #endif @@ -3620,6 +3668,26 @@ int Intvar_log_event::do_update_pos(RELAY_LOG_INFO *rli) rli->inc_event_relay_log_pos(); return 0; } + + +Log_event::enum_skip_reason +Intvar_log_event::shall_skip(RELAY_LOG_INFO *rli) +{ + /* + It is a common error to set the slave skip counter to 1 instead + of 2 when recovering from an insert which used a auto increment, + rand, or user var. Therefore, if the slave skip counter is 1, + we just say that this event should be skipped because of the + slave skip count, but we do not change the value of the slave + skip counter since it will be decreased by the following insert + event. + */ + if (rli->slave_skip_counter == 1) + return Log_event::EVENT_SKIP_COUNT; + else + return Log_event::shall_skip(rli); +} + #endif @@ -3694,6 +3762,25 @@ int Rand_log_event::do_update_pos(RELAY_LOG_INFO *rli) return 0; } + +Log_event::enum_skip_reason +Rand_log_event::shall_skip(RELAY_LOG_INFO *rli) +{ + /* + It is a common error to set the slave skip counter to 1 instead + of 2 when recovering from an insert which used a auto increment, + rand, or user var. Therefore, if the slave skip counter is 1, + we just say that this event should be skipped because of the + slave skip count, but we do not change the value of the slave + skip counter since it will be decreased by the following insert + event. + */ + if (rli->slave_skip_counter == 1) + return Log_event::EVENT_SKIP_COUNT; + else + return Log_event::shall_skip(rli); +} + #endif /* !MYSQL_CLIENT */ @@ -4116,6 +4203,23 @@ int User_var_log_event::do_update_pos(RELAY_LOG_INFO *rli) return 0; } +Log_event::enum_skip_reason +User_var_log_event::shall_skip(RELAY_LOG_INFO *rli) + { + /* + It is a common error to set the slave skip counter to 1 instead + of 2 when recovering from an insert which used a auto increment, + rand, or user var. Therefore, if the slave skip counter is 1, + we just say that this event should be skipped because of the + slave skip count, but we do not change the value of the slave + skip counter since it will be decreased by the following insert + event. + */ + if (rli->slave_skip_counter == 1) + return Log_event::EVENT_SKIP_COUNT; + else + return Log_event::shall_skip(rli); + } #endif /* !MYSQL_CLIENT */ @@ -5814,9 +5918,9 @@ int Rows_log_event::do_apply_event(RELAY_LOG_INFO const *rli) break; default: - slave_print_msg(ERROR_LEVEL, rli, error, + slave_print_msg(ERROR_LEVEL, rli, thd->net.last_errno, "Error in %s event: row application failed", - get_type_str()); + get_type_str(), error); thd->query_error= 1; break; } @@ -5835,11 +5939,12 @@ int Rows_log_event::do_apply_event(RELAY_LOG_INFO const *rli) if (error) { /* error has occured during the transaction */ - slave_print_msg(ERROR_LEVEL, rli, error, + slave_print_msg(ERROR_LEVEL, rli, thd->net.last_errno, "Error in %s event: error during transaction execution " "on table %s.%s", get_type_str(), table->s->db.str, table->s->table_name.str); + /* If one day we honour --skip-slave-errors in row-based replication, and the error should be skipped, then we would clear mappings, rollback, @@ -5851,7 +5956,7 @@ int Rows_log_event::do_apply_event(RELAY_LOG_INFO const *rli) thread is certainly going to stop. */ thd->reset_current_stmt_binlog_row_based(); - const_cast(rli)->cleanup_context(thd, 1); + const_cast(rli)->cleanup_context(thd, error); thd->query_error= 1; DBUG_RETURN(error); } @@ -5934,9 +6039,9 @@ int Rows_log_event::do_apply_event(RELAY_LOG_INFO const *rli) wait (reached end of last relay log and nothing gets appended there), we timeout after one minute, and notify DBA about the problem. When WL#2975 is implemented, just remove the member - st_relay_log_info::unsafe_to_stop_at and all its occurences. + st_relay_log_info::last_event_start_time and all its occurences. */ - const_cast(rli)->unsafe_to_stop_at= time(0); + const_cast(rli)->last_event_start_time= time(0); } DBUG_ASSERT(error == 0); @@ -6599,6 +6704,32 @@ copy_extra_record_fields(TABLE *table, return 0; // All OK } +/** + Check if an error is a duplicate key error. + + This function is used to check if an error code is one of the + duplicate key error, i.e., and error code for which it is sensible + to do a get_dup_key() to retrieve the duplicate key. + + @param errcode The error code to check. + + @return true if the error code is such that + get_dup_key() will return true, false + otherwise. + */ +bool +is_duplicate_key_error(int errcode) +{ + switch (errcode) + { + case HA_ERR_FOUND_DUPP_KEY: + case HA_ERR_FOUND_DUPP_UNIQUE: + return true; + } + return false; +} + + /* Replace the provided record in the database. @@ -6633,10 +6764,15 @@ replace_record(THD *thd, TABLE *table, while ((error= table->file->ha_write_row(table->record[0]))) { + if (!is_duplicate_key_error(error)) + { + table->file->print_error(error, MYF(0)); + DBUG_RETURN(error); + } if ((keynum= table->file->get_dup_key(error)) < 0) { /* We failed to retrieve the duplicate key */ - DBUG_RETURN(HA_ERR_FOUND_DUPP_KEY); + DBUG_RETURN(error); } /* @@ -6653,7 +6789,10 @@ replace_record(THD *thd, TABLE *table, { error= table->file->rnd_pos(table->record[1], table->file->dup_ref); if (error) + { + table->file->print_error(error, MYF(0)); DBUG_RETURN(error); + } } else { @@ -6670,12 +6809,15 @@ replace_record(THD *thd, TABLE *table, } key_copy((byte*)key.get(), table->record[0], table->key_info + keynum, 0); - error= table->file->index_read_idx(table->record[1], keynum, + error= table->file->index_read_idx(table->record[1], keynum, (const byte*)key.get(), table->key_info[keynum].key_length, HA_READ_KEY_EXACT); if (error) + { + table->file->print_error(error, MYF(0)); DBUG_RETURN(error); + } } /* @@ -6708,15 +6850,21 @@ replace_record(THD *thd, TABLE *table, { error=table->file->ha_update_row(table->record[1], table->record[0]); + if (error) + table->file->print_error(error, MYF(0)); DBUG_RETURN(error); } else { if ((error= table->file->ha_delete_row(table->record[1]))) + { + table->file->print_error(error, MYF(0)); DBUG_RETURN(error); + } /* Will retry ha_write_row() with the offending row removed. */ } } + DBUG_RETURN(error); } diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc index 75e4bd168ee..36334351da2 100644 --- a/sql/rpl_rli.cc +++ b/sql/rpl_rli.cc @@ -36,7 +36,7 @@ st_relay_log_info::st_relay_log_info() inited(0), abort_slave(0), slave_running(0), until_condition(UNTIL_NONE), until_log_pos(0), retried_trans(0), tables_to_lock(0), tables_to_lock_count(0), - unsafe_to_stop_at(0) + last_event_start_time(0) { DBUG_ENTER("st_relay_log_info::st_relay_log_info"); @@ -1001,6 +1001,22 @@ bool st_relay_log_info::is_until_satisfied() log_pos= group_relay_log_pos; } +#ifndef DBUG_OFF + { + char buf[32]; + DBUG_PRINT("info", ("group_master_log_name='%s', group_master_log_pos=%s", + group_master_log_name, llstr(group_master_log_pos, buf))); + DBUG_PRINT("info", ("group_relay_log_name='%s', group_relay_log_pos=%s", + group_relay_log_name, llstr(group_relay_log_pos, buf))); + DBUG_PRINT("info", ("(%s) log_name='%s', log_pos=%s", + until_condition == UNTIL_MASTER_POS ? "master" : "relay", + log_name, llstr(log_pos, buf))); + DBUG_PRINT("info", ("(%s) until_log_name='%s', until_log_pos=%s", + until_condition == UNTIL_MASTER_POS ? "master" : "relay", + until_log_name, llstr(until_log_pos, buf))); + } +#endif + if (until_log_names_cmp_result == UNTIL_LOG_NAMES_CMP_UNKNOWN) { /* @@ -1095,7 +1111,7 @@ void st_relay_log_info::cleanup_context(THD *thd, bool error) m_table_map.clear_tables(); close_thread_tables(thd); clear_tables_to_lock(); - unsafe_to_stop_at= 0; + last_event_start_time= 0; DBUG_VOID_RETURN; } #endif diff --git a/sql/rpl_rli.h b/sql/rpl_rli.h index cecf351fd88..ed9ef3a9115 100644 --- a/sql/rpl_rli.h +++ b/sql/rpl_rli.h @@ -305,7 +305,14 @@ typedef struct st_relay_log_info DBUG_ASSERT(tables_to_lock == NULL && tables_to_lock_count == 0); } - time_t unsafe_to_stop_at; + /* + Used by row-based replication to detect that it should not stop at + this event, but give it a chance to send more events. The time + where the last event inside a group started is stored here. If the + variable is zero, we are not in a group (but may be in a + transaction). + */ + time_t last_event_start_time; } RELAY_LOG_INFO; diff --git a/sql/slave.cc b/sql/slave.cc index ed5f2aa5c44..b58069a82ca 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -517,11 +517,11 @@ static bool sql_slave_killed(THD* thd, RELAY_LOG_INFO* rli) really one minute of idleness, we don't timeout if the slave SQL thread is actively working. */ - if (!rli->unsafe_to_stop_at) + if (rli->last_event_start_time == 0) DBUG_RETURN(1); DBUG_PRINT("info", ("Slave SQL thread is in an unsafe situation, giving " "it some grace period")); - if (difftime(time(0), rli->unsafe_to_stop_at) > 60) + if (difftime(time(0), rli->last_event_start_time) > 60) { slave_print_msg(ERROR_LEVEL, rli, 0, "SQL thread had to stop in an unsafe situation, in " @@ -1737,61 +1737,14 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) now the relay log starts with its Format_desc, has a Rotate etc). */ - DBUG_PRINT("info",("type_code=%d, server_id=%d",type_code,ev->server_id)); + DBUG_PRINT("info",("type_code=%d (%s), server_id=%d", + type_code, ev->get_type_str(), ev->server_id)); - if ((ev->server_id == (uint32) ::server_id && - !replicate_same_server_id && - type_code != FORMAT_DESCRIPTION_EVENT) || - (rli->slave_skip_counter && - type_code != ROTATE_EVENT && type_code != STOP_EVENT && - type_code != START_EVENT_V3 && type_code!= FORMAT_DESCRIPTION_EVENT)) - { - DBUG_PRINT("info", ("event skipped")); - /* - We only skip the event here and do not increase the group log - position. In the event that we have to restart, this means - that we might have to skip the event again, but that is a - minor issue. - If we were to increase the group log position when skipping an - event, it might be that we are restarting at the wrong - position and have events before that we should have executed, - so not increasing the group log position is a sure bet in this - case. - - In this way, we just step the group log position when we - *know* that we are at the end of a group. - */ - rli->inc_event_relay_log_pos(); - - /* - Protect against common user error of setting the counter to 1 - instead of 2 while recovering from an insert which used auto_increment, - rand or user var. - */ - if (rli->slave_skip_counter && - !((type_code == INTVAR_EVENT || - type_code == RAND_EVENT || - type_code == USER_VAR_EVENT) && - rli->slave_skip_counter == 1) && - /* - The events from ourselves which have something to do with the relay - log itself must be skipped, true, but they mustn't decrement - rli->slave_skip_counter, because the user is supposed to not see - these events (they are not in the master's binlog) and if we - decremented, START SLAVE would for example decrement when it sees - the Rotate, so the event which the user probably wanted to skip - would not be skipped. - */ - !(ev->server_id == (uint32) ::server_id && - (type_code == ROTATE_EVENT || type_code == STOP_EVENT || - type_code == START_EVENT_V3 || type_code == FORMAT_DESCRIPTION_EVENT))) - --rli->slave_skip_counter; - pthread_mutex_unlock(&rli->data_lock); - delete ev; - DBUG_RETURN(0); // avoid infinite update loops - } - pthread_mutex_unlock(&rli->data_lock); + /* + Execute the event, but first we set some data that is needed for + the thread. + */ thd->server_id = ev->server_id; // use the original server id for logging thd->set_time(); // time the query @@ -1799,7 +1752,8 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) if (!ev->when) ev->when = time(NULL); ev->thd = thd; // because up to this point, ev->thd == 0 - exec_res = ev->exec_event(rli); + + exec_res= ev->exec_event(rli); DBUG_PRINT("info", ("exec_event result = %d", exec_res)); DBUG_ASSERT(rli->sql_thd==thd); /* @@ -2354,13 +2308,17 @@ Slave SQL thread aborted. Can't execute init_slave query"); THD_CHECK_SENTRY(thd); if (exec_relay_log_event(thd,rli)) { + DBUG_PRINT("info", ("exec_relay_log_event() failed")); // do not scare the user if SQL thread was simply killed or stopped if (!sql_slave_killed(thd,rli)) { /* - retrieve as much info as possible from the thd and, error codes and warnings - and print this to the error log as to allow the user to locate the error + retrieve as much info as possible from the thd and, error + codes and warnings and print this to the error log as to + allow the user to locate the error */ + DBUG_PRINT("info", ("thd->net.last_errno=%d; rli->last_slave_errno=%d", + thd->net.last_errno, rli->last_slave_errno)); if (thd->net.last_errno != 0) { if (rli->last_slave_errno == 0) @@ -2682,6 +2640,7 @@ static int queue_binlog_ver_1_event(MASTER_INFO *mi, const char *buf, my_free((char*) tmp_buf, MYF(MY_ALLOW_ZERO_PTR)); DBUG_RETURN(1); } + pthread_mutex_lock(&mi->data_lock); ev->log_pos= mi->master_log_pos; /* 3.23 events don't contain log_pos */ switch (ev->get_type_code()) { From e61a1841a50e64fca49d4228a6a31487ca8c9d70 Mon Sep 17 00:00:00 2001 From: "mats@romeo.(none)" <> Date: Mon, 12 Feb 2007 16:46:42 +0100 Subject: [PATCH 04/22] BUG#22583 (RBR between MyISAM and non-MyISAM tables containing BIT field does not work): Changing packed row format to only include null bits for those columns that are present in the row as well as writing BIT columns in a storage engine-independent format. The change in row format is incompatible with the previous format and a slave will not be able to read the new events. --- mysql-test/extra/rpl_tests/rpl_deadlock.test | 4 +- mysql-test/extra/rpl_tests/rpl_log.test | 6 +- .../extra/rpl_tests/rpl_row_charset.test | 2 +- mysql-test/r/rpl_000015.result | 4 +- mysql-test/r/rpl_change_master.result | 4 +- mysql-test/r/rpl_deadlock_innodb.result | 4 +- mysql-test/r/rpl_flushlog_loop.result | 4 +- mysql-test/r/rpl_log_pos.result | 8 +- mysql-test/r/rpl_row_basic_11bugs.result | 115 ++++++++++++++- mysql-test/r/rpl_row_charset.result | 2 +- mysql-test/r/rpl_row_create_table.result | 32 ++-- mysql-test/r/rpl_row_delayed_ins.result | 14 +- mysql-test/r/rpl_row_drop.result | 8 +- mysql-test/r/rpl_row_flsh_tbls.result | 4 +- mysql-test/r/rpl_row_inexist_tbl.result | 2 +- mysql-test/r/rpl_row_log.result | 16 +- mysql-test/r/rpl_row_log_innodb.result | 16 +- mysql-test/r/rpl_row_max_relay_size.result | 22 +-- mysql-test/r/rpl_row_reset_slave.result | 6 +- mysql-test/r/rpl_row_until.result | 8 +- mysql-test/r/rpl_server_id1.result | 2 +- mysql-test/r/rpl_server_id2.result | 2 +- mysql-test/r/rpl_switch_stm_row_mixed.result | 4 +- mysql-test/r/rpl_truncate_2myisam.result | 66 ++++----- mysql-test/r/rpl_truncate_3innodb.result | 90 ++++++------ mysql-test/t/rpl_loaddata_s.test | 2 +- mysql-test/t/rpl_log_pos.test | 2 +- mysql-test/t/rpl_row_basic_11bugs-master.opt | 3 +- mysql-test/t/rpl_row_basic_11bugs-slave.opt | 1 + mysql-test/t/rpl_row_basic_11bugs.test | 70 ++++++++- mysql-test/t/rpl_row_create_table.test | 10 +- mysql-test/t/rpl_row_flsh_tbls.test | 2 +- mysql-test/t/rpl_row_mysqlbinlog.test | 4 +- mysql-test/t/rpl_switch_stm_row_mixed.test | 4 +- mysql-test/t/user_var-binlog.test | 2 +- sql/log_event.cc | 139 ++++++++++-------- sql/log_event.h | 19 ++- sql/sql_class.cc | 113 ++++++++++++-- 38 files changed, 549 insertions(+), 267 deletions(-) create mode 100644 mysql-test/t/rpl_row_basic_11bugs-slave.opt diff --git a/mysql-test/extra/rpl_tests/rpl_deadlock.test b/mysql-test/extra/rpl_tests/rpl_deadlock.test index 64df1f272cc..d132c34ef90 100644 --- a/mysql-test/extra/rpl_tests/rpl_deadlock.test +++ b/mysql-test/extra/rpl_tests/rpl_deadlock.test @@ -73,7 +73,7 @@ show slave status; # 2) Test lock wait timeout stop slave; -change master to master_log_pos=536; # the BEGIN log event +change master to master_log_pos=539; # the BEGIN log event begin; select * from t2 for update; # hold lock start slave; @@ -96,7 +96,7 @@ set global max_relay_log_size=0; # This is really copy-paste of 2) of above stop slave; -change master to master_log_pos=536; +change master to master_log_pos=539; begin; select * from t2 for update; start slave; diff --git a/mysql-test/extra/rpl_tests/rpl_log.test b/mysql-test/extra/rpl_tests/rpl_log.test index cc3a9b4ffb5..4f40cab4e7e 100644 --- a/mysql-test/extra/rpl_tests/rpl_log.test +++ b/mysql-test/extra/rpl_tests/rpl_log.test @@ -42,13 +42,13 @@ select count(*) from t1; show binlog events; --replace_column 2 # 5 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ -show binlog events from 102 limit 1; +show binlog events from 105 limit 1; --replace_column 2 # 5 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ -show binlog events from 102 limit 2; +show binlog events from 105 limit 2; --replace_column 2 # 5 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ -show binlog events from 102 limit 2,1; +show binlog events from 105 limit 2,1; flush logs; # We need an extra update before doing save_master_pos. diff --git a/mysql-test/extra/rpl_tests/rpl_row_charset.test b/mysql-test/extra/rpl_tests/rpl_row_charset.test index 336a038db10..b3959c53d15 100644 --- a/mysql-test/extra/rpl_tests/rpl_row_charset.test +++ b/mysql-test/extra/rpl_tests/rpl_row_charset.test @@ -115,7 +115,7 @@ drop database mysqltest2; drop database mysqltest3; --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ -show binlog events from 102; +show binlog events from 105; sync_slave_with_master; # Check that we can change global.collation_server (since 5.0.3) diff --git a/mysql-test/r/rpl_000015.result b/mysql-test/r/rpl_000015.result index a2763d4f023..eb9b1ef4882 100644 --- a/mysql-test/r/rpl_000015.result +++ b/mysql-test/r/rpl_000015.result @@ -1,7 +1,7 @@ reset master; show master status; File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 102 +master-bin.000001 105 reset slave; show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master @@ -17,7 +17,7 @@ Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File start slave; show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_PORT 7 master-bin.000001 102 # # master-bin.000001 Yes Yes 0 0 102 # None 0 No # +# 127.0.0.1 root MASTER_PORT 7 master-bin.000001 105 # # master-bin.000001 Yes Yes 0 0 105 # None 0 No # drop table if exists t1; create table t1 (n int, PRIMARY KEY(n)); insert into t1 values (10),(45),(90); diff --git a/mysql-test/r/rpl_change_master.result b/mysql-test/r/rpl_change_master.result index 513de9494ba..a9ea380df09 100644 --- a/mysql-test/r/rpl_change_master.result +++ b/mysql-test/r/rpl_change_master.result @@ -13,11 +13,11 @@ insert into t1 values(2); stop slave; show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 # # # master-bin.000001 No No 0 0 187 # None 0 No # +# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 # # # master-bin.000001 No No 0 0 190 # None 0 No # change master to master_user='root'; show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 # # # master-bin.000001 No No 0 0 187 # None 0 No # +# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 # # # master-bin.000001 No No 0 0 190 # None 0 No # start slave; select * from t1; n diff --git a/mysql-test/r/rpl_deadlock_innodb.result b/mysql-test/r/rpl_deadlock_innodb.result index b9a23950ed8..22ca1c3cec1 100644 --- a/mysql-test/r/rpl_deadlock_innodb.result +++ b/mysql-test/r/rpl_deadlock_innodb.result @@ -78,7 +78,7 @@ Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # stop slave; -change master to master_log_pos=536; +change master to master_log_pos=539; begin; select * from t2 for update; a @@ -128,7 +128,7 @@ Master_SSL_Key Seconds_Behind_Master # set global max_relay_log_size=0; stop slave; -change master to master_log_pos=536; +change master to master_log_pos=539; begin; select * from t2 for update; a diff --git a/mysql-test/r/rpl_flushlog_loop.result b/mysql-test/r/rpl_flushlog_loop.result index 16d8ba251f4..a600f103069 100644 --- a/mysql-test/r/rpl_flushlog_loop.result +++ b/mysql-test/r/rpl_flushlog_loop.result @@ -24,7 +24,7 @@ Master_User root Master_Port SLAVE_PORT Connect_Retry 60 Master_Log_File slave-bin.000001 -Read_Master_Log_Pos 212 +Read_Master_Log_Pos 215 Relay_Log_File # Relay_Log_Pos # Relay_Master_Log_File slave-bin.000001 @@ -39,7 +39,7 @@ Replicate_Wild_Ignore_Table Last_Errno 0 Last_Error Skip_Counter 0 -Exec_Master_Log_Pos 212 +Exec_Master_Log_Pos 215 Relay_Log_Space # Until_Condition None Until_Log_File diff --git a/mysql-test/r/rpl_log_pos.result b/mysql-test/r/rpl_log_pos.result index c7484022b23..8a80b5315d4 100644 --- a/mysql-test/r/rpl_log_pos.result +++ b/mysql-test/r/rpl_log_pos.result @@ -6,10 +6,10 @@ drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; show master status; File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 102 +master-bin.000001 105 show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 102 # # master-bin.000001 Yes Yes 0 0 102 # None 0 No # +# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 105 # # master-bin.000001 Yes Yes 0 0 105 # None 0 No # stop slave; change master to master_log_pos=74; start slave; @@ -30,13 +30,13 @@ Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File # 127.0.0.1 root MASTER_PORT 1 master-bin.000001 177 # # master-bin.000001 No Yes 0 0 177 # None 0 No # show master status; File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 102 +master-bin.000001 105 create table if not exists t1 (n int); drop table if exists t1; create table t1 (n int); insert into t1 values (1),(2),(3); stop slave; -change master to master_log_pos=102; +change master to master_log_pos=105; start slave; select * from t1 ORDER BY n; n diff --git a/mysql-test/r/rpl_row_basic_11bugs.result b/mysql-test/r/rpl_row_basic_11bugs.result index e49facd2d70..a3542f9a931 100644 --- a/mysql-test/r/rpl_row_basic_11bugs.result +++ b/mysql-test/r/rpl_row_basic_11bugs.result @@ -25,11 +25,11 @@ SHOW TABLES; Tables_in_test_ignore t2 INSERT INTO t2 VALUES (3,3), (4,4); -SHOW BINLOG EVENTS FROM 102; +SHOW BINLOG EVENTS FROM 105; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 102 Query 1 195 use `test`; CREATE TABLE t1 (a INT, b INT) -master-bin.000001 195 Table_map 1 235 table_id: # (test.t1) -master-bin.000001 235 Write_rows 1 282 table_id: # flags: STMT_END_F +master-bin.000001 105 Query 1 198 use `test`; CREATE TABLE t1 (a INT, b INT) +master-bin.000001 198 Table_map 1 238 table_id: # (test.t1) +master-bin.000001 238 Write_rows 1 285 table_id: # flags: STMT_END_F **** On Slave **** SHOW DATABASES; Database @@ -56,10 +56,10 @@ DELETE FROM t1 WHERE a = 0; UPDATE t1 SET a=99 WHERE a = 0; SHOW BINLOG EVENTS; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4 -master-bin.000001 102 Query 1 188 use `test`; CREATE TABLE t1 (a INT) -master-bin.000001 188 Table_map 1 227 table_id: # (test.t1) -master-bin.000001 227 Write_rows 1 266 table_id: # flags: STMT_END_F +master-bin.000001 4 Format_desc 1 105 Server ver: SERVER_VERSION, Binlog ver: 4 +master-bin.000001 105 Query 1 191 use `test`; CREATE TABLE t1 (a INT) +master-bin.000001 191 Table_map 1 230 table_id: # (test.t1) +master-bin.000001 230 Write_rows 1 269 table_id: # flags: STMT_END_F DROP TABLE t1; ================ Test for BUG#17620 ================ drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; @@ -120,3 +120,102 @@ HEX(a) b SELECT HEX(a),b FROM t1; HEX(a) b 0 2 +DROP TABLE IF EXISTS t1; +================ Test for BUG#22583 ================ +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +**** On Master **** +CREATE TABLE t1_myisam (k INT, a BIT(1), b BIT(9)) ENGINE=MYISAM; +CREATE TABLE t1_innodb (k INT, a BIT(1), b BIT(9)) ENGINE=INNODB; +CREATE TABLE t2_myisam (k INT, a BIT(1) NOT NULL, b BIT(4) NOT NULL) ENGINE=MYISAM; +CREATE TABLE t2_innodb (k INT, a BIT(1) NOT NULL, b BIT(4) NOT NULL) ENGINE=INNODB; +**** On Slave **** +ALTER TABLE t1_myisam ENGINE=INNODB; +ALTER TABLE t1_innodb ENGINE=MYISAM; +ALTER TABLE t2_myisam ENGINE=INNODB; +ALTER TABLE t2_innodb ENGINE=MYISAM; +**** On Master **** +INSERT INTO t1_myisam VALUES(1, b'0', 257); +INSERT INTO t1_myisam VALUES(2, b'1', 256); +INSERT INTO t1_innodb VALUES(1, b'0', 257); +INSERT INTO t1_innodb VALUES(2, b'1', 256); +SELECT k, HEX(a),HEX(b) FROM t1_myisam; +k HEX(a) HEX(b) +1 0 101 +2 1 100 +SELECT k, HEX(a),HEX(b) FROM t1_innodb; +k HEX(a) HEX(b) +1 0 101 +2 1 100 +INSERT INTO t2_myisam VALUES(1, b'0', 9); +INSERT INTO t2_myisam VALUES(2, b'1', 8); +INSERT INTO t2_innodb VALUES(1, b'0', 9); +INSERT INTO t2_innodb VALUES(2, b'1', 8); +SELECT k, HEX(a),HEX(b) FROM t2_myisam; +k HEX(a) HEX(b) +1 0 9 +2 1 8 +SELECT k, HEX(a),HEX(b) FROM t2_innodb; +k HEX(a) HEX(b) +1 0 9 +2 1 8 +**** On Slave **** +SELECT k, HEX(a),HEX(b) FROM t1_myisam; +k HEX(a) HEX(b) +1 0 101 +2 1 100 +SELECT k, HEX(a),HEX(b) FROM t1_innodb; +k HEX(a) HEX(b) +1 0 101 +2 1 100 +SELECT k, HEX(a),HEX(b) FROM t2_myisam; +k HEX(a) HEX(b) +1 0 9 +2 1 8 +SELECT k, HEX(a),HEX(b) FROM t2_innodb; +k HEX(a) HEX(b) +1 0 9 +2 1 8 +**** On Master **** +UPDATE t1_myisam SET a=0 WHERE k=2; +SELECT k, HEX(a),HEX(b) FROM t1_myisam; +k HEX(a) HEX(b) +1 0 101 +2 0 100 +UPDATE t1_innodb SET a=0 WHERE k=2; +SELECT k, HEX(a),HEX(b) FROM t1_innodb; +k HEX(a) HEX(b) +1 0 101 +2 0 100 +UPDATE t2_myisam SET a=0 WHERE k=2; +SELECT k, HEX(a),HEX(b) FROM t2_myisam; +k HEX(a) HEX(b) +1 0 9 +2 0 8 +UPDATE t2_innodb SET a=0 WHERE k=2; +SELECT k, HEX(a),HEX(b) FROM t2_innodb; +k HEX(a) HEX(b) +1 0 9 +2 0 8 +**** On Slave **** +SELECT k, HEX(a),HEX(b) FROM t1_myisam; +k HEX(a) HEX(b) +1 0 101 +2 0 100 +SELECT k, HEX(a),HEX(b) FROM t1_innodb; +k HEX(a) HEX(b) +1 0 101 +2 0 100 +SELECT k, HEX(a),HEX(b) FROM t2_myisam; +k HEX(a) HEX(b) +1 0 9 +2 0 8 +SELECT k, HEX(a),HEX(b) FROM t2_innodb; +k HEX(a) HEX(b) +1 0 9 +2 0 8 +**** On Master **** +DROP TABLE IF EXISTS t1_myisam, t1_innodb, t2_myisam, t2_innodb; diff --git a/mysql-test/r/rpl_row_charset.result b/mysql-test/r/rpl_row_charset.result index 79cf75c8cc1..2462dd0b505 100644 --- a/mysql-test/r/rpl_row_charset.result +++ b/mysql-test/r/rpl_row_charset.result @@ -109,7 +109,7 @@ a b 1 cp850_general_ci drop database mysqltest2; drop database mysqltest3; -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # drop database if exists mysqltest2 master-bin.000001 # Query 1 # drop database if exists mysqltest3 diff --git a/mysql-test/r/rpl_row_create_table.result b/mysql-test/r/rpl_row_create_table.result index 03388f59b8c..6a1877c0fec 100644 --- a/mysql-test/r/rpl_row_create_table.result +++ b/mysql-test/r/rpl_row_create_table.result @@ -8,27 +8,27 @@ CREATE TABLE t1 (a INT, b INT); CREATE TABLE t2 (a INT, b INT) ENGINE=Merge; CREATE TABLE t3 (a INT, b INT) CHARSET=utf8; CREATE TABLE t4 (a INT, b INT) ENGINE=Merge CHARSET=utf8; -SHOW BINLOG EVENTS FROM 212; +SHOW BINLOG EVENTS FROM 215; Log_name # -Pos 212 +Pos 215 Event_type Query Server_id # End_log_pos # Info use `test`; CREATE TABLE t1 (a INT, b INT) Log_name # -Pos 305 +Pos 308 Event_type Query Server_id # End_log_pos # Info use `test`; CREATE TABLE t2 (a INT, b INT) ENGINE=Merge Log_name # -Pos 411 +Pos 414 Event_type Query Server_id # End_log_pos # Info use `test`; CREATE TABLE t3 (a INT, b INT) CHARSET=utf8 Log_name # -Pos 517 +Pos 520 Event_type Query Server_id # End_log_pos # @@ -127,7 +127,7 @@ NULL 5 10 NULL 6 12 CREATE TABLE t7 (UNIQUE(b)) SELECT a,b FROM tt3; ERROR 23000: Duplicate entry '2' for key 'b' -SHOW BINLOG EVENTS FROM 1256; +SHOW BINLOG EVENTS FROM 1097; Log_name Pos Event_type Server_id End_log_pos Info CREATE TABLE t7 (a INT, b INT UNIQUE); INSERT INTO t7 SELECT a,b FROM tt3; @@ -137,11 +137,11 @@ a b 1 2 2 4 3 6 -SHOW BINLOG EVENTS FROM 1118; +SHOW BINLOG EVENTS FROM 1097; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 1118 Query 1 1218 use `test`; CREATE TABLE t7 (a INT, b INT UNIQUE) -master-bin.000001 1218 Table_map 1 1258 table_id: # (test.t7) -master-bin.000001 1258 Write_rows 1 1314 table_id: # flags: STMT_END_F +master-bin.000001 1097 Query 1 1197 use `test`; CREATE TABLE t7 (a INT, b INT UNIQUE) +master-bin.000001 1197 Table_map 1 1237 table_id: # (test.t7) +master-bin.000001 1237 Write_rows 1 1293 table_id: # flags: STMT_END_F SELECT * FROM t7 ORDER BY a,b; a b 1 2 @@ -154,10 +154,10 @@ INSERT INTO t7 SELECT a,b FROM tt4; ROLLBACK; Warnings: Warning 1196 Some non-transactional changed tables couldn't be rolled back -SHOW BINLOG EVENTS FROM 1314; +SHOW BINLOG EVENTS FROM 1293; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 1314 Table_map 1 1354 table_id: # (test.t7) -master-bin.000001 1354 Write_rows 1 1410 table_id: # flags: STMT_END_F +master-bin.000001 1293 Table_map 1 1333 table_id: # (test.t7) +master-bin.000001 1333 Write_rows 1 1389 table_id: # flags: STMT_END_F SELECT * FROM t7 ORDER BY a,b; a b 1 2 @@ -192,10 +192,10 @@ Create Table CREATE TABLE `t9` ( `a` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 -SHOW BINLOG EVENTS FROM 1410; +SHOW BINLOG EVENTS FROM 1389; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 1410 Query 1 1496 use `test`; CREATE TABLE t8 LIKE t4 -master-bin.000001 1496 Query 1 1635 use `test`; CREATE TABLE `t9` ( +master-bin.000001 1389 Query 1 1475 use `test`; CREATE TABLE t8 LIKE t4 +master-bin.000001 1475 Query 1 1614 use `test`; CREATE TABLE `t9` ( `a` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL ) diff --git a/mysql-test/r/rpl_row_delayed_ins.result b/mysql-test/r/rpl_row_delayed_ins.result index 31fffeb59cc..cad38f77d52 100644 --- a/mysql-test/r/rpl_row_delayed_ins.result +++ b/mysql-test/r/rpl_row_delayed_ins.result @@ -14,13 +14,13 @@ a 3 show binlog events; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 102 Server ver: VERSION, Binlog ver: 4 -master-bin.000001 102 Query 1 222 use `test`; create table t1(a int not null primary key) engine=myisam -master-bin.000001 222 Table_map 1 261 table_id: # (test.t1) -master-bin.000001 261 Write_rows 1 295 table_id: # flags: STMT_END_F -master-bin.000001 295 Table_map 1 334 table_id: # (test.t1) -master-bin.000001 334 Write_rows 1 373 table_id: # flags: STMT_END_F -master-bin.000001 373 Query 1 448 use `test`; flush tables +master-bin.000001 4 Format_desc 1 105 Server ver: VERSION, Binlog ver: 4 +master-bin.000001 105 Query 1 225 use `test`; create table t1(a int not null primary key) engine=myisam +master-bin.000001 225 Table_map 1 264 table_id: # (test.t1) +master-bin.000001 264 Write_rows 1 298 table_id: # flags: STMT_END_F +master-bin.000001 298 Table_map 1 337 table_id: # (test.t1) +master-bin.000001 337 Write_rows 1 376 table_id: # flags: STMT_END_F +master-bin.000001 376 Query 1 451 use `test`; flush tables SELECT * FROM t1 ORDER BY a; a 1 diff --git a/mysql-test/r/rpl_row_drop.result b/mysql-test/r/rpl_row_drop.result index 4ef21884fda..cdf52ceb9b9 100644 --- a/mysql-test/r/rpl_row_drop.result +++ b/mysql-test/r/rpl_row_drop.result @@ -43,10 +43,10 @@ t2 DROP TABLE t1,t2; SHOW BINLOG EVENTS; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 102 Server ver: VERSION, Binlog ver: 4 -master-bin.000001 102 Query 1 188 use `test`; CREATE TABLE t1 (a int) -master-bin.000001 188 Query 1 274 use `test`; CREATE TABLE t2 (a int) -master-bin.000001 274 Query 1 378 use `test`; DROP TABLE `t1` /* generated by server */ +master-bin.000001 4 Format_desc 1 105 Server ver: VERSION, Binlog ver: 4 +master-bin.000001 105 Query 1 191 use `test`; CREATE TABLE t1 (a int) +master-bin.000001 191 Query 1 277 use `test`; CREATE TABLE t2 (a int) +master-bin.000001 277 Query 1 381 use `test`; DROP TABLE `t1` /* generated by server */ SHOW TABLES; Tables_in_test t2 diff --git a/mysql-test/r/rpl_row_flsh_tbls.result b/mysql-test/r/rpl_row_flsh_tbls.result index e2352b8605b..d5b8dc48009 100644 --- a/mysql-test/r/rpl_row_flsh_tbls.result +++ b/mysql-test/r/rpl_row_flsh_tbls.result @@ -12,13 +12,13 @@ create table t4 (a int); insert into t4 select * from t3; rename table t1 to t5, t2 to t1; flush no_write_to_binlog tables; -SHOW BINLOG EVENTS FROM 615 ; +SHOW BINLOG EVENTS FROM 618 ; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; rename table t1 to t5, t2 to t1 select * from t3; a flush tables; -SHOW BINLOG EVENTS FROM 615 ; +SHOW BINLOG EVENTS FROM 618 ; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; rename table t1 to t5, t2 to t1 master-bin.000001 # Query 1 # use `test`; flush tables diff --git a/mysql-test/r/rpl_row_inexist_tbl.result b/mysql-test/r/rpl_row_inexist_tbl.result index 5f5a4556d76..188dfd5924a 100644 --- a/mysql-test/r/rpl_row_inexist_tbl.result +++ b/mysql-test/r/rpl_row_inexist_tbl.result @@ -39,7 +39,7 @@ Replicate_Wild_Ignore_Table Last_Errno 1146 Last_Error Error 'Table 'test.t1' doesn't exist' on opening table `test`.`t1` Skip_Counter 0 -Exec_Master_Log_Pos 519 +Exec_Master_Log_Pos 522 Relay_Log_Space # Until_Condition None Until_Log_File diff --git a/mysql-test/r/rpl_row_log.result b/mysql-test/r/rpl_row_log.result index 89163e1e37b..b7785bbe6b3 100644 --- a/mysql-test/r/rpl_row_log.result +++ b/mysql-test/r/rpl_row_log.result @@ -26,14 +26,14 @@ master-bin.000001 # Query 1 # use `test`; drop table t1 master-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=MyISAM master-bin.000001 # Table_map 1 # table_id: # (test.t1) master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F -show binlog events from 102 limit 1; +show binlog events from 105 limit 1; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM -show binlog events from 102 limit 2; +show binlog events from 105 limit 2; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM master-bin.000001 # Table_map 1 # table_id: # (test.t1) -show binlog events from 102 limit 2,1; +show binlog events from 105 limit 2,1; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F flush logs; @@ -67,13 +67,13 @@ master-bin.000002 # Table_map 1 # table_id: # (test.t2) master-bin.000002 # Write_rows 1 # table_id: # flags: STMT_END_F show binary logs; Log_name File_size -master-bin.000001 1256 -master-bin.000002 373 +master-bin.000001 1259 +master-bin.000002 376 start slave; show binary logs; Log_name File_size -slave-bin.000001 1354 -slave-bin.000002 274 +slave-bin.000001 1357 +slave-bin.000002 277 show binlog events in 'slave-bin.000001' from 4; Log_name Pos Event_type Server_id End_log_pos Info slave-bin.000001 # Format_desc 2 # Server ver: VERSION, Binlog ver: 4 @@ -94,7 +94,7 @@ slave-bin.000002 # Table_map 1 # table_id: # (test.t2) slave-bin.000002 # Write_rows 1 # table_id: # flags: STMT_END_F show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 373 # # master-bin.000002 Yes Yes # 0 0 373 # None 0 No # +# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 376 # # master-bin.000002 Yes Yes # 0 0 376 # None 0 No # show binlog events in 'slave-bin.000005' from 4; ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Could not find target log DROP TABLE t1; diff --git a/mysql-test/r/rpl_row_log_innodb.result b/mysql-test/r/rpl_row_log_innodb.result index 3bcd8a6a0fb..f51d99a07c3 100644 --- a/mysql-test/r/rpl_row_log_innodb.result +++ b/mysql-test/r/rpl_row_log_innodb.result @@ -28,14 +28,14 @@ master-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not nul master-bin.000001 # Table_map 1 # table_id: # (test.t1) master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Xid 1 # COMMIT /* XID */ -show binlog events from 102 limit 1; +show binlog events from 105 limit 1; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=InnoDB -show binlog events from 102 limit 2; +show binlog events from 105 limit 2; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=InnoDB master-bin.000001 # Table_map 1 # table_id: # (test.t1) -show binlog events from 102 limit 2,1; +show binlog events from 105 limit 2,1; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F flush logs; @@ -72,13 +72,13 @@ master-bin.000002 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000002 # Xid 1 # COMMIT /* XID */ show binary logs; Log_name File_size -master-bin.000001 1310 -master-bin.000002 400 +master-bin.000001 1313 +master-bin.000002 403 start slave; show binary logs; Log_name File_size -slave-bin.000001 1408 -slave-bin.000002 301 +slave-bin.000001 1411 +slave-bin.000002 304 show binlog events in 'slave-bin.000001' from 4; Log_name Pos Event_type Server_id End_log_pos Info slave-bin.000001 # Format_desc 2 # Server ver: VERSION, Binlog ver: 4 @@ -102,7 +102,7 @@ slave-bin.000002 # Write_rows 1 # table_id: # flags: STMT_END_F slave-bin.000002 # Xid 1 # COMMIT /* XID */ show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 400 # # master-bin.000002 Yes Yes # 0 0 400 # None 0 No # +# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 403 # # master-bin.000002 Yes Yes # 0 0 403 # None 0 No # show binlog events in 'slave-bin.000005' from 4; ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Could not find target log DROP TABLE t1; diff --git a/mysql-test/r/rpl_row_max_relay_size.result b/mysql-test/r/rpl_row_max_relay_size.result index 163e8231de5..9f420c120d3 100644 --- a/mysql-test/r/rpl_row_max_relay_size.result +++ b/mysql-test/r/rpl_row_max_relay_size.result @@ -29,7 +29,7 @@ Master_User root Master_Port MASTER_PORT Connect_Retry 1 Master_Log_File master-bin.000001 -Read_Master_Log_Pos 58664 +Read_Master_Log_Pos 58667 Relay_Log_File # Relay_Log_Pos # Relay_Master_Log_File master-bin.000001 @@ -44,7 +44,7 @@ Replicate_Wild_Ignore_Table Last_Errno 0 Last_Error Skip_Counter 0 -Exec_Master_Log_Pos 58664 +Exec_Master_Log_Pos 58667 Relay_Log_Space # Until_Condition None Until_Log_File @@ -72,7 +72,7 @@ Master_User root Master_Port MASTER_PORT Connect_Retry 1 Master_Log_File master-bin.000001 -Read_Master_Log_Pos 58664 +Read_Master_Log_Pos 58667 Relay_Log_File # Relay_Log_Pos # Relay_Master_Log_File master-bin.000001 @@ -87,7 +87,7 @@ Replicate_Wild_Ignore_Table Last_Errno 0 Last_Error Skip_Counter 0 -Exec_Master_Log_Pos 58664 +Exec_Master_Log_Pos 58667 Relay_Log_Space # Until_Condition None Until_Log_File @@ -115,7 +115,7 @@ Master_User root Master_Port MASTER_PORT Connect_Retry 1 Master_Log_File master-bin.000001 -Read_Master_Log_Pos 58664 +Read_Master_Log_Pos 58667 Relay_Log_File # Relay_Log_Pos # Relay_Master_Log_File master-bin.000001 @@ -130,7 +130,7 @@ Replicate_Wild_Ignore_Table Last_Errno 0 Last_Error Skip_Counter 0 -Exec_Master_Log_Pos 58664 +Exec_Master_Log_Pos 58667 Relay_Log_Space # Until_Condition None Until_Log_File @@ -196,7 +196,7 @@ Master_User root Master_Port MASTER_PORT Connect_Retry 1 Master_Log_File master-bin.000001 -Read_Master_Log_Pos 58750 +Read_Master_Log_Pos 58753 Relay_Log_File # Relay_Log_Pos # Relay_Master_Log_File master-bin.000001 @@ -211,7 +211,7 @@ Replicate_Wild_Ignore_Table Last_Errno 0 Last_Error Skip_Counter 0 -Exec_Master_Log_Pos 58750 +Exec_Master_Log_Pos 58753 Relay_Log_Space # Until_Condition None Until_Log_File @@ -235,7 +235,7 @@ Master_User root Master_Port MASTER_PORT Connect_Retry 1 Master_Log_File master-bin.000001 -Read_Master_Log_Pos 58826 +Read_Master_Log_Pos 58829 Relay_Log_File # Relay_Log_Pos # Relay_Master_Log_File master-bin.000001 @@ -250,7 +250,7 @@ Replicate_Wild_Ignore_Table Last_Errno 0 Last_Error Skip_Counter 0 -Exec_Master_Log_Pos 58826 +Exec_Master_Log_Pos 58829 Relay_Log_Space # Until_Condition None Until_Log_File @@ -265,7 +265,7 @@ Seconds_Behind_Master # flush logs; show master status; File master-bin.000002 -Position 102 +Position 105 Binlog_Do_DB Binlog_Ignore_DB # diff --git a/mysql-test/r/rpl_row_reset_slave.result b/mysql-test/r/rpl_row_reset_slave.result index 57fc95708e5..a93db7b2c7e 100644 --- a/mysql-test/r/rpl_row_reset_slave.result +++ b/mysql-test/r/rpl_row_reset_slave.result @@ -6,12 +6,12 @@ drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 102 # # master-bin.000001 Yes Yes # 0 0 102 # None 0 No # +# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 105 # # master-bin.000001 Yes Yes # 0 0 105 # None 0 No # stop slave; change master to master_user='test'; show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 test MASTER_PORT 1 master-bin.000001 102 # # master-bin.000001 No No # 0 0 102 # None 0 No # +# 127.0.0.1 test MASTER_PORT 1 master-bin.000001 105 # # master-bin.000001 No No # 0 0 105 # None 0 No # reset slave; show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master @@ -19,7 +19,7 @@ Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File start slave; show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 102 # # master-bin.000001 Yes Yes # 0 0 102 # None 0 No # +# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 105 # # master-bin.000001 Yes Yes # 0 0 105 # None 0 No # stop slave; reset slave; start slave; diff --git a/mysql-test/r/rpl_row_until.result b/mysql-test/r/rpl_row_until.result index 8d4b0d6b591..6d0da57baeb 100644 --- a/mysql-test/r/rpl_row_until.result +++ b/mysql-test/r/rpl_row_until.result @@ -21,7 +21,7 @@ n 4 show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 740 slave-relay-bin.000004 # master-bin.000001 # No 0 0 311 # Master master-bin.000001 311 No # +# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 743 slave-relay-bin.000004 # master-bin.000001 # No 0 0 314 # Master master-bin.000001 311 No # start slave until master_log_file='master-no-such-bin.000001', master_log_pos=291; select * from t1; n @@ -31,7 +31,7 @@ n 4 show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 740 slave-relay-bin.000004 # master-bin.000001 # No 0 0 311 # Master master-no-such-bin.000001 291 No # +# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 743 slave-relay-bin.000004 # master-bin.000001 # No 0 0 314 # Master master-no-such-bin.000001 291 No # start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=728; select * from t2; n @@ -39,13 +39,13 @@ n 2 show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 740 slave-relay-bin.000004 # master-bin.000001 # No 0 0 586 # Relay slave-relay-bin.000004 728 No # +# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 743 slave-relay-bin.000004 # master-bin.000001 # No 0 0 589 # Relay slave-relay-bin.000004 728 No # start slave; stop slave; start slave until master_log_file='master-bin.000001', master_log_pos=740; show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 740 slave-relay-bin.000004 # master-bin.000001 Yes No 0 0 740 # Master master-bin.000001 740 No # +# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 743 slave-relay-bin.000004 # master-bin.000001 Yes No 0 0 743 # Master master-bin.000001 740 No # start slave until master_log_file='master-bin', master_log_pos=561; ERROR HY000: Incorrect parameter or combination of parameters for START SLAVE UNTIL start slave until master_log_file='master-bin.000001', master_log_pos=561, relay_log_pos=12; diff --git a/mysql-test/r/rpl_server_id1.result b/mysql-test/r/rpl_server_id1.result index c94a7748fcd..7091a26f272 100644 --- a/mysql-test/r/rpl_server_id1.result +++ b/mysql-test/r/rpl_server_id1.result @@ -10,7 +10,7 @@ stop slave; change master to master_port=SLAVE_PORT; show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master - 127.0.0.1 root SLAVE_PORT 1 4 slave-relay-bin.000001 4 No No # # 0 0 0 102 None 0 No NULL + 127.0.0.1 root SLAVE_PORT 1 4 slave-relay-bin.000001 4 No No # # 0 0 0 105 None 0 No NULL start slave; insert into t1 values (1); show status like "slave_running"; diff --git a/mysql-test/r/rpl_server_id2.result b/mysql-test/r/rpl_server_id2.result index 72db862040e..3ad15d7ce5b 100644 --- a/mysql-test/r/rpl_server_id2.result +++ b/mysql-test/r/rpl_server_id2.result @@ -10,7 +10,7 @@ stop slave; change master to master_port=SLAVE_PORT; show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master - 127.0.0.1 root SLAVE_PORT 1 4 slave-relay-bin.000001 4 No No # 0 0 0 102 None 0 No NULL + 127.0.0.1 root SLAVE_PORT 1 4 slave-relay-bin.000001 4 No No # 0 0 0 105 None 0 No NULL start slave; insert into t1 values (1); select * from t1; diff --git a/mysql-test/r/rpl_switch_stm_row_mixed.result b/mysql-test/r/rpl_switch_stm_row_mixed.result index 047bfe53704..2f970adea11 100644 --- a/mysql-test/r/rpl_switch_stm_row_mixed.result +++ b/mysql-test/r/rpl_switch_stm_row_mixed.result @@ -382,7 +382,7 @@ CREATE TABLE t12 (data LONG); LOCK TABLES t12 WRITE; INSERT INTO t12 VALUES(UUID()); UNLOCK TABLES; -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # drop database if exists mysqltest1 master-bin.000001 # Query 1 # create database mysqltest1 @@ -692,7 +692,7 @@ master-bin.000001 # Query 1 # use `mysqltest1`; DROP TABLE IF EXISTS t12 master-bin.000001 # Query 1 # use `mysqltest1`; CREATE TABLE t12 (data LONG) master-bin.000001 # Table_map 1 # table_id: # (mysqltest1.t12) master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # drop database if exists mysqltest1 master-bin.000001 # Query 1 # create database mysqltest1 diff --git a/mysql-test/r/rpl_truncate_2myisam.result b/mysql-test/r/rpl_truncate_2myisam.result index 41640a709b9..23e4630c3c8 100644 --- a/mysql-test/r/rpl_truncate_2myisam.result +++ b/mysql-test/r/rpl_truncate_2myisam.result @@ -31,11 +31,11 @@ a b DROP TABLE t1; SHOW BINLOG EVENTS; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4 -master-bin.000001 102 Query 1 210 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM -master-bin.000001 210 Query 1 307 use `test`; INSERT INTO t1 VALUES (1,1), (2,2) -master-bin.000001 307 Query 1 387 use `test`; TRUNCATE TABLE t1 -master-bin.000001 387 Query 1 463 use `test`; DROP TABLE t1 +master-bin.000001 4 Format_desc 1 105 Server ver: SERVER_VERSION, Binlog ver: 4 +master-bin.000001 105 Query 1 213 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM +master-bin.000001 213 Query 1 310 use `test`; INSERT INTO t1 VALUES (1,1), (2,2) +master-bin.000001 310 Query 1 390 use `test`; TRUNCATE TABLE t1 +master-bin.000001 390 Query 1 466 use `test`; DROP TABLE t1 **** On Master **** SET SESSION BINLOG_FORMAT=MIXED; SET GLOBAL BINLOG_FORMAT=MIXED; @@ -63,11 +63,11 @@ a b DROP TABLE t1; SHOW BINLOG EVENTS; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4 -master-bin.000001 102 Query 1 210 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM -master-bin.000001 210 Query 1 307 use `test`; INSERT INTO t1 VALUES (1,1), (2,2) -master-bin.000001 307 Query 1 387 use `test`; TRUNCATE TABLE t1 -master-bin.000001 387 Query 1 463 use `test`; DROP TABLE t1 +master-bin.000001 4 Format_desc 1 105 Server ver: SERVER_VERSION, Binlog ver: 4 +master-bin.000001 105 Query 1 213 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM +master-bin.000001 213 Query 1 310 use `test`; INSERT INTO t1 VALUES (1,1), (2,2) +master-bin.000001 310 Query 1 390 use `test`; TRUNCATE TABLE t1 +master-bin.000001 390 Query 1 466 use `test`; DROP TABLE t1 **** On Master **** SET SESSION BINLOG_FORMAT=ROW; SET GLOBAL BINLOG_FORMAT=ROW; @@ -95,12 +95,12 @@ a b DROP TABLE t1; SHOW BINLOG EVENTS; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4 -master-bin.000001 102 Query 1 210 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM -master-bin.000001 210 Table_map 1 250 table_id: # (test.t1) -master-bin.000001 250 Write_rows 1 297 table_id: # flags: STMT_END_F -master-bin.000001 297 Query 1 377 use `test`; TRUNCATE TABLE t1 -master-bin.000001 377 Query 1 453 use `test`; DROP TABLE t1 +master-bin.000001 4 Format_desc 1 105 Server ver: SERVER_VERSION, Binlog ver: 4 +master-bin.000001 105 Query 1 213 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM +master-bin.000001 213 Table_map 1 253 table_id: # (test.t1) +master-bin.000001 253 Write_rows 1 300 table_id: # flags: STMT_END_F +master-bin.000001 300 Query 1 380 use `test`; TRUNCATE TABLE t1 +master-bin.000001 380 Query 1 456 use `test`; DROP TABLE t1 **** On Master **** SET SESSION BINLOG_FORMAT=STATEMENT; SET GLOBAL BINLOG_FORMAT=STATEMENT; @@ -128,11 +128,11 @@ a b DROP TABLE t1; SHOW BINLOG EVENTS; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4 -master-bin.000001 102 Query 1 210 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM -master-bin.000001 210 Query 1 307 use `test`; INSERT INTO t1 VALUES (1,1), (2,2) -master-bin.000001 307 Query 1 384 use `test`; DELETE FROM t1 -master-bin.000001 384 Query 1 460 use `test`; DROP TABLE t1 +master-bin.000001 4 Format_desc 1 105 Server ver: SERVER_VERSION, Binlog ver: 4 +master-bin.000001 105 Query 1 213 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM +master-bin.000001 213 Query 1 310 use `test`; INSERT INTO t1 VALUES (1,1), (2,2) +master-bin.000001 310 Query 1 387 use `test`; DELETE FROM t1 +master-bin.000001 387 Query 1 463 use `test`; DROP TABLE t1 **** On Master **** SET SESSION BINLOG_FORMAT=MIXED; SET GLOBAL BINLOG_FORMAT=MIXED; @@ -160,11 +160,11 @@ a b DROP TABLE t1; SHOW BINLOG EVENTS; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4 -master-bin.000001 102 Query 1 210 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM -master-bin.000001 210 Query 1 307 use `test`; INSERT INTO t1 VALUES (1,1), (2,2) -master-bin.000001 307 Query 1 384 use `test`; DELETE FROM t1 -master-bin.000001 384 Query 1 460 use `test`; DROP TABLE t1 +master-bin.000001 4 Format_desc 1 105 Server ver: SERVER_VERSION, Binlog ver: 4 +master-bin.000001 105 Query 1 213 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM +master-bin.000001 213 Query 1 310 use `test`; INSERT INTO t1 VALUES (1,1), (2,2) +master-bin.000001 310 Query 1 387 use `test`; DELETE FROM t1 +master-bin.000001 387 Query 1 463 use `test`; DROP TABLE t1 **** On Master **** SET SESSION BINLOG_FORMAT=ROW; SET GLOBAL BINLOG_FORMAT=ROW; @@ -193,10 +193,10 @@ a b DROP TABLE t1; SHOW BINLOG EVENTS; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4 -master-bin.000001 102 Query 1 210 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM -master-bin.000001 210 Table_map 1 250 table_id: # (test.t1) -master-bin.000001 250 Write_rows 1 297 table_id: # flags: STMT_END_F -master-bin.000001 297 Table_map 1 337 table_id: # (test.t1) -master-bin.000001 337 Delete_rows 1 384 table_id: # flags: STMT_END_F -master-bin.000001 384 Query 1 460 use `test`; DROP TABLE t1 +master-bin.000001 4 Format_desc 1 105 Server ver: SERVER_VERSION, Binlog ver: 4 +master-bin.000001 105 Query 1 213 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=MyISAM +master-bin.000001 213 Table_map 1 253 table_id: # (test.t1) +master-bin.000001 253 Write_rows 1 300 table_id: # flags: STMT_END_F +master-bin.000001 300 Table_map 1 340 table_id: # (test.t1) +master-bin.000001 340 Delete_rows 1 387 table_id: # flags: STMT_END_F +master-bin.000001 387 Query 1 463 use `test`; DROP TABLE t1 diff --git a/mysql-test/r/rpl_truncate_3innodb.result b/mysql-test/r/rpl_truncate_3innodb.result index 062c9704ae0..c7edd5014c2 100644 --- a/mysql-test/r/rpl_truncate_3innodb.result +++ b/mysql-test/r/rpl_truncate_3innodb.result @@ -31,13 +31,13 @@ a b DROP TABLE t1; SHOW BINLOG EVENTS; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4 -master-bin.000001 102 Query 1 210 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB -master-bin.000001 210 Query 1 97 use `test`; INSERT INTO t1 VALUES (1,1), (2,2) -master-bin.000001 307 Xid 1 334 COMMIT /* xid= */ -master-bin.000001 334 Query 1 80 use `test`; TRUNCATE TABLE t1 -master-bin.000001 414 Xid 1 441 COMMIT /* xid= */ -master-bin.000001 441 Query 1 517 use `test`; DROP TABLE t1 +master-bin.000001 4 Format_desc 1 105 Server ver: SERVER_VERSION, Binlog ver: 4 +master-bin.000001 105 Query 1 213 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB +master-bin.000001 213 Query 1 97 use `test`; INSERT INTO t1 VALUES (1,1), (2,2) +master-bin.000001 310 Xid 1 337 COMMIT /* xid= */ +master-bin.000001 337 Query 1 80 use `test`; TRUNCATE TABLE t1 +master-bin.000001 417 Xid 1 444 COMMIT /* xid= */ +master-bin.000001 444 Query 1 520 use `test`; DROP TABLE t1 **** On Master **** SET SESSION BINLOG_FORMAT=MIXED; SET GLOBAL BINLOG_FORMAT=MIXED; @@ -65,13 +65,13 @@ a b DROP TABLE t1; SHOW BINLOG EVENTS; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4 -master-bin.000001 102 Query 1 210 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB -master-bin.000001 210 Query 1 97 use `test`; INSERT INTO t1 VALUES (1,1), (2,2) -master-bin.000001 307 Xid 1 334 COMMIT /* xid= */ -master-bin.000001 334 Query 1 80 use `test`; TRUNCATE TABLE t1 -master-bin.000001 414 Xid 1 441 COMMIT /* xid= */ -master-bin.000001 441 Query 1 517 use `test`; DROP TABLE t1 +master-bin.000001 4 Format_desc 1 105 Server ver: SERVER_VERSION, Binlog ver: 4 +master-bin.000001 105 Query 1 213 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB +master-bin.000001 213 Query 1 97 use `test`; INSERT INTO t1 VALUES (1,1), (2,2) +master-bin.000001 310 Xid 1 337 COMMIT /* xid= */ +master-bin.000001 337 Query 1 80 use `test`; TRUNCATE TABLE t1 +master-bin.000001 417 Xid 1 444 COMMIT /* xid= */ +master-bin.000001 444 Query 1 520 use `test`; DROP TABLE t1 **** On Master **** SET SESSION BINLOG_FORMAT=ROW; SET GLOBAL BINLOG_FORMAT=ROW; @@ -99,14 +99,14 @@ a b DROP TABLE t1; SHOW BINLOG EVENTS; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4 -master-bin.000001 102 Query 1 210 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB -master-bin.000001 210 Table_map 1 40 table_id: # (test.t1) -master-bin.000001 250 Write_rows 1 87 table_id: # flags: STMT_END_F -master-bin.000001 297 Xid 1 324 COMMIT /* xid= */ -master-bin.000001 324 Query 1 80 use `test`; TRUNCATE TABLE t1 -master-bin.000001 404 Xid 1 431 COMMIT /* xid= */ -master-bin.000001 431 Query 1 507 use `test`; DROP TABLE t1 +master-bin.000001 4 Format_desc 1 105 Server ver: SERVER_VERSION, Binlog ver: 4 +master-bin.000001 105 Query 1 213 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB +master-bin.000001 213 Table_map 1 40 table_id: # (test.t1) +master-bin.000001 253 Write_rows 1 87 table_id: # flags: STMT_END_F +master-bin.000001 300 Xid 1 327 COMMIT /* xid= */ +master-bin.000001 327 Query 1 80 use `test`; TRUNCATE TABLE t1 +master-bin.000001 407 Xid 1 434 COMMIT /* xid= */ +master-bin.000001 434 Query 1 510 use `test`; DROP TABLE t1 **** On Master **** SET SESSION BINLOG_FORMAT=STATEMENT; SET GLOBAL BINLOG_FORMAT=STATEMENT; @@ -134,13 +134,13 @@ a b DROP TABLE t1; SHOW BINLOG EVENTS; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4 -master-bin.000001 102 Query 1 210 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB -master-bin.000001 210 Query 1 97 use `test`; INSERT INTO t1 VALUES (1,1), (2,2) -master-bin.000001 307 Xid 1 334 COMMIT /* xid= */ -master-bin.000001 334 Query 1 77 use `test`; DELETE FROM t1 -master-bin.000001 411 Xid 1 438 COMMIT /* xid= */ -master-bin.000001 438 Query 1 514 use `test`; DROP TABLE t1 +master-bin.000001 4 Format_desc 1 105 Server ver: SERVER_VERSION, Binlog ver: 4 +master-bin.000001 105 Query 1 213 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB +master-bin.000001 213 Query 1 97 use `test`; INSERT INTO t1 VALUES (1,1), (2,2) +master-bin.000001 310 Xid 1 337 COMMIT /* xid= */ +master-bin.000001 337 Query 1 77 use `test`; DELETE FROM t1 +master-bin.000001 414 Xid 1 441 COMMIT /* xid= */ +master-bin.000001 441 Query 1 517 use `test`; DROP TABLE t1 **** On Master **** SET SESSION BINLOG_FORMAT=MIXED; SET GLOBAL BINLOG_FORMAT=MIXED; @@ -168,13 +168,13 @@ a b DROP TABLE t1; SHOW BINLOG EVENTS; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4 -master-bin.000001 102 Query 1 210 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB -master-bin.000001 210 Query 1 97 use `test`; INSERT INTO t1 VALUES (1,1), (2,2) -master-bin.000001 307 Xid 1 334 COMMIT /* xid= */ -master-bin.000001 334 Query 1 77 use `test`; DELETE FROM t1 -master-bin.000001 411 Xid 1 438 COMMIT /* xid= */ -master-bin.000001 438 Query 1 514 use `test`; DROP TABLE t1 +master-bin.000001 4 Format_desc 1 105 Server ver: SERVER_VERSION, Binlog ver: 4 +master-bin.000001 105 Query 1 213 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB +master-bin.000001 213 Query 1 97 use `test`; INSERT INTO t1 VALUES (1,1), (2,2) +master-bin.000001 310 Xid 1 337 COMMIT /* xid= */ +master-bin.000001 337 Query 1 77 use `test`; DELETE FROM t1 +master-bin.000001 414 Xid 1 441 COMMIT /* xid= */ +master-bin.000001 441 Query 1 517 use `test`; DROP TABLE t1 **** On Master **** SET SESSION BINLOG_FORMAT=ROW; SET GLOBAL BINLOG_FORMAT=ROW; @@ -203,12 +203,12 @@ a b DROP TABLE t1; SHOW BINLOG EVENTS; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4 -master-bin.000001 102 Query 1 210 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB -master-bin.000001 210 Table_map 1 40 table_id: # (test.t1) -master-bin.000001 250 Write_rows 1 87 table_id: # flags: STMT_END_F -master-bin.000001 297 Xid 1 324 COMMIT /* xid= */ -master-bin.000001 324 Table_map 1 40 table_id: # (test.t1) -master-bin.000001 364 Delete_rows 1 87 table_id: # flags: STMT_END_F -master-bin.000001 411 Xid 1 438 COMMIT /* xid= */ -master-bin.000001 438 Query 1 514 use `test`; DROP TABLE t1 +master-bin.000001 4 Format_desc 1 105 Server ver: SERVER_VERSION, Binlog ver: 4 +master-bin.000001 105 Query 1 213 use `test`; CREATE TABLE t1 (a INT, b LONG) ENGINE=InnoDB +master-bin.000001 213 Table_map 1 40 table_id: # (test.t1) +master-bin.000001 253 Write_rows 1 87 table_id: # flags: STMT_END_F +master-bin.000001 300 Xid 1 327 COMMIT /* xid= */ +master-bin.000001 327 Table_map 1 40 table_id: # (test.t1) +master-bin.000001 367 Delete_rows 1 87 table_id: # flags: STMT_END_F +master-bin.000001 414 Xid 1 441 COMMIT /* xid= */ +master-bin.000001 441 Query 1 517 use `test`; DROP TABLE t1 diff --git a/mysql-test/t/rpl_loaddata_s.test b/mysql-test/t/rpl_loaddata_s.test index 2c94c8ef953..e9c0ce96925 100644 --- a/mysql-test/t/rpl_loaddata_s.test +++ b/mysql-test/t/rpl_loaddata_s.test @@ -22,7 +22,7 @@ sync_with_master; select count(*) from test.t1; # check that LOAD was replicated --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ -show binlog events from 102; # should be nothing +show binlog events from 105; # should be nothing # Cleanup connection master; diff --git a/mysql-test/t/rpl_log_pos.test b/mysql-test/t/rpl_log_pos.test index 61c24da514e..ffc62bb2f51 100644 --- a/mysql-test/t/rpl_log_pos.test +++ b/mysql-test/t/rpl_log_pos.test @@ -49,7 +49,7 @@ insert into t1 values (1),(2),(3); save_master_pos; connection slave; stop slave; -change master to master_log_pos=102; +change master to master_log_pos=105; start slave; sync_with_master; select * from t1 ORDER BY n; diff --git a/mysql-test/t/rpl_row_basic_11bugs-master.opt b/mysql-test/t/rpl_row_basic_11bugs-master.opt index ad03cdaa6d1..ceba85f40e5 100644 --- a/mysql-test/t/rpl_row_basic_11bugs-master.opt +++ b/mysql-test/t/rpl_row_basic_11bugs-master.opt @@ -1 +1,2 @@ ---binlog_ignore_db=test_ignore +--binlog_ignore_db=test_ignore --innodb + diff --git a/mysql-test/t/rpl_row_basic_11bugs-slave.opt b/mysql-test/t/rpl_row_basic_11bugs-slave.opt new file mode 100644 index 00000000000..627becdbfb5 --- /dev/null +++ b/mysql-test/t/rpl_row_basic_11bugs-slave.opt @@ -0,0 +1 @@ +--innodb diff --git a/mysql-test/t/rpl_row_basic_11bugs.test b/mysql-test/t/rpl_row_basic_11bugs.test index 37bfd01e260..bec3478f456 100644 --- a/mysql-test/t/rpl_row_basic_11bugs.test +++ b/mysql-test/t/rpl_row_basic_11bugs.test @@ -26,7 +26,7 @@ CREATE TABLE t2 (a INT, b INT); SHOW TABLES; INSERT INTO t2 VALUES (3,3), (4,4); --replace_regex /table_id: [0-9]+/table_id: #/ -SHOW BINLOG EVENTS FROM 102; +SHOW BINLOG EVENTS FROM 105; sync_slave_with_master; --echo **** On Slave **** SHOW DATABASES; @@ -114,3 +114,71 @@ UPDATE t1 SET a=0 WHERE b=2; SELECT HEX(a),b FROM t1; sync_slave_with_master; SELECT HEX(a),b FROM t1; + +connection master; +DROP TABLE IF EXISTS t1; +sync_slave_with_master; + +# BUG#22583: RBR between MyISAM and non-MyISAM tables containing a BIT +# field does not work + +--echo ================ Test for BUG#22583 ================ +--disable_query_log +--source include/master-slave-reset.inc +--enable_query_log + +--echo **** On Master **** +connection master; +CREATE TABLE t1_myisam (k INT, a BIT(1), b BIT(9)) ENGINE=MYISAM; +CREATE TABLE t1_innodb (k INT, a BIT(1), b BIT(9)) ENGINE=INNODB; +CREATE TABLE t2_myisam (k INT, a BIT(1) NOT NULL, b BIT(4) NOT NULL) ENGINE=MYISAM; +CREATE TABLE t2_innodb (k INT, a BIT(1) NOT NULL, b BIT(4) NOT NULL) ENGINE=INNODB; +--echo **** On Slave **** +sync_slave_with_master; +ALTER TABLE t1_myisam ENGINE=INNODB; +ALTER TABLE t1_innodb ENGINE=MYISAM; +ALTER TABLE t2_myisam ENGINE=INNODB; +ALTER TABLE t2_innodb ENGINE=MYISAM; + +--echo **** On Master **** +connection master; +INSERT INTO t1_myisam VALUES(1, b'0', 257); +INSERT INTO t1_myisam VALUES(2, b'1', 256); +INSERT INTO t1_innodb VALUES(1, b'0', 257); +INSERT INTO t1_innodb VALUES(2, b'1', 256); +SELECT k, HEX(a),HEX(b) FROM t1_myisam; +SELECT k, HEX(a),HEX(b) FROM t1_innodb; +INSERT INTO t2_myisam VALUES(1, b'0', 9); +INSERT INTO t2_myisam VALUES(2, b'1', 8); +INSERT INTO t2_innodb VALUES(1, b'0', 9); +INSERT INTO t2_innodb VALUES(2, b'1', 8); +SELECT k, HEX(a),HEX(b) FROM t2_myisam; +SELECT k, HEX(a),HEX(b) FROM t2_innodb; +--echo **** On Slave **** +sync_slave_with_master; +SELECT k, HEX(a),HEX(b) FROM t1_myisam; +SELECT k, HEX(a),HEX(b) FROM t1_innodb; +SELECT k, HEX(a),HEX(b) FROM t2_myisam; +SELECT k, HEX(a),HEX(b) FROM t2_innodb; + +--echo **** On Master **** +connection master; +UPDATE t1_myisam SET a=0 WHERE k=2; +SELECT k, HEX(a),HEX(b) FROM t1_myisam; +UPDATE t1_innodb SET a=0 WHERE k=2; +SELECT k, HEX(a),HEX(b) FROM t1_innodb; +UPDATE t2_myisam SET a=0 WHERE k=2; +SELECT k, HEX(a),HEX(b) FROM t2_myisam; +UPDATE t2_innodb SET a=0 WHERE k=2; +SELECT k, HEX(a),HEX(b) FROM t2_innodb; +--echo **** On Slave **** +sync_slave_with_master; +SELECT k, HEX(a),HEX(b) FROM t1_myisam; +SELECT k, HEX(a),HEX(b) FROM t1_innodb; +SELECT k, HEX(a),HEX(b) FROM t2_myisam; +SELECT k, HEX(a),HEX(b) FROM t2_innodb; + +--echo **** On Master **** +connection master; +DROP TABLE IF EXISTS t1_myisam, t1_innodb, t2_myisam, t2_innodb; +sync_slave_with_master; diff --git a/mysql-test/t/rpl_row_create_table.test b/mysql-test/t/rpl_row_create_table.test index 3a711e5b496..bc1752b3d5b 100644 --- a/mysql-test/t/rpl_row_create_table.test +++ b/mysql-test/t/rpl_row_create_table.test @@ -32,7 +32,7 @@ CREATE TABLE t3 (a INT, b INT) CHARSET=utf8; CREATE TABLE t4 (a INT, b INT) ENGINE=Merge CHARSET=utf8; --replace_column 1 # 4 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ ---query_vertical SHOW BINLOG EVENTS FROM 212 +--query_vertical SHOW BINLOG EVENTS FROM 215 --echo **** On Master **** --query_vertical SHOW CREATE TABLE t1 --query_vertical SHOW CREATE TABLE t2 @@ -67,7 +67,7 @@ connection master; CREATE TABLE t7 (UNIQUE(b)) SELECT a,b FROM tt3; # Shouldn't be written to the binary log --replace_regex /table_id: [0-9]+/table_id: #/ -SHOW BINLOG EVENTS FROM 1256; +SHOW BINLOG EVENTS FROM 1097; # Test that INSERT-SELECT works the same way as for SBR. CREATE TABLE t7 (a INT, b INT UNIQUE); @@ -76,7 +76,7 @@ INSERT INTO t7 SELECT a,b FROM tt3; SELECT * FROM t7 ORDER BY a,b; # Should be written to the binary log --replace_regex /table_id: [0-9]+/table_id: #/ -SHOW BINLOG EVENTS FROM 1118; +SHOW BINLOG EVENTS FROM 1097; sync_slave_with_master; SELECT * FROM t7 ORDER BY a,b; @@ -87,7 +87,7 @@ BEGIN; INSERT INTO t7 SELECT a,b FROM tt4; ROLLBACK; --replace_regex /table_id: [0-9]+/table_id: #/ -SHOW BINLOG EVENTS FROM 1314; +SHOW BINLOG EVENTS FROM 1293; SELECT * FROM t7 ORDER BY a,b; sync_slave_with_master; SELECT * FROM t7 ORDER BY a,b; @@ -102,7 +102,7 @@ CREATE TEMPORARY TABLE tt7 SELECT 1; --query_vertical SHOW CREATE TABLE t8 --query_vertical SHOW CREATE TABLE t9 --replace_regex /table_id: [0-9]+/table_id: #/ -SHOW BINLOG EVENTS FROM 1410; +SHOW BINLOG EVENTS FROM 1389; sync_slave_with_master; --echo **** On Slave **** --query_vertical SHOW CREATE TABLE t8 diff --git a/mysql-test/t/rpl_row_flsh_tbls.test b/mysql-test/t/rpl_row_flsh_tbls.test index 9e8efc1ac9c..ef8fb171989 100644 --- a/mysql-test/t/rpl_row_flsh_tbls.test +++ b/mysql-test/t/rpl_row_flsh_tbls.test @@ -1,7 +1,7 @@ # depends on the binlog output -- source include/have_binlog_format_row.inc -let $rename_event_pos= 615; +let $rename_event_pos= 618; # Bug#18326: Do not lock table for writing during prepare of statement # The use of the ps protocol causes extra table maps in the binlog, so diff --git a/mysql-test/t/rpl_row_mysqlbinlog.test b/mysql-test/t/rpl_row_mysqlbinlog.test index 3b4c8db86d8..0bef8b5a62f 100644 --- a/mysql-test/t/rpl_row_mysqlbinlog.test +++ b/mysql-test/t/rpl_row_mysqlbinlog.test @@ -167,7 +167,7 @@ connection master; select "--- Test 2 position test --" as ""; --enable_query_log --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=412 $MYSQLTEST_VARDIR/log/master-bin.000001 +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=415 $MYSQLTEST_VARDIR/log/master-bin.000001 # These are tests for remote binlog. # They should return the same as previous test. @@ -263,7 +263,7 @@ select "--- Test 6 reading stdin --" as ""; select "--- Test 7 reading stdin w/position --" as ""; --enable_query_log --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---exec $MYSQL_BINLOG --short-form --position=412 - < $MYSQLTEST_VARDIR/log/master-bin.000001 +--exec $MYSQL_BINLOG --short-form --position=415 - < $MYSQLTEST_VARDIR/log/master-bin.000001 # Bug#16217 (mysql client did not know how not switch its internal charset) --disable_query_log diff --git a/mysql-test/t/rpl_switch_stm_row_mixed.test b/mysql-test/t/rpl_switch_stm_row_mixed.test index d345b62b8eb..24e1c17f59c 100644 --- a/mysql-test/t/rpl_switch_stm_row_mixed.test +++ b/mysql-test/t/rpl_switch_stm_row_mixed.test @@ -498,7 +498,7 @@ UNLOCK TABLES; --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ -show binlog events from 102; +show binlog events from 105; sync_slave_with_master; # as we're using UUID we don't SELECT but use "diff" like in rpl_row_UUID @@ -515,7 +515,7 @@ sync_slave_with_master; connection master; --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ -show binlog events from 102; +show binlog events from 105; # Now test that mysqlbinlog works fine on a binlog generated by the # mixed mode diff --git a/mysql-test/t/user_var-binlog.test b/mysql-test/t/user_var-binlog.test index 6615e48ca42..9f1c790847d 100644 --- a/mysql-test/t/user_var-binlog.test +++ b/mysql-test/t/user_var-binlog.test @@ -15,7 +15,7 @@ SET @var2=char(ascii('a')); insert into t1 values (@var1),(@var2); --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ -show binlog events from 102; +show binlog events from 105; # more important than SHOW BINLOG EVENTS, mysqlbinlog (where we # absolutely need variables names to be quoted and strings to be # escaped). diff --git a/sql/log_event.cc b/sql/log_event.cc index 4a6346bf57c..804c29724d5 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1000,7 +1000,8 @@ Log_event* Log_event::read_log_event(const char* buf, uint event_len, ev = new Execute_load_query_log_event(buf, event_len, description_event); break; default: - DBUG_PRINT("error",("Unknown evernt code: %d",(int) buf[EVENT_TYPE_OFFSET])); + DBUG_PRINT("error",("Unknown event code: %d", + (int) buf[EVENT_TYPE_OFFSET])); ev= NULL; break; } @@ -5449,19 +5450,19 @@ int Rows_log_event::do_add_row_data(byte *const row_data, SYNOPSIS unpack_row() - rli Relay log info - table Table to unpack into - colcnt Number of columns to read from record - record Record where the data should be unpacked - row Packed row data - cols Pointer to columns data to fill in - row_end Pointer to variable that will hold the value of the - one-after-end position for the row + rli Relay log info + table Table to unpack into + colcnt Number of columns to read from record + record Record where the data should be unpacked + row_data Packed row data + cols Pointer to columns data to fill in + row_end Pointer to variable that will hold the value of the + one-after-end position for the row master_reclength - Pointer to variable that will be set to the length of the - record on the master side - rw_set Pointer to bitmap that holds either the read_set or the - write_set of the table + Pointer to variable that will be set to the length of the + record on the master side + rw_set Pointer to bitmap that holds either the read_set or the + write_set of the table DESCRIPTION @@ -5484,62 +5485,78 @@ int Rows_log_event::do_add_row_data(byte *const row_data, static int unpack_row(RELAY_LOG_INFO *rli, TABLE *table, uint const colcnt, byte *record, - char const *row, MY_BITMAP const *cols, - char const **row_end, ulong *master_reclength, + char const *const row_data, MY_BITMAP const *cols, + char const **const row_end, ulong *const master_reclength, MY_BITMAP* const rw_set, Log_event_type const event_type) { - DBUG_ASSERT(record && row); + DBUG_ENTER("unpack_row"); + DBUG_ASSERT(record && row_data); my_ptrdiff_t const offset= record - (byte*) table->record[0]; - my_size_t master_null_bytes= table->s->null_bytes; - - if (colcnt != table->s->fields) - { - Field **fptr= &table->field[colcnt-1]; - do - master_null_bytes= (*fptr)->last_null_byte(); - while (master_null_bytes == Field::LAST_NULL_BYTE_UNDEF && - fptr-- > table->field); - - /* - If master_null_bytes is LAST_NULL_BYTE_UNDEF (0) at this time, - there were no nullable fields nor BIT fields at all in the - columns that are common to the master and the slave. In that - case, there is only one null byte holding the X bit. - - OBSERVE! There might still be nullable columns following the - common columns, so table->s->null_bytes might be greater than 1. - */ - if (master_null_bytes == Field::LAST_NULL_BYTE_UNDEF) - master_null_bytes= 1; - } - - DBUG_ASSERT(master_null_bytes <= table->s->null_bytes); - memcpy(record, row, master_null_bytes); // [1] + my_size_t const master_null_byte_count= (bitmap_bits_set(cols) + 7) / 8; int error= 0; - bitmap_set_all(rw_set); + char const *null_ptr= row_data; + char const *pack_ptr= row_data + master_null_byte_count; + + bitmap_clear_all(rw_set); + + memcpy(record, table->s->default_values, table->s->null_bytes); Field **const begin_ptr = table->field; Field **field_ptr; - char const *ptr= row + master_null_bytes; Field **const end_ptr= begin_ptr + colcnt; + + DBUG_ASSERT(null_ptr < row_data + master_null_byte_count); + + // Mask to mask out the correct bit among the null bits + unsigned int null_mask= 1U; + // The "current" null bits + unsigned int null_bits= *null_ptr++; for (field_ptr= begin_ptr ; field_ptr < end_ptr ; ++field_ptr) { Field *const f= *field_ptr; if (bitmap_is_set(cols, field_ptr - begin_ptr)) { - f->move_field_offset(offset); - ptr= f->unpack(f->ptr, ptr); - f->move_field_offset(-offset); + if ((null_mask & 0xFF) == 0) + { + DBUG_ASSERT(null_ptr < row_data + master_null_byte_count); + null_mask= 1U; + null_bits= *null_ptr++; + } + + DBUG_ASSERT(null_mask & 0xFF); // One of the 8 LSB should be set + + /* Field...::unpack() cannot return 0 */ - DBUG_ASSERT(ptr != NULL); + DBUG_ASSERT(pack_ptr != NULL); + + if ((null_bits & null_mask) && f->maybe_null()) + f->set_null(offset); + else + { + f->set_notnull(offset); + + /* + We only unpack the field if it was non-null + */ + f->move_field_offset(offset); + pack_ptr= f->unpack(f->ptr, pack_ptr); + f->move_field_offset(-offset); + } + + bitmap_set_bit(rw_set, field_ptr - begin_ptr); + null_mask <<= 1; } - else - bitmap_clear_bit(rw_set, field_ptr - begin_ptr); } - *row_end = ptr; + /* + We should now have read all the null bytes, otherwise something is + really wrong. + */ + DBUG_ASSERT(null_ptr == row_data + master_null_byte_count); + + *row_end = pack_ptr; if (master_reclength) { if (*field_ptr) @@ -5563,10 +5580,6 @@ unpack_row(RELAY_LOG_INFO *rli, { uint32 const mask= NOT_NULL_FLAG | NO_DEFAULT_VALUE_FLAG; - DBUG_PRINT("debug", ("flags = 0x%x, mask = 0x%x, flags & mask = 0x%x", - (*field_ptr)->flags, mask, - (*field_ptr)->flags & mask)); - if (event_type == WRITE_ROWS_EVENT && ((*field_ptr)->flags & mask) == mask) { @@ -5581,7 +5594,7 @@ unpack_row(RELAY_LOG_INFO *rli, (*field_ptr)->set_default(); } - return error; + DBUG_RETURN(error); } int Rows_log_event::exec_event(st_relay_log_info *rli) @@ -6740,6 +6753,8 @@ static int find_and_fetch_row(TABLE *table, byte *key) DBUG_ASSERT(table->in_use != NULL); + DBUG_DUMP("record[0]", table->record[0], table->s->reclength); + if ((table->file->ha_table_flags() & HA_PRIMARY_KEY_REQUIRED_FOR_POSITION) && table->s->primary_key < MAX_KEY) { @@ -6842,16 +6857,18 @@ static int find_and_fetch_row(TABLE *table, byte *key) /* Continue until we find the right record or have made a full loop */ do { + error= table->file->rnd_next(table->record[1]); + /* - We need to set the null bytes to ensure that the filler bit - are all set when returning. There are storage engines that - just set the necessary bits on the bytes and don't set the - filler bits correctly. + Patching the returned record since some storage engines do + not set the filler bits correctly. */ my_ptrdiff_t const pos= table->s->null_bytes > 0 ? table->s->null_bytes - 1 : 0; - table->record[1][pos]= 0xFF; - error= table->file->rnd_next(table->record[1]); + table->record[1][pos]|= 256U - (1U << table->s->last_null_bit_pos); + + DBUG_DUMP("record[0]", table->record[0], table->s->reclength); + DBUG_DUMP("record[1]", table->record[1], table->s->reclength); switch (error) { diff --git a/sql/log_event.h b/sql/log_event.h index 81ce2f18b4d..93546ddba8a 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -442,10 +442,23 @@ enum Log_event_type XID_EVENT= 16, BEGIN_LOAD_QUERY_EVENT= 17, EXECUTE_LOAD_QUERY_EVENT= 18, + TABLE_MAP_EVENT = 19, - WRITE_ROWS_EVENT = 20, - UPDATE_ROWS_EVENT = 21, - DELETE_ROWS_EVENT = 22, + + /* + These event numbers were used for 5.1.0 to 5.1.15 and are + therefore obsolete. + */ + PRE_GA_WRITE_ROWS_EVENT = 20, + PRE_GA_UPDATE_ROWS_EVENT = 21, + PRE_GA_DELETE_ROWS_EVENT = 22, + + /* + These event numbers are used from 5.1.16 and forward + */ + WRITE_ROWS_EVENT = 23, + UPDATE_ROWS_EVENT = 24, + DELETE_ROWS_EVENT = 25, /* Add new events here - right above this comment! diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 3fd0e621422..00a68a3d30e 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -2527,30 +2527,113 @@ my_size_t THD::max_row_length_blob(TABLE *table, const byte *data) const } -my_size_t THD::pack_row(TABLE *table, MY_BITMAP const* cols, byte *row_data, - const byte *record) const +/* + Pack a record of data for a table into a format suitable for + transfer via the binary log. + + SYNOPSIS + THD::pack_row() + table Table describing the format of the record + cols Bitmap with a set bit for each column that should be + stored in the row + row_data Pointer to memory where row will be written + record Pointer to record that should be packed. It is assumed + that the pointer refers to either record[0] or + record[1], but no such check is made since the code does + not rely on that. + + DESCRIPTION + + The format for a row in transfer with N fields is the following: + + ceil(N/8) null bytes: + One null bit for every column *regardless of whether it can be + null or not*. This simplifies the decoding. Observe that the + number of null bits is equal to the number of set bits in the + 'cols' bitmap. The number of null bytes is the smallest number + of bytes necessary to store the null bits. + + Padding bits are 1. + + N packets: + Each field is stored in packed format. + + + RETURN VALUE + + The number of bytes written at 'row_data'. + */ +my_size_t +THD::pack_row(TABLE *table, MY_BITMAP const* cols, + byte *const row_data, const byte *record) const { Field **p_field= table->field, *field; - int n_null_bytes= table->s->null_bytes; - byte *ptr; - uint i; + int const null_byte_count= (bitmap_bits_set(cols) + 7) / 8; + byte *pack_ptr = row_data + null_byte_count; + byte *null_ptr = row_data; my_ptrdiff_t const rec_offset= record - table->record[0]; my_ptrdiff_t const def_offset= table->s->default_values - table->record[0]; - memcpy(row_data, record, n_null_bytes); - ptr= row_data+n_null_bytes; - for (i= 0 ; (field= *p_field) ; i++, p_field++) + /* + We write the null bits and the packed records using one pass + through all the fields. The null bytes are written little-endian, + i.e., the first fields are in the first byte. + */ + unsigned int null_bits= (1U << 8) - 1; + // Mask to mask out the correct but among the null bits + unsigned int null_mask= 1U; + for ( ; (field= *p_field) ; p_field++) { - if (bitmap_is_set(cols,i)) + DBUG_PRINT("debug", ("null_mask=%d; null_ptr=%p; row_data=%p; null_byte_count=%d", + null_mask, null_ptr, row_data, null_byte_count)); + if (bitmap_is_set(cols, p_field - table->field)) { - my_ptrdiff_t const offset= - field->is_null(rec_offset) ? def_offset : rec_offset; - field->move_field_offset(offset); - ptr= (byte*)field->pack((char *) ptr, field->ptr); - field->move_field_offset(-offset); + my_ptrdiff_t offset; + if (field->is_null(rec_offset)) + { + offset= def_offset; + null_bits |= null_mask; + } + else + { + offset= rec_offset; + null_bits &= ~null_mask; + + /* + We only store the data of the field if it is non-null + */ + field->move_field_offset(offset); + pack_ptr= (byte*)field->pack((char *) pack_ptr, field->ptr); + field->move_field_offset(-offset); + } + + null_mask <<= 1; + if ((null_mask & 0xFF) == 0) + { + DBUG_ASSERT(null_ptr < row_data + null_byte_count); + null_mask = 1U; + *null_ptr++ = null_bits; + null_bits= (1U << 8) - 1; + } } } - return (static_cast(ptr - row_data)); + + /* + Write the last (partial) byte, if there is one + */ + if ((null_mask & 0xFF) > 1) + { + DBUG_ASSERT(null_ptr < row_data + null_byte_count); + *null_ptr++ = null_bits; + } + + /* + The null pointer should now point to the first byte of the + packed data. If it doesn't, something is very wrong. + */ + DBUG_ASSERT(null_ptr == row_data + null_byte_count); + + return static_cast(pack_ptr - row_data); } From 844131937fc50c577f9147e1cf57523b43737de0 Mon Sep 17 00:00:00 2001 From: "mats@romeo.(none)" <> Date: Wed, 7 Mar 2007 11:54:32 +0100 Subject: [PATCH 05/22] BUG#22583 (RBR between MyISAM and non-MyISAM tables does not work): Post-merge fixes. --- mysql-test/extra/binlog_tests/binlog.test | 8 +- .../binlog_tests/binlog_insert_delayed.test | 2 +- .../binlog_tests/ctype_cp932_binlog.test | 2 +- .../extra/binlog_tests/ctype_ucs_binlog.test | 2 +- .../mix_innodb_myisam_binlog.test | 28 +++--- mysql-test/r/binlog_row_binlog.result | 10 +- mysql-test/r/binlog_row_ctype_ucs.result | 6 +- mysql-test/r/binlog_row_insert_select.result | 8 +- .../r/binlog_row_mix_innodb_myisam.result | 28 +++--- mysql-test/r/ctype_cp932_binlog_row.result | 2 +- .../r/flush_block_commit_notembedded.result | 4 +- mysql-test/r/rpl_row_create_table.result | 94 +++++++++---------- mysql-test/r/rpl_row_delayed_ins.result | 10 +- .../t/binlog_row_mix_innodb_myisam.test | 2 +- mysql-test/t/rpl_row_create_table.test | 13 ++- sql/log_event.cc | 37 ++++---- 16 files changed, 135 insertions(+), 121 deletions(-) diff --git a/mysql-test/extra/binlog_tests/binlog.test b/mysql-test/extra/binlog_tests/binlog.test index 48d9b859c26..a1f34606fe1 100644 --- a/mysql-test/extra/binlog_tests/binlog.test +++ b/mysql-test/extra/binlog_tests/binlog.test @@ -22,7 +22,7 @@ commit; # first COMMIT must be Query_log_event, second - Xid_log_event --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// -show binlog events from 102; +show binlog events from 105; drop table t1,t2; # @@ -44,10 +44,10 @@ commit; drop table t1; --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// -show binlog events in 'master-bin.000001' from 102; +show binlog events in 'master-bin.000001' from 105; --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// -show binlog events in 'master-bin.000002' from 102; +show binlog events in 'master-bin.000002' from 105; # Test of a too big SET INSERT_ID: see if the truncated value goes # into binlog (right), or the too big value (wrong); we look at the @@ -69,7 +69,7 @@ create table if not exists t3 like tt1; --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// -show binlog events from 102; +show binlog events from 105; drop table t1,t2,t3,tt1; -- source extra/binlog_tests/binlog_insert_delayed.test diff --git a/mysql-test/extra/binlog_tests/binlog_insert_delayed.test b/mysql-test/extra/binlog_tests/binlog_insert_delayed.test index 4da883b9e60..a2ccb34ee07 100644 --- a/mysql-test/extra/binlog_tests/binlog_insert_delayed.test +++ b/mysql-test/extra/binlog_tests/binlog_insert_delayed.test @@ -25,7 +25,7 @@ inc $count; # the way --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ -show binlog events from 102; +show binlog events from 105; insert delayed into t1 values (null),(null),(null),(null); inc $count; inc $count; inc $count; inc $count; diff --git a/mysql-test/extra/binlog_tests/ctype_cp932_binlog.test b/mysql-test/extra/binlog_tests/ctype_cp932_binlog.test index 5e93d6e126e..5c07b3b8f89 100644 --- a/mysql-test/extra/binlog_tests/ctype_cp932_binlog.test +++ b/mysql-test/extra/binlog_tests/ctype_cp932_binlog.test @@ -28,7 +28,7 @@ SET @var1= x'8300'; EXECUTE stmt1 USING @var1; --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ -SHOW BINLOG EVENTS FROM 102; +SHOW BINLOG EVENTS FROM 105; SELECT HEX(f1) FROM t1; DROP table t1; # end test for bug#11338 diff --git a/mysql-test/extra/binlog_tests/ctype_ucs_binlog.test b/mysql-test/extra/binlog_tests/ctype_ucs_binlog.test index fcf39e38163..3b1ea3b959b 100644 --- a/mysql-test/extra/binlog_tests/ctype_ucs_binlog.test +++ b/mysql-test/extra/binlog_tests/ctype_ucs_binlog.test @@ -10,7 +10,7 @@ set @v=convert('abc' using ucs2); reset master; insert into t2 values (@v); --replace_regex /table_id: [0-9]+/table_id: #/ -show binlog events from 102; +show binlog events from 105; # more important than SHOW BINLOG EVENTS, mysqlbinlog (where we # absolutely need variables names to be quoted and strings to be # escaped). diff --git a/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test b/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test index bdc49573ae5..2c6f66de8bc 100644 --- a/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test +++ b/mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test @@ -31,7 +31,7 @@ commit; --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// -show binlog events from 102; +show binlog events from 105; delete from t1; delete from t2; @@ -45,7 +45,7 @@ rollback; --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// -show binlog events from 102; +show binlog events from 105; delete from t1; delete from t2; @@ -61,7 +61,7 @@ commit; --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// -show binlog events from 102; +show binlog events from 105; delete from t1; delete from t2; @@ -79,7 +79,7 @@ select a from t1 order by a; # check that savepoints work :) --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// -show binlog events from 102; +show binlog events from 105; # and when ROLLBACK is not explicit? delete from t1; @@ -101,7 +101,7 @@ connection con2; select get_lock("a",10); --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// -show binlog events from 102; +show binlog events from 105; # and when not in a transact1on? delete from t1; @@ -113,7 +113,7 @@ insert into t2 select * from t1; --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// -show binlog events from 102; +show binlog events from 105; # Check that when the query updat1ng the MyISAM table is the first in the # transaction, we log it immediately. @@ -126,13 +126,13 @@ begin; insert into t2 select * from t1; --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// -show binlog events from 102; +show binlog events from 105; insert into t1 values(11); commit; --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// -show binlog events from 102; +show binlog events from 105; # Check that things work like before this BEGIN/ROLLBACK code was added, @@ -151,7 +151,7 @@ commit; --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// -show binlog events from 102; +show binlog events from 105; delete from t1; delete from t2; @@ -164,7 +164,7 @@ rollback; --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// -show binlog events from 102; +show binlog events from 105; delete from t1; delete from t2; @@ -180,7 +180,7 @@ commit; --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// -show binlog events from 102; +show binlog events from 105; delete from t1; delete from t2; @@ -198,7 +198,7 @@ select a from t1 order by a; # check that savepoints work :) --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// -show binlog events from 102; +show binlog events from 105; # Test for BUG#5714, where a MyISAM update in the transaction used to # release row-level locks in InnoDB @@ -259,7 +259,7 @@ connection con3; select get_lock("lock1",60); --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// -show binlog events from 102; +show binlog events from 105; do release_lock("lock1"); drop table t0,t2; @@ -326,7 +326,7 @@ SELECT * from t2; DROP TABLE t1,t2; --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ /\/\* xid=.* \*\//\/* xid= *\// -show binlog events from 102; +show binlog events from 105; # Test for BUG#16559 (ROLLBACK should always have a zero error code in # binlog). Has to be here and not earlier, as the SELECTs influence diff --git a/mysql-test/r/binlog_row_binlog.result b/mysql-test/r/binlog_row_binlog.result index aee270bd7f6..4a0824e0aa3 100644 --- a/mysql-test/r/binlog_row_binlog.result +++ b/mysql-test/r/binlog_row_binlog.result @@ -8,7 +8,7 @@ commit; begin; insert t2 values (5); commit; -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; create table t1 (a int) engine=innodb master-bin.000001 # Query 1 # use `test`; create table t2 (a int) engine=innodb @@ -26,7 +26,7 @@ create table t1 (n int) engine=innodb; begin; commit; drop table t1; -show binlog events in 'master-bin.000001' from 102; +show binlog events in 'master-bin.000001' from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; create table t1 (n int) engine=innodb master-bin.000001 # Query 1 # use `test`; BEGIN @@ -232,7 +232,7 @@ master-bin.000001 # Table_map 1 # table_id: # (test.t1) master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Xid 1 # COMMIT /* xid= */ master-bin.000001 # Rotate 1 # master-bin.000002;pos=4 -show binlog events in 'master-bin.000002' from 102; +show binlog events in 'master-bin.000002' from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000002 # Query 1 # use `test`; drop table t1 reset master; @@ -249,7 +249,7 @@ create table t1 (a int); create table if not exists t2 select * from t1; create temporary table tt1 (a int); create table if not exists t3 like tt1; -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; create table t1 (id tinyint auto_increment primary key) master-bin.000001 # Table_map 1 # table_id: # (test.t1) @@ -268,7 +268,7 @@ set @@session.auto_increment_increment=1, @@session.auto_increment_offset=1; insert delayed into t1 values (207); insert delayed into t1 values (null); insert delayed into t1 values (300); -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; create table t1 (id tinyint auto_increment primary key) master-bin.000001 # Table_map 1 # table_id: # (test.t1) diff --git a/mysql-test/r/binlog_row_ctype_ucs.result b/mysql-test/r/binlog_row_ctype_ucs.result index 4eeff79e13a..69fc0ab5781 100644 --- a/mysql-test/r/binlog_row_ctype_ucs.result +++ b/mysql-test/r/binlog_row_ctype_ucs.result @@ -3,10 +3,10 @@ create table t2 (c char(30)) charset=ucs2; set @v=convert('abc' using ucs2); reset master; insert into t2 values (@v); -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 102 Table_map 1 141 table_id: # (test.t2) -master-bin.000001 141 Write_rows 1 231 table_id: # flags: STMT_END_F +master-bin.000001 105 Table_map 1 144 table_id: # (test.t2) +master-bin.000001 144 Write_rows 1 234 table_id: # flags: STMT_END_F flush logs; /*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; diff --git a/mysql-test/r/binlog_row_insert_select.result b/mysql-test/r/binlog_row_insert_select.result index 14cef6709b6..12a9f05d84e 100644 --- a/mysql-test/r/binlog_row_insert_select.result +++ b/mysql-test/r/binlog_row_insert_select.result @@ -8,9 +8,9 @@ insert into t1 select * from t2; ERROR 23000: Duplicate entry '2' for key 'a' show binlog events; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 102 Server ver: VERSION, Binlog ver: 4 -master-bin.000001 102 Table_map 1 141 table_id: # (test.t1) -master-bin.000001 141 Write_rows 1 175 table_id: # flags: STMT_END_F +master-bin.000001 4 Format_desc 1 105 Server ver: VERSION, Binlog ver: 4 +master-bin.000001 105 Table_map 1 144 table_id: # (test.t1) +master-bin.000001 144 Write_rows 1 178 table_id: # flags: STMT_END_F select * from t1; a 1 @@ -23,5 +23,5 @@ create table t2(unique(a)) select a from t1; ERROR 23000: Duplicate entry '1' for key 'a' show binlog events; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 102 Server ver: VERSION, Binlog ver: 4 +master-bin.000001 4 Format_desc 1 105 Server ver: VERSION, Binlog ver: 4 drop table t1; diff --git a/mysql-test/r/binlog_row_mix_innodb_myisam.result b/mysql-test/r/binlog_row_mix_innodb_myisam.result index 185ca33d4db..3ac5a63b93b 100644 --- a/mysql-test/r/binlog_row_mix_innodb_myisam.result +++ b/mysql-test/r/binlog_row_mix_innodb_myisam.result @@ -6,7 +6,7 @@ begin; insert into t1 values(1); insert into t2 select * from t1; commit; -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; BEGIN master-bin.000001 # Table_map 1 # table_id: # (test.t1) @@ -23,7 +23,7 @@ insert into t2 select * from t1; rollback; Warnings: Warning 1196 Some non-transactional changed tables couldn't be rolled back -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; BEGIN master-bin.000001 # Table_map 1 # table_id: # (test.t1) @@ -43,7 +43,7 @@ rollback to savepoint my_savepoint; Warnings: Warning 1196 Some non-transactional changed tables couldn't be rolled back commit; -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; BEGIN master-bin.000001 # Table_map 1 # table_id: # (test.t1) @@ -72,7 +72,7 @@ select a from t1 order by a; a 5 7 -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; BEGIN master-bin.000001 # Table_map 1 # table_id: # (test.t1) @@ -98,7 +98,7 @@ insert into t2 select * from t1; select get_lock("a",10); get_lock("a",10) 1 -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; BEGIN master-bin.000001 # Table_map 1 # table_id: # (test.t1) @@ -111,7 +111,7 @@ delete from t2; reset master; insert into t1 values(9); insert into t2 select * from t1; -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Table_map 1 # table_id: # (test.t1) master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F @@ -124,7 +124,7 @@ reset master; insert into t1 values(10); begin; insert into t2 select * from t1; -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Table_map 1 # table_id: # (test.t1) master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F @@ -133,7 +133,7 @@ master-bin.000001 # Table_map 1 # table_id: # (test.t2) master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F insert into t1 values(11); commit; -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Table_map 1 # table_id: # (test.t1) master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F @@ -152,7 +152,7 @@ begin; insert into t1 values(12); insert into t2 select * from t1; commit; -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; BEGIN master-bin.000001 # Table_map 1 # table_id: # (test.t1) @@ -167,7 +167,7 @@ begin; insert into t1 values(13); insert into t2 select * from t1; rollback; -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info delete from t1; delete from t2; @@ -179,7 +179,7 @@ insert into t1 values(15); insert into t2 select * from t1; rollback to savepoint my_savepoint; commit; -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; BEGIN master-bin.000001 # Table_map 1 # table_id: # (test.t1) @@ -200,7 +200,7 @@ select a from t1 order by a; a 16 18 -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; BEGIN master-bin.000001 # Table_map 1 # table_id: # (test.t1) @@ -252,7 +252,7 @@ insert into t2 values (3); select get_lock("lock1",60); get_lock("lock1",60) 1 -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; BEGIN master-bin.000001 # Table_map 1 # table_id: # (test.t1) @@ -355,7 +355,7 @@ SELECT * from t2; a b 100 100 DROP TABLE t1,t2; -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Table_map 1 # table_id: # (test.t1) master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F diff --git a/mysql-test/r/ctype_cp932_binlog_row.result b/mysql-test/r/ctype_cp932_binlog_row.result index f1a64241fbb..9292be362af 100644 --- a/mysql-test/r/ctype_cp932_binlog_row.result +++ b/mysql-test/r/ctype_cp932_binlog_row.result @@ -6,7 +6,7 @@ CREATE TABLE t1(f1 blob); PREPARE stmt1 FROM 'INSERT INTO t1 VALUES(?)'; SET @var1= x'8300'; EXECUTE stmt1 USING @var1; -SHOW BINLOG EVENTS FROM 102; +SHOW BINLOG EVENTS FROM 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; CREATE TABLE t1(f1 blob) master-bin.000001 # Table_map 1 # table_id: # (test.t1) diff --git a/mysql-test/r/flush_block_commit_notembedded.result b/mysql-test/r/flush_block_commit_notembedded.result index 1d045b21763..e49e8817967 100644 --- a/mysql-test/r/flush_block_commit_notembedded.result +++ b/mysql-test/r/flush_block_commit_notembedded.result @@ -5,11 +5,11 @@ insert t1 values (1); flush tables with read lock; show master status; File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 102 +master-bin.000001 105 commit; show master status; File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000001 102 +master-bin.000001 105 unlock tables; drop table t1; set autocommit=1; diff --git a/mysql-test/r/rpl_row_create_table.result b/mysql-test/r/rpl_row_create_table.result index 7e03a75affd..d89afb3e5f3 100644 --- a/mysql-test/r/rpl_row_create_table.result +++ b/mysql-test/r/rpl_row_create_table.result @@ -13,25 +13,25 @@ Log_name # Pos 215 Event_type Query Server_id # -End_log_pos # +End_log_pos 308 Info use `test`; CREATE TABLE t1 (a INT, b INT) Log_name # Pos 308 Event_type Query Server_id # -End_log_pos # +End_log_pos 414 Info use `test`; CREATE TABLE t2 (a INT, b INT) ENGINE=Merge Log_name # Pos 414 Event_type Query Server_id # -End_log_pos # +End_log_pos 520 Info use `test`; CREATE TABLE t3 (a INT, b INT) CHARSET=utf8 Log_name # Pos 520 Event_type Query Server_id # -End_log_pos # +End_log_pos 639 Info use `test`; CREATE TABLE t4 (a INT, b INT) ENGINE=Merge CHARSET=utf8 **** On Master **** SHOW CREATE TABLE t1; @@ -127,7 +127,7 @@ NULL 5 10 NULL 6 12 CREATE TABLE t7 (UNIQUE(b)) SELECT a,b FROM tt3; ERROR 23000: Duplicate entry '2' for key 'b' -SHOW BINLOG EVENTS FROM 959; +SHOW BINLOG EVENTS FROM 1097; Log_name Pos Event_type Server_id End_log_pos Info CREATE TABLE t7 (a INT, b INT UNIQUE); INSERT INTO t7 SELECT a,b FROM tt3; @@ -139,9 +139,9 @@ a b 3 6 SHOW BINLOG EVENTS FROM 1097; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 1097 Query 1 1197 use `test`; CREATE TABLE t7 (a INT, b INT UNIQUE) -master-bin.000001 1197 Table_map 1 1237 table_id: # (test.t7) -master-bin.000001 1237 Write_rows 1 1293 table_id: # flags: STMT_END_F +# 1097 Query # 1197 use `test`; CREATE TABLE t7 (a INT, b INT UNIQUE) +# 1197 Table_map # 1237 table_id: # (test.t7) +# 1237 Write_rows # 1293 table_id: # flags: STMT_END_F SELECT * FROM t7 ORDER BY a,b; a b 1 2 @@ -156,8 +156,8 @@ Warnings: Warning 1196 Some non-transactional changed tables couldn't be rolled back SHOW BINLOG EVENTS FROM 1293; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 1293 Table_map 1 1333 table_id: # (test.t7) -master-bin.000001 1333 Write_rows 1 1389 table_id: # flags: STMT_END_F +# 1293 Table_map # 1333 table_id: # (test.t7) +# 1333 Write_rows # 1389 table_id: # flags: STMT_END_F SELECT * FROM t7 ORDER BY a,b; a b 1 2 @@ -194,8 +194,8 @@ Create Table CREATE TABLE `t9` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 SHOW BINLOG EVENTS FROM 1389; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 1389 Query 1 1475 use `test`; CREATE TABLE t8 LIKE t4 -master-bin.000001 1475 Query 1 1614 use `test`; CREATE TABLE `t9` ( +# 1389 Query # 1475 use `test`; CREATE TABLE t8 LIKE t4 +# 1475 Query # 1614 use `test`; CREATE TABLE `t9` ( `a` int(11) DEFAULT NULL, `b` int(11) DEFAULT NULL ) @@ -274,33 +274,33 @@ a 3 SHOW BINLOG EVENTS; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 102 Server ver: #, Binlog ver: # -master-bin.000001 102 Query 1 188 use `test`; CREATE TABLE t1 (a INT) -master-bin.000001 188 Table_map 1 227 table_id: # (test.t1) -master-bin.000001 227 Write_rows 1 271 table_id: # flags: STMT_END_F -master-bin.000001 271 Query 1 339 use `test`; BEGIN -master-bin.000001 339 Query 1 125 use `test`; CREATE TABLE `t2` ( +# 4 Format_desc # 105 Server ver: #, Binlog ver: # +# 105 Query # 191 use `test`; CREATE TABLE t1 (a INT) +# 191 Table_map # 230 table_id: # (test.t1) +# 230 Write_rows # 274 table_id: # flags: STMT_END_F +# 274 Query # 342 use `test`; BEGIN +# 342 Query # 125 use `test`; CREATE TABLE `t2` ( `a` int(11) DEFAULT NULL ) ENGINE=InnoDB -master-bin.000001 464 Table_map 1 164 table_id: # (test.t2) -master-bin.000001 503 Write_rows 1 208 table_id: # flags: STMT_END_F -master-bin.000001 547 Xid 1 574 COMMIT /* XID */ -master-bin.000001 574 Query 1 642 use `test`; BEGIN -master-bin.000001 642 Query 1 125 use `test`; CREATE TABLE `t3` ( +# 467 Table_map # 164 table_id: # (test.t2) +# 506 Write_rows # 208 table_id: # flags: STMT_END_F +# 550 Xid # 577 COMMIT /* XID */ +# 577 Query # 645 use `test`; BEGIN +# 645 Query # 125 use `test`; CREATE TABLE `t3` ( `a` int(11) DEFAULT NULL ) ENGINE=InnoDB -master-bin.000001 767 Table_map 1 164 table_id: # (test.t3) -master-bin.000001 806 Write_rows 1 208 table_id: # flags: STMT_END_F -master-bin.000001 850 Xid 1 877 COMMIT /* XID */ -master-bin.000001 877 Query 1 945 use `test`; BEGIN -master-bin.000001 945 Query 1 125 use `test`; CREATE TABLE `t4` ( +# 770 Table_map # 164 table_id: # (test.t3) +# 809 Write_rows # 208 table_id: # flags: STMT_END_F +# 853 Xid # 880 COMMIT /* XID */ +# 880 Query # 948 use `test`; BEGIN +# 948 Query # 125 use `test`; CREATE TABLE `t4` ( `a` int(11) DEFAULT NULL ) ENGINE=InnoDB -master-bin.000001 1070 Table_map 1 164 table_id: # (test.t4) -master-bin.000001 1109 Write_rows 1 208 table_id: # flags: STMT_END_F -master-bin.000001 1153 Xid 1 1180 COMMIT /* XID */ -master-bin.000001 1180 Table_map 1 1219 table_id: # (test.t1) -master-bin.000001 1219 Write_rows 1 1263 table_id: # flags: STMT_END_F +# 1073 Table_map # 164 table_id: # (test.t4) +# 1112 Write_rows # 208 table_id: # flags: STMT_END_F +# 1156 Xid # 1183 COMMIT /* XID */ +# 1183 Table_map # 1222 table_id: # (test.t1) +# 1222 Write_rows # 1266 table_id: # flags: STMT_END_F SHOW TABLES; Tables_in_test t1 @@ -365,17 +365,17 @@ a 9 SHOW BINLOG EVENTS; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 102 Server ver: #, Binlog ver: # -master-bin.000001 102 Query 1 188 use `test`; CREATE TABLE t1 (a INT) -master-bin.000001 188 Table_map 1 227 table_id: # (test.t1) -master-bin.000001 227 Write_rows 1 271 table_id: # flags: STMT_END_F -master-bin.000001 271 Query 1 371 use `test`; CREATE TABLE t2 (a INT) ENGINE=INNODB -master-bin.000001 371 Query 1 439 use `test`; BEGIN -master-bin.000001 439 Table_map 1 39 table_id: # (test.t2) -master-bin.000001 478 Write_rows 1 83 table_id: # flags: STMT_END_F -master-bin.000001 522 Table_map 1 122 table_id: # (test.t2) -master-bin.000001 561 Write_rows 1 161 table_id: # flags: STMT_END_F -master-bin.000001 600 Xid 1 627 COMMIT /* XID */ +# 4 Format_desc # 105 Server ver: #, Binlog ver: # +# 105 Query # 191 use `test`; CREATE TABLE t1 (a INT) +# 191 Table_map # 230 table_id: # (test.t1) +# 230 Write_rows # 274 table_id: # flags: STMT_END_F +# 274 Query # 374 use `test`; CREATE TABLE t2 (a INT) ENGINE=INNODB +# 374 Query # 442 use `test`; BEGIN +# 442 Table_map # 39 table_id: # (test.t2) +# 481 Write_rows # 83 table_id: # flags: STMT_END_F +# 525 Table_map # 122 table_id: # (test.t2) +# 564 Write_rows # 161 table_id: # flags: STMT_END_F +# 603 Xid # 630 COMMIT /* XID */ SELECT * FROM t2 ORDER BY a; a 1 @@ -394,10 +394,10 @@ INSERT INTO t2 SELECT a+2 FROM tt2; ROLLBACK; SELECT * FROM t2 ORDER BY a; a -SHOW BINLOG EVENTS FROM 627; +SHOW BINLOG EVENTS FROM 630; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 627 Query 1 80 use `test`; TRUNCATE TABLE t2 -master-bin.000001 707 Xid 1 734 COMMIT /* XID */ +# 630 Query # 80 use `test`; TRUNCATE TABLE t2 +# 710 Xid # 737 COMMIT /* XID */ SELECT * FROM t2 ORDER BY a; a DROP TABLE t1,t2; diff --git a/mysql-test/r/rpl_row_delayed_ins.result b/mysql-test/r/rpl_row_delayed_ins.result index cad38f77d52..e07a06f42fa 100644 --- a/mysql-test/r/rpl_row_delayed_ins.result +++ b/mysql-test/r/rpl_row_delayed_ins.result @@ -5,7 +5,9 @@ reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; create table t1(a int not null primary key) engine=myisam; -insert delayed into t1 values (1),(2),(3); +insert delayed into t1 values (1); +insert delayed into t1 values (2); +insert delayed into t1 values (3); flush tables; SELECT * FROM t1 ORDER BY a; a @@ -19,8 +21,10 @@ master-bin.000001 105 Query 1 225 use `test`; create table t1(a int not null pri master-bin.000001 225 Table_map 1 264 table_id: # (test.t1) master-bin.000001 264 Write_rows 1 298 table_id: # flags: STMT_END_F master-bin.000001 298 Table_map 1 337 table_id: # (test.t1) -master-bin.000001 337 Write_rows 1 376 table_id: # flags: STMT_END_F -master-bin.000001 376 Query 1 451 use `test`; flush tables +master-bin.000001 337 Write_rows 1 371 table_id: # flags: STMT_END_F +master-bin.000001 371 Table_map 1 410 table_id: # (test.t1) +master-bin.000001 410 Write_rows 1 444 table_id: # flags: STMT_END_F +master-bin.000001 444 Query 1 519 use `test`; flush tables SELECT * FROM t1 ORDER BY a; a 1 diff --git a/mysql-test/t/binlog_row_mix_innodb_myisam.test b/mysql-test/t/binlog_row_mix_innodb_myisam.test index b131e5350af..14aeb1f3428 100644 --- a/mysql-test/t/binlog_row_mix_innodb_myisam.test +++ b/mysql-test/t/binlog_row_mix_innodb_myisam.test @@ -20,7 +20,7 @@ # ER_SERVER_SHUTDOWN (i.e. disconnection just rolls back transaction # and does not make slave to stop) flush logs; ---exec $MYSQL_BINLOG --start-position=516 $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output +--exec $MYSQL_BINLOG --start-position=519 $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR eval select (@a:=load_file("$MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output")) diff --git a/mysql-test/t/rpl_row_create_table.test b/mysql-test/t/rpl_row_create_table.test index bde1974c124..bcb3d7651f3 100644 --- a/mysql-test/t/rpl_row_create_table.test +++ b/mysql-test/t/rpl_row_create_table.test @@ -34,7 +34,7 @@ CREATE TABLE t1 (a INT, b INT); CREATE TABLE t2 (a INT, b INT) ENGINE=Merge; CREATE TABLE t3 (a INT, b INT) CHARSET=utf8; CREATE TABLE t4 (a INT, b INT) ENGINE=Merge CHARSET=utf8; ---replace_column 1 # 4 # 5 # +--replace_column 1 # 4 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ --query_vertical SHOW BINLOG EVENTS FROM 215 --echo **** On Master **** @@ -70,8 +70,9 @@ connection master; --error 1062 CREATE TABLE t7 (UNIQUE(b)) SELECT a,b FROM tt3; # Shouldn't be written to the binary log +--replace_column 1 # 4 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ -SHOW BINLOG EVENTS FROM 959; +SHOW BINLOG EVENTS FROM 1097; # Test that INSERT-SELECT works the same way as for SBR. CREATE TABLE t7 (a INT, b INT UNIQUE); @@ -79,6 +80,7 @@ CREATE TABLE t7 (a INT, b INT UNIQUE); INSERT INTO t7 SELECT a,b FROM tt3; SELECT * FROM t7 ORDER BY a,b; # Should be written to the binary log +--replace_column 1 # 4 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ SHOW BINLOG EVENTS FROM 1097; sync_slave_with_master; @@ -90,6 +92,7 @@ INSERT INTO tt4 VALUES (4,8), (5,10), (6,12); BEGIN; INSERT INTO t7 SELECT a,b FROM tt4; ROLLBACK; +--replace_column 1 # 4 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ SHOW BINLOG EVENTS FROM 1293; SELECT * FROM t7 ORDER BY a,b; @@ -105,6 +108,7 @@ CREATE TEMPORARY TABLE tt7 SELECT 1; --echo **** On Master **** --query_vertical SHOW CREATE TABLE t8 --query_vertical SHOW CREATE TABLE t9 +--replace_column 1 # 4 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ SHOW BINLOG EVENTS FROM 1389; sync_slave_with_master; @@ -156,6 +160,7 @@ SELECT * FROM t1 ORDER BY a; SELECT * FROM t2 ORDER BY a; SELECT * FROM t3 ORDER BY a; SELECT * FROM t4 ORDER BY a; +--replace_column 1 # 4 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/ SHOW BINLOG EVENTS; sync_slave_with_master; @@ -201,6 +206,7 @@ INSERT INTO t2 SELECT a+2 FROM tt1; COMMIT; SELECT * FROM t2 ORDER BY a; +--replace_column 1 # 4 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/ SHOW BINLOG EVENTS; sync_slave_with_master; @@ -219,8 +225,9 @@ INSERT INTO t2 SELECT a+2 FROM tt2; ROLLBACK; SELECT * FROM t2 ORDER BY a; +--replace_column 1 # 4 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /Server ver: .*, Binlog ver: .*/Server ver: #, Binlog ver: #/ /table_id: [0-9]+/table_id: #/ -SHOW BINLOG EVENTS FROM 627; +SHOW BINLOG EVENTS FROM 630; sync_slave_with_master; SELECT * FROM t2 ORDER BY a; diff --git a/sql/log_event.cc b/sql/log_event.cc index 97c40194855..c5905ad6829 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -5601,8 +5601,7 @@ unpack_row(RELAY_LOG_INFO *rli, MY_BITMAP* const rw_set, Log_event_type const event_type) { DBUG_ENTER("unpack_row"); - DBUG_ASSERT(record && row_data); - my_ptrdiff_t const offset= record - (byte*) table->record[0]; + DBUG_ASSERT(row_data); my_size_t const master_null_byte_count= (bitmap_bits_set(cols) + 7) / 8; int error= 0; @@ -5611,7 +5610,7 @@ unpack_row(RELAY_LOG_INFO *rli, bitmap_clear_all(rw_set); - memcpy(record, table->s->default_values, table->s->null_bytes); + memcpy(table->record[0], table->s->default_values, table->s->null_bytes); Field **const begin_ptr = table->field; Field **field_ptr; @@ -5642,17 +5641,15 @@ unpack_row(RELAY_LOG_INFO *rli, DBUG_ASSERT(pack_ptr != NULL); if ((null_bits & null_mask) && f->maybe_null()) - f->set_null(offset); + f->set_null(); else { - f->set_notnull(offset); + f->set_notnull(); /* We only unpack the field if it was non-null */ - f->move_field_offset(offset); pack_ptr= f->unpack(f->ptr, pack_ptr); - f->move_field_offset(-offset); } bitmap_set_bit(rw_set, field_ptr - begin_ptr); @@ -6994,15 +6991,19 @@ static int find_and_fetch_row(TABLE *table, byte *key) while (record_compare(table)) { int error; + /* We need to set the null bytes to ensure that the filler bit are all set when returning. There are storage engines that just set the necessary bits on the bytes and don't set the filler bits correctly. */ - my_ptrdiff_t const pos= - table->s->null_bytes > 0 ? table->s->null_bytes - 1 : 0; - table->record[1][pos]= 0xFF; + if (table->s->null_bytes > 0) + { + table->record[1][table->s->null_bytes - 1]|= + 256U - (1U << table->s->last_null_bit_pos); + } + if ((error= table->file->index_next(table->record[1]))) { table->file->print_error(error, MYF(0)); @@ -7028,15 +7029,17 @@ static int find_and_fetch_row(TABLE *table, byte *key) /* Continue until we find the right record or have made a full loop */ do { - error= table->file->rnd_next(table->record[1]); - /* - Patching the returned record since some storage engines do - not set the filler bits correctly. + Patching the record before calling rnd_next() since some + storage engines do not set the filler bits correctly. */ - my_ptrdiff_t const pos= - table->s->null_bytes > 0 ? table->s->null_bytes - 1 : 0; - table->record[1][pos]|= 256U - (1U << table->s->last_null_bit_pos); + if (table->s->null_bytes > 0) + { + table->record[1][table->s->null_bytes - 1]|= + 256U - (1U << table->s->last_null_bit_pos); + } + + error= table->file->rnd_next(table->record[1]); DBUG_DUMP("record[0]", table->record[0], table->s->reclength); DBUG_DUMP("record[1]", table->record[1], table->s->reclength); From d44eb9f0c92dd1eb3263f68a26d6382fa205710d Mon Sep 17 00:00:00 2001 From: "cbell/Chuck@mysql_cab_desk." <> Date: Fri, 9 Mar 2007 12:18:28 -0500 Subject: [PATCH 06/22] Bug #25543 Replication of wrong values if using rand() in stored procedure When rand() is called multiple times inside a stored procedure, the server does not binlog the correct random seed values. This patch corrects the problem by resetting rand_used= 0 in THD::cleanup_after_query() allowing the system to save the random seeds if needed for each command in a stored procedure body. However, rand_used is not reset if executing in a stored function or trigger because these operations are binlogged by call and thus only the calling statement need detect the call to rand() made by its substatements. These substatements must not set rand_used to 0 because it would remove the detection of rand() by the calling statement. --- mysql-test/r/rpl_misc_functions.result | 27 +++++++++- mysql-test/t/rpl_misc_functions.test | 68 +++++++++++++++++++++++++- sql/sql_class.cc | 12 +++++ 3 files changed, 103 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/rpl_misc_functions.result b/mysql-test/r/rpl_misc_functions.result index c11663b8ac8..526414cec9c 100644 --- a/mysql-test/r/rpl_misc_functions.result +++ b/mysql-test/r/rpl_misc_functions.result @@ -18,6 +18,29 @@ create table t2 like t1; load data local infile 'MYSQLTEST_VARDIR/master-data/test/rpl_misc_functions.outfile' into table t2; select * from t1, t2 where (t1.id=t2.id) and not(t1.i=t2.i and t1.r1=t2.r1 and t1.r2=t2.r2 and t1.p=t2.p); id i r1 r2 p id i r1 r2 p -stop slave; -drop table t1; drop table t1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (col_a double default NULL); +CREATE PROCEDURE test_replication_sp1() +BEGIN +INSERT INTO t1 VALUES (rand()), (rand()); +INSERT INTO t1 VALUES (rand()); +END| +CREATE PROCEDURE test_replication_sp2() +BEGIN +CALL test_replication_sp1(); +CALL test_replication_sp1(); +END| +CREATE FUNCTION test_replication_sf() RETURNS DOUBLE DETERMINISTIC +BEGIN +RETURN (rand() + rand()); +END| +CALL test_replication_sp1(); +CALL test_replication_sp2(); +INSERT INTO t1 VALUES (test_replication_sf()); +INSERT INTO t1 VALUES (test_replication_sf()); +INSERT INTO t1 VALUES (test_replication_sf()); +DROP PROCEDURE IF EXISTS test_replication_sp1; +DROP PROCEDURE IF EXISTS test_replication_sp2; +DROP FUNCTION IF EXISTS test_replication_sf; +DROP TABLE IF EXISTS t1; diff --git a/mysql-test/t/rpl_misc_functions.test b/mysql-test/t/rpl_misc_functions.test index 6e0bda90503..43ce3afc8ad 100644 --- a/mysql-test/t/rpl_misc_functions.test +++ b/mysql-test/t/rpl_misc_functions.test @@ -28,10 +28,74 @@ create table t2 like t1; eval load data local infile '$MYSQLTEST_VARDIR/master-data/test/rpl_misc_functions.outfile' into table t2; # compare them with the replica; the SELECT below should return no row select * from t1, t2 where (t1.id=t2.id) and not(t1.i=t2.i and t1.r1=t2.r1 and t1.r2=t2.r2 and t1.p=t2.p); -stop slave; -drop table t1; connection master; drop table t1; # End of 4.1 tests + +# +# BUG#25543 test calling rand() multiple times on the master in +# a stored procedure. +# + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 (col_a double default NULL); + +DELIMITER |; + +# Use a SP that calls rand() multiple times +CREATE PROCEDURE test_replication_sp1() +BEGIN + INSERT INTO t1 VALUES (rand()), (rand()); + INSERT INTO t1 VALUES (rand()); +END| + +# Use a SP that calls another SP to call rand() multiple times +CREATE PROCEDURE test_replication_sp2() +BEGIN + CALL test_replication_sp1(); + CALL test_replication_sp1(); +END| + +# Use a SF that calls rand() multiple times +CREATE FUNCTION test_replication_sf() RETURNS DOUBLE DETERMINISTIC +BEGIN + RETURN (rand() + rand()); +END| + +DELIMITER ;| + +# Exercise the functions and procedures then compare the results on +# the master to those on the slave. +CALL test_replication_sp1(); +CALL test_replication_sp2(); +INSERT INTO t1 VALUES (test_replication_sf()); +INSERT INTO t1 VALUES (test_replication_sf()); +INSERT INTO t1 VALUES (test_replication_sf()); + +# Record the results of the query on the master +--exec $MYSQL --port=$MASTER_MYPORT test -e "SELECT * FROM test.t1" > $MYSQLTEST_VARDIR/tmp/rpl_rand_master.sql + +--sync_slave_with_master + +# Record the results of the query on the slave +--exec $MYSQL --port=$SLAVE_MYPORT test -e "SELECT * FROM test.t1" > $MYSQLTEST_VARDIR/tmp/rpl_rand_slave.sql + +# Compare the results from the master to the slave. +--exec diff $MYSQLTEST_VARDIR/tmp/rpl_rand_master.sql $MYSQLTEST_VARDIR/tmp/rpl_rand_slave.sql + +# Cleanup +--disable_warnings +DROP PROCEDURE IF EXISTS test_replication_sp1; +DROP PROCEDURE IF EXISTS test_replication_sp2; +DROP FUNCTION IF EXISTS test_replication_sf; +DROP TABLE IF EXISTS t1; +--enable_warnings + +# If all is good, when can cleanup our dump files. +--system rm $MYSQLTEST_VARDIR/tmp/rpl_rand_master.sql +--system rm $MYSQLTEST_VARDIR/tmp/rpl_rand_slave.sql diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 3c91e3e8fb7..adb7323c463 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -575,6 +575,18 @@ void THD::cleanup_after_query() clear_next_insert_id= 0; next_insert_id= 0; } + /* + Reset rand_used so that detection of calls to rand() will save random + seeds if needed by the slave. + + Do not reset rand_used if inside a stored function or trigger because + only the call to these operations is logged. Thus only the calling + statement needs to detect rand() calls made by its substatements. These + substatements must not set rand_used to 0 because it would remove the + detection of rand() by the calling statement. + */ + if (!in_sub_stmt) + rand_used= 0; /* Free Items that were created during this execution */ free_items(); /* Reset where. */ From d695f7495548ed312ffc1fb158f154f9d1ae8642 Mon Sep 17 00:00:00 2001 From: "mats@romeo.(none)" <> Date: Tue, 20 Mar 2007 08:52:01 +0100 Subject: [PATCH 07/22] BUG#22583: RBR between MyISAM and non-MyISAM tables containing a BIT field does not work Fix to prevent MyISAM from reading data from NULL BLOB. Fix to make record comparison independent of values of unused bits in record. Updating binlog positions in tests. --- .../extra/rpl_tests/rpl_multi_query.test | 2 +- .../extra/rpl_tests/rpl_stm_charset.test | 2 +- mysql-test/include/show_binlog_events.inc | 2 +- mysql-test/r/binlog_stm_binlog.result | 20 ++-- mysql-test/r/binlog_stm_ctype_ucs.result | 6 +- mysql-test/r/binlog_stm_insert_select.result | 6 +- .../r/binlog_stm_mix_innodb_myisam.result | 28 ++--- mysql-test/r/ctype_cp932_binlog_stm.result | 14 +-- mysql-test/r/ndb_binlog_multi.result | 4 + mysql-test/r/rpl_known_bugs_detection.result | 4 +- mysql-test/r/rpl_loaddata.result | 6 +- mysql-test/r/rpl_loaddata_s.result | 2 +- mysql-test/r/rpl_ndb_charset.result | 2 +- mysql-test/r/rpl_ndb_extraCol.result | 54 ++++----- mysql-test/r/rpl_ndb_log.result | 19 ++-- mysql-test/r/rpl_ndb_multi.result | 4 +- mysql-test/r/rpl_rbr_to_sbr.result | 4 +- mysql-test/r/rpl_rotate_logs.result | 30 ++--- mysql-test/r/rpl_row_basic_11bugs-master.opt | 1 + mysql-test/r/rpl_row_basic_11bugs-slave.opt | 1 + mysql-test/r/rpl_sp.result | 2 +- mysql-test/r/rpl_stm_charset.result | 2 +- mysql-test/r/rpl_stm_flsh_tbls.result | 4 +- mysql-test/r/rpl_stm_log.result | 16 +-- mysql-test/r/rpl_stm_max_relay_size.result | 22 ++-- mysql-test/r/rpl_stm_multi_query.result | 2 +- mysql-test/r/rpl_stm_reset_slave.result | 6 +- mysql-test/r/rpl_stm_until.result | 16 +-- mysql-test/r/rpl_truncate_7ndb.result | 72 ++++++------ mysql-test/r/user_var-binlog.result | 2 +- .../t/binlog_stm_mix_innodb_myisam.test | 2 +- mysql-test/t/ctype_cp932_binlog_stm.test | 2 +- mysql-test/t/mysqlbinlog.test | 4 +- mysql-test/t/mysqlbinlog2.test | 16 +-- mysql-test/t/rpl_sp.test | 2 +- mysql-test/t/rpl_stm_flsh_tbls.test | 2 +- sql/log_event.cc | 104 +++++++++++++++--- 37 files changed, 286 insertions(+), 201 deletions(-) create mode 100644 mysql-test/r/rpl_row_basic_11bugs-master.opt create mode 100644 mysql-test/r/rpl_row_basic_11bugs-slave.opt diff --git a/mysql-test/extra/rpl_tests/rpl_multi_query.test b/mysql-test/extra/rpl_tests/rpl_multi_query.test index 30a83886a86..a1b3b9de5f5 100644 --- a/mysql-test/extra/rpl_tests/rpl_multi_query.test +++ b/mysql-test/extra/rpl_tests/rpl_multi_query.test @@ -25,6 +25,6 @@ select * from mysqltest.t1; connection master; --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ -show binlog events from 102; +show binlog events from 105; drop database mysqltest; sync_slave_with_master; diff --git a/mysql-test/extra/rpl_tests/rpl_stm_charset.test b/mysql-test/extra/rpl_tests/rpl_stm_charset.test index 5657b06e88f..4822ba60db0 100644 --- a/mysql-test/extra/rpl_tests/rpl_stm_charset.test +++ b/mysql-test/extra/rpl_tests/rpl_stm_charset.test @@ -111,7 +111,7 @@ drop database mysqltest2; drop database mysqltest3; --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ -show binlog events from 102; +show binlog events from 105; sync_slave_with_master; # Check that we can change global.collation_server (since 5.0.3) diff --git a/mysql-test/include/show_binlog_events.inc b/mysql-test/include/show_binlog_events.inc index ae848d10687..ce59bdb4f94 100644 --- a/mysql-test/include/show_binlog_events.inc +++ b/mysql-test/include/show_binlog_events.inc @@ -1,4 +1,4 @@ ---let $binlog_start=102 +--let $binlog_start=105 --replace_result $binlog_start --replace_column 2 # 4 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ diff --git a/mysql-test/r/binlog_stm_binlog.result b/mysql-test/r/binlog_stm_binlog.result index fb0453b5b68..0d587175cd3 100644 --- a/mysql-test/r/binlog_stm_binlog.result +++ b/mysql-test/r/binlog_stm_binlog.result @@ -4,11 +4,11 @@ insert into t1 values (1,2); commit; show binlog events; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 102 Server ver: #, Binlog ver: # -master-bin.000001 102 Query 1 209 use `test`; create table t1 (a int, b int) engine=innodb -master-bin.000001 209 Query 1 277 use `test`; BEGIN -master-bin.000001 277 Query 1 90 use `test`; insert into t1 values (1,2) -master-bin.000001 367 Xid 1 394 COMMIT /* XID */ +master-bin.000001 4 Format_desc 1 105 Server ver: #, Binlog ver: # +master-bin.000001 105 Query 1 212 use `test`; create table t1 (a int, b int) engine=innodb +master-bin.000001 212 Query 1 280 use `test`; BEGIN +master-bin.000001 280 Query 1 90 use `test`; insert into t1 values (1,2) +master-bin.000001 370 Xid 1 397 COMMIT /* XID */ drop table t1; drop table if exists t1, t2; reset master; @@ -20,7 +20,7 @@ commit; begin; insert t2 values (5); commit; -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; create table t1 (a int) engine=innodb master-bin.000001 # Query 1 # use `test`; create table t2 (a int) engine=innodb @@ -36,7 +36,7 @@ create table t1 (n int) engine=innodb; begin; commit; drop table t1; -show binlog events in 'master-bin.000001' from 102; +show binlog events in 'master-bin.000001' from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; create table t1 (n int) engine=innodb master-bin.000001 # Query 1 # use `test`; BEGIN @@ -142,7 +142,7 @@ master-bin.000001 # Query 1 # use `test`; insert into t1 values(2 + 4) master-bin.000001 # Query 1 # use `test`; insert into t1 values(1 + 4) master-bin.000001 # Xid 1 # COMMIT /* xid= */ master-bin.000001 # Rotate 1 # master-bin.000002;pos=4 -show binlog events in 'master-bin.000002' from 102; +show binlog events in 'master-bin.000002' from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000002 # Query 1 # use `test`; drop table t1 reset master; @@ -164,7 +164,7 @@ INSERT INTO user SET host='localhost', user='@#@', password=password('Just a tes UPDATE user SET password=password('Another password') WHERE host='localhost' AND user='@#@'; DELETE FROM user WHERE host='localhost' AND user='@#@'; use test; -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; create table t1 (id tinyint auto_increment primary key) master-bin.000001 # Intvar 1 # INSERT_ID=127 @@ -183,7 +183,7 @@ set @@session.auto_increment_increment=1, @@session.auto_increment_offset=1; insert delayed into t1 values (207); insert delayed into t1 values (null); insert delayed into t1 values (300); -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; create table t1 (id tinyint auto_increment primary key) master-bin.000001 # Intvar 1 # INSERT_ID=127 diff --git a/mysql-test/r/binlog_stm_ctype_ucs.result b/mysql-test/r/binlog_stm_ctype_ucs.result index 76f3a3b06b9..e79803223e3 100644 --- a/mysql-test/r/binlog_stm_ctype_ucs.result +++ b/mysql-test/r/binlog_stm_ctype_ucs.result @@ -3,10 +3,10 @@ create table t2 (c char(30)) charset=ucs2; set @v=convert('abc' using ucs2); reset master; insert into t2 values (@v); -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 102 User var 1 142 @`v`=_ucs2 0x006100620063 COLLATE ucs2_general_ci -master-bin.000001 142 Query 1 231 use `test`; insert into t2 values (@v) +master-bin.000001 105 User var 1 145 @`v`=_ucs2 0x006100620063 COLLATE ucs2_general_ci +master-bin.000001 145 Query 1 234 use `test`; insert into t2 values (@v) flush logs; /*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; diff --git a/mysql-test/r/binlog_stm_insert_select.result b/mysql-test/r/binlog_stm_insert_select.result index 646a76b254d..47dc9cb3097 100644 --- a/mysql-test/r/binlog_stm_insert_select.result +++ b/mysql-test/r/binlog_stm_insert_select.result @@ -8,8 +8,8 @@ insert into t1 select * from t2; ERROR 23000: Duplicate entry '2' for key 'a' show binlog events; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 102 Server ver: VERSION, Binlog ver: 4 -master-bin.000001 102 Query 1 196 use `test`; insert into t1 select * from t2 +master-bin.000001 4 Format_desc 1 105 Server ver: VERSION, Binlog ver: 4 +master-bin.000001 105 Query 1 199 use `test`; insert into t1 select * from t2 select * from t1; a 1 @@ -22,5 +22,5 @@ create table t2(unique(a)) select a from t1; ERROR 23000: Duplicate entry '1' for key 'a' show binlog events; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 102 Server ver: VERSION, Binlog ver: 4 +master-bin.000001 4 Format_desc 1 105 Server ver: VERSION, Binlog ver: 4 drop table t1; diff --git a/mysql-test/r/binlog_stm_mix_innodb_myisam.result b/mysql-test/r/binlog_stm_mix_innodb_myisam.result index 23f4e50826a..5592c06460e 100644 --- a/mysql-test/r/binlog_stm_mix_innodb_myisam.result +++ b/mysql-test/r/binlog_stm_mix_innodb_myisam.result @@ -6,7 +6,7 @@ begin; insert into t1 values(1); insert into t2 select * from t1; commit; -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; BEGIN master-bin.000001 # Query 1 # use `test`; insert into t1 values(1) @@ -21,7 +21,7 @@ insert into t2 select * from t1; rollback; Warnings: Warning 1196 Some non-transactional changed tables couldn't be rolled back -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; BEGIN master-bin.000001 # Query 1 # use `test`; insert into t1 values(2) @@ -39,7 +39,7 @@ rollback to savepoint my_savepoint; Warnings: Warning 1196 Some non-transactional changed tables couldn't be rolled back commit; -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; BEGIN master-bin.000001 # Query 1 # use `test`; insert into t1 values(3) @@ -65,7 +65,7 @@ select a from t1 order by a; a 5 7 -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; BEGIN master-bin.000001 # Query 1 # use `test`; insert into t1 values(5) @@ -87,7 +87,7 @@ insert into t2 select * from t1; select get_lock("a",10); get_lock("a",10) 1 -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; BEGIN master-bin.000001 # Query 1 # use `test`; insert into t1 values(8) @@ -98,7 +98,7 @@ delete from t2; reset master; insert into t1 values(9); insert into t2 select * from t1; -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; insert into t1 values(9) master-bin.000001 # Xid 1 # COMMIT /* xid= */ @@ -109,14 +109,14 @@ reset master; insert into t1 values(10); begin; insert into t2 select * from t1; -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; insert into t1 values(10) master-bin.000001 # Xid 1 # COMMIT /* xid= */ master-bin.000001 # Query 1 # use `test`; insert into t2 select * from t1 insert into t1 values(11); commit; -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; insert into t1 values(10) master-bin.000001 # Xid 1 # COMMIT /* xid= */ @@ -132,7 +132,7 @@ begin; insert into t1 values(12); insert into t2 select * from t1; commit; -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; BEGIN master-bin.000001 # Query 1 # use `test`; insert into t1 values(12) @@ -145,7 +145,7 @@ begin; insert into t1 values(13); insert into t2 select * from t1; rollback; -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info delete from t1; delete from t2; @@ -157,7 +157,7 @@ insert into t1 values(15); insert into t2 select * from t1; rollback to savepoint my_savepoint; commit; -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; BEGIN master-bin.000001 # Query 1 # use `test`; insert into t1 values(14) @@ -177,7 +177,7 @@ select a from t1 order by a; a 16 18 -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; BEGIN master-bin.000001 # Query 1 # use `test`; insert into t1 values(16) @@ -227,7 +227,7 @@ insert into t2 values (3); select get_lock("lock1",60); get_lock("lock1",60) 1 -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; BEGIN master-bin.000001 # Query 1 # use `test`; insert into t1 values(16) @@ -331,7 +331,7 @@ SELECT * from t2; a b 100 100 DROP TABLE t1,t2; -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; INSERT INTO t1 values (1,1),(1,2) master-bin.000001 # Query 1 # use `test`; DROP TABLE if exists t2 diff --git a/mysql-test/r/ctype_cp932_binlog_stm.result b/mysql-test/r/ctype_cp932_binlog_stm.result index ef024e2fa20..d9d982a77dc 100644 --- a/mysql-test/r/ctype_cp932_binlog_stm.result +++ b/mysql-test/r/ctype_cp932_binlog_stm.result @@ -6,7 +6,7 @@ CREATE TABLE t1(f1 blob); PREPARE stmt1 FROM 'INSERT INTO t1 VALUES(?)'; SET @var1= x'8300'; EXECUTE stmt1 USING @var1; -SHOW BINLOG EVENTS FROM 102; +SHOW BINLOG EVENTS FROM 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; CREATE TABLE t1(f1 blob) master-bin.000001 # User var 1 # @`var1`=_binary 0x8300 COLLATE binary @@ -30,17 +30,17 @@ HEX(s1) HEX(s2) d 466F6F2773206120426172 ED40ED41ED42 47.93 DROP PROCEDURE bug18293| DROP TABLE t4| -SHOW BINLOG EVENTS FROM 406| +SHOW BINLOG EVENTS FROM 409| Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 406 Query 1 572 use `test`; CREATE TABLE t4 (s1 CHAR(50) CHARACTER SET latin1, +master-bin.000001 409 Query 1 575 use `test`; CREATE TABLE t4 (s1 CHAR(50) CHARACTER SET latin1, s2 CHAR(50) CHARACTER SET cp932, d DECIMAL(10,2)) -master-bin.000001 572 Query 1 820 use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE bug18293 (IN ins1 CHAR(50), +master-bin.000001 575 Query 1 823 use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE bug18293 (IN ins1 CHAR(50), IN ins2 CHAR(50) CHARACTER SET cp932, IN ind DECIMAL(10,2)) BEGIN INSERT INTO t4 VALUES (ins1, ins2, ind); END -master-bin.000001 820 Query 1 1039 use `test`; INSERT INTO t4 VALUES ( NAME_CONST('ins1',_latin1 0x466F6F2773206120426172), NAME_CONST('ins2',_cp932 0xED40ED41ED42), NAME_CONST('ind',47.93)) -master-bin.000001 1039 Query 1 1128 use `test`; DROP PROCEDURE bug18293 -master-bin.000001 1128 Query 1 1207 use `test`; DROP TABLE t4 +master-bin.000001 823 Query 1 1042 use `test`; INSERT INTO t4 VALUES ( NAME_CONST('ins1',_latin1 0x466F6F2773206120426172), NAME_CONST('ins2',_cp932 0xED40ED41ED42), NAME_CONST('ind',47.93)) +master-bin.000001 1042 Query 1 1131 use `test`; DROP PROCEDURE bug18293 +master-bin.000001 1131 Query 1 1210 use `test`; DROP TABLE t4 diff --git a/mysql-test/r/ndb_binlog_multi.result b/mysql-test/r/ndb_binlog_multi.result index 3a84c89a7a4..cae1cfa8ce7 100644 --- a/mysql-test/r/ndb_binlog_multi.result +++ b/mysql-test/r/ndb_binlog_multi.result @@ -13,6 +13,7 @@ master-bin1.000001 # Query # # BEGIN master-bin1.000001 # Table_map # # table_id: # (test.t2) master-bin1.000001 # Table_map # # table_id: # (mysql.ndb_apply_status) master-bin1.000001 # Write_rows # # table_id: # +master-bin1.000001 # Write_rows # # table_id: # master-bin1.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin1.000001 # Query # # COMMIT select * from t2 order by a; @@ -35,6 +36,7 @@ master-bin.000001 # Query # # BEGIN master-bin.000001 # Table_map # # table_id: # (test.t2) master-bin.000001 # Table_map # # table_id: # (mysql.ndb_apply_status) master-bin.000001 # Write_rows # # table_id: # +master-bin.000001 # Write_rows # # table_id: # master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # use `test`; DROP TABLE t2 @@ -53,6 +55,7 @@ master-bin1.000001 # Query # # BEGIN master-bin1.000001 # Table_map # # table_id: # (test.t1) master-bin1.000001 # Table_map # # table_id: # (mysql.ndb_apply_status) master-bin1.000001 # Write_rows # # table_id: # +master-bin1.000001 # Write_rows # # table_id: # master-bin1.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin1.000001 # Query # # COMMIT SELECT @the_epoch2:=epoch,inserts,updates,deletes,schemaops FROM @@ -71,6 +74,7 @@ master-bin1.000001 # Query # # BEGIN master-bin1.000001 # Table_map # # table_id: # (test.t1) master-bin1.000001 # Table_map # # table_id: # (mysql.ndb_apply_status) master-bin1.000001 # Write_rows # # table_id: # +master-bin1.000001 # Write_rows # # table_id: # master-bin1.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin1.000001 # Query # # COMMIT master-bin1.000001 # Query # # use `test`; drop table t1 diff --git a/mysql-test/r/rpl_known_bugs_detection.result b/mysql-test/r/rpl_known_bugs_detection.result index eabc6185780..2d6fffd89a0 100644 --- a/mysql-test/r/rpl_known_bugs_detection.result +++ b/mysql-test/r/rpl_known_bugs_detection.result @@ -33,7 +33,7 @@ Replicate_Wild_Ignore_Table Last_Errno 1105 Last_Error Error 'master may suffer from http://bugs.mysql.com/bug.php?id=24432 so slave stops; check error log on slave for more info' on query. Default database: 'test'. Query: 'INSERT INTO t1(b) VALUES(1),(1),(2) ON DUPLICATE KEY UPDATE t1.b=10' Skip_Counter 0 -Exec_Master_Log_Pos 242 +Exec_Master_Log_Pos 245 Relay_Log_Space # Until_Condition None Until_Log_File @@ -115,7 +115,7 @@ FROM t2 ON DUPLICATE KEY UPDATE t1.field_3 = t2.field_c' Skip_Counter 0 -Exec_Master_Log_Pos 1274 +Exec_Master_Log_Pos 1277 Relay_Log_Space # Until_Condition None Until_Log_File diff --git a/mysql-test/r/rpl_loaddata.result b/mysql-test/r/rpl_loaddata.result index cae11e98caa..7a6e5740c14 100644 --- a/mysql-test/r/rpl_loaddata.result +++ b/mysql-test/r/rpl_loaddata.result @@ -28,7 +28,7 @@ day id category name 2003-03-22 2416 a bbbbb show master status; File Position Binlog_Do_DB Binlog_Ignore_DB -slave-bin.000001 1276 +slave-bin.000001 1279 drop table t1; drop table t2; drop table t3; @@ -39,7 +39,7 @@ set global sql_slave_skip_counter=1; start slave; show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1793 # # master-bin.000001 Yes Yes # 0 0 1793 # None 0 No # +# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1796 # # master-bin.000001 Yes Yes # 0 0 1796 # None 0 No # set sql_log_bin=0; delete from t1; set sql_log_bin=1; @@ -49,7 +49,7 @@ change master to master_user='test'; change master to master_user='root'; show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1828 # # master-bin.000001 No No # 0 0 1828 # None 0 No # +# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1831 # # master-bin.000001 No No # 0 0 1831 # None 0 No # set global sql_slave_skip_counter=1; start slave; set sql_log_bin=0; diff --git a/mysql-test/r/rpl_loaddata_s.result b/mysql-test/r/rpl_loaddata_s.result index f0c79c81c15..3f092e3afff 100644 --- a/mysql-test/r/rpl_loaddata_s.result +++ b/mysql-test/r/rpl_loaddata_s.result @@ -10,6 +10,6 @@ load data infile '../std_data_ln/rpl_loaddata.dat' into table test.t1; select count(*) from test.t1; count(*) 2 -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info drop table test.t1; diff --git a/mysql-test/r/rpl_ndb_charset.result b/mysql-test/r/rpl_ndb_charset.result index 0ce4446c8a5..41dd5791702 100644 --- a/mysql-test/r/rpl_ndb_charset.result +++ b/mysql-test/r/rpl_ndb_charset.result @@ -109,7 +109,7 @@ a b 1 cp850_general_ci drop database mysqltest2; drop database mysqltest3; -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # drop database if exists mysqltest2 master-bin.000001 # Query 1 # drop database if exists mysqltest3 diff --git a/mysql-test/r/rpl_ndb_extraCol.result b/mysql-test/r/rpl_ndb_extraCol.result index bc40e24ecac..336a6152d36 100644 --- a/mysql-test/r/rpl_ndb_extraCol.result +++ b/mysql-test/r/rpl_ndb_extraCol.result @@ -28,9 +28,9 @@ a b c *** Select from slave *** SELECT * FROM t1 ORDER BY a; a b c d e -1 2 TEXAS 2 TEST -2 1 AUSTIN 2 TEST -3 4 QA 2 TEST +1 2 TEXAS NULL NULL +2 1 AUSTIN NULL NULL +3 4 QA NULL NULL *** Drop t1 *** DROP TABLE t1; *** Create t3 on slave *** @@ -289,9 +289,9 @@ a b c *** Select from slave *** SELECT * FROM t7 ORDER BY a; a b c d e -1 b1b1 Kyle 0000-00-00 00:00:00 Extra Column Testing -2 b1b1 JOE 0000-00-00 00:00:00 Extra Column Testing -3 b1b1 QA 0000-00-00 00:00:00 Extra Column Testing +1 b1b1 Kyle NULL NULL +2 b1b1 JOE NULL NULL +3 b1b1 QA NULL NULL *** Drop t7 *** DROP TABLE t7; *** Create t8 on slave *** @@ -447,9 +447,9 @@ a b c *** Select on Slave *** SELECT * FROM t12 ORDER BY a; a b f c e -1 b1b1b1b1b1b1b1b1 Kyle test 1 -2 b1b1b1b1b1b1b1b1 JOE test 1 -3 b1b1b1b1b1b1b1b1 QA test 1 +1 b1b1b1b1b1b1b1b1 Kyle NULL NULL +2 b1b1b1b1b1b1b1b1 JOE NULL NULL +3 b1b1b1b1b1b1b1b1 QA NULL NULL *** Drop t12 *** DROP TABLE t12; **** Extra Colums End **** @@ -479,9 +479,9 @@ a b c *** Select on Slave **** SELECT * FROM t13 ORDER BY a; a b c d e -1 b1b1b1b1b1b1b1b1 Kyle 1 CURRENT_TIMESTAMP -2 b1b1b1b1b1b1b1b1 JOE 1 CURRENT_TIMESTAMP -3 b1b1b1b1b1b1b1b1 QA 1 CURRENT_TIMESTAMP +1 b1b1b1b1b1b1b1b1 Kyle NULL CURRENT_TIMESTAMP +2 b1b1b1b1b1b1b1b1 JOE NULL CURRENT_TIMESTAMP +3 b1b1b1b1b1b1b1b1 QA NULL CURRENT_TIMESTAMP *** Drop t13 *** DROP TABLE t13; *** 22117 END *** @@ -515,9 +515,9 @@ c1 c2 c3 c4 c5 *** Select on Slave **** SELECT * FROM t14 ORDER BY c1; c1 c2 c3 c4 c5 c6 c7 -1 1.00 Replication Testing Extra Col b1b1b1b1b1b1b1b1 Kyle 1 CURRENT_TIMESTAMP -2 2.00 This Test Should work b1b1b1b1b1b1b1b1 JOE 1 CURRENT_TIMESTAMP -3 3.00 If is does not, I will open a bug b1b1b1b1b1b1b1b1 QA 1 CURRENT_TIMESTAMP +1 1.00 Replication Testing Extra Col b1b1b1b1b1b1b1b1 Kyle NULL CURRENT_TIMESTAMP +2 2.00 This Test Should work b1b1b1b1b1b1b1b1 JOE NULL CURRENT_TIMESTAMP +3 3.00 If is does not, I will open a bug b1b1b1b1b1b1b1b1 QA NULL CURRENT_TIMESTAMP *** connect to master and drop columns *** ALTER TABLE t14 DROP COLUMN c2; ALTER TABLE t14 DROP COLUMN c4; @@ -530,9 +530,9 @@ c1 c3 c5 *** Select from Slave *** SELECT * FROM t14 ORDER BY c1; c1 c3 c5 c6 c7 -1 Replication Testing Extra Col Kyle 1 CURRENT_TIMESTAMP -2 This Test Should work JOE 1 CURRENT_TIMESTAMP -3 If is does not, I will open a bug QA 1 CURRENT_TIMESTAMP +1 Replication Testing Extra Col Kyle NULL CURRENT_TIMESTAMP +2 This Test Should work JOE NULL CURRENT_TIMESTAMP +3 If is does not, I will open a bug QA NULL CURRENT_TIMESTAMP *** Drop t14 *** DROP TABLE t14; *** Create t15 on slave *** @@ -563,9 +563,9 @@ c1 c2 c3 c4 c5 *** Select on Slave **** SELECT * FROM t15 ORDER BY c1; c1 c2 c3 c4 c5 c6 c7 -1 1.00 Replication Testing Extra Col b1b1b1b1b1b1b1b1 Kyle 1 CURRENT_TIMESTAMP -2 2.00 This Test Should work b1b1b1b1b1b1b1b1 JOE 1 CURRENT_TIMESTAMP -3 3.00 If is does not, I will open a bug b1b1b1b1b1b1b1b1 QA 1 CURRENT_TIMESTAMP +1 1.00 Replication Testing Extra Col b1b1b1b1b1b1b1b1 Kyle NULL CURRENT_TIMESTAMP +2 2.00 This Test Should work b1b1b1b1b1b1b1b1 JOE NULL CURRENT_TIMESTAMP +3 3.00 If is does not, I will open a bug b1b1b1b1b1b1b1b1 QA NULL CURRENT_TIMESTAMP *** Add column on master that is a Extra on Slave *** ALTER TABLE t15 ADD COLUMN c6 INT AFTER c5; ******************************************** @@ -618,9 +618,9 @@ c1 c2 c3 c4 c5 c6 *** Try to select from slave **** SELECT * FROM t15 ORDER BY c1; c1 c2 c3 c4 c5 c6 c7 -1 1.00 Replication Testing Extra Col b1b1b1b1b1b1b1b1 Kyle 1 CURRENT_TIMESTAMP -2 2.00 This Test Should work b1b1b1b1b1b1b1b1 JOE 1 CURRENT_TIMESTAMP -3 3.00 If is does not, I will open a bug b1b1b1b1b1b1b1b1 QA 1 CURRENT_TIMESTAMP +1 1.00 Replication Testing Extra Col b1b1b1b1b1b1b1b1 Kyle NULL CURRENT_TIMESTAMP +2 2.00 This Test Should work b1b1b1b1b1b1b1b1 JOE NULL CURRENT_TIMESTAMP +3 3.00 If is does not, I will open a bug b1b1b1b1b1b1b1b1 QA NULL CURRENT_TIMESTAMP 5 2.00 Replication Testing b1b1b1b1b1b1b1b1 Buda 2 CURRENT_TIMESTAMP *** DROP TABLE t15 *** DROP TABLE t15; @@ -652,9 +652,9 @@ c1 c2 c3 c4 c5 *** Select on Slave **** SELECT * FROM t16 ORDER BY c1; c1 c2 c3 c4 c5 c6 c7 -1 1.00 Replication Testing Extra Col b1b1b1b1b1b1b1b1 Kyle 1 CURRENT_TIMESTAMP -2 2.00 This Test Should work b1b1b1b1b1b1b1b1 JOE 1 CURRENT_TIMESTAMP -3 3.00 If is does not, I will open a bug b1b1b1b1b1b1b1b1 QA 1 CURRENT_TIMESTAMP +1 1.00 Replication Testing Extra Col b1b1b1b1b1b1b1b1 Kyle NULL CURRENT_TIMESTAMP +2 2.00 This Test Should work b1b1b1b1b1b1b1b1 JOE NULL CURRENT_TIMESTAMP +3 3.00 If is does not, I will open a bug b1b1b1b1b1b1b1b1 QA NULL CURRENT_TIMESTAMP *** Add Partition on master *** ALTER TABLE t16 PARTITION BY KEY(c1) PARTITIONS 4; INSERT INTO t16 () VALUES(4,1.00,'Replication Rocks',@b1,'Omer'); diff --git a/mysql-test/r/rpl_ndb_log.result b/mysql-test/r/rpl_ndb_log.result index 66db8c24bb2..dcd103a5b68 100644 --- a/mysql-test/r/rpl_ndb_log.result +++ b/mysql-test/r/rpl_ndb_log.result @@ -32,16 +32,17 @@ master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Table_map 1 # table_id: # (test.t1) master-bin.000001 # Table_map 1 # table_id: # (mysql.ndb_apply_status) master-bin.000001 # Write_rows 1 # table_id: # +master-bin.000001 # Write_rows 1 # table_id: # master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Query 1 # COMMIT -show binlog events from 102 limit 1; +show binlog events from 105 limit 1; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=NDB -show binlog events from 102 limit 2; +show binlog events from 105 limit 2; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=NDB master-bin.000001 # Query 1 # BEGIN -show binlog events from 102 limit 2,1; +show binlog events from 105 limit 2,1; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Table_map 1 # table_id: # (test.t1) flush logs; @@ -71,6 +72,7 @@ master-bin.000001 # Query 1 # BEGIN master-bin.000001 # Table_map 1 # table_id: # (test.t1) master-bin.000001 # Table_map 1 # table_id: # (mysql.ndb_apply_status) master-bin.000001 # Write_rows 1 # table_id: # +master-bin.000001 # Write_rows 1 # table_id: # master-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000001 # Query 1 # COMMIT master-bin.000001 # Rotate 1 # master-bin.000002;pos=4 @@ -87,13 +89,13 @@ master-bin.000002 # Write_rows 1 # table_id: # flags: STMT_END_F master-bin.000002 # Query 1 # COMMIT show binary logs; Log_name File_size -master-bin.000001 1702 -master-bin.000002 593 +master-bin.000001 1734 +master-bin.000002 596 start slave; show binary logs; Log_name File_size -slave-bin.000001 1797 -slave-bin.000002 198 +slave-bin.000001 1829 +slave-bin.000002 201 show binlog events in 'slave-bin.000001' from 4; Log_name Pos Event_type Server_id End_log_pos Info slave-bin.000001 # Format_desc 2 # Server ver: VERSION, Binlog ver: 4 @@ -110,6 +112,7 @@ slave-bin.000001 # Query 2 # BEGIN slave-bin.000001 # Table_map 2 # table_id: # (test.t1) slave-bin.000001 # Table_map 2 # table_id: # (mysql.ndb_apply_status) slave-bin.000001 # Write_rows 2 # table_id: # +slave-bin.000001 # Write_rows 2 # table_id: # slave-bin.000001 # Write_rows 2 # table_id: # flags: STMT_END_F slave-bin.000001 # Query 2 # COMMIT slave-bin.000001 # Query 1 # use `test`; create table t3 (a int)ENGINE=NDB @@ -126,7 +129,7 @@ slave-bin.000002 # Write_rows 2 # table_id: # flags: STMT_END_F slave-bin.000002 # Query 2 # COMMIT show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 593 # # master-bin.000002 Yes Yes # 0 0 593 # None 0 No # +# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 596 # # master-bin.000002 Yes Yes # 0 0 596 # None 0 No # show binlog events in 'slave-bin.000005' from 4; ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Could not find target log DROP TABLE t1; diff --git a/mysql-test/r/rpl_ndb_multi.result b/mysql-test/r/rpl_ndb_multi.result index 66819c2c9c8..a42bccbf9a5 100644 --- a/mysql-test/r/rpl_ndb_multi.result +++ b/mysql-test/r/rpl_ndb_multi.result @@ -26,11 +26,11 @@ stop slave; SELECT @the_pos:=Position,@the_file:=SUBSTRING_INDEX(FILE, '/', -1) FROM mysql.ndb_binlog_index WHERE epoch = ; @the_pos:=Position @the_file:=SUBSTRING_INDEX(FILE, '/', -1) -102 master-bin1.000001 +105 master-bin1.000001 CHANGE MASTER TO master_port=, master_log_file = 'master-bin1.000001', -master_log_pos = 102 ; +master_log_pos = 105 ; start slave; INSERT INTO t1 VALUES ("row2","will go away",2),("row3","will change",3),("row4","D",4); DELETE FROM t1 WHERE c3 = 1; diff --git a/mysql-test/r/rpl_rbr_to_sbr.result b/mysql-test/r/rpl_rbr_to_sbr.result index 4b2d129c732..d36277bed36 100644 --- a/mysql-test/r/rpl_rbr_to_sbr.result +++ b/mysql-test/r/rpl_rbr_to_sbr.result @@ -28,7 +28,7 @@ Master_User root Master_Port MASTER_PORT Connect_Retry 1 Master_Log_File master-bin.000001 -Read_Master_Log_Pos 450 +Read_Master_Log_Pos 453 Relay_Log_File # Relay_Log_Pos # Relay_Master_Log_File master-bin.000001 @@ -43,7 +43,7 @@ Replicate_Wild_Ignore_Table Last_Errno 0 Last_Error Skip_Counter 0 -Exec_Master_Log_Pos 450 +Exec_Master_Log_Pos 453 Relay_Log_Space # Until_Condition None Until_Log_File diff --git a/mysql-test/r/rpl_rotate_logs.result b/mysql-test/r/rpl_rotate_logs.result index 264f5d224bd..8f0cf29ab34 100644 --- a/mysql-test/r/rpl_rotate_logs.result +++ b/mysql-test/r/rpl_rotate_logs.result @@ -16,7 +16,7 @@ create table t1 (s text); insert into t1 values('Could not break slave'),('Tried hard'); show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_PORT 60 master-bin.000001 552 # # master-bin.000001 Yes Yes # 0 0 552 # None 0 No # +# 127.0.0.1 root MASTER_PORT 60 master-bin.000001 555 # # master-bin.000001 Yes Yes # 0 0 555 # None 0 No # select * from t1; s Could not break slave @@ -27,9 +27,9 @@ insert into t2 values (34),(67),(123); flush logs; show binary logs; Log_name File_size -master-bin.000001 596 -master-bin.000002 367 -master-bin.000003 102 +master-bin.000001 599 +master-bin.000002 370 +master-bin.000003 105 create table t3 select * from temp_table; select * from t3; a @@ -43,21 +43,21 @@ start slave; purge master logs to 'master-bin.000002'; show master logs; Log_name File_size -master-bin.000002 367 -master-bin.000003 411 +master-bin.000002 370 +master-bin.000003 414 purge binary logs to 'master-bin.000002'; show binary logs; Log_name File_size -master-bin.000002 367 -master-bin.000003 411 +master-bin.000002 370 +master-bin.000003 414 purge master logs before now(); show binary logs; Log_name File_size -master-bin.000003 411 +master-bin.000003 414 insert into t2 values (65); show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_PORT 60 master-bin.000003 500 # # master-bin.000003 Yes Yes # 0 0 500 # None 0 No # +# 127.0.0.1 root MASTER_PORT 60 master-bin.000003 503 # # master-bin.000003 Yes Yes # 0 0 503 # None 0 No # select * from t2; m 34 @@ -74,18 +74,18 @@ count(*) create table t4 select * from temp_table; show binary logs; Log_name File_size -master-bin.000003 4189 -master-bin.000004 4194 -master-bin.000005 2036 +master-bin.000003 4192 +master-bin.000004 4197 +master-bin.000005 2039 show master status; File Position Binlog_Do_DB Binlog_Ignore_DB -master-bin.000005 2036 +master-bin.000005 2039 select * from t4; a testing temporary tables part 2 show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_PORT 60 master-bin.000005 2036 # # master-bin.000005 Yes Yes # 0 0 2036 # None 0 No # +# 127.0.0.1 root MASTER_PORT 60 master-bin.000005 2039 # # master-bin.000005 Yes Yes # 0 0 2039 # None 0 No # lock tables t3 read; select count(*) from t3 where n >= 4; count(*) diff --git a/mysql-test/r/rpl_row_basic_11bugs-master.opt b/mysql-test/r/rpl_row_basic_11bugs-master.opt new file mode 100644 index 00000000000..627becdbfb5 --- /dev/null +++ b/mysql-test/r/rpl_row_basic_11bugs-master.opt @@ -0,0 +1 @@ +--innodb diff --git a/mysql-test/r/rpl_row_basic_11bugs-slave.opt b/mysql-test/r/rpl_row_basic_11bugs-slave.opt new file mode 100644 index 00000000000..627becdbfb5 --- /dev/null +++ b/mysql-test/r/rpl_row_basic_11bugs-slave.opt @@ -0,0 +1 @@ +--innodb diff --git a/mysql-test/r/rpl_sp.result b/mysql-test/r/rpl_sp.result index ea07a86d009..9b316abd63c 100644 --- a/mysql-test/r/rpl_sp.result +++ b/mysql-test/r/rpl_sp.result @@ -381,7 +381,7 @@ return 0; end| use mysqltest; set @a:= mysqltest2.f1(); -show binlog events in 'master-bin.000001' from 102; +show binlog events in 'master-bin.000001' from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # drop database if exists mysqltest1 master-bin.000001 # Query 1 # create database mysqltest1 diff --git a/mysql-test/r/rpl_stm_charset.result b/mysql-test/r/rpl_stm_charset.result index f1691608bc7..a0e155b2787 100644 --- a/mysql-test/r/rpl_stm_charset.result +++ b/mysql-test/r/rpl_stm_charset.result @@ -103,7 +103,7 @@ a b 1 cp850_general_ci drop database mysqltest2; drop database mysqltest3; -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # drop database if exists mysqltest2 master-bin.000001 # Query 1 # drop database if exists mysqltest3 diff --git a/mysql-test/r/rpl_stm_flsh_tbls.result b/mysql-test/r/rpl_stm_flsh_tbls.result index a6123d75cb3..fbdbe49f04d 100644 --- a/mysql-test/r/rpl_stm_flsh_tbls.result +++ b/mysql-test/r/rpl_stm_flsh_tbls.result @@ -12,13 +12,13 @@ create table t4 (a int); insert into t4 select * from t3; rename table t1 to t5, t2 to t1; flush no_write_to_binlog tables; -SHOW BINLOG EVENTS FROM 652 ; +SHOW BINLOG EVENTS FROM 655 ; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; rename table t1 to t5, t2 to t1 select * from t3; a flush tables; -SHOW BINLOG EVENTS FROM 652 ; +SHOW BINLOG EVENTS FROM 655 ; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; rename table t1 to t5, t2 to t1 master-bin.000001 # Query 1 # use `test`; flush tables diff --git a/mysql-test/r/rpl_stm_log.result b/mysql-test/r/rpl_stm_log.result index e0b1aa12c9b..63e939d44a3 100644 --- a/mysql-test/r/rpl_stm_log.result +++ b/mysql-test/r/rpl_stm_log.result @@ -26,14 +26,14 @@ master-bin.000001 # Query 1 # use `test`; drop table t1 master-bin.000001 # Query 1 # use `test`; create table t1 (word char(20) not null)ENGINE=MyISAM master-bin.000001 # Begin_load_query 1 # ;file_id=1;block_len=581 master-bin.000001 # Execute_load_query 1 # use `test`; load data infile '../std_data_ln/words.dat' into table t1 ignore 1 lines ;file_id=1 -show binlog events from 102 limit 1; +show binlog events from 105 limit 1; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM -show binlog events from 102 limit 2; +show binlog events from 105 limit 2; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; create table t1(n int not null auto_increment primary key)ENGINE=MyISAM master-bin.000001 # Intvar 1 # INSERT_ID=1 -show binlog events from 102 limit 2,1; +show binlog events from 105 limit 2,1; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; insert into t1 values (NULL) flush logs; @@ -66,13 +66,13 @@ master-bin.000002 # Query 1 # use `test`; create table t2 (n int)ENGINE=MyISAM master-bin.000002 # Query 1 # use `test`; insert into t2 values (1) show binary logs; Log_name File_size -master-bin.000001 1343 -master-bin.000002 388 +master-bin.000001 1346 +master-bin.000002 391 start slave; show binary logs; Log_name File_size -slave-bin.000001 1443 -slave-bin.000002 289 +slave-bin.000001 1446 +slave-bin.000002 292 show binlog events in 'slave-bin.000001' from 4; Log_name Pos Event_type Server_id End_log_pos Info slave-bin.000001 # Format_desc 2 # Server ver: VERSION, Binlog ver: 4 @@ -92,7 +92,7 @@ slave-bin.000002 # Query 1 # use `test`; create table t2 (n int)ENGINE=MyISAM slave-bin.000002 # Query 1 # use `test`; insert into t2 values (1) show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 388 # # master-bin.000002 Yes Yes # 0 0 388 # None 0 No # +# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 391 # # master-bin.000002 Yes Yes # 0 0 391 # None 0 No # show binlog events in 'slave-bin.000005' from 4; ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Could not find target log DROP TABLE t1; diff --git a/mysql-test/r/rpl_stm_max_relay_size.result b/mysql-test/r/rpl_stm_max_relay_size.result index c4a9a5bd3ff..ab0a4cd978d 100644 --- a/mysql-test/r/rpl_stm_max_relay_size.result +++ b/mysql-test/r/rpl_stm_max_relay_size.result @@ -28,7 +28,7 @@ Master_User root Master_Port MASTER_PORT Connect_Retry 1 Master_Log_File master-bin.000001 -Read_Master_Log_Pos 72956 +Read_Master_Log_Pos 72959 Relay_Log_File # Relay_Log_Pos # Relay_Master_Log_File master-bin.000001 @@ -43,7 +43,7 @@ Replicate_Wild_Ignore_Table Last_Errno 0 Last_Error Skip_Counter 0 -Exec_Master_Log_Pos 72956 +Exec_Master_Log_Pos 72959 Relay_Log_Space # Until_Condition None Until_Log_File @@ -71,7 +71,7 @@ Master_User root Master_Port MASTER_PORT Connect_Retry 1 Master_Log_File master-bin.000001 -Read_Master_Log_Pos 72956 +Read_Master_Log_Pos 72959 Relay_Log_File # Relay_Log_Pos # Relay_Master_Log_File master-bin.000001 @@ -86,7 +86,7 @@ Replicate_Wild_Ignore_Table Last_Errno 0 Last_Error Skip_Counter 0 -Exec_Master_Log_Pos 72956 +Exec_Master_Log_Pos 72959 Relay_Log_Space # Until_Condition None Until_Log_File @@ -114,7 +114,7 @@ Master_User root Master_Port MASTER_PORT Connect_Retry 1 Master_Log_File master-bin.000001 -Read_Master_Log_Pos 72956 +Read_Master_Log_Pos 72959 Relay_Log_File # Relay_Log_Pos # Relay_Master_Log_File master-bin.000001 @@ -129,7 +129,7 @@ Replicate_Wild_Ignore_Table Last_Errno 0 Last_Error Skip_Counter 0 -Exec_Master_Log_Pos 72956 +Exec_Master_Log_Pos 72959 Relay_Log_Space # Until_Condition None Until_Log_File @@ -195,7 +195,7 @@ Master_User root Master_Port MASTER_PORT Connect_Retry 1 Master_Log_File master-bin.000001 -Read_Master_Log_Pos 73042 +Read_Master_Log_Pos 73045 Relay_Log_File # Relay_Log_Pos # Relay_Master_Log_File master-bin.000001 @@ -210,7 +210,7 @@ Replicate_Wild_Ignore_Table Last_Errno 0 Last_Error Skip_Counter 0 -Exec_Master_Log_Pos 73042 +Exec_Master_Log_Pos 73045 Relay_Log_Space # Until_Condition None Until_Log_File @@ -234,7 +234,7 @@ Master_User root Master_Port MASTER_PORT Connect_Retry 1 Master_Log_File master-bin.000001 -Read_Master_Log_Pos 73118 +Read_Master_Log_Pos 73121 Relay_Log_File # Relay_Log_Pos # Relay_Master_Log_File master-bin.000001 @@ -249,7 +249,7 @@ Replicate_Wild_Ignore_Table Last_Errno 0 Last_Error Skip_Counter 0 -Exec_Master_Log_Pos 73118 +Exec_Master_Log_Pos 73121 Relay_Log_Space # Until_Condition None Until_Log_File @@ -264,7 +264,7 @@ Seconds_Behind_Master # flush logs; show master status; File master-bin.000002 -Position 102 +Position 105 Binlog_Do_DB Binlog_Ignore_DB set global max_binlog_size= @my_max_binlog_size; diff --git a/mysql-test/r/rpl_stm_multi_query.result b/mysql-test/r/rpl_stm_multi_query.result index bf914e6ce6c..726e2bad697 100644 --- a/mysql-test/r/rpl_stm_multi_query.result +++ b/mysql-test/r/rpl_stm_multi_query.result @@ -19,7 +19,7 @@ n 3 4 5 -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # drop database if exists mysqltest master-bin.000001 # Query 1 # create database mysqltest diff --git a/mysql-test/r/rpl_stm_reset_slave.result b/mysql-test/r/rpl_stm_reset_slave.result index 834b9add089..4ce942869a8 100644 --- a/mysql-test/r/rpl_stm_reset_slave.result +++ b/mysql-test/r/rpl_stm_reset_slave.result @@ -6,12 +6,12 @@ drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 102 # # master-bin.000001 Yes Yes # 0 0 102 # None 0 No # +# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 105 # # master-bin.000001 Yes Yes # 0 0 105 # None 0 No # stop slave; change master to master_user='test'; show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 test MASTER_PORT 1 master-bin.000001 102 # # master-bin.000001 No No # 0 0 102 # None 0 No # +# 127.0.0.1 test MASTER_PORT 1 master-bin.000001 105 # # master-bin.000001 No No # 0 0 105 # None 0 No # reset slave; show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master @@ -19,7 +19,7 @@ Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File start slave; show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 102 # # master-bin.000001 Yes Yes # 0 0 102 # None 0 No # +# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 105 # # master-bin.000001 Yes Yes # 0 0 105 # None 0 No # stop slave; reset slave; start slave; diff --git a/mysql-test/r/rpl_stm_until.result b/mysql-test/r/rpl_stm_until.result index e8e33b66864..81e23da2bd0 100644 --- a/mysql-test/r/rpl_stm_until.result +++ b/mysql-test/r/rpl_stm_until.result @@ -26,7 +26,7 @@ Master_User root Master_Port MASTER_MYPORT Connect_Retry 1 Master_Log_File master-bin.000001 -Read_Master_Log_Pos 780 +Read_Master_Log_Pos 783 Relay_Log_File slave-relay-bin.000004 Relay_Log_Pos # Relay_Master_Log_File master-bin.000001 @@ -41,7 +41,7 @@ Replicate_Wild_Ignore_Table Last_Errno 0 Last_Error Skip_Counter 0 -Exec_Master_Log_Pos 323 +Exec_Master_Log_Pos 326 Relay_Log_Space # Until_Condition Master Until_Log_File master-bin.000001 @@ -67,7 +67,7 @@ Master_User root Master_Port MASTER_MYPORT Connect_Retry 1 Master_Log_File master-bin.000001 -Read_Master_Log_Pos 780 +Read_Master_Log_Pos 783 Relay_Log_File slave-relay-bin.000004 Relay_Log_Pos # Relay_Master_Log_File master-bin.000001 @@ -82,7 +82,7 @@ Replicate_Wild_Ignore_Table Last_Errno 0 Last_Error Skip_Counter 0 -Exec_Master_Log_Pos 323 +Exec_Master_Log_Pos 326 Relay_Log_Space # Until_Condition Master Until_Log_File master-no-such-bin.000001 @@ -106,7 +106,7 @@ Master_User root Master_Port MASTER_MYPORT Connect_Retry 1 Master_Log_File master-bin.000001 -Read_Master_Log_Pos 780 +Read_Master_Log_Pos 783 Relay_Log_File slave-relay-bin.000004 Relay_Log_Pos # Relay_Master_Log_File master-bin.000001 @@ -121,7 +121,7 @@ Replicate_Wild_Ignore_Table Last_Errno 0 Last_Error Skip_Counter 0 -Exec_Master_Log_Pos 612 +Exec_Master_Log_Pos 615 Relay_Log_Space # Until_Condition Relay Until_Log_File slave-relay-bin.000004 @@ -143,7 +143,7 @@ Master_User root Master_Port MASTER_MYPORT Connect_Retry 1 Master_Log_File master-bin.000001 -Read_Master_Log_Pos 780 +Read_Master_Log_Pos 783 Relay_Log_File slave-relay-bin.000004 Relay_Log_Pos # Relay_Master_Log_File master-bin.000001 @@ -158,7 +158,7 @@ Replicate_Wild_Ignore_Table Last_Errno 0 Last_Error Skip_Counter 0 -Exec_Master_Log_Pos 780 +Exec_Master_Log_Pos 783 Relay_Log_Space # Until_Condition Master Until_Log_File master-bin.000001 diff --git a/mysql-test/r/rpl_truncate_7ndb.result b/mysql-test/r/rpl_truncate_7ndb.result index 63d4b0f9411..59c285d8a82 100644 --- a/mysql-test/r/rpl_truncate_7ndb.result +++ b/mysql-test/r/rpl_truncate_7ndb.result @@ -29,16 +29,17 @@ a b DROP TABLE t1; SHOW BINLOG EVENTS; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4 -master-bin.000001 102 Query 1 219 use `test`; CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB -master-bin.000001 219 Query 1 283 BEGIN -master-bin.000001 283 Table_map 1 40 table_id: # (test.t1) -master-bin.000001 323 Table_map 1 95 table_id: # (mysql.ndb_apply_status) -master-bin.000001 378 Write_rows 1 137 table_id: # -master-bin.000001 420 Write_rows 1 184 table_id: # flags: STMT_END_F -master-bin.000001 467 Query 1 532 COMMIT -master-bin.000001 532 Query 1 612 use `test`; TRUNCATE TABLE t1 -master-bin.000001 612 Query 1 688 use `test`; DROP TABLE t1 +master-bin.000001 4 Format_desc 1 105 Server ver: SERVER_VERSION, Binlog ver: 4 +master-bin.000001 105 Query 1 222 use `test`; CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB +master-bin.000001 222 Query 1 286 BEGIN +master-bin.000001 286 Table_map 1 40 table_id: # (test.t1) +master-bin.000001 326 Table_map 1 95 table_id: # (mysql.ndb_apply_status) +master-bin.000001 381 Write_rows 1 137 table_id: # +master-bin.000001 423 Write_rows 1 175 table_id: # +master-bin.000001 461 Write_rows 1 213 table_id: # flags: STMT_END_F +master-bin.000001 499 Query 1 564 COMMIT +master-bin.000001 564 Query 1 644 use `test`; TRUNCATE TABLE t1 +master-bin.000001 644 Query 1 720 use `test`; DROP TABLE t1 **** On Master **** CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB; INSERT INTO t1 VALUES (1,1), (2,2); @@ -65,27 +66,30 @@ a b DROP TABLE t1; SHOW BINLOG EVENTS; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 4 Format_desc 1 102 Server ver: SERVER_VERSION, Binlog ver: 4 -master-bin.000001 102 Query 1 219 use `test`; CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB -master-bin.000001 219 Query 1 283 BEGIN -master-bin.000001 283 Table_map 1 40 table_id: # (test.t1) -master-bin.000001 323 Table_map 1 95 table_id: # (mysql.ndb_apply_status) -master-bin.000001 378 Write_rows 1 137 table_id: # -master-bin.000001 420 Write_rows 1 184 table_id: # flags: STMT_END_F -master-bin.000001 467 Query 1 532 COMMIT -master-bin.000001 532 Query 1 612 use `test`; TRUNCATE TABLE t1 -master-bin.000001 612 Query 1 688 use `test`; DROP TABLE t1 -master-bin.000001 688 Query 1 805 use `test`; CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB -master-bin.000001 805 Query 1 869 BEGIN -master-bin.000001 869 Table_map 1 40 table_id: # (test.t1) -master-bin.000001 909 Table_map 1 95 table_id: # (mysql.ndb_apply_status) -master-bin.000001 964 Write_rows 1 137 table_id: # -master-bin.000001 1006 Write_rows 1 184 table_id: # flags: STMT_END_F -master-bin.000001 1053 Query 1 1118 COMMIT -master-bin.000001 1118 Query 1 1182 BEGIN -master-bin.000001 1182 Table_map 1 40 table_id: # (test.t1) -master-bin.000001 1222 Table_map 1 95 table_id: # (mysql.ndb_apply_status) -master-bin.000001 1277 Write_rows 1 137 table_id: # -master-bin.000001 1319 Delete_rows 1 176 table_id: # flags: STMT_END_F -master-bin.000001 1358 Query 1 1423 COMMIT -master-bin.000001 1423 Query 1 1499 use `test`; DROP TABLE t1 +master-bin.000001 4 Format_desc 1 105 Server ver: SERVER_VERSION, Binlog ver: 4 +master-bin.000001 105 Query 1 222 use `test`; CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB +master-bin.000001 222 Query 1 286 BEGIN +master-bin.000001 286 Table_map 1 40 table_id: # (test.t1) +master-bin.000001 326 Table_map 1 95 table_id: # (mysql.ndb_apply_status) +master-bin.000001 381 Write_rows 1 137 table_id: # +master-bin.000001 423 Write_rows 1 175 table_id: # +master-bin.000001 461 Write_rows 1 213 table_id: # flags: STMT_END_F +master-bin.000001 499 Query 1 564 COMMIT +master-bin.000001 564 Query 1 644 use `test`; TRUNCATE TABLE t1 +master-bin.000001 644 Query 1 720 use `test`; DROP TABLE t1 +master-bin.000001 720 Query 1 837 use `test`; CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB +master-bin.000001 837 Query 1 901 BEGIN +master-bin.000001 901 Table_map 1 40 table_id: # (test.t1) +master-bin.000001 941 Table_map 1 95 table_id: # (mysql.ndb_apply_status) +master-bin.000001 996 Write_rows 1 137 table_id: # +master-bin.000001 1038 Write_rows 1 175 table_id: # +master-bin.000001 1076 Write_rows 1 213 table_id: # flags: STMT_END_F +master-bin.000001 1114 Query 1 1179 COMMIT +master-bin.000001 1179 Query 1 1243 BEGIN +master-bin.000001 1243 Table_map 1 40 table_id: # (test.t1) +master-bin.000001 1283 Table_map 1 95 table_id: # (mysql.ndb_apply_status) +master-bin.000001 1338 Write_rows 1 137 table_id: # +master-bin.000001 1380 Delete_rows 1 171 table_id: # +master-bin.000001 1414 Delete_rows 1 205 table_id: # flags: STMT_END_F +master-bin.000001 1448 Query 1 1513 COMMIT +master-bin.000001 1513 Query 1 1589 use `test`; DROP TABLE t1 diff --git a/mysql-test/r/user_var-binlog.result b/mysql-test/r/user_var-binlog.result index 1c50289a85d..901d0718d0d 100644 --- a/mysql-test/r/user_var-binlog.result +++ b/mysql-test/r/user_var-binlog.result @@ -6,7 +6,7 @@ INSERT INTO t1 VALUES(@`a b`); set @var1= "';aaa"; SET @var2=char(ascii('a')); insert into t1 values (@var1),(@var2); -show binlog events from 102; +show binlog events from 105; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # User var 1 # @`a b`=_latin1 0x68656C6C6F COLLATE latin1_swedish_ci master-bin.000001 # Query 1 # use `test`; INSERT INTO t1 VALUES(@`a b`) diff --git a/mysql-test/t/binlog_stm_mix_innodb_myisam.test b/mysql-test/t/binlog_stm_mix_innodb_myisam.test index 8d7399b918e..980de0961af 100644 --- a/mysql-test/t/binlog_stm_mix_innodb_myisam.test +++ b/mysql-test/t/binlog_stm_mix_innodb_myisam.test @@ -12,7 +12,7 @@ # ER_SERVER_SHUTDOWN (i.e. disconnection just rolls back transaction # and does not make slave to stop) flush logs; ---exec $MYSQL_BINLOG --start-position=551 $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output +--exec $MYSQL_BINLOG --start-position=554 $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR eval select (@a:=load_file("$MYSQLTEST_VARDIR/tmp/mix_innodb_myisam_binlog.output")) diff --git a/mysql-test/t/ctype_cp932_binlog_stm.test b/mysql-test/t/ctype_cp932_binlog_stm.test index 9111c4ad369..7ebb20f4d22 100644 --- a/mysql-test/t/ctype_cp932_binlog_stm.test +++ b/mysql-test/t/ctype_cp932_binlog_stm.test @@ -22,7 +22,7 @@ CALL bug18293("Foo's a Bar", _cp932 0xED40ED41ED42, 47.93)| SELECT HEX(s1),HEX(s2),d FROM t4| DROP PROCEDURE bug18293| DROP TABLE t4| -SHOW BINLOG EVENTS FROM 406| +SHOW BINLOG EVENTS FROM 409| delimiter ;| # End of 5.0 tests diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index 852cc6d2e36..d91a7cb57df 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -65,7 +65,7 @@ select "--- --database --" as ""; select "--- --position --" as ""; --enable_query_log --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=235 $MYSQLTEST_VARDIR/log/master-bin.000002 +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=238 $MYSQLTEST_VARDIR/log/master-bin.000002 # These are tests for remote binlog. # They should return the same as previous test. @@ -97,7 +97,7 @@ select "--- --database --" as ""; select "--- --position --" as ""; --enable_query_log --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --position=235 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002 +--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --position=238 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002 # Bug#7853 (mysqlbinlog does not accept input from stdin) --disable_query_log diff --git a/mysql-test/t/mysqlbinlog2.test b/mysql-test/t/mysqlbinlog2.test index 85a678055d4..52045abbe78 100644 --- a/mysql-test/t/mysqlbinlog2.test +++ b/mysql-test/t/mysqlbinlog2.test @@ -52,11 +52,11 @@ select "--- offset --" as ""; --disable_query_log select "--- start-position --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --start-position=604 $MYSQLTEST_VARDIR/log/master-bin.000001 +--exec $MYSQL_BINLOG --short-form --start-position=607 $MYSQLTEST_VARDIR/log/master-bin.000001 --disable_query_log select "--- stop-position --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --stop-position=604 $MYSQLTEST_VARDIR/log/master-bin.000001 +--exec $MYSQL_BINLOG --short-form --stop-position=607 $MYSQLTEST_VARDIR/log/master-bin.000001 --disable_query_log select "--- start-datetime --" as ""; --enable_query_log @@ -82,11 +82,11 @@ select "--- offset --" as ""; --disable_query_log select "--- start-position --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --start-position=604 $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002 +--exec $MYSQL_BINLOG --short-form --start-position=607 $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002 --disable_query_log select "--- stop-position --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --stop-position=130 $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002 +--exec $MYSQL_BINLOG --short-form --stop-position=133 $MYSQLTEST_VARDIR/log/master-bin.000001 $MYSQLTEST_VARDIR/log/master-bin.000002 --disable_query_log select "--- start-datetime --" as ""; --enable_query_log @@ -109,11 +109,11 @@ select "--- offset --" as ""; --disable_query_log select "--- start-position --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --start-position=604 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 +--exec $MYSQL_BINLOG --short-form --start-position=607 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 --disable_query_log select "--- stop-position --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --stop-position=604 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 +--exec $MYSQL_BINLOG --short-form --stop-position=607 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 --disable_query_log select "--- start-datetime --" as ""; --enable_query_log @@ -136,11 +136,11 @@ select "--- offset --" as ""; --disable_query_log select "--- start-position --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --start-position=604 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002 +--exec $MYSQL_BINLOG --short-form --start-position=607 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002 --disable_query_log select "--- stop-position --" as ""; --enable_query_log ---exec $MYSQL_BINLOG --short-form --stop-position=130 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002 +--exec $MYSQL_BINLOG --short-form --stop-position=133 --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 master-bin.000002 --disable_query_log select "--- start-datetime --" as ""; --enable_query_log diff --git a/mysql-test/t/rpl_sp.test b/mysql-test/t/rpl_sp.test index 9230b3bff4f..75ecbe303ce 100644 --- a/mysql-test/t/rpl_sp.test +++ b/mysql-test/t/rpl_sp.test @@ -566,7 +566,7 @@ connection master; # were written to the binary log. --replace_column 2 # 5 # --replace_regex /table_id: [0-9]+/table_id: #/ -show binlog events in 'master-bin.000001' from 102; +show binlog events in 'master-bin.000001' from 105; # Restore log_bin_trust_function_creators to its original value. diff --git a/mysql-test/t/rpl_stm_flsh_tbls.test b/mysql-test/t/rpl_stm_flsh_tbls.test index 43a5234ccc7..c571ae638b6 100644 --- a/mysql-test/t/rpl_stm_flsh_tbls.test +++ b/mysql-test/t/rpl_stm_flsh_tbls.test @@ -1,7 +1,7 @@ # depends on the binlog output --source include/have_binlog_format_mixed_or_statement.inc -let $rename_event_pos= 652; +let $rename_event_pos= 655; -- source extra/rpl_tests/rpl_flsh_tbls.test # End of 4.1 tests diff --git a/sql/log_event.cc b/sql/log_event.cc index f35ac998fa6..3fe6b39503e 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -5641,7 +5641,7 @@ unpack_row(RELAY_LOG_INFO *rli, bitmap_clear_all(rw_set); - memcpy(table->record[0], table->s->default_values, table->s->null_bytes); + empty_record(table); Field **const begin_ptr = table->field; Field **field_ptr; @@ -5657,6 +5657,10 @@ unpack_row(RELAY_LOG_INFO *rli, { Field *const f= *field_ptr; + /* + No need to bother about columns that does not exist: they have + gotten default values when being emptied above. + */ if (bitmap_is_set(cols, field_ptr - begin_ptr)) { if ((null_mask & 0xFF) == 0) @@ -5680,10 +5684,13 @@ unpack_row(RELAY_LOG_INFO *rli, /* We only unpack the field if it was non-null */ + const char *const old_ptr= pack_ptr; pack_ptr= f->unpack(f->ptr, pack_ptr); + DBUG_PRINT("debug", ("Unpacking field '%s' from %d bytes", + f->field_name, pack_ptr - old_ptr)); } - bitmap_set_bit(rw_set, field_ptr - begin_ptr); + bitmap_set_bit(rw_set, f->field_index); null_mask <<= 1; } } @@ -6784,6 +6791,15 @@ copy_extra_record_fields(TABLE *table, return 0; // All OK } +#define DBUG_PRINT_BITSET(N,FRM,BS) \ + do { \ + char buf[256]; \ + for (uint i = 0 ; i < (BS)->n_bits ; ++i) \ + buf[i] = bitmap_is_set((BS), i) ? '1' : '0'; \ + buf[(BS)->n_bits] = '\0'; \ + DBUG_PRINT((N), ((FRM), buf)); \ + } while (0) + /* Replace the provided record in the database. @@ -6816,6 +6832,12 @@ replace_record(THD *thd, TABLE *table, int keynum; auto_afree_ptr key(NULL); +#ifndef DBUG_OFF + DBUG_DUMP("record[0]", table->record[0], table->s->reclength); + DBUG_PRINT_BITSET("debug", "write_set = %s", table->write_set); + DBUG_PRINT_BITSET("debug", "read_set = %s", table->read_set); +#endif + while ((error= table->file->ha_write_row(table->record[0]))) { if (error == HA_ERR_LOCK_DEADLOCK || error == HA_ERR_LOCK_WAIT_TIMEOUT) @@ -6937,20 +6959,75 @@ void Write_rows_log_event::print(FILE *file, PRINT_EVENT_INFO* print_event_info) */ static bool record_compare(TABLE *table) { + /* + Need to set the X bit and the filler bits in both records since + there are engines that do not set it correctly. + + In addition, since MyISAM checks that one hasn't tampered with the + record, it is necessary to restore the old bytes into the record + after doing the comparison. + + TODO[record format ndb]: Remove it once NDB returns correct + records. Check that the other engines also return correct records. + */ + + bool result= FALSE; + byte saved_x[2], saved_filler[2]; + + if (table->s->null_bytes > 0) + { + for (int i = 0 ; i < 2 ; ++i) + { + saved_x[i]= table->record[i][0]; + saved_filler[i]= table->record[i][table->s->null_bytes - 1]; + table->record[i][0]|= 1U; + table->record[i][table->s->null_bytes - 1]|= + 256U - (1U << table->s->last_null_bit_pos); + } + } + if (table->s->blob_fields + table->s->varchar_fields == 0) - return cmp_record(table,record[1]); + { + result= cmp_record(table,record[1]); + goto record_compare_exit; + } + /* Compare null bits */ if (memcmp(table->null_flags, table->null_flags+table->s->rec_buff_length, table->s->null_bytes)) - return TRUE; // Diff in NULL value + { + result= TRUE; // Diff in NULL value + goto record_compare_exit; + } + /* Compare updated fields */ for (Field **ptr=table->field ; *ptr ; ptr++) { if ((*ptr)->cmp_binary_offset(table->s->rec_buff_length)) - return TRUE; + { + result= TRUE; + goto record_compare_exit; + } } - return FALSE; + +record_compare_exit: + /* + Restore the saved bytes. + + TODO[record format ndb]: Remove this code once NDB returns the + correct record format. + */ + if (table->s->null_bytes > 0) + { + for (int i = 0 ; i < 2 ; ++i) + { + table->record[i][0]= saved_x[i]; + table->record[i][table->s->null_bytes - 1]= saved_filler[i]; + } + } + + return result; } @@ -7094,6 +7171,9 @@ static int find_and_fetch_row(TABLE *table, byte *key) are all set when returning. There are storage engines that just set the necessary bits on the bytes and don't set the filler bits correctly. + + TODO[record format ndb]: Remove this code once NDB returns the + correct record format. */ if (table->s->null_bytes > 0) { @@ -7126,16 +7206,6 @@ static int find_and_fetch_row(TABLE *table, byte *key) /* Continue until we find the right record or have made a full loop */ do { - /* - Patching the record before calling rnd_next() since some - storage engines do not set the filler bits correctly. - */ - if (table->s->null_bytes > 0) - { - table->record[1][table->s->null_bytes - 1]|= - 256U - (1U << table->s->last_null_bit_pos); - } - error= table->file->rnd_next(table->record[1]); DBUG_DUMP("record[0]", table->record[0], table->s->reclength); @@ -7154,6 +7224,7 @@ static int find_and_fetch_row(TABLE *table, byte *key) default: table->file->print_error(error, MYF(0)); + DBUG_PRINT("info", ("Record not found")); table->file->ha_rnd_end(); DBUG_RETURN(error); } @@ -7163,6 +7234,7 @@ static int find_and_fetch_row(TABLE *table, byte *key) /* Have to restart the scan to be able to fetch the next row. */ + DBUG_PRINT("info", ("Record %sfound", restart_count == 2 ? "not " : "")); table->file->ha_rnd_end(); DBUG_ASSERT(error == HA_ERR_END_OF_FILE || error == 0); From b1f69b48ef4ff2354b8b7cd9889a3ab02dea548c Mon Sep 17 00:00:00 2001 From: "mats@romeo.(none)" <> Date: Tue, 20 Mar 2007 14:13:07 +0100 Subject: [PATCH 08/22] BUG#26969: Field_bit::pack() and Field_bit::unpack() does not work correctly Fixing code for Field_bit packing and unpacking to work with arbitrary pointers instead of requiring Field::ptr --- sql/field.cc | 34 ++++++++++++++++++++++++++++++---- sql/sql_class.cc | 4 +--- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/sql/field.cc b/sql/field.cc index 488a5d591a3..ecfdb46ac02 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -8505,9 +8505,28 @@ char *Field_bit::pack(char *to, const char *from, uint max_length) { DBUG_ASSERT(max_length); uint length; - if (bit_len) + if (bit_len > 0) { - uchar bits= get_rec_bits(bit_ptr, bit_ofs, bit_len); + /* + We have the following: + + ptr Points into a field in record R1 + from Points to a field in a record R2 + bit_ptr Points to the byte (in the null bytes) that holds the + odd bits of R1 + from_bitp Points to the byte that holds the odd bits of R2 + + We have the following: + + ptr - bit_ptr = from - from_bitp + + We want to isolate 'from_bitp', so this gives: + + ptr - bit_ptr - from = - from_bitp + - ptr + bit_ptr + from = from_bitp + bit_ptr + from - ptr = from_bitp + */ + uchar bits= get_rec_bits(bit_ptr + (from - ptr), bit_ofs, bit_len); *to++= bits; } length= min(bytes_in_rec, max_length - (bit_len > 0)); @@ -8518,9 +8537,16 @@ char *Field_bit::pack(char *to, const char *from, uint max_length) const char *Field_bit::unpack(char *to, const char *from) { - if (bit_len) + if (bit_len > 0) { - set_rec_bits(*from, bit_ptr, bit_ofs, bit_len); + /* + set_rec_bits is a macro, don't put the post-increment in the + argument since that might cause strange side-effects. + + For the choice of the second argument, see the explanation for + Field_bit::pack(). + */ + set_rec_bits(*from, bit_ptr + (to - ptr), bit_ofs, bit_len); from++; } memcpy(to, from, bytes_in_rec); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 4ca15a8a5f9..0b87a4185dd 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -2619,9 +2619,7 @@ THD::pack_row(TABLE *table, MY_BITMAP const* cols, /* We only store the data of the field if it is non-null */ - field->move_field_offset(offset); - pack_ptr= (byte*)field->pack((char *) pack_ptr, field->ptr); - field->move_field_offset(-offset); + pack_ptr= (byte*)field->pack((char *) pack_ptr, field->ptr + offset); } null_mask <<= 1; From 2ee007ba9d0eb8517a43d767bf2ec4b7fcdad5ad Mon Sep 17 00:00:00 2001 From: "mats@romeo.(none)" <> Date: Thu, 22 Mar 2007 08:32:41 +0100 Subject: [PATCH 09/22] BUG#23171: Illegal group log position Tail fixes after re-applying patches to older version of clone. --- sql/log_event.cc | 119 +++++++++++---------- sql/log_event.h | 266 +++++++++++++++++++++++++++++++++------------- sql/rpl_rli.cc | 3 +- sql/rpl_rli.h | 9 ++ sql/slave.cc | 97 +++++++++++++---- sql/sql_binlog.cc | 12 ++- 6 files changed, 356 insertions(+), 150 deletions(-) diff --git a/sql/log_event.cc b/sql/log_event.cc index ec7136b5d58..8fb1457088e 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -596,14 +596,20 @@ int Log_event::do_update_pos(RELAY_LOG_INFO *rli) Log_event::enum_skip_reason -Log_event::shall_skip(RELAY_LOG_INFO *rli) +Log_event::do_shall_skip(RELAY_LOG_INFO *rli) { - if (this->server_id == ::server_id && !replicate_same_server_id) - return EVENT_SKIP_SAME_SID; + DBUG_PRINT("info", ("ev->server_id=%lu, ::server_id=%lu," + " rli->replicate_same_server_id=%d," + " rli->slave_skip_counter=%d", + (ulong) server_id, (ulong) ::server_id, + rli->replicate_same_server_id, + rli->slave_skip_counter)); + if (server_id == ::server_id && !rli->replicate_same_server_id) + return EVENT_SKIP_IGNORE; else if (rli->slave_skip_counter > 0) return EVENT_SKIP_COUNT; else - return EVENT_NOT_SKIPPED; + return EVENT_SKIP_NOT; } @@ -2566,9 +2572,9 @@ int Format_description_log_event::do_update_pos(RELAY_LOG_INFO *rli) } Log_event::enum_skip_reason -Format_description_log_event::shall_skip(RELAY_LOG_INFO *rli) +Format_description_log_event::do_shall_skip(RELAY_LOG_INFO *rli) { - return Log_event::EVENT_NOT_SKIPPED; + return Log_event::EVENT_SKIP_NOT; } #endif @@ -3077,7 +3083,7 @@ void Load_log_event::set_fields(const char* affected_db, */ int Load_log_event::do_apply_event(NET* net, RELAY_LOG_INFO const *rli, - bool use_rli_only_for_errors) + bool use_rli_only_for_errors) { LEX_STRING new_db; new_db.length= db_len; @@ -3416,6 +3422,7 @@ Rotate_log_event::Rotate_log_event(const char* buf, uint event_len, ident_offset = post_header_len; set_if_smaller(ident_len,FN_REFLEN-1); new_log_ident= my_strndup(buf + ident_offset, (uint) ident_len, MYF(MY_WME)); + DBUG_PRINT("debug", ("new_log_ident: '%s'", new_log_ident)); DBUG_VOID_RETURN; } @@ -3438,11 +3445,13 @@ bool Rotate_log_event::write(IO_CACHE* file) /** Helper function to detect if the event is inside a group. */ +#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) static bool is_in_group(THD *const thd, RELAY_LOG_INFO *const rli) { return (thd->options & OPTION_BEGIN) != 0 || (rli->last_event_start_time > 0); } +#endif /* @@ -3470,7 +3479,8 @@ int Rotate_log_event::do_update_pos(RELAY_LOG_INFO *rli) char buf[32]; #endif - DBUG_PRINT("info", ("server_id=%lu; ::server_id=%lu", this->server_id, ::server_id)); + DBUG_PRINT("info", ("server_id=%lu; ::server_id=%lu", + (ulong) this->server_id, (ulong) ::server_id)); DBUG_PRINT("info", ("new_log_ident: %s", this->new_log_ident)); DBUG_PRINT("info", ("pos: %s", llstr(this->pos, buf))); @@ -3490,10 +3500,15 @@ int Rotate_log_event::do_update_pos(RELAY_LOG_INFO *rli) In that case, we don't want to touch the coordinates which correspond to the beginning of the transaction. Starting from 5.0.0, there also are some rotates from the slave itself, in the - relay log. + relay log, which shall not change the group positions. */ - if (!is_in_group(thd, rli)) + if ((server_id != ::server_id || rli->replicate_same_server_id) && + !is_in_group(thd, rli)) { + DBUG_PRINT("info", ("old group_master_log_name: '%s' " + "old group_master_log_pos: %lu", + rli->group_master_log_name, + (ulong) rli->group_master_log_pos)); memcpy(rli->group_master_log_name, new_log_ident, ident_len+1); rli->notify_group_master_log_name_update(); rli->group_master_log_pos= pos; @@ -3524,18 +3539,17 @@ int Rotate_log_event::do_update_pos(RELAY_LOG_INFO *rli) Log_event::enum_skip_reason -Rotate_log_event::shall_skip(RELAY_LOG_INFO *rli) +Rotate_log_event::do_shall_skip(RELAY_LOG_INFO *rli) { - - enum_skip_reason reason= Log_event::shall_skip(rli); + enum_skip_reason reason= Log_event::do_shall_skip(rli); switch (reason) { - case Log_event::EVENT_NOT_SKIPPED: + case Log_event::EVENT_SKIP_NOT: case Log_event::EVENT_SKIP_COUNT: - return Log_event::EVENT_NOT_SKIPPED; + return Log_event::EVENT_SKIP_NOT; - case Log_event::EVENT_SKIP_SAME_SID: - return Log_event::EVENT_SKIP_SAME_SID; + case Log_event::EVENT_SKIP_IGNORE: + return Log_event::EVENT_SKIP_IGNORE; } DBUG_ASSERT(0); } @@ -3671,21 +3685,20 @@ int Intvar_log_event::do_update_pos(RELAY_LOG_INFO *rli) Log_event::enum_skip_reason -Intvar_log_event::shall_skip(RELAY_LOG_INFO *rli) +Intvar_log_event::do_shall_skip(RELAY_LOG_INFO *rli) { /* - It is a common error to set the slave skip counter to 1 instead - of 2 when recovering from an insert which used a auto increment, - rand, or user var. Therefore, if the slave skip counter is 1, - we just say that this event should be skipped because of the - slave skip count, but we do not change the value of the slave - skip counter since it will be decreased by the following insert - event. + It is a common error to set the slave skip counter to 1 instead of + 2 when recovering from an insert which used a auto increment, + rand, or user var. Therefore, if the slave skip counter is 1, we + just say that this event should be skipped by ignoring it, meaning + that we do not change the value of the slave skip counter since it + will be decreased by the following insert event. */ if (rli->slave_skip_counter == 1) - return Log_event::EVENT_SKIP_COUNT; + return Log_event::EVENT_SKIP_IGNORE; else - return Log_event::shall_skip(rli); + return Log_event::do_shall_skip(rli); } #endif @@ -3764,21 +3777,20 @@ int Rand_log_event::do_update_pos(RELAY_LOG_INFO *rli) Log_event::enum_skip_reason -Rand_log_event::shall_skip(RELAY_LOG_INFO *rli) +Rand_log_event::do_shall_skip(RELAY_LOG_INFO *rli) { /* - It is a common error to set the slave skip counter to 1 instead - of 2 when recovering from an insert which used a auto increment, - rand, or user var. Therefore, if the slave skip counter is 1, - we just say that this event should be skipped because of the - slave skip count, but we do not change the value of the slave - skip counter since it will be decreased by the following insert - event. + It is a common error to set the slave skip counter to 1 instead of + 2 when recovering from an insert which used a auto increment, + rand, or user var. Therefore, if the slave skip counter is 1, we + just say that this event should be skipped by ignoring it, meaning + that we do not change the value of the slave skip counter since it + will be decreased by the following insert event. */ if (rli->slave_skip_counter == 1) - return Log_event::EVENT_SKIP_COUNT; + return Log_event::EVENT_SKIP_IGNORE; else - return Log_event::shall_skip(rli); + return Log_event::do_shall_skip(rli); } #endif /* !MYSQL_CLIENT */ @@ -4204,22 +4216,21 @@ int User_var_log_event::do_update_pos(RELAY_LOG_INFO *rli) } Log_event::enum_skip_reason -User_var_log_event::shall_skip(RELAY_LOG_INFO *rli) - { - /* - It is a common error to set the slave skip counter to 1 instead - of 2 when recovering from an insert which used a auto increment, - rand, or user var. Therefore, if the slave skip counter is 1, - we just say that this event should be skipped because of the - slave skip count, but we do not change the value of the slave - skip counter since it will be decreased by the following insert - event. - */ - if (rli->slave_skip_counter == 1) - return Log_event::EVENT_SKIP_COUNT; - else - return Log_event::shall_skip(rli); - } +User_var_log_event::do_shall_skip(RELAY_LOG_INFO *rli) +{ + /* + It is a common error to set the slave skip counter to 1 instead + of 2 when recovering from an insert which used a auto increment, + rand, or user var. Therefore, if the slave skip counter is 1, we + just say that this event should be skipped by ignoring it, meaning + that we do not change the value of the slave skip counter since it + will be decreased by the following insert event. + */ + if (rli->slave_skip_counter == 1) + return Log_event::EVENT_SKIP_IGNORE; + else + return Log_event::do_shall_skip(rli); +} #endif /* !MYSQL_CLIENT */ @@ -5920,7 +5931,7 @@ int Rows_log_event::do_apply_event(RELAY_LOG_INFO const *rli) default: slave_print_msg(ERROR_LEVEL, rli, thd->net.last_errno, "Error in %s event: row application failed", - get_type_str(), error); + get_type_str()); thd->query_error= 1; break; } diff --git a/sql/log_event.h b/sql/log_event.h index 794cf410841..8da02a77b50 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -558,6 +558,33 @@ typedef struct st_print_event_info class Log_event { public: + /** + Enumeration of what kinds of skipping (and non-skipping) that can + occur when the slave executes an event. + + @see shall_skip + @see do_shall_skip + */ + enum enum_skip_reason { + /** + Don't skip event. + */ + EVENT_SKIP_NOT, + + /** + Skip event by ignoring it. + + This means that the slave skip counter will not be changed. + */ + EVENT_SKIP_IGNORE, + + /** + Skip event and decrease skip counter. + */ + EVENT_SKIP_COUNT + }; + + /* The offset in the log where this event originally appeared (it is preserved in relay logs, making SHOW SLAVE STATUS able to print @@ -633,40 +660,6 @@ public: #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(). @@ -747,36 +740,125 @@ public: /* 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) +public: + + /** + Apply the event to the database. + + This function represents the public interface for applying an + event. + + @see do_apply_event + */ + int apply_event(RELAY_LOG_INFO const *rli) { + return do_apply_event(rli); + } + + + /** + Update the relay log position. + + This function represents the public interface for "stepping over" + the event and will update the relay log information. + + @see do_update_pos + */ + int update_pos(RELAY_LOG_INFO *rli) + { + return do_update_pos(rli); + } + + /** + Decide if the event shall be skipped, and the reason for skipping + it. + + @see do_shall_skip + */ + enum_skip_reason shall_skip(RELAY_LOG_INFO *rli) + { + return do_shall_skip(rli); + } + +protected: /** Primitive to apply an event to the database. This is where the change to the database is made. + @note The primitive is protected instead of private, since there + is a hierarchy of actions to be performed in some cases. + + @see Format_description_log_event::do_apply_event() + @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); + virtual int do_apply_event(RELAY_LOG_INFO const *rli) + { + return 0; /* Default implementation does nothing */ + } + /** - Advance binary log coordinates. + Advance relay log coordinates. - This function is called to advance the binary log or relay log - coordinates to just after the event. + This function is called to advance the relay log coordinates to + just after the event. It is essential that both the relay log + coordinate and the group log position is updated correctly, since + this function is used also for skipping events. + + Normally, each implementation of do_update_pos() shall: + + - Update the event position to refer to the position just after + the event. + + - Update the group log position to refer to the position just + after the event if the event is last in a group @param rli Pointer to relay log info structure @retval 0 Coordinates changed successfully - @retval errno Error code if advancing failed + @retval errno Error code if advancing failed (usually just + 1). Observe that handler errors are returned by the + do_apply_event() function, and not by this one. */ - virtual int advance_coord_impl(RELAY_LOG_INFO *rli) - { - // !!! Dummy implementation for this patch only - return 0; - } + virtual int do_update_pos(RELAY_LOG_INFO *rli); + + + /** + Decide if this event shall be skipped or not and the reason for + skipping it. + + The default implementation decide that the event shall be skipped + if either: + + - the server id of the event is the same as the server id of the + server and rli->replicate_same_server_id is true, + or + + - if rli->slave_skip_counter is greater than zero. + + @see do_apply_event + @see do_update_pos + + @retval Log_event::EVENT_SKIP_NOT + The event shall not be skipped and should be applied. + + @retval Log_event::EVENT_SKIP_IGNORE + The event shall be skipped by just ignoring it, i.e., the slave + skip counter shall not be changed. This happends if, for example, + the originating server id of the event is the same as the server + id of the slave. + + @retval Log_event::EVENT_SKIP_COUNT + The event shall be skipped because the slave skip counter was + non-zero. The caller shall decrease the counter by one. + */ + virtual enum_skip_reason do_shall_skip(RELAY_LOG_INFO *rli); + #endif }; @@ -818,8 +900,8 @@ public: uint16 error_code; ulong thread_id; /* - For events created by Query_log_event::apply_event_impl (and - Load_log_event::apply_event_impl()) we need the *original* thread + For events created by Query_log_event::do_apply_event (and + Load_log_event::do_apply_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). */ @@ -913,8 +995,10 @@ public: 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, + virtual int do_apply_event(RELAY_LOG_INFO const *rli); + virtual int do_update_pos(RELAY_LOG_INFO *rli); + + int do_apply_event(RELAY_LOG_INFO const *rli, const char *query_arg, uint32 q_len_arg); #endif /* HAVE_REPLICATION */ @@ -981,7 +1065,7 @@ public: private: #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) - virtual int apply_event_impl(RELAY_LOG_INFO* rli); + virtual int do_apply_event(RELAY_LOG_INFO const* rli); #endif }; @@ -1086,13 +1170,13 @@ public: 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) + virtual int do_apply_event(RELAY_LOG_INFO const* rli) { - return apply_event_impl(thd->slave_net,rli,0); + return do_apply_event(thd->slave_net,rli,0); } - int apply_event_impl(NET* net, RELAY_LOG_INFO* rli, - bool use_rli_only_for_errors); + int do_apply_event(NET *net, RELAY_LOG_INFO const *rli, + bool use_rli_only_for_errors); #endif }; @@ -1171,9 +1255,20 @@ public: } virtual bool is_artificial_event() { return artificial_event; } -protected: /* !!! Protected in this patch to allow old usage */ +protected: #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) - virtual int apply_event_impl(RELAY_LOG_INFO* rli); + virtual int do_apply_event(RELAY_LOG_INFO const *rli); + virtual enum_skip_reason do_shall_skip(RELAY_LOG_INFO*) + { + /* + Events from ourself should be skipped, but they should not + decrease the slave skip counter. + */ + if (this->server_id == ::server_id) + return Log_event::EVENT_SKIP_IGNORE; + else + return Log_event::EVENT_SKIP_NOT; + } #endif }; @@ -1222,9 +1317,11 @@ public: return FORMAT_DESCRIPTION_HEADER_LEN; } -private: +protected: #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) - virtual int apply_event_impl(RELAY_LOG_INFO* rli); + virtual int do_apply_event(RELAY_LOG_INFO const *rli); + virtual int do_update_pos(RELAY_LOG_INFO *rli); + virtual enum_skip_reason do_shall_skip(RELAY_LOG_INFO *rli); #endif }; @@ -1266,7 +1363,9 @@ public: private: #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) - virtual int apply_event_impl(RELAY_LOG_INFO* rli); + virtual int do_apply_event(RELAY_LOG_INFO const *rli); + virtual int do_update_pos(RELAY_LOG_INFO *rli); + virtual enum_skip_reason do_shall_skip(RELAY_LOG_INFO *rli); #endif }; @@ -1310,7 +1409,9 @@ class Rand_log_event: public Log_event private: #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) - virtual int apply_event_impl(RELAY_LOG_INFO* rli); + virtual int do_apply_event(RELAY_LOG_INFO const *rli); + virtual int do_update_pos(RELAY_LOG_INFO *rli); + virtual enum_skip_reason do_shall_skip(RELAY_LOG_INFO *rli); #endif }; @@ -1351,7 +1452,7 @@ class Xid_log_event: public Log_event private: #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) - virtual int apply_event_impl(RELAY_LOG_INFO* rli); + virtual int do_apply_event(RELAY_LOG_INFO const *rli); #endif }; @@ -1396,7 +1497,9 @@ public: private: #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) - virtual int apply_event_impl(RELAY_LOG_INFO* rli); + virtual int do_apply_event(RELAY_LOG_INFO const *rli); + virtual int do_update_pos(RELAY_LOG_INFO *rli); + virtual enum_skip_reason do_shall_skip(RELAY_LOG_INFO *rli); #endif }; @@ -1425,7 +1528,18 @@ public: private: #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) - virtual int apply_event_impl(RELAY_LOG_INFO* rli); + virtual int do_update_pos(RELAY_LOG_INFO *rli); + virtual enum_skip_reason do_shall_skip(RELAY_LOG_INFO *rli) + { + /* + Events from ourself should be skipped, but they should not + decrease the slave skip counter. + */ + if (this->server_id == ::server_id) + return Log_event::EVENT_SKIP_IGNORE; + else + return Log_event::EVENT_SKIP_NOT; + } #endif }; @@ -1474,7 +1588,8 @@ public: private: #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) - virtual int apply_event_impl(RELAY_LOG_INFO* rli); + virtual int do_update_pos(RELAY_LOG_INFO *rli); + virtual enum_skip_reason do_shall_skip(RELAY_LOG_INFO *rli); #endif }; @@ -1546,7 +1661,7 @@ public: private: #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) - virtual int apply_event_impl(RELAY_LOG_INFO* rli); + virtual int do_apply_event(RELAY_LOG_INFO const *rli); #endif }; @@ -1600,7 +1715,7 @@ public: private: #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) - virtual int apply_event_impl(RELAY_LOG_INFO* rli); + virtual int do_apply_event(RELAY_LOG_INFO const *rli); #endif }; @@ -1640,7 +1755,7 @@ public: private: #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) - virtual int apply_event_impl(RELAY_LOG_INFO* rli); + virtual int do_apply_event(RELAY_LOG_INFO const *rli); #endif }; @@ -1679,7 +1794,7 @@ public: private: #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) - virtual int apply_event_impl(RELAY_LOG_INFO* rli); + virtual int do_apply_event(RELAY_LOG_INFO const *rli); #endif }; @@ -1771,7 +1886,7 @@ public: private: #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) - virtual int apply_event_impl(RELAY_LOG_INFO* rli); + virtual int do_apply_event(RELAY_LOG_INFO const *rli); #endif }; @@ -1880,7 +1995,8 @@ public: private: #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) - virtual int apply_event_impl(RELAY_LOG_INFO* rli); + virtual int do_apply_event(RELAY_LOG_INFO const *rli); + virtual int do_update_pos(RELAY_LOG_INFO *rli); #endif #ifndef MYSQL_CLIENT @@ -2037,7 +2153,7 @@ protected: private: #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) - virtual int apply_event_impl(RELAY_LOG_INFO* rli); + virtual int do_apply_event(RELAY_LOG_INFO const *rli); /* Primitive to prepare for a sequence of row executions. @@ -2086,7 +2202,7 @@ private: RETURN VALUE Error code, if something went wrong, 0 otherwise. */ - virtual int do_prepare_row(THD*, RELAY_LOG_INFO*, TABLE*, + virtual int do_prepare_row(THD*, RELAY_LOG_INFO const*, TABLE*, char const *row_start, char const **row_end) = 0; /* @@ -2157,7 +2273,7 @@ private: virtual int do_before_row_operations(TABLE *table); virtual int do_after_row_operations(TABLE *table, int error); - virtual int do_prepare_row(THD*, RELAY_LOG_INFO*, TABLE*, + virtual int do_prepare_row(THD*, RELAY_LOG_INFO const*, TABLE*, char const *row_start, char const **row_end); virtual int do_exec_row(TABLE *table); #endif @@ -2222,7 +2338,7 @@ private: virtual int do_before_row_operations(TABLE *table); virtual int do_after_row_operations(TABLE *table, int error); - virtual int do_prepare_row(THD*, RELAY_LOG_INFO*, TABLE*, + virtual int do_prepare_row(THD*, RELAY_LOG_INFO const*, TABLE*, char const *row_start, char const **row_end); virtual int do_exec_row(TABLE *table); #endif /* !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) */ @@ -2293,7 +2409,7 @@ private: virtual int do_before_row_operations(TABLE *table); virtual int do_after_row_operations(TABLE *table, int error); - virtual int do_prepare_row(THD*, RELAY_LOG_INFO*, TABLE*, + virtual int do_prepare_row(THD*, RELAY_LOG_INFO const*, TABLE*, char const *row_start, char const **row_end); virtual int do_exec_row(TABLE *table); #endif diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc index 36334351da2..182592ac403 100644 --- a/sql/rpl_rli.cc +++ b/sql/rpl_rli.cc @@ -29,7 +29,8 @@ int init_strvar_from_file(char *var, int max_size, IO_CACHE *f, st_relay_log_info::st_relay_log_info() - :no_storage(FALSE), info_fd(-1), cur_log_fd(-1), save_temporary_tables(0), + :no_storage(FALSE), replicate_same_server_id(::replicate_same_server_id), + info_fd(-1), cur_log_fd(-1), save_temporary_tables(0), cur_log_old_open_count(0), group_master_log_pos(0), log_space_total(0), ignore_log_space_limit(0), last_master_timestamp(0), slave_skip_counter(0), abort_pos_wait(0), slave_run_id(0), sql_thd(0), last_slave_errno(0), diff --git a/sql/rpl_rli.h b/sql/rpl_rli.h index ed9ef3a9115..6365df8cec5 100644 --- a/sql/rpl_rli.h +++ b/sql/rpl_rli.h @@ -57,6 +57,15 @@ typedef struct st_relay_log_info */ bool no_storage; + /* + If true, events with the same server id should be replicated. This + field is set on creation of a relay log info structure by copying + the value of ::replicate_same_server_id and can be overridden if + necessary. For example of when this is done, check sql_binlog.cc, + where the BINLOG statement can be used to execute "raw" events. + */ + bool replicate_same_server_id; + /*** The following variables can only be read when protect by data lock ****/ /* diff --git a/sql/slave.cc b/sql/slave.cc index b58069a82ca..0e705d732ea 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -811,7 +811,7 @@ do not trust column Seconds_Behind_Master of SHOW SLAVE STATUS"); { if ((master_row= mysql_fetch_row(master_res)) && (::server_id == strtoul(master_row[1], 0, 10)) && - !replicate_same_server_id) + !mi->rli.replicate_same_server_id) errmsg= "The slave I/O thread stops because master and slave have equal \ MySQL server ids; these ids must be different for replication to work (or \ the --replicate-same-server-id option must be used on slave but this does \ @@ -1721,20 +1721,9 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) if (ev) { int type_code = ev->get_type_code(); - int exec_res; + int exec_res= 0; /* - Queries originating from this server must be skipped. - Low-level events (Format_desc, Rotate, Stop) from this server - must also be skipped. But for those we don't want to modify - group_master_log_pos, because these events did not exist on the master. - Format_desc is not completely skipped. - Skip queries specified by the user in slave_skip_counter. - We can't however skip events that has something to do with the - log files themselves. - Filtering on own server id is extremely important, to ignore execution of - events created by the creation/rotation of the relay log (remember that - now the relay log starts with its Format_desc, has a Rotate etc). */ DBUG_PRINT("info",("type_code=%d (%s), server_id=%d", @@ -1742,8 +1731,27 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) /* - Execute the event, but first we set some data that is needed for + Execute the event to change the database and update the binary + log coordinates, but first we set some data that is needed for the thread. + + The event will be executed unless it is supposed to be skipped. + + Queries originating from this server must be skipped. Low-level + events (Format_description_log_event, Rotate_log_event, + Stop_log_event) from this server must also be skipped. But for + those we don't want to modify 'group_master_log_pos', because + these events did not exist on the master. + Format_description_log_event is not completely skipped. + + Skip queries specified by the user in 'slave_skip_counter'. We + can't however skip events that has something to do with the log + files themselves. + + Filtering on own server id is extremely important, to ignore + execution of events created by the creation/rotation of the relay + log (remember that now the relay log starts with its Format_desc, + has a Rotate etc). */ thd->server_id = ev->server_id; // use the original server id for logging @@ -1753,9 +1761,62 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) ev->when = time(NULL); ev->thd = thd; // because up to this point, ev->thd == 0 - exec_res= ev->exec_event(rli); - DBUG_PRINT("info", ("exec_event result = %d", exec_res)); - DBUG_ASSERT(rli->sql_thd==thd); + int reason= ev->shall_skip(rli); + if (reason == Log_event::EVENT_SKIP_COUNT) + --rli->slave_skip_counter; + pthread_mutex_unlock(&rli->data_lock); + if (reason == Log_event::EVENT_SKIP_NOT) + exec_res= ev->apply_event(rli); +#ifndef DBUG_OFF + else + { + /* + This only prints information to the debug trace. + + TODO: Print an informational message to the error log? + */ + static const char *const explain[] = { + "event was not skipped", // EVENT_SKIP_NOT, + "event originated from this server", // EVENT_SKIP_IGNORE, + "event skip counter was non-zero" // EVENT_SKIP_COUNT + }; + DBUG_PRINT("info", ("%s was skipped because %s", + ev->get_type_str(), explain[reason])); + } +#endif + + DBUG_PRINT("info", ("apply_event error = %d", exec_res)); + if (exec_res == 0) + { + int error= ev->update_pos(rli); + char buf[22]; + DBUG_PRINT("info", ("update_pos error = %d", error)); + DBUG_PRINT("info", ("group %s %s", + llstr(rli->group_relay_log_pos, buf), + rli->group_relay_log_name)); + DBUG_PRINT("info", ("event %s %s", + llstr(rli->event_relay_log_pos, buf), + rli->event_relay_log_name)); + /* + The update should not fail, so print an error message and + return an error code. + + TODO: Replace this with a decent error message when merged + with BUG#24954 (which adds several new error message). + */ + if (error) + { + slave_print_msg(ERROR_LEVEL, rli, ER_UNKNOWN_ERROR, + "It was not possible to update the positions" + " of the relay log information: the slave may" + " be in an inconsistent state." + " Stopped in %s position %s", + rli->group_relay_log_name, + llstr(rli->group_relay_log_pos, buf)); + DBUG_RETURN(1); + } + } + /* Format_description_log_event should not be deleted because it will be used to read info about the relay log's format; it will be deleted when @@ -2902,7 +2963,7 @@ int queue_event(MASTER_INFO* mi,const char* buf, ulong event_len) pthread_mutex_lock(log_lock); if ((uint4korr(buf + SERVER_ID_OFFSET) == ::server_id) && - !replicate_same_server_id) + !mi->rli.replicate_same_server_id) { /* Do not write it to the relay log. diff --git a/sql/sql_binlog.cc b/sql/sql_binlog.cc index 23ca5330053..27418c9f9fc 100644 --- a/sql/sql_binlog.cc +++ b/sql/sql_binlog.cc @@ -150,9 +150,17 @@ void mysql_client_binlog_statement(THD* thd) DBUG_PRINT("info", ("bytes_decoded=%d; bufptr=0x%lx; buf[EVENT_LEN_OFFSET]=%u", bytes_decoded, bufptr, uint4korr(bufptr+EVENT_LEN_OFFSET))); ev->thd= thd; - if (int err= ev->exec_event(thd->rli_fake)) + /* + We go directly to the application phase, since we don't need + to check if the event shall be skipped or not. + + Neither do we have to update the log positions, since that is + not used at all: the rli_fake instance is used only for error + reporting. + */ + if (int err= ev->apply_event(thd->rli_fake)) { - DBUG_PRINT("info", ("exec_event() - error=%d", error)); + DBUG_PRINT("info", ("apply_event() - error=%d", error)); /* TODO: Maybe a better error message since the BINLOG statement now contains several events. From f0a95a4e20e095ae27f3003bbcdc8d3eb2aa01d2 Mon Sep 17 00:00:00 2001 From: "guilhem@gbichot3.local" <> Date: Thu, 22 Mar 2007 15:07:32 +0100 Subject: [PATCH 10/22] - renaming TMP_TABLE to NON_TRANSACTIONAL_TMP_TABLE because this is what it actually means (Monty approved the renaming) - correcting description of transaction_alloc command-line options (our manual is correct) - fix for a failure of rpl_trigger. --- mysql-test/t/rpl_misc_functions.test | 2 ++ sql/lock.cc | 8 ++++---- sql/mysqld.cc | 4 ++-- sql/sql_base.cc | 2 +- sql/sql_derived.cc | 2 +- sql/sql_select.cc | 2 +- sql/table.h | 3 ++- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/mysql-test/t/rpl_misc_functions.test b/mysql-test/t/rpl_misc_functions.test index 43ce3afc8ad..f00beff583a 100644 --- a/mysql-test/t/rpl_misc_functions.test +++ b/mysql-test/t/rpl_misc_functions.test @@ -89,12 +89,14 @@ INSERT INTO t1 VALUES (test_replication_sf()); --exec diff $MYSQLTEST_VARDIR/tmp/rpl_rand_master.sql $MYSQLTEST_VARDIR/tmp/rpl_rand_slave.sql # Cleanup +connection master; --disable_warnings DROP PROCEDURE IF EXISTS test_replication_sp1; DROP PROCEDURE IF EXISTS test_replication_sp2; DROP FUNCTION IF EXISTS test_replication_sf; DROP TABLE IF EXISTS t1; --enable_warnings +--sync_slave_with_master # If all is good, when can cleanup our dump files. --system rm $MYSQLTEST_VARDIR/tmp/rpl_rand_master.sql diff --git a/sql/lock.cc b/sql/lock.cc index bf1512b754c..233d12d9cc4 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -544,7 +544,7 @@ TABLE_LIST *mysql_lock_have_duplicate(THD *thd, TABLE_LIST *needle, goto end; /* A temporary table does not have locks. */ - if (table->s->tmp_table == TMP_TABLE) + if (table->s->tmp_table == NON_TRANSACTIONAL_TMP_TABLE) goto end; /* Get command lock or LOCK TABLES lock. Maybe empty for INSERT DELAYED. */ @@ -569,7 +569,7 @@ TABLE_LIST *mysql_lock_have_duplicate(THD *thd, TABLE_LIST *needle, if (haystack->placeholder()) continue; table2= haystack->table; - if (table2->s->tmp_table == TMP_TABLE) + if (table2->s->tmp_table == NON_TRANSACTIONAL_TMP_TABLE) continue; /* All tables in list must be in lock. */ @@ -655,7 +655,7 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count, *write_lock_used=0; for (i=tables=lock_count=0 ; i < count ; i++) { - if (table_ptr[i]->s->tmp_table != TMP_TABLE) + if (table_ptr[i]->s->tmp_table != NON_TRANSACTIONAL_TMP_TABLE) { tables+=table_ptr[i]->file->lock_count(); lock_count++; @@ -697,7 +697,7 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count, TABLE *table; enum thr_lock_type lock_type; - if ((table=table_ptr[i])->s->tmp_table == TMP_TABLE) + if ((table=table_ptr[i])->s->tmp_table == NON_TRANSACTIONAL_TMP_TABLE) continue; lock_type= table->reginfo.lock_type; if (lock_type >= TL_WRITE_ALLOW_WRITE) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 9a7928b214f..0237ed144e8 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -6120,12 +6120,12 @@ The minimum value for this variable is 4096.", (gptr*) &max_system_variables.tmp_table_size, 0, GET_ULL, REQUIRED_ARG, 32*1024*1024L, 1024, MAX_MEM_TABLE_SIZE, 0, 1, 0}, {"transaction_alloc_block_size", OPT_TRANS_ALLOC_BLOCK_SIZE, - "Allocation block size for transactions to be stored in binary log", + "Allocation block size for various transaction-related structures", (gptr*) &global_system_variables.trans_alloc_block_size, (gptr*) &max_system_variables.trans_alloc_block_size, 0, GET_ULONG, REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ~0L, 0, 1024, 0}, {"transaction_prealloc_size", OPT_TRANS_PREALLOC_SIZE, - "Persistent buffer for transactions to be stored in binary log", + "Persistent buffer for various transaction-related structures", (gptr*) &global_system_variables.trans_prealloc_size, (gptr*) &max_system_variables.trans_prealloc_size, 0, GET_ULONG, REQUIRED_ARG, TRANS_ALLOC_PREALLOC_SIZE, 1024, ~0L, 0, 1024, 0}, diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 77bb1d9642b..e8cb3ae675d 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2950,7 +2950,7 @@ TABLE *open_temporary_table(THD *thd, const char *path, const char *db, share= tmp_table->s; tmp_table->reginfo.lock_type=TL_WRITE; // Simulate locked share->tmp_table= (tmp_table->file->has_transactions() ? - TRANSACTIONAL_TMP_TABLE : TMP_TABLE); + TRANSACTIONAL_TMP_TABLE : NON_TRANSACTIONAL_TMP_TABLE); share->table_cache_key= (char*) (tmp_table+1); share->db= share->table_cache_key; share->key_length= (uint) (strmov(((char*) (share->table_name= diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index cd46f3bcc0e..84622398f6f 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -179,7 +179,7 @@ exit: orig_table_list->table_name= (char*) table->s->table_name; orig_table_list->table_name_length= strlen((char*)table->s->table_name); table->derived_select_number= first_select->select_number; - table->s->tmp_table= TMP_TABLE; + table->s->tmp_table= NON_TRANSACTIONAL_TMP_TABLE; #ifndef NO_EMBEDDED_ACCESS_CHECKS if (orig_table_list->referencing_view) table->grant= orig_table_list->grant; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 9fe92d63da3..433aef68e25 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -9165,7 +9165,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, table->s->table_name= table->s->path= tmpname; table->s->db= ""; table->s->blob_ptr_size= mi_portable_sizeof_char_ptr; - table->s->tmp_table= TMP_TABLE; + table->s->tmp_table= NON_TRANSACTIONAL_TMP_TABLE; table->s->db_low_byte_first=1; // True for HEAP and MyISAM table->s->table_charset= param->table_charset; table->s->keys_for_keyread.init(); diff --git a/sql/table.h b/sql/table.h index e2bd5ba0a7d..5fc73b22d2d 100644 --- a/sql/table.h +++ b/sql/table.h @@ -55,7 +55,8 @@ typedef struct st_grant_info ulong orig_want_privilege; } GRANT_INFO; -enum tmp_table_type {NO_TMP_TABLE=0, TMP_TABLE=1, TRANSACTIONAL_TMP_TABLE=2, +enum tmp_table_type {NO_TMP_TABLE=0, + NON_TRANSACTIONAL_TMP_TABLE=1, TRANSACTIONAL_TMP_TABLE=2, SYSTEM_TMP_TABLE=3}; enum frm_type_enum From 82f3f318c64ae7c379948b530b7c9d8b3deac836 Mon Sep 17 00:00:00 2001 From: "mats@romeo.(none)" <> Date: Thu, 22 Mar 2007 16:59:55 +0100 Subject: [PATCH 11/22] BUG#23171: Illegal group log position Post-merge fixes. --- mysql-test/r/rpl_ndb_basic.result | 4 ++-- sql/log_event.cc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/rpl_ndb_basic.result b/mysql-test/r/rpl_ndb_basic.result index 32a1c790c99..d6a9cdd4102 100644 --- a/mysql-test/r/rpl_ndb_basic.result +++ b/mysql-test/r/rpl_ndb_basic.result @@ -97,8 +97,8 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 146 -Last_Error Error in Write_rows event: error during transaction execution on table test.t1 +Last_Errno 1105 +Last_Error Unknown error Skip_Counter 0 Exec_Master_Log_Pos Relay_Log_Space diff --git a/sql/log_event.cc b/sql/log_event.cc index 8e6311ce53a..6dae0342886 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -6024,7 +6024,7 @@ int Rows_log_event::do_apply_event(RELAY_LOG_INFO const *rli) mysql_unlock_tables(thd, thd->lock); thd->lock= 0; thd->query_error= 1; - rli->clear_tables_to_lock(); + const_cast(rli)->clear_tables_to_lock(); DBUG_RETURN(ERR_BAD_TABLE_DEF); } } From 21492b54b4a4f6ac852e7b2159b0b717fe444b6f Mon Sep 17 00:00:00 2001 From: "guilhem@gbichot3.local" <> Date: Thu, 22 Mar 2007 17:31:39 +0100 Subject: [PATCH 12/22] Fix for BUG#26194 "mysqlbinlog --base64-output produces invalid SQL"; when it was printing a Query event, it produced invalid SQL (missing the BINLOG keyword, so the SQL started with the base64 string, which is incorrect). Note: no testcase; I have a .test which shows that the bugfix works, but it triggers BUG#26361 and so gives Valgrind warnings. I'm sending this test to the fixer of BUG#26361 for her/him to push when she/he fixes BUG#26361. --- client/mysqlbinlog.cc | 16 +++++++--------- sql/log_event.cc | 9 +++------ sql/log_event.h | 8 ++++++++ sql/records.cc | 3 ++- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 940fac6da38..50235534cb8 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -483,19 +483,17 @@ static int write_event_header_and_base64(Log_event *ev, FILE *result_file, PRINT_EVENT_INFO *print_event_info) { + IO_CACHE *head= &print_event_info->head_cache; + IO_CACHE *body= &print_event_info->body_cache; DBUG_ENTER("write_event_header_and_base64"); - /* Write header and base64 output to cache */ - IO_CACHE result_cache; - if (open_cached_file(&result_cache, NULL, NULL, 0, MYF(MY_WME | MY_NABP))) - return 1; - ev->print_header(&result_cache, print_event_info, FALSE); - ev->print_base64(&result_cache, print_event_info, FALSE); + /* Write header and base64 output to cache */ + ev->print_header(head, print_event_info, FALSE); + ev->print_base64(body, print_event_info, FALSE); /* Read data from cache and write to result file */ - my_b_copy_to_file(&result_cache, result_file); - close_cached_file(&result_cache); - DBUG_RETURN(0); + DBUG_RETURN(copy_event_cache_to_file_and_reinit(head, result_file) || + copy_event_cache_to_file_and_reinit(body, result_file)); } diff --git a/sql/log_event.cc b/sql/log_event.cc index f8d3c43bfba..dc411c14f93 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -75,8 +75,7 @@ public: ~Write_on_release_cache() { - if (!my_b_copy_to_file(m_cache, m_file)) - reinit_io_cache(m_cache, WRITE_CACHE, 0L, FALSE, TRUE); + copy_event_cache_to_file_and_reinit(m_cache, m_file); if (m_flags | FLUSH_F) fflush(m_file); } @@ -6160,10 +6159,8 @@ void Rows_log_event::print_helper(FILE *file, if (get_flags(STMT_END_F)) { - my_b_copy_to_file(head, file); - my_b_copy_to_file(body, file); - reinit_io_cache(head, WRITE_CACHE, 0, FALSE, TRUE); - reinit_io_cache(body, WRITE_CACHE, 0, FALSE, TRUE); + copy_event_cache_to_file_and_reinit(head, file); + copy_event_cache_to_file_and_reinit(body, file); } } #endif diff --git a/sql/log_event.h b/sql/log_event.h index 7cbe8925d9a..656860a2b55 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -2230,4 +2230,12 @@ private: #endif }; +static inline bool copy_event_cache_to_file_and_reinit(IO_CACHE *cache, + FILE *file) +{ + return + my_b_copy_to_file(cache, file) || + reinit_io_cache(cache, WRITE_CACHE, 0, FALSE, TRUE); +} + #endif /* _log_event_h */ diff --git a/sql/records.cc b/sql/records.cc index 0923ab1d75e..0fb9f4f9650 100644 --- a/sql/records.cc +++ b/sql/records.cc @@ -150,7 +150,8 @@ void init_read_record(READ_RECORD *info,THD *thd, TABLE *table, info->file= table->file; info->forms= &info->table; /* Only one table */ - if (table->s->tmp_table == TMP_TABLE && !table->sort.addon_field) + if (table->s->tmp_table == NON_TRANSACTIONAL_TMP_TABLE && + !table->sort.addon_field) VOID(table->file->extra(HA_EXTRA_MMAP)); if (table->sort.addon_field) From 1b426d3c6dfcf488cf798ce59d0fda48d87a3ab7 Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Tue, 27 Mar 2007 12:20:20 +0500 Subject: [PATCH 13/22] Bug#27079 Crash while grouping empty ucs2 strings Problem: GROUP BY on empty ucs2 strings crashed server. Reason: sometimes mi_unique_hash() is executed with ptr=null and length=0, which means "empty string". The branch of code handling UCS2 character set was not safe against ptr=null and fell into and endless loop even if length=0 because of poiter arithmetic overflow. Fix: adding special check for length=0 to avoid pointer arithmetic overflow. --- mysql-test/r/ctype_uca.result | 9 +++++++++ mysql-test/t/ctype_uca.test | 10 ++++++++++ strings/ctype-uca.c | 34 +++++++++++++++++++++++++++------- 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/ctype_uca.result b/mysql-test/r/ctype_uca.result index 3e286c77c00..1fd1493bf1e 100644 --- a/mysql-test/r/ctype_uca.result +++ b/mysql-test/r/ctype_uca.result @@ -2654,3 +2654,12 @@ ii 2 ii 2 İİ 4 İİ 4 ii 2 İİ 4 II 2 ıı 4 II 2 DROP TABLE t1; +CREATE TABLE t1 ( +c1 text character set ucs2 collate ucs2_polish_ci NOT NULL +) ENGINE=MyISAM; +insert into t1 values (''),('a'); +SELECT COUNT(*), c1 FROM t1 GROUP BY c1; +COUNT(*) c1 +1 +1 a +DROP TABLE IF EXISTS t1; diff --git a/mysql-test/t/ctype_uca.test b/mysql-test/t/ctype_uca.test index 3e49b9de883..64349bc40a6 100644 --- a/mysql-test/t/ctype_uca.test +++ b/mysql-test/t/ctype_uca.test @@ -475,3 +475,13 @@ ALTER TABLE t1 MODIFY a VARCHAR(30) character set utf8 collate utf8_turkish_ci; SELECT a, length(a) la, @l:=lower(a) l, length(@l) ll, @u:=upper(a) u, length(@u) lu FROM t1 ORDER BY id; DROP TABLE t1; + +# +# Bug #27079 Crash while grouping empty ucs2 strings +# +CREATE TABLE t1 ( + c1 text character set ucs2 collate ucs2_polish_ci NOT NULL +) ENGINE=MyISAM; +insert into t1 values (''),('a'); +SELECT COUNT(*), c1 FROM t1 GROUP BY c1; +DROP TABLE IF EXISTS t1; diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index 1292d7f5ede..3aad36f858c 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -6744,7 +6744,7 @@ typedef struct my_uca_scanner_handler_st int (*next)(my_uca_scanner *scanner); } my_uca_scanner_handler; -static uint16 nochar[]= {0}; +static uint16 nochar[]= {0,0}; #ifdef HAVE_CHARSET_ucs2 @@ -6769,13 +6769,33 @@ static void my_uca_scanner_init_ucs2(my_uca_scanner *scanner, CHARSET_INFO *cs __attribute__((unused)), const uchar *str, uint length) { - /* Note, no needs to initialize scanner->wbeg */ - scanner->sbeg= str; - scanner->send= str + length - 2; scanner->wbeg= nochar; - scanner->uca_length= cs->sort_order; - scanner->uca_weight= cs->sort_order_big; - scanner->contractions= cs->contractions; + if (length) + { + scanner->sbeg= str; + scanner->send= str + length - 2; + scanner->uca_length= cs->sort_order; + scanner->uca_weight= cs->sort_order_big; + scanner->contractions= cs->contractions; + } + else + { + /* + Sometimes this function is called with + str=NULL and length=0, which should be + considered as an empty string. + + The above initialization is unsafe for such cases, + because scanner->send is initialized to (NULL-2), which is 0xFFFFFFFE. + Then we fall into an endless loop in my_uca_scanner_next_ucs2(). + + Do special initialization for the case when length=0. + Initialize scanner->sbeg to an address greater than scanner->send. + Next call of my_uca_scanner_next_ucs2() will correctly return with -1. + */ + scanner->sbeg= (uchar*) &nochar[1]; + scanner->send= (uchar*) &nochar[0]; + } } From 5e52cd3650e924efd4ec88f81dcf95a628978cf9 Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Tue, 27 Mar 2007 13:30:43 +0500 Subject: [PATCH 14/22] Bug#25946 Namespace not include for xsi usage within --xml output with null/nil values Fix: adding namespace reference into "mysql --xml" output, to make it work similary to "mysqldump --xml". --- client/mysql.cc | 3 ++- mysql-test/r/client_xml.result | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 2faa2f31a50..510420fdf3d 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2529,7 +2529,8 @@ print_table_data_xml(MYSQL_RES *result) tee_fputs("\n\n", PAGER); + tee_fputs("\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">", + PAGER); fields = mysql_fetch_fields(result); while ((cur = mysql_fetch_row(result))) diff --git a/mysql-test/r/client_xml.result b/mysql-test/r/client_xml.result index 7395b2433e8..6a148954fcd 100644 --- a/mysql-test/r/client_xml.result +++ b/mysql-test/r/client_xml.result @@ -7,7 +7,7 @@ insert into t1 values (1, 2, 'a&b ab'); +" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 1 2 @@ -34,7 +34,7 @@ insert into t1 values (1, 2, 'a&b ab'); +" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 1 @@ -42,7 +42,7 @@ insert into t1 values (1, 2, 'a&b ab'); +" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 1 @@ -50,7 +50,7 @@ insert into t1 values (1, 2, 'a&b ab'); +" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 0 @@ -58,7 +58,7 @@ insert into t1 values (1, 2, 'a&b ab'); +" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 1 @@ -66,7 +66,7 @@ insert into t1 values (1, 2, 'a&b ab'); +" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> From daa7e9c386ae1ff8cc891f8acf25d495bda5dd0a Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Tue, 27 Mar 2007 15:06:41 +0500 Subject: [PATCH 15/22] Bug#22378 Make error, strings/ctype-utf8.c, uni_plane undeclared - Fixing utf8_general_cs according to recent changes. - Compiling utf8_general_cs in pentium-debug-max configuration to avoid these problems in the future. --- BUILD/compile-pentium-debug-max | 2 +- config/ac-macros/character_sets.m4 | 13 +++++++++++++ strings/ctype-utf8.c | 7 ++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/BUILD/compile-pentium-debug-max b/BUILD/compile-pentium-debug-max index 7a11ad24c44..a69513ac6bb 100755 --- a/BUILD/compile-pentium-debug-max +++ b/BUILD/compile-pentium-debug-max @@ -6,6 +6,6 @@ path=`dirname $0` extra_flags="$pentium_cflags $debug_cflags $max_cflags" c_warnings="$c_warnings $debug_extra_warnings" cxx_warnings="$cxx_warnings $debug_extra_warnings" -extra_configs="$pentium_configs $debug_configs $max_configs" +extra_configs="$pentium_configs $debug_configs $max_configs --with-experimental-collations" . "$path/FINISH.sh" diff --git a/config/ac-macros/character_sets.m4 b/config/ac-macros/character_sets.m4 index 1ab6e7dd780..8c3e8ca73b7 100644 --- a/config/ac-macros/character_sets.m4 +++ b/config/ac-macros/character_sets.m4 @@ -429,3 +429,16 @@ then else AC_MSG_RESULT(no) fi + + +# Shall we build experimental collations +AC_ARG_WITH(experimental-collations, + [], + [with_exp_coll=$withval], + [with_exp_coll=no] +) + +if test "$with_exp_coll" = "yes" +then + AC_DEFINE([HAVE_UTF8_GENERAL_CS], [1], [certain Japanese customer]) +fi diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 0e28ff7e342..387ce16a43d 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -2764,6 +2764,7 @@ static int my_strnncoll_utf8_cs(CHARSET_INFO *cs, const uchar *te=t+tlen; int save_diff = 0; int diff; + MY_UNICASE_INFO **uni_plane= cs->caseinfo; while ( s < se && t < te ) { @@ -2800,13 +2801,16 @@ static int my_strnncoll_utf8_cs(CHARSET_INFO *cs, static int my_strnncollsp_utf8_cs(CHARSET_INFO *cs, const uchar *s, uint slen, - const uchar *t, uint tlen) + const uchar *t, uint tlen, + my_bool diff_if_only_endspace_difference + __attribute__((unused))) { int s_res,t_res; my_wc_t s_wc,t_wc; const uchar *se= s+slen; const uchar *te= t+tlen; int save_diff = 0; + MY_UNICASE_INFO **uni_plane= cs->caseinfo; while ( s < se && t < te ) { @@ -2875,6 +2879,7 @@ static MY_COLLATION_HANDLER my_collation_cs_handler = my_strnncoll_utf8_cs, my_strnncollsp_utf8_cs, my_strnxfrm_utf8, + my_strnxfrmlen_utf8, my_like_range_simple, my_wildcmp_mb, my_strcasecmp_utf8, From 06b5e9bb53f81deb972a7a7c0935681f3a85b977 Mon Sep 17 00:00:00 2001 From: "mats@romeo.(none)" <> Date: Tue, 27 Mar 2007 12:17:51 +0200 Subject: [PATCH 16/22] BUG#27441 (There is no COLS bitmap for the after image of an update rows event): Adding a after image COLS bitmap to Update_rows_log_event (for telling what columns that are present in the after image of each row update). Also fixing case where Rows_log_event length was not correctly computed (happened when the number of columns in a table was more than 251). --- mysql-test/r/rpl_row_inexist_tbl.result | 2 +- sql/log_event.cc | 160 +++++++++++++++++++++--- sql/log_event.h | 47 +++++-- 3 files changed, 177 insertions(+), 32 deletions(-) diff --git a/mysql-test/r/rpl_row_inexist_tbl.result b/mysql-test/r/rpl_row_inexist_tbl.result index 188dfd5924a..d482f6f5e94 100644 --- a/mysql-test/r/rpl_row_inexist_tbl.result +++ b/mysql-test/r/rpl_row_inexist_tbl.result @@ -39,7 +39,7 @@ Replicate_Wild_Ignore_Table Last_Errno 1146 Last_Error Error 'Table 'test.t1' doesn't exist' on opening table `test`.`t1` Skip_Counter 0 -Exec_Master_Log_Pos 522 +Exec_Master_Log_Pos 523 Relay_Log_Space # Until_Condition None Until_Log_File diff --git a/sql/log_event.cc b/sql/log_event.cc index ac8984c64bc..b146fe044d2 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -5604,7 +5604,10 @@ Rows_log_event::Rows_log_event(THD *thd_arg, TABLE *tbl_arg, ulong tid, memcpy(m_cols.bitmap, cols->bitmap, no_bytes_in_map(cols)); } else - m_cols.bitmap= 0; // to not free it + { + // Needed because bitmap_init() does not set it to null on failure + m_cols.bitmap= 0; + } } #endif @@ -5641,14 +5644,57 @@ Rows_log_event::Rows_log_event(const char *buf, uint event_len, m_flags= uint2korr(post_start); - byte const *const var_start= (const byte *)buf + common_header_len + - post_header_len; + byte const *const var_start= + (const byte *)buf + common_header_len + post_header_len; byte const *const ptr_width= var_start; uchar *ptr_after_width= (uchar*) ptr_width; + DBUG_PRINT("debug", ("Reading from %p", ptr_after_width)); m_width = net_field_length(&ptr_after_width); + DBUG_PRINT("debug", ("m_width=%lu", m_width)); + /* if bitmap_init fails, catched in is_valid() */ + if (likely(!bitmap_init(&m_cols, + m_width <= sizeof(m_bitbuf)*8 ? m_bitbuf : NULL, + (m_width + 7) & ~7UL, + false))) + { + DBUG_PRINT("debug", ("Reading from %p", ptr_after_width)); + memcpy(m_cols.bitmap, ptr_after_width, (m_width + 7) / 8); + ptr_after_width+= (m_width + 7) / 8; + DBUG_DUMP("m_cols", (char*) m_cols.bitmap, no_bytes_in_map(&m_cols)); + } + else + { + // Needed because bitmap_init() does not set it to null on failure + m_cols.bitmap= NULL; + DBUG_VOID_RETURN; + } - const uint byte_count= (m_width + 7) / 8; - const byte* const ptr_rows_data= var_start + byte_count + 1; + m_cols_ai.bitmap= m_cols.bitmap; /* See explanation in is_valid() */ + + if (event_type == UPDATE_ROWS_EVENT) + { + DBUG_PRINT("debug", ("Reading from %p", ptr_after_width)); + + /* if bitmap_init fails, catched in is_valid() */ + if (likely(!bitmap_init(&m_cols_ai, + m_width <= sizeof(m_bitbuf_ai)*8 ? m_bitbuf_ai : NULL, + (m_width + 7) & ~7UL, + false))) + { + DBUG_PRINT("debug", ("Reading from %p", ptr_after_width)); + memcpy(m_cols_ai.bitmap, ptr_after_width, (m_width + 7) / 8); + ptr_after_width+= (m_width + 7) / 8; + DBUG_DUMP("m_cols_ai", (char*) m_cols_ai.bitmap, no_bytes_in_map(&m_cols_ai)); + } + else + { + // Needed because bitmap_init() does not set it to null on failure + m_cols_ai.bitmap= 0; + DBUG_VOID_RETURN; + } + } + + const byte* const ptr_rows_data= (const byte*) ptr_after_width; my_size_t const data_size= event_len - (ptr_rows_data - (const byte *) buf); DBUG_PRINT("info",("m_table_id: %lu m_flags: %d m_width: %lu data_size: %lu", @@ -5657,12 +5703,6 @@ Rows_log_event::Rows_log_event(const char *buf, uint event_len, m_rows_buf= (byte*)my_malloc(data_size, MYF(MY_WME)); if (likely((bool)m_rows_buf)) { - /* if bitmap_init fails, catched in is_valid() */ - if (likely(!bitmap_init(&m_cols, - m_width <= sizeof(m_bitbuf)*8 ? m_bitbuf : NULL, - (m_width + 7) & ~7UL, - false))) - memcpy(m_cols.bitmap, ptr_after_width, byte_count); m_rows_end= m_rows_buf + data_size; m_rows_cur= m_rows_end; memcpy(m_rows_buf, ptr_rows_data, data_size); @@ -5681,6 +5721,29 @@ Rows_log_event::~Rows_log_event() my_free((gptr)m_rows_buf, MYF(MY_ALLOW_ZERO_PTR)); } +int Rows_log_event::get_data_size() +{ + int const type_code= get_type_code(); + + char buf[sizeof(m_width)+1]; + char *end= net_store_length(buf, (m_width + 7) / 8); + + DBUG_EXECUTE_IF("old_row_based_repl_4_byte_map_id_master", + return 6 + no_bytes_in_map(&m_cols) + (end - buf) + + (type_code == UPDATE_ROWS_EVENT ? no_bytes_in_map(&m_cols_ai) : 0) + + (m_rows_cur - m_rows_buf);); + int data_size= ROWS_HEADER_LEN; + data_size+= no_bytes_in_map(&m_cols); + data_size+= end - buf; + + if (type_code == UPDATE_ROWS_EVENT) + data_size+= no_bytes_in_map(&m_cols_ai); + + data_size+= (m_rows_cur - m_rows_buf); + return data_size; +} + + #ifndef MYSQL_CLIENT int Rows_log_event::do_add_row_data(byte *const row_data, my_size_t const length) @@ -5911,7 +5974,7 @@ int Rows_log_event::do_apply_event(RELAY_LOG_INFO const *rli) If m_table_id == ~0UL, then we have a dummy event that does not contain any data. In that case, we just remove all tables in the tables_to_lock list, close the thread tables, and return with - success. The relay log position will be stepped in + success. */ if (m_table_id == ~0UL) { @@ -6291,15 +6354,35 @@ bool Rows_log_event::write_data_body(IO_CACHE*file) */ char sbuf[sizeof(m_width)]; my_ptrdiff_t const data_size= m_rows_cur - m_rows_buf; + bool res= false; char *const sbuf_end= net_store_length((char*) sbuf, (uint) m_width); DBUG_ASSERT(static_cast(sbuf_end - sbuf) <= sizeof(sbuf)); - return (my_b_safe_write(file, reinterpret_cast(sbuf), - sbuf_end - sbuf) || - my_b_safe_write(file, reinterpret_cast(m_cols.bitmap), - no_bytes_in_map(&m_cols)) || - my_b_safe_write(file, m_rows_buf, (uint) data_size)); + DBUG_DUMP("m_width", sbuf, sbuf_end - sbuf); + res= res || my_b_safe_write(file, + reinterpret_cast(sbuf), + sbuf_end - sbuf); + + DBUG_DUMP("m_cols", (char*) m_cols.bitmap, no_bytes_in_map(&m_cols)); + res= res || my_b_safe_write(file, + reinterpret_cast(m_cols.bitmap), + no_bytes_in_map(&m_cols)); + /* + TODO[refactor write]: Remove the "down cast" here (and elsewhere). + */ + if (get_type_code() == UPDATE_ROWS_EVENT) + { + DBUG_DUMP("m_cols_ai", (char*) m_cols_ai.bitmap, no_bytes_in_map(&m_cols_ai)); + res= res || my_b_safe_write(file, + reinterpret_cast(m_cols_ai.bitmap), + no_bytes_in_map(&m_cols_ai)); + } + DBUG_DUMP("rows", m_rows_buf, data_size); + res= res || my_b_safe_write(file, m_rows_buf, (uint) data_size); + + return res; + } #endif @@ -7584,16 +7667,55 @@ void Delete_rows_log_event::print(FILE *file, */ #if !defined(MYSQL_CLIENT) Update_rows_log_event::Update_rows_log_event(THD *thd_arg, TABLE *tbl_arg, - ulong tid, MY_BITMAP const *cols, + ulong tid, + MY_BITMAP const *cols_bi, + MY_BITMAP const *cols_ai, + bool is_transactional) +: Rows_log_event(thd_arg, tbl_arg, tid, cols_bi, is_transactional) +#ifdef HAVE_REPLICATION + , m_memory(NULL), m_key(NULL) + +#endif +{ + init(cols_ai); +} + +Update_rows_log_event::Update_rows_log_event(THD *thd_arg, TABLE *tbl_arg, + ulong tid, + MY_BITMAP const *cols, bool is_transactional) : Rows_log_event(thd_arg, tbl_arg, tid, cols, is_transactional) #ifdef HAVE_REPLICATION , m_memory(NULL), m_key(NULL) #endif { + init(cols); +} + +void Update_rows_log_event::init(MY_BITMAP const *cols) +{ + /* if bitmap_init fails, catched in is_valid() */ + if (likely(!bitmap_init(&m_cols_ai, + m_width <= sizeof(m_bitbuf_ai)*8 ? m_bitbuf_ai : NULL, + (m_width + 7) & ~7UL, + false))) + { + /* Cols can be zero if this is a dummy binrows event */ + if (likely(cols != NULL)) + memcpy(m_cols_ai.bitmap, cols->bitmap, no_bytes_in_map(cols)); + } } #endif /* !defined(MYSQL_CLIENT) */ + +Update_rows_log_event::~Update_rows_log_event() +{ + if (m_cols_ai.bitmap == m_bitbuf_ai) // no my_malloc happened + m_cols_ai.bitmap= 0; // so no my_free in bitmap_free + bitmap_free(&m_cols_ai); // To pair with bitmap_init(). +} + + /* Constructor used by slave to read the event from the binary log. */ @@ -7678,7 +7800,7 @@ int Update_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli, store_record(table, record[1]); char const *next_start = *row_end; /* m_after_image is the after image for the update */ - error= unpack_row(rli, table, m_width, next_start, &m_cols, row_end, + error= unpack_row(rli, table, m_width, next_start, &m_cols_ai, row_end, &m_master_reclength, table->write_set, UPDATE_ROWS_EVENT); bmove_align(m_after_image, table->record[0], table->s->reclength); restore_record(table, record[1]); diff --git a/sql/log_event.h b/sql/log_event.h index a573140ef33..a5dbaed6855 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -2160,14 +2160,7 @@ public: #endif /* Member functions to implement superclass interface */ - virtual int get_data_size() - { - DBUG_EXECUTE_IF("old_row_based_repl_4_byte_map_id_master", - return 6 + 1 + no_bytes_in_map(&m_cols) + - (m_rows_cur - m_rows_buf);); - return ROWS_HEADER_LEN + 1 + no_bytes_in_map(&m_cols) + - (m_rows_cur - m_rows_buf); - } + virtual int get_data_size(); MY_BITMAP const *get_cols() const { return &m_cols; } my_size_t get_width() const { return m_width; } @@ -2178,9 +2171,14 @@ public: virtual bool write_data_body(IO_CACHE *file); virtual const char *get_db() { return m_table->s->db.str; } #endif + /* + Check that malloc() succeeded in allocating memory for the rows + buffer and the COLS vector. Checking that an Update_rows_log_event + is valid is done in the Update_rows_log_event::is_valid() + function. + */ virtual bool is_valid() const { - /* that's how we check malloc() succeeded */ return m_rows_buf && m_cols.bitmap; } @@ -2213,10 +2211,20 @@ protected: ulong m_table_id; /* Table ID */ MY_BITMAP m_cols; /* Bitmap denoting columns available */ ulong m_width; /* The width of the columns bitmap */ + /* + Bitmap for columns available in the after image, if present. These + fields are only available for Update_rows events. Observe that the + width of both the before image COLS vector and the after image + COLS vector is the same: the number of columns of the table on the + master. + */ + MY_BITMAP m_cols_ai; + ulong m_master_reclength; /* Length of record on master side */ - /* Bit buffer in the same memory as the class */ + /* Bit buffers in the same memory as the class */ uint32 m_bitbuf[128/(sizeof(uint32)*8)]; + uint32 m_bitbuf_ai[128/(sizeof(uint32)*8)]; byte *m_rows_buf; /* The rows in packed format */ byte *m_rows_cur; /* One-after the end of the data */ @@ -2376,10 +2384,20 @@ public: }; #ifndef MYSQL_CLIENT - Update_rows_log_event(THD*, TABLE*, ulong table_id, - MY_BITMAP const *cols, bool is_transactional); + Update_rows_log_event(THD*, TABLE*, ulong table_id, + MY_BITMAP const *cols_bi, + MY_BITMAP const *cols_ai, + bool is_transactional); + + Update_rows_log_event(THD*, TABLE*, ulong table_id, + MY_BITMAP const *cols, + bool is_transactional); + + void init(MY_BITMAP const *cols); #endif + virtual ~Update_rows_log_event(); + #ifdef HAVE_REPLICATION Update_rows_log_event(const char *buf, uint event_len, const Format_description_log_event *description_event); @@ -2398,6 +2416,11 @@ public: } #endif + virtual bool is_valid() const + { + return Rows_log_event::is_valid() && m_cols_ai.bitmap; + } + private: virtual Log_event_type get_type_code() { return (Log_event_type)TYPE_CODE; } From c9a7855f7f6f7d2808f77afe9022814da69f0370 Mon Sep 17 00:00:00 2001 From: "mats@romeo.(none)" <> Date: Tue, 27 Mar 2007 17:21:47 +0200 Subject: [PATCH 17/22] BUG#22583 (RBR between MyISAM and non-MyISAM tables containing a BIT field does not work): Enabling previously disabled test. --- mysql-test/t/disabled.def | 1 - 1 file changed, 1 deletion(-) diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 769c9ab1512..5ac1952edba 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -27,7 +27,6 @@ rpl_ndb_ddl : BUG#18946 result file needs update + test needs to ch rpl_ndb_innodb2ndb : Bug #19710 Cluster replication to partition table fails on DELETE FROM statement rpl_ndb_myisam2ndb : Bug #19710 Cluster replication to partition table fails on DELETE FROM statement rpl_row_blob_innodb : BUG#18980 2006-04-10 kent Test fails randomly -rpl_multi_engine : BUG#22583 2006-09-23 lars synchronization : Bug#24529 Test 'synchronization' fails on Mac pushbuild; Also on Linux 64 bit. # the below testcase have been reworked to avoid the bug, test contains comment, keep bug open From d0ce263f567165d867da3d3af98b1ce1d78fcac9 Mon Sep 17 00:00:00 2001 From: "mats@romeo.(none)" <> Date: Tue, 27 Mar 2007 17:45:23 +0200 Subject: [PATCH 18/22] Eliminating some compiler warnings. --- sql/log_event.cc | 1 + sql/slave.cc | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sql/log_event.cc b/sql/log_event.cc index b146fe044d2..6a5add0599e 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -3683,6 +3683,7 @@ Rotate_log_event::do_shall_skip(RELAY_LOG_INFO *rli) return Log_event::EVENT_SKIP_IGNORE; } DBUG_ASSERT(0); + return Log_event::EVENT_SKIP_NOT; // To keep compiler happy } #endif diff --git a/sql/slave.cc b/sql/slave.cc index 278edae99f4..55a774fd747 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1722,7 +1722,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) } if (ev) { - int type_code = ev->get_type_code(); + int const type_code= ev->get_type_code(); int exec_res= 0; /* @@ -1828,7 +1828,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) used to read info about the relay log's format; it will be deleted when the SQL thread does not need it, i.e. when this thread terminates. */ - if (ev->get_type_code() != FORMAT_DESCRIPTION_EVENT) + if (type_code != FORMAT_DESCRIPTION_EVENT) { DBUG_PRINT("info", ("Deleting the event after it has been executed")); delete ev; From 7054aaaafa001d52b16da73a9c6299dd0b9e8f1b Mon Sep 17 00:00:00 2001 From: "mats@romeo.(none)" <> Date: Tue, 27 Mar 2007 18:04:02 +0200 Subject: [PATCH 19/22] Eliminating a warning for unused variable in non-debug build. --- sql/log_event.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sql/log_event.cc b/sql/log_event.cc index 6a5add0599e..6b5c234681b 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -5906,7 +5906,9 @@ unpack_row(RELAY_LOG_INFO const *rli, /* We only unpack the field if it was non-null */ +#ifndef DBUG_OFF const char *const old_ptr= pack_ptr; +#endif pack_ptr= f->unpack(f->ptr, pack_ptr); DBUG_PRINT("debug", ("Unpacking field '%s' from %d bytes", f->field_name, pack_ptr - old_ptr)); From cc403587687a8669f0976b8424c49593535697ed Mon Sep 17 00:00:00 2001 From: "aelkin/elkin@dsl-hkibras1-ff1dc300-249.dhcp.inet.fi" <> Date: Wed, 28 Mar 2007 12:18:06 +0300 Subject: [PATCH 20/22] Bug#27015 s_query.q_append() called without s_query.reserve()? there is a way to miss allocation for the punctuation marks, namely if (q == EOF) is true inside of append_identifier(), i.e in case names are not quoted (not by default). Replacing q_append with the method with reallocation if needed. --- sql/sql_base.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 02191959233..16f30038c81 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1328,10 +1328,10 @@ void close_temporary_tables(THD *thd) due to special characters in the names */ append_identifier(thd, &s_query, table->s->db.str, strlen(table->s->db.str)); - s_query.q_append('.'); + s_query.append('.'); append_identifier(thd, &s_query, table->s->table_name.str, strlen(table->s->table_name.str)); - s_query.q_append(','); + s_query.append(','); next= table->next; close_temporary(table, 1, 1); } From 0488fd87c8ae405ada2d229bd4186d6bccab792b Mon Sep 17 00:00:00 2001 From: "mats@romeo.(none)" <> Date: Wed, 28 Mar 2007 15:30:03 +0200 Subject: [PATCH 21/22] Eliminating some warnings. --- sql/field.h | 8 ++++---- sql/log_event.cc | 5 ----- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/sql/field.h b/sql/field.h index f27ed8b9394..27eac2be729 100644 --- a/sql/field.h +++ b/sql/field.h @@ -193,9 +193,9 @@ public: */ virtual void sql_type(String &str) const =0; virtual uint size_of() const =0; // For new field - inline bool is_null(uint row_offset=0) + inline bool is_null(my_ptrdiff_t row_offset= 0) { return null_ptr ? (null_ptr[row_offset] & null_bit ? 1 : 0) : table->null_row; } - inline bool is_real_null(uint row_offset=0) + inline bool is_real_null(my_ptrdiff_t row_offset= 0) { return null_ptr ? (null_ptr[row_offset] & null_bit ? 1 : 0) : 0; } inline bool is_null_in_record(const uchar *record) { @@ -210,9 +210,9 @@ public: return 0; return test(null_ptr[offset] & null_bit); } - inline void set_null(int row_offset=0) + inline void set_null(my_ptrdiff_t row_offset= 0) { if (null_ptr) null_ptr[row_offset]|= null_bit; } - inline void set_notnull(int row_offset=0) + inline void set_notnull(my_ptrdiff_t row_offset= 0) { if (null_ptr) null_ptr[row_offset]&= (uchar) ~null_bit; } inline bool maybe_null(void) { return null_ptr != 0 || table->maybe_null; } inline bool real_maybe_null(void) { return null_ptr != 0; } diff --git a/sql/log_event.cc b/sql/log_event.cc index 6b5c234681b..c9d93a2d53a 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -5906,12 +5906,7 @@ unpack_row(RELAY_LOG_INFO const *rli, /* We only unpack the field if it was non-null */ -#ifndef DBUG_OFF - const char *const old_ptr= pack_ptr; -#endif pack_ptr= f->unpack(f->ptr, pack_ptr); - DBUG_PRINT("debug", ("Unpacking field '%s' from %d bytes", - f->field_name, pack_ptr - old_ptr)); } bitmap_set_bit(rw_set, f->field_index); From d5c66804431f4df36ae32154592ba8a952ed8a8e Mon Sep 17 00:00:00 2001 From: "bar@mysql.com" <> Date: Thu, 29 Mar 2007 10:32:38 +0500 Subject: [PATCH 22/22] Code layout fix for bug N 27079 Thanks to Gluh for suggestion. --- strings/ctype-uca.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index 3aad36f858c..1263882846d 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -6777,25 +6777,24 @@ static void my_uca_scanner_init_ucs2(my_uca_scanner *scanner, scanner->uca_length= cs->sort_order; scanner->uca_weight= cs->sort_order_big; scanner->contractions= cs->contractions; + return; } - else - { - /* - Sometimes this function is called with - str=NULL and length=0, which should be - considered as an empty string. + + /* + Sometimes this function is called with + str=NULL and length=0, which should be + considered as an empty string. + + The above initialization is unsafe for such cases, + because scanner->send is initialized to (NULL-2), which is 0xFFFFFFFE. + Then we fall into an endless loop in my_uca_scanner_next_ucs2(). - The above initialization is unsafe for such cases, - because scanner->send is initialized to (NULL-2), which is 0xFFFFFFFE. - Then we fall into an endless loop in my_uca_scanner_next_ucs2(). - - Do special initialization for the case when length=0. - Initialize scanner->sbeg to an address greater than scanner->send. - Next call of my_uca_scanner_next_ucs2() will correctly return with -1. - */ - scanner->sbeg= (uchar*) &nochar[1]; - scanner->send= (uchar*) &nochar[0]; - } + Do special initialization for the case when length=0. + Initialize scanner->sbeg to an address greater than scanner->send. + Next call of my_uca_scanner_next_ucs2() will correctly return with -1. + */ + scanner->sbeg= (uchar*) &nochar[1]; + scanner->send= (uchar*) &nochar[0]; }