From: Dmitry Lenev Date: April 13 2011 7:14am Subject: bzr push into mysql-trunk branch (Dmitry.Lenev:3355 to 3356) Bug#11938039 List-Archive: http://lists.mysql.com/commits/135310 X-Bug: 11938039 Message-Id: <20110413071447.D59DE74065D@bandersnatch> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3356 Dmitry Lenev 2011-04-13 [merge] Merged fix for Bug#11938039 RE-EXECUTION OF FRM-ONLY ALTER TABLE WITH RENAME CLAUSE FAILS OR ABORTS SERVER into trunk. modified: mysql-test/r/alter_table.result mysql-test/t/alter_table.test sql/sql_table.cc 3355 Dmitry Shulga 2011-04-12 Follow-up for patch removing '--max-long-data-size' variable use (which itself was a follow-up to fix for bug#56976). Removed tests that used this variable. removed: mysql-test/suite/sys_vars/r/max_long_data_size_basic.result mysql-test/suite/sys_vars/t/max_long_data_size_basic.test modified: mysql-test/r/mysqld--help-notwin.result mysql-test/r/mysqld--help-win.result mysql-test/r/variables.result mysql-test/t/variables.test === modified file 'mysql-test/r/alter_table.result' --- a/mysql-test/r/alter_table.result 2011-02-21 11:34:23 +0000 +++ b/mysql-test/r/alter_table.result 2011-04-13 07:13:13 +0000 @@ -1391,3 +1391,16 @@ CREATE DATABASE db1 CHARACTER SET utf8; CREATE TABLE db1.t1 (bar TINYTEXT, KEY (bar(100))); ALTER TABLE db1.t1 ADD baz INT; DROP DATABASE db1; +# +# Bug#11938039 RE-EXECUTION OF FRM-ONLY ALTER TABLE WITH RENAME +# CLAUSE FAILS OR ABORTS SERVER. +# +drop table if exists t1; +create table t1 (a int); +prepare stmt1 from 'alter table t1 alter column a set default 1, rename to t2'; +execute stmt1; +rename table t2 to t1; +# The below statement should succeed and not emit error or abort server. +execute stmt1; +deallocate prepare stmt1; +drop table t2; === modified file 'mysql-test/t/alter_table.test' --- a/mysql-test/t/alter_table.test 2011-02-21 11:30:08 +0000 +++ b/mysql-test/t/alter_table.test 2011-04-13 06:16:40 +0000 @@ -1159,3 +1159,20 @@ CREATE TABLE db1.t1 (bar TINYTEXT, KEY ( ALTER TABLE db1.t1 ADD baz INT; DROP DATABASE db1; + + +--echo # +--echo # Bug#11938039 RE-EXECUTION OF FRM-ONLY ALTER TABLE WITH RENAME +--echo # CLAUSE FAILS OR ABORTS SERVER. +--echo # +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int); +prepare stmt1 from 'alter table t1 alter column a set default 1, rename to t2'; +execute stmt1; +rename table t2 to t1; +--echo # The below statement should succeed and not emit error or abort server. +execute stmt1; +deallocate prepare stmt1; +drop table t2; === modified file 'sql/sql_table.cc' --- a/sql/sql_table.cc 2011-03-30 11:43:32 +0000 +++ b/sql/sql_table.cc 2011-04-13 07:13:13 +0000 @@ -6861,15 +6861,15 @@ bool mysql_alter_table(THD *thd,char *ne 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 { @@ -6879,20 +6879,21 @@ bool mysql_alter_table(THD *thd,char *ne 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; No bundle (reason: useless for push emails).