diff options
Diffstat (limited to 'sql/sql_admin.cc')
-rw-r--r-- | sql/sql_admin.cc | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc index 82fc1cbfff7..f2523b44317 100644 --- a/sql/sql_admin.cc +++ b/sql/sql_admin.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2010, 2015, Oracle and/or its affiliates. - Copyright (c) 2011, 2016, MariaDB + Copyright (c) 2011, 2018, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -240,7 +240,7 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list, if (thd->locked_tables_list.locked_tables()) { - if (thd->locked_tables_list.reopen_tables(thd)) + if (thd->locked_tables_list.reopen_tables(thd, false)) goto end; /* Restore the table in the table list with the new opened table */ table_list->table= pos_in_locked_tables->table; @@ -267,7 +267,7 @@ end: tdc_release_share(table->s); } /* In case of a temporary table there will be no metadata lock. */ - if (error && has_mdl_lock) + if (unlikely(error) && has_mdl_lock) thd->mdl_context.release_transactional_locks(); DBUG_RETURN(error); @@ -525,7 +525,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, If open_and_lock_tables() failed, close_thread_tables() will close the table and table->table can therefore be invalid. */ - if (open_error) + if (unlikely(open_error)) table->table= NULL; /* @@ -533,7 +533,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, so any errors opening the table are logical errors. In these cases it does not make sense to try to repair. */ - if (open_error && thd->locked_tables_mode) + if (unlikely(open_error) && thd->locked_tables_mode) { result_code= HA_ADMIN_FAILED; goto send_result; @@ -828,7 +828,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, repair_table_use_frm, FALSE); thd->open_options&= ~extra_open_options; - if (!open_error) + if (unlikely(!open_error)) { TABLE *tab= table->table; Field **field_ptr= tab->field; @@ -1175,7 +1175,9 @@ send_result_message: } else { - if (trans_commit_stmt(thd) || trans_commit_implicit(thd)) + if (trans_commit_stmt(thd) || + (stmt_causes_implicit_commit(thd, CF_IMPLICIT_COMMIT_END) && + trans_commit_implicit(thd))) goto err; } close_thread_tables(thd); @@ -1209,7 +1211,8 @@ send_result_message: err: /* Make sure this table instance is not reused after the failure. */ trans_rollback_stmt(thd); - trans_rollback(thd); + if (stmt_causes_implicit_commit(thd, CF_IMPLICIT_COMMIT_END)) + trans_rollback(thd); if (table && table->table) { table->table->m_needs_reopen= true; |