From 301b26b1149be6551927d1fa5d547bb37a393971 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 21 Jan 2005 15:14:31 +0400 Subject: A fix (bug #7261: Alter table loses temp table with lower_case_table_names=2). --- sql/sql_table.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index c3bfbe086f1..e01df8a3fcd 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3231,7 +3231,8 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, } /* Remove link to old table and rename the new one */ close_temporary_table(thd,table->table_cache_key,table_name); - if (rename_temporary_table(thd, new_table, new_db, new_alias)) + /* Should pass the 'new_name' as we store table name in the cache */ + if (rename_temporary_table(thd, new_table, new_db, new_name)) { // Fatal error close_temporary_table(thd,new_db,tmp_name); my_free((gptr) new_table,MYF(0)); -- cgit v1.2.1 From ae27c7502de145f8e2da800d5cea0c98b18f866e Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 25 Jan 2005 10:58:30 +0400 Subject: Test case (bug #7261: Alter table loses temp table with lower_case_table_names=2). --- mysql-test/r/lowercase_table2.result | 12 +++++++++++- mysql-test/t/lowercase_table2.test | 13 ++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/lowercase_table2.result b/mysql-test/r/lowercase_table2.result index 3be73f6cc6a..cfd8f78a77c 100644 --- a/mysql-test/r/lowercase_table2.result +++ b/mysql-test/r/lowercase_table2.result @@ -1,4 +1,4 @@ -DROP TABLE IF EXISTS t1,t2,T1,T2,t3,T3; +DROP TABLE IF EXISTS t1,t2,T1,T2,t3,T3,tT; DROP DATABASE IF EXISTS `TEST_$1`; DROP DATABASE IF EXISTS `test_$1`; CREATE TABLE T1 (a int); @@ -131,3 +131,13 @@ show tables like 't1%'; Tables_in_test (t1%) t1 drop table t1; +create temporary table tT(a int(11), b varchar(8)); +insert into tT values (1, 'abc'); +select * from tT; +a b +1 abc +alter table tT add index (a); +select * from tT; +a b +1 abc +drop table tT; diff --git a/mysql-test/t/lowercase_table2.test b/mysql-test/t/lowercase_table2.test index a4eaeac4ef4..237dcd29950 100644 --- a/mysql-test/t/lowercase_table2.test +++ b/mysql-test/t/lowercase_table2.test @@ -10,7 +10,7 @@ show variables like "lower_case_table_names"; enable_query_log; --disable_warnings -DROP TABLE IF EXISTS t1,t2,T1,T2,t3,T3; +DROP TABLE IF EXISTS t1,t2,T1,T2,t3,T3,tT; DROP DATABASE IF EXISTS `TEST_$1`; DROP DATABASE IF EXISTS `test_$1`; --enable_warnings @@ -100,3 +100,14 @@ show tables like 'T1%'; alter table t1 add index (A); show tables like 't1%'; drop table t1; + +# +# Bug #7261: Alter table loses temp table +# + +create temporary table tT(a int(11), b varchar(8)); +insert into tT values (1, 'abc'); +select * from tT; +alter table tT add index (a); +select * from tT; +drop table tT; -- cgit v1.2.1