diff --git a/mysql-test/r/binlog_index.result b/mysql-test/r/binlog_index.result index 9c22a33435a..90a29f616e0 100644 --- a/mysql-test/r/binlog_index.result +++ b/mysql-test/r/binlog_index.result @@ -9,7 +9,7 @@ master-bin.000003 # master-bin.000004 # purge binary logs TO 'master-bin.000004'; Warnings: -Warning 1476 Being purged log MYSQLTEST_VARDIR/log/master-bin.000001 was not found +Warning 1611 Being purged log MYSQLTEST_VARDIR/log/master-bin.000001 was not found *** must show a list starting from the 'TO' argument of PURGE *** show binary logs; Log_name File_size @@ -20,7 +20,7 @@ flush logs; flush logs; *** must be a warning master-bin.000001 was not found *** Warnings: -Warning 1476 Being purged log MYSQLTEST_VARDIR/log/master-bin.000001 was not found +Warning 1611 Being purged log MYSQLTEST_VARDIR/log/master-bin.000001 was not found *** must show one record, of the active binlog, left in the index file after PURGE *** show binary logs; Log_name File_size diff --git a/mysql-test/r/ctype_big5.result b/mysql-test/r/ctype_big5.result index b88ea14b559..2c8059a8afc 100644 --- a/mysql-test/r/ctype_big5.result +++ b/mysql-test/r/ctype_big5.result @@ -78,8 +78,8 @@ level smallint unsigned); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `name` varchar(10) default NULL, - `level` smallint(5) unsigned default NULL + `name` varchar(10) DEFAULT NULL, + `level` smallint(5) unsigned DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=big5 insert into t1 values ('string',1); select concat(name,space(level)), concat(name, repeat(' ',level)) from t1; diff --git a/mysql-test/suite/binlog/r/binlog_auto_increment_bug33029.result b/mysql-test/suite/binlog/r/binlog_auto_increment_bug33029.result index 6fbadf68721..68f1f0b2566 100644 --- a/mysql-test/suite/binlog/r/binlog_auto_increment_bug33029.result +++ b/mysql-test/suite/binlog/r/binlog_auto_increment_bug33029.result @@ -36,3 +36,4 @@ DROP PROCEDURE IF EXISTS p1; DROP PROCEDURE IF EXISTS p2; DROP FUNCTION IF EXISTS f1; DROP TRIGGER IF EXISTS tr1; +stop slave sql_thread; diff --git a/mysql-test/suite/binlog/r/binlog_stm_blackhole.result b/mysql-test/suite/binlog/r/binlog_stm_blackhole.result index cef1d2f94c8..619fd39a2a9 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_blackhole.result +++ b/mysql-test/suite/binlog/r/binlog_stm_blackhole.result @@ -172,6 +172,7 @@ master-bin.000001 # Query # # use `test`; BEGIN master-bin.000001 # Query # # use `test`; insert into t1 values(1) master-bin.000001 # Query # # use `test`; COMMIT drop table if exists t1; +reset master; create table t1 (a int auto_increment, primary key (a)) engine=blackhole; insert into t1 values (11), (NULL), (NULL), (NULL); set insert_id= 3; @@ -181,10 +182,16 @@ insert into t1 values (55), (NULL); show binlog events from ; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # use `test`; create table t1 (a int auto_increment, primary key (a)) engine=blackhole +master-bin.000001 # Query 1 # use `test`; BEGIN master-bin.000001 # Intvar 1 # INSERT_ID=1 master-bin.000001 # Query 1 # use `test`; insert into t1 values (11), (NULL), (NULL), (NULL) +master-bin.000001 # Query 1 # use `test`; COMMIT +master-bin.000001 # Query 1 # use `test`; BEGIN master-bin.000001 # Intvar 1 # INSERT_ID=3 master-bin.000001 # Query 1 # use `test`; insert into t1 values (NULL), (33), (NULL) +master-bin.000001 # Query 1 # use `test`; COMMIT +master-bin.000001 # Query 1 # use `test`; BEGIN master-bin.000001 # Intvar 1 # INSERT_ID=5 master-bin.000001 # Query 1 # use `test`; insert into t1 values (55), (NULL) +master-bin.000001 # Query 1 # use `test`; COMMIT drop table t1; diff --git a/mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test b/mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test index 83c5b9513c4..e77c9398c59 100644 --- a/mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test +++ b/mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test @@ -45,3 +45,10 @@ DROP PROCEDURE IF EXISTS p2; DROP FUNCTION IF EXISTS f1; DROP TRIGGER IF EXISTS tr1; enable_warnings; + +remove_file $MYSQLTEST_VARDIR/master-data/slave-relay-bin.000001; +remove_file $MYSQLTEST_VARDIR/master-data/slave-relay-bin.index; +stop slave sql_thread; +let $keep_connection=1; +source include/wait_for_slave_sql_to_stop.inc; + diff --git a/mysql-test/r/rpl_auto_increment_bug33029.result b/mysql-test/suite/rpl/r/rpl_stm_auto_increment_bug33029.result similarity index 95% rename from mysql-test/r/rpl_auto_increment_bug33029.result rename to mysql-test/suite/rpl/r/rpl_stm_auto_increment_bug33029.result index fb17553f5a0..2f6e98d5eec 100644 --- a/mysql-test/r/rpl_auto_increment_bug33029.result +++ b/mysql-test/suite/rpl/r/rpl_stm_auto_increment_bug33029.result @@ -64,7 +64,9 @@ master-bin.000001 # Intvar # # INSERT_ID=9 master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (NULL) master-bin.000001 # Intvar # # INSERT_ID=10 master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (NULL) +master-bin.000001 # Intvar # # INSERT_ID=1 master-bin.000001 # Query # # use `test`; DELETE FROM t1 WHERE id = 1 +master-bin.000001 # Intvar # # INSERT_ID=2 master-bin.000001 # Query # # use `test`; DELETE FROM t1 WHERE id = 2 master-bin.000001 # Query # # use `test`; DELETE FROM t2 WHERE id = 1 master-bin.000001 # Query # # use `test`; DELETE FROM t2 WHERE id = 2 @@ -100,7 +102,9 @@ show binlog events from ; Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Intvar # # INSERT_ID=11 master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (NULL) +master-bin.000001 # Intvar # # INSERT_ID=3 master-bin.000001 # Query # # use `test`; DELETE FROM t1 WHERE id = f1(3) +master-bin.000001 # Intvar # # INSERT_ID=12 master-bin.000001 # Query # # use `test`; DELETE FROM t1 WHERE id = f1(4) master-bin.000001 # Query # # use `test`; DELETE FROM t2 WHERE id = 3 master-bin.000001 # Query # # use `test`; DELETE FROM t2 WHERE id = 4 diff --git a/mysql-test/t/rpl_auto_increment_bug33029.test b/mysql-test/suite/rpl/t/rpl_stm_auto_increment_bug33029.test similarity index 98% rename from mysql-test/t/rpl_auto_increment_bug33029.test rename to mysql-test/suite/rpl/t/rpl_stm_auto_increment_bug33029.test index db548945c7f..a8139bbbcd2 100644 --- a/mysql-test/t/rpl_auto_increment_bug33029.test +++ b/mysql-test/suite/rpl/t/rpl_stm_auto_increment_bug33029.test @@ -8,6 +8,7 @@ # value might be associated with these statement, which could cause # duplicate entry error and stop the slave. +source include/have_binlog_format_statement.inc; source include/master-slave.inc; --disable_warnings diff --git a/sql/log.cc b/sql/log.cc index 8789dce4cd4..6e6a29c59b7 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2746,14 +2746,62 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd) for (;;) { - my_delete_allow_opened(linfo.log_file_name, MYF(MY_WME)); + if ((error= my_delete_allow_opened(linfo.log_file_name, MYF(0))) != 0) + { + if (my_errno == ENOENT) + { + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE), + linfo.log_file_name); + sql_print_information("Failed to delete file '%s'", + linfo.log_file_name); + my_errno= 0; + error= 0; + } + else + { + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_BINLOG_PURGE_FATAL_ERR, + "a problem with deleting %s; " + "consider examining correspondence " + "of your binlog index file " + "to the actual binlog files", + linfo.log_file_name); + error= 1; + goto err; + } + } if (find_next_log(&linfo, 0)) break; } /* Start logging with a new file */ close(LOG_CLOSE_INDEX); - my_delete_allow_opened(index_file_name, MYF(MY_WME)); // Reset (open will update) + if ((error= my_delete_allow_opened(index_file_name, MYF(0)))) // Reset (open will update) + { + if (my_errno == ENOENT) + { + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE), + index_file_name); + sql_print_information("Failed to delete file '%s'", + index_file_name); + my_errno= 0; + error= 0; + } + else + { + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_BINLOG_PURGE_FATAL_ERR, + "a problem with deleting %s; " + "consider examining correspondence " + "of your binlog index file " + "to the actual binlog files", + index_file_name); + error= 1; + goto err; + } + } if (!thd->slave_thread) need_start_event=1; if (!open_index_file(index_file_name, 0)) @@ -2913,6 +2961,7 @@ int MYSQL_BIN_LOG::update_log_index(LOG_INFO* log_info, bool need_update_threads 0 ok @retval LOG_INFO_EOF to_log not found + LOG_INFO_EMFILE too many files opened LOG_INFO_FATAL if any other than ENOENT error from my_stat() or my_delete() */ @@ -3004,28 +3053,19 @@ int MYSQL_BIN_LOG::purge_logs(const char *to_log, "of your binlog index file " "to the actual binlog files", log_info.log_file_name); + if (my_errno == EMFILE) + { + DBUG_PRINT("info", + ("my_errno: %d, set ret = LOG_INFO_EMFILE", my_errno)); + error= LOG_INFO_EMFILE; + } error= LOG_INFO_FATAL; goto err; } } } - /* - It's not fatal if we can't delete a log file ; - if we could delete it, take its size into account - */ - DBUG_PRINT("info",("purging %s",log_info.log_file_name)); - if (!my_delete(log_info.log_file_name, MYF(0)) && decrease_log_space) - *decrease_log_space-= file_size; ha_binlog_index_purge_file(current_thd, log_info.log_file_name); - if (current_thd->is_slave_error) { - DBUG_PRINT("info",("slave error: %d", current_thd->is_slave_error)); - if (my_errno == EMFILE) { - DBUG_PRINT("info",("my_errno: %d, set ret = LOG_INFO_EMFILE", my_errno)); - ret = LOG_INFO_EMFILE; - break; - } - } if (find_next_log(&log_info, 0) || exit_loop) break; diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 247cccfa838..48ab3ea64c1 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1069,19 +1069,6 @@ bool THD::store_globals() void THD::cleanup_after_query() { - last_insert_id_used= FALSE; - if (clear_next_insert_id) - { - clear_next_insert_id= 0; - next_insert_id= 0; - - /* - BUG#33029, if one statement in a SP set this member to 1, all - statment after this statement in the SP would be considered used - INSERT_ID value, reset this member after each query to fix this. - */ - insert_id_used= 0; - } /* Reset rand_used so that detection of calls to rand() will save random seeds if needed by the slave.