From 9c3c566fcbc4f6f1452fc7c5440890d9d2e78efc Mon Sep 17 00:00:00 2001
From: "ram@gw.mysql.r18.ru" <>
Date: Fri, 21 Jan 2005 15:14:31 +0400
Subject: [PATCH] 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 c3bfbe086f..e01df8a3fc 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));
-- 
2.30.9