From 56a6e71f9c535d448da148c836d92f8c52c7e202 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Tue, 9 Jul 2013 15:42:36 +0400 Subject: [PATCH] Fix merge.test failure - Problem: mysql_admin_table() calls open_temporary_tables(). This causes assertion failure, because mysql_execute_command() has already called open_temporary_tables() - Solution: call close_thread_tables() at the start of mysql_admin_table(), like mysql-5.6 does --- mysql-test/r/merge.result | 4 ++-- sql/sql_admin.cc | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result index b5c85555ed8..a68cbb0c65a 100644 --- a/mysql-test/r/merge.result +++ b/mysql-test/r/merge.result @@ -2262,7 +2262,7 @@ CREATE TABLE m1(a int)engine=merge union=(t1,t2,t3,t4,t5,t6,t7); SELECT 1 FROM m1; 1 HANDLER m1 OPEN; -ERROR HY000: Table storage engine for 'm1' doesn't have this option +ERROR HY000: Storage engine MRG_MyISAM of the table `test`.`m1` doesn't have this option DROP TABLE m1,t1,t2,t3,t4,t5,t6,t7; SELECT 1 FROM m1; ERROR 42S02: Table 'test.m1' doesn't exist @@ -3421,7 +3421,7 @@ CREATE TABLE t2 (c1 int); CREATE TABLE t3 (c1 int) ENGINE = MERGE UNION (t1,t2); START TRANSACTION; HANDLER t3 OPEN; -ERROR HY000: Table storage engine for 't3' doesn't have this option +ERROR HY000: Storage engine MRG_MyISAM of the table `test`.`t3` doesn't have this option DROP TABLE t1, t2, t3; # Connection default. # Disconnecting con1, all mdl_tickets must have been released. diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc index e96e60e0feb..ca5ef9a2fc8 100644 --- a/sql/sql_admin.cc +++ b/sql/sql_admin.cc @@ -352,6 +352,14 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, mysql_ha_rm_tables(thd, tables); + /* + Close all temporary tables which were pre-open to simplify + privilege checking. Clear all references to closed tables. + */ + close_thread_tables(thd); + for (table= tables; table; table= table->next_local) + table->table= NULL; + for (table= tables; table; table= table->next_local) { char table_name[SAFE_NAME_LEN*2+2];