diff options
author | unknown <mkindahl@dl145h.mysql.com> | 2008-03-31 09:57:29 +0200 |
---|---|---|
committer | unknown <mkindahl@dl145h.mysql.com> | 2008-03-31 09:57:29 +0200 |
commit | d59b8cf0937877931be65c6f4ebffa427b4118b0 (patch) | |
tree | 125ec97c77a830ddd76af39cf2d541c0bdfbbd4d /sql | |
parent | ed1d366a23e4320e0dcee29c642c94e6ce491fd3 (diff) | |
parent | 4020e6a2d7910be74c0f22e884c6f4ee8ba7865b (diff) | |
download | mariadb-git-d59b8cf0937877931be65c6f4ebffa427b4118b0.tar.gz |
Merge mkindahl@bk-internal.mysql.com:/home/bk/mysql-5.0
into dl145h.mysql.com:/data0/mkindahl/mysql-5.0-rpl-merge
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_blackhole.cc | 2 | ||||
-rw-r--r-- | sql/log.cc | 153 | ||||
-rw-r--r-- | sql/share/errmsg.txt | 2 | ||||
-rw-r--r-- | sql/sql_class.cc | 7 |
4 files changed, 137 insertions, 27 deletions
diff --git a/sql/ha_blackhole.cc b/sql/ha_blackhole.cc index e477686d18e..01ede3d3bd2 100644 --- a/sql/ha_blackhole.cc +++ b/sql/ha_blackhole.cc @@ -115,7 +115,7 @@ const char *ha_blackhole::index_type(uint key_number) int ha_blackhole::write_row(byte * buf) { DBUG_ENTER("ha_blackhole::write_row"); - DBUG_RETURN(0); + DBUG_RETURN(table->next_number_field ? update_auto_increment() : 0); } int ha_blackhole::rnd_init(bool scan) diff --git a/sql/log.cc b/sql/log.cc index 15e8679171c..9e112e46c65 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1180,6 +1180,8 @@ int MYSQL_LOG::update_log_index(LOG_INFO* log_info, bool need_update_threads) RETURN VALUES 0 ok LOG_INFO_EOF to_log not found + LOG_INFO_FATAL if any other than ENOENT error from + my_stat() or my_delete() */ int MYSQL_LOG::purge_logs(const char *to_log, @@ -1208,33 +1210,75 @@ int MYSQL_LOG::purge_logs(const char *to_log, while ((strcmp(to_log,log_info.log_file_name) || (exit_loop=included)) && !log_in_use(log_info.log_file_name)) { - ulong file_size= 0; - if (decrease_log_space) //stat the file we want to delete + MY_STAT s; + if (!my_stat(log_info.log_file_name, &s, MYF(0))) { - MY_STAT s; - - /* - If we could not stat, we can't know the amount - of space that deletion will free. In most cases, - deletion won't work either, so it's not a problem. - */ - if (my_stat(log_info.log_file_name,&s,MYF(0))) - file_size= s.st_size; - else - sql_print_information("Failed to execute my_stat on file '%s'", + if (my_errno == ENOENT) + { + /* + It's not fatal if we can't stat a log file that does not exist; + If we could not stat, we won't delete. + */ + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE), + log_info.log_file_name); + sql_print_information("Failed to execute my_stat on file '%s'", log_info.log_file_name); + my_errno= 0; + } + else + { + /* + Other than ENOENT are fatal + */ + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_BINLOG_PURGE_FATAL_ERR, + "a problem with getting info on being purged %s; " + "consider examining correspondence " + "of your binlog index file " + "to the actual binlog files", + log_info.log_file_name); + error= LOG_INFO_FATAL; + goto err; + } + } + else + { + DBUG_PRINT("info",("purging %s",log_info.log_file_name)); + if (!my_delete(log_info.log_file_name, MYF(0))) + { + if (decrease_log_space) + *decrease_log_space-= s.st_size; + } + else + { + 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), + log_info.log_file_name); + sql_print_information("Failed to delete file '%s'", + log_info.log_file_name); + my_errno= 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", + log_info.log_file_name); + 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; if (find_next_log(&log_info, 0) || exit_loop) break; } - + /* If we get killed -9 here, the sysadmin would have to edit the log index file after restart - otherwise, this should be safe @@ -1263,6 +1307,8 @@ err: RETURN VALUES 0 ok LOG_INFO_PURGE_NO_ROTATE Binary file that can't be rotated + LOG_INFO_FATAL if any other than ENOENT error from + my_stat() or my_delete() */ int MYSQL_LOG::purge_logs_before_date(time_t purge_time) @@ -1286,11 +1332,66 @@ int MYSQL_LOG::purge_logs_before_date(time_t purge_time) while (strcmp(log_file_name, log_info.log_file_name) && !log_in_use(log_info.log_file_name)) { - /* It's not fatal even if we can't delete a log file */ - if (!my_stat(log_info.log_file_name, &stat_area, MYF(0)) || - stat_area.st_mtime >= purge_time) - break; - my_delete(log_info.log_file_name, MYF(0)); + if (!my_stat(log_info.log_file_name, &stat_area, MYF(0))) + { + if (my_errno == ENOENT) + { + /* + It's not fatal if we can't stat a log file that does not exist. + */ + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE), + log_info.log_file_name); + sql_print_information("Failed to execute my_stat on file '%s'", + log_info.log_file_name); + my_errno= 0; + } + else + { + /* + Other than ENOENT are fatal + */ + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_BINLOG_PURGE_FATAL_ERR, + "a problem with getting info on being purged %s; " + "consider examining correspondence " + "of your binlog index file " + "to the actual binlog files", + log_info.log_file_name); + error= LOG_INFO_FATAL; + goto err; + } + } + else + { + if (stat_area.st_mtime >= purge_time) + break; + if (my_delete(log_info.log_file_name, MYF(0))) + { + if (my_errno == ENOENT) + { + /* It's not fatal even if we can't delete a log file */ + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE), + log_info.log_file_name); + sql_print_information("Failed to delete file '%s'", + log_info.log_file_name); + my_errno= 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", + log_info.log_file_name); + error= LOG_INFO_FATAL; + goto err; + } + } + } if (find_next_log(&log_info, 0)) break; } diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index 9e6cf462113..516dba1cd08 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -5641,3 +5641,5 @@ ER_NAME_BECOMES_EMPTY eng "Name '%-.64s' has become ''" ER_AMBIGUOUS_FIELD_TERM eng "First character of the FIELDS TERMINATED string is ambiguous; please use non-optional and non-empty FIELDS ENCLOSED BY" +ER_LOG_PURGE_NO_FILE + eng "Being purged log %s was not found" diff --git a/sql/sql_class.cc b/sql/sql_class.cc index e36ed0c425f..f541c8b3677 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -622,6 +622,13 @@ void THD::cleanup_after_query() { 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 |