Commit 4d1d8ed3 authored by dlenev@mysql.com's avatar dlenev@mysql.com

Follow-up for the fix for bug #18153 "ALTER/OPTIMIZE/REPAIR on transactional

tables corrupt triggers".

It turned out that we also have relied at certain places that
(new_table != table_name) were always true on Windows and for transactional
tables. Since our fix for the bug brakes this assumption we have to add new
flag to pass this information around.
This code needs to be refactored but I dare not to do this in 5.0.
parent e5d51965
...@@ -3182,6 +3182,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -3182,6 +3182,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
uint db_create_options, used_fields; uint db_create_options, used_fields;
enum db_type old_db_type,new_db_type; enum db_type old_db_type,new_db_type;
bool need_copy_table; bool need_copy_table;
bool no_table_reopen= FALSE;
DBUG_ENTER("mysql_alter_table"); DBUG_ENTER("mysql_alter_table");
thd->proc_info="init"; thd->proc_info="init";
...@@ -3833,6 +3834,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -3833,6 +3834,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
*/ */
close_cached_table(thd, table); close_cached_table(thd, table);
table=0; // Marker that table is closed table=0; // Marker that table is closed
no_table_reopen= TRUE;
} }
#if (!defined( __WIN__) && !defined( __EMX__) && !defined( OS2)) #if (!defined( __WIN__) && !defined( __EMX__) && !defined( OS2))
else else
...@@ -3871,7 +3873,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -3871,7 +3873,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
VOID(pthread_mutex_unlock(&LOCK_open)); VOID(pthread_mutex_unlock(&LOCK_open));
goto err; goto err;
} }
if (thd->lock || new_name != table_name) // True if WIN32 if (thd->lock || new_name != table_name || no_table_reopen) // True if WIN32
{ {
/* /*
Not table locking or alter table with rename Not table locking or alter table with rename
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment