Commit daf333ab authored by Michael Widenius's avatar Michael Widenius

Rename of stat table tried to rename open table.

When compiling with -DEXTRA_DEBUG and run main.stat_tables_missing
on go the warning:
Warning:  Table: ./mysql/column_stats is open on rename old_table

This happened because rename_table_in_stat_tables() re-open the
table that was to be renamed.
Fixed by moving update of stat tables after all renames has been made.
parent bff7cf9d
...@@ -9157,11 +9157,6 @@ simple_rename_or_index_change(THD *thd, TABLE_LIST *table_list, ...@@ -9157,11 +9157,6 @@ simple_rename_or_index_change(THD *thd, TABLE_LIST *table_list,
close_all_tables_for_name(thd, table->s, HA_EXTRA_PREPARE_FOR_RENAME, close_all_tables_for_name(thd, table->s, HA_EXTRA_PREPARE_FOR_RENAME,
NULL); NULL);
(void) rename_table_in_stat_tables(thd, &alter_ctx->db,
&alter_ctx->table_name,
&alter_ctx->new_db,
&alter_ctx->new_alias);
if (mysql_rename_table(old_db_type, &alter_ctx->db, &alter_ctx->table_name, if (mysql_rename_table(old_db_type, &alter_ctx->db, &alter_ctx->table_name,
&alter_ctx->new_db, &alter_ctx->new_alias, 0)) &alter_ctx->new_db, &alter_ctx->new_alias, 0))
error= -1; error= -1;
...@@ -9178,6 +9173,12 @@ simple_rename_or_index_change(THD *thd, TABLE_LIST *table_list, ...@@ -9178,6 +9173,12 @@ simple_rename_or_index_change(THD *thd, TABLE_LIST *table_list,
NO_FK_CHECKS); NO_FK_CHECKS);
error= -1; error= -1;
} }
/* Update stat tables last. This is to be able to handle rename of a stat table */
if (error == 0)
(void) rename_table_in_stat_tables(thd, &alter_ctx->db,
&alter_ctx->table_name,
&alter_ctx->new_db,
&alter_ctx->new_alias);
} }
if (likely(!error)) if (likely(!error))
......
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