Commit 8b7a63b1 authored by Michael Widenius's avatar Michael Widenius

Added logging of all messages (also system warnings) one gets during a MyISAM...

Added logging of all messages (also system warnings) one gets during a MyISAM recovery or auto-recovery.


sql/mysqld.cc:
  Log errors if thd->log_all_errors is set
sql/sql_class.cc:
  Add log_all_errors
sql/sql_class.h:
  Add log_all_errors
storage/myisam/ha_myisam.cc:
  Write db and table name for all logged errors
  Log errors also during auto_recovery
  During auto_recovery, set thd->log_all_errors if log_warnings >2 to ensure that system errors are also logged to file
parent 1a344b87
......@@ -3155,7 +3155,7 @@ to_error_log:
/* When simulating OOM, skip writing to error log to avoid mtr errors */
DBUG_EXECUTE_IF("simulate_out_of_memory", DBUG_RETURN(0););
if (!thd || (MyFlags & ME_NOREFRESH))
if (!thd || thd->log_all_errors || (MyFlags & ME_NOREFRESH))
(*func)("%s: %s", my_progname_short, str); /* purecov: inspected */
DBUG_RETURN(0);
}
......
......@@ -662,7 +662,7 @@ THD::THD()
Open_tables_state(refresh_version), rli_fake(0),
lock_id(&main_lock_id),
user_time(0), in_sub_stmt(0),
sql_log_bin_toplevel(false),
sql_log_bin_toplevel(false), log_all_errors(0),
binlog_table_maps(0), binlog_flags(0UL),
table_map_for_update(0),
arg_of_last_insert_id_function(FALSE),
......
......@@ -1467,6 +1467,8 @@ public:
bool sql_log_bin_toplevel;
/* True when opt_userstat_running is set at start of query */
bool userstat_running;
/* True if we want to log all errors */
bool log_all_errors;
/* container for handler's private per-connection data */
Ha_data ha_data[MAX_HA];
......
......@@ -91,14 +91,16 @@ static void mi_check_print_msg(HA_CHECK *param, const char* msg_type,
if (!thd->vio_ok())
{
sql_print_error("%s", msgbuf);
sql_print_error("%s.%s: %s", param->db_name, param->table_name, msgbuf);
return;
}
if (param->testflag & (T_CREATE_MISSING_KEYS | T_SAFE_REPAIR |
T_AUTO_REPAIR))
{
my_message(ER_NOT_KEYFILE,msgbuf,MYF(MY_WME));
my_message(ER_NOT_KEYFILE, msgbuf, MYF(MY_WME));
if (thd->variables.log_warnings > 2)
sql_print_error("%s.%s: %s", param->db_name, param->table_name, msgbuf);
return;
}
length=(uint) (strxmov(name, param->db_name,".",param->table_name,NullS) -
......@@ -124,7 +126,7 @@ static void mi_check_print_msg(HA_CHECK *param, const char* msg_type,
sql_print_error("Failed on my_net_write, writing to stderr instead: %s\n",
msgbuf);
else if (thd->variables.log_warnings > 2)
sql_print_error("%s", msgbuf);
sql_print_error("%s.%s: %s", param->db_name, param->table_name, msgbuf);
#ifdef THREAD
if (param->need_print_msg_lock)
......@@ -1668,7 +1670,10 @@ bool ha_myisam::check_and_repair(THD *thd)
if ((marked_crashed= mi_is_crashed(file)) || check(thd, &check_opt))
{
bool save_log_all_errors;
sql_print_warning("Recovering table: '%s'",table->s->path.str);
save_log_all_errors= thd->log_all_errors;
thd->log_all_errors= (thd->variables.log_warnings > 2);
if (myisam_recover_options & HA_RECOVER_FULL_BACKUP)
{
char buff[MY_BACKUP_NAME_EXTRA_LENGTH+1];
......@@ -1686,6 +1691,7 @@ bool ha_myisam::check_and_repair(THD *thd)
T_AUTO_REPAIR);
if (repair(thd, &check_opt))
error=1;
thd->log_all_errors= save_log_all_errors;
}
thd->set_query(old_query, old_query_length);
DBUG_RETURN(error);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment