From cf8df9ca442200d9ea01d4480cb7bf70675ca188 Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Thu, 15 Apr 2010 18:53:57 +0200 Subject: Bug #47459 Assertion in Diagnostics_area::set_eof_status on OPTIMIZE TABLE This assertion could be triggered during execution of OPTIMIZE TABLE for InnoDB tables. As part of optimize for InnoDB tables, the table is recreated and then opened again. If the reopen failed for any reason, the assertion would be triggered. This could for example be caused by a concurrent DROP TABLE executed by a different connection. The reason for the assertion was that any failures during reopening were ignored. This patch fixes the problem by making sure that the result of reopening the table is checked and that any error messages are sent to the client. Test case added to innodb_mysql_sync.test. --- sql/sql_table.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'sql/sql_table.cc') diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 2a9e01daf18..5b957cccabd 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -5016,11 +5016,17 @@ send_result_message: { /* Clear the ticket released in close_thread_tables(). */ table->mdl_request.ticket= NULL; - if ((table->table= open_ltable(thd, table, lock_type, 0)) && - ((result_code= table->table->file->ha_analyze(thd, check_opt)) > 0)) - result_code= 0; // analyze went ok - if (result_code) // analyze failed - table->table->file->print_error(result_code, MYF(0)); + DEBUG_SYNC(thd, "ha_admin_open_ltable"); + if (table->table= open_ltable(thd, table, lock_type, 0)) + { + result_code= table->table->file->ha_analyze(thd, check_opt); + if (result_code == HA_ADMIN_ALREADY_DONE) + result_code= HA_ADMIN_OK; + else if (result_code) // analyze failed + table->table->file->print_error(result_code, MYF(0)); + } + else + result_code= -1; // open failed } /* Start a new row for the final status row */ protocol->prepare_for_resend(); -- cgit v1.2.1