diff options
| author | Dmitry Lenev <Dmitry.Lenev@oracle.com> | 2011-04-13 10:16:40 +0400 |
|---|---|---|
| committer | Dmitry Lenev <Dmitry.Lenev@oracle.com> | 2011-04-13 10:16:40 +0400 |
| commit | be65ee15fb4f25b75c1703dc083916cfaaa3c6f4 (patch) | |
| tree | c7623bed32d508d3bbe3953e54446258fc91f47e /sql/sql_table.cc | |
| parent | 288d71b95e06772913b8ea4c44efac53d17bc12a (diff) | |
| download | mariadb-git-be65ee15fb4f25b75c1703dc083916cfaaa3c6f4.tar.gz | |
Bug#11938039 "RE-EXECUTION OF FRM-ONLY ALTER TABLE WITH RENAME
CLAUSE FAILS OR ABORTS SERVER".
Attempt to re-execute prepared ALTER TABLE statement which
involves .FRM-only changes and also have RENAME clause led
to unwarranted 'Table doesn't exist' error in production
builds and assertion failure for debug builds.
This problem stemmed from the fact that for such ALTER TABLE
mysql_alter_table() code changed table list element for table
to be altered when it tried to re-open table under new name.
Since this change was not reverted back before next
re-execution, it made this statement re-execution unsafe.
This fix addresses this problem by avoiding changing table list
element from the main table list in such a situation. Instead
temporary TABLE_LIST object is used.
Diffstat (limited to 'sql/sql_table.cc')
| -rw-r--r-- | sql/sql_table.cc | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc index ce4218869ff..f98ac676525 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -6660,15 +6660,15 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, NO need to tamper with MERGE tables. The real open is done later. */ Open_table_context ot_ctx(thd, MYSQL_OPEN_REOPEN); - TABLE *t_table; + TABLE_LIST temp_table_list; + TABLE_LIST *t_table_list; if (new_name != table_name || new_db != db) { - table_list->alias= new_name; - table_list->table_name= new_name; - table_list->table_name_length= strlen(new_name); - table_list->db= new_db; - table_list->db_length= strlen(new_db); - table_list->mdl_request.ticket= target_mdl_request.ticket; + temp_table_list.init_one_table(new_db, strlen(new_db), + new_name, strlen(new_name), + new_name, TL_READ_NO_INSERT); + temp_table_list.mdl_request.ticket= target_mdl_request.ticket; + t_table_list= &temp_table_list; } else { @@ -6678,20 +6678,21 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, to request the lock. */ table_list->mdl_request.ticket= mdl_ticket; + t_table_list= table_list; } - if (open_table(thd, table_list, thd->mem_root, &ot_ctx)) + if (open_table(thd, t_table_list, thd->mem_root, &ot_ctx)) { goto err_with_mdl; } - t_table= table_list->table; /* Tell the handler that a new frm file is in place. */ - error= t_table->file->ha_create_handler_files(path, NULL, CHF_INDEX_FLAG, - create_info); + error= t_table_list->table->file->ha_create_handler_files(path, NULL, + CHF_INDEX_FLAG, + create_info); - DBUG_ASSERT(thd->open_tables == t_table); + DBUG_ASSERT(thd->open_tables == t_table_list->table); close_thread_table(thd, &thd->open_tables); - table_list->table= 0; + t_table_list->table= NULL; if (error) goto err_with_mdl; |
