From 7772a4533c119a45d9b2f79d1608d300b102af43 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Thu, 19 Mar 2015 16:58:51 +0400 Subject: MDEV-7715 - Spiral patch 017_mariadb-10.0.15.get_error_at_commit.diff Let open_ltable() rollback statement only if it failed to lock transactional table. This allows spider to safely open non-transactional system tables during commit. --- sql/sql_base.cc | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index b4c3e5ecafd..bc401903cf5 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -5013,16 +5013,23 @@ TABLE *open_n_lock_single_table(THD *thd, TABLE_LIST *table_l, lock_flags Flags passed to mysql_lock_table NOTE - This function doesn't do anything like SP/SF/views/triggers analysis done + This function doesn't do anything like SP/SF/views/triggers analysis done in open_table()/lock_tables(). It is intended for opening of only one - concrete table. And used only in special contexts. + concrete table. And used only in special contexts: + - (CREATE|DROP|ALTER) (FUNCTION|PROCEDURE|SERVER) + - (INSTALL|UNINSTALL) PLUGIN + - log tables + - OPTIMIZE TABLE falled back to ALTER + + In most cases it is used to open non-transactional system table. An + exception is OPTIMIZE TABLE: it may open any table. RETURN VALUES table Opened table 0 Error - + If ok, the following are also set: - table_list->lock_type lock_type + table_list->lock_type lock_type table_list->table table */ @@ -5087,7 +5094,11 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type, if (thd->locked_tables_mode) { if (check_lock_and_start_stmt(thd, thd->lex, table_list)) + { + if (!thd->in_sub_stmt && table->file->has_transactions()) + trans_rollback_stmt(thd); table= 0; + } } else { @@ -5096,6 +5107,8 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type, if (! (thd->lock= mysql_lock_tables(thd, &table_list->table, 1, lock_flags))) { + if (!thd->in_sub_stmt && table->file->has_transactions()) + trans_rollback_stmt(thd); table= 0; } } @@ -5105,11 +5118,7 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type, end: if (table == NULL) - { - if (!thd->in_sub_stmt) - trans_rollback_stmt(thd); close_thread_tables(thd); - } THD_STAGE_INFO(thd, stage_after_opening_tables); thd_proc_info(thd, 0); -- cgit v1.2.1