From 92f1c7623635adeeab08a58d83179e6b62a0b240 Mon Sep 17 00:00:00 2001 From: "kostja@bodhi.local" <> Date: Tue, 12 Dec 2006 01:50:12 +0300 Subject: [PATCH] Post-merge fixes for Bug#4968 "Stored procedure crash if cursor opened on altered table" and Bug#19733 "Repeated alter, or repeated create/drop, fails" --- mysql-test/r/ps.result | 282 ++++++++--------------------------------- mysql-test/r/sp.result | 17 +++ mysql-test/t/ps.test | 72 +++++++++++ mysql-test/t/sp.test | 28 ++++ sql/sql_insert.cc | 15 +-- sql/sql_lex.cc | 3 +- sql/sql_parse.cc | 24 ++-- sql/sql_table.cc | 20 +-- sql/sql_yacc.yy | 4 +- 9 files changed, 203 insertions(+), 262 deletions(-) diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index 7e5919af1b9..b54d31ecc99 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -1055,230 +1055,6 @@ EXECUTE stmt USING @a; 0 0 DEALLOCATE PREPARE stmt; DROP TABLE t1; -ERROR HY000: Unknown error -show status like 'prepared_stmt_count'; -Variable_name Value -Prepared_stmt_count 0 -set global max_prepared_stmt_count=1; -prepare stmt from "select 1"; -show status like 'prepared_stmt_count'; -Variable_name Value -Prepared_stmt_count 1 -prepare stmt1 from "select 1"; -ERROR HY000: Unknown error -show status like 'prepared_stmt_count'; -Variable_name Value -Prepared_stmt_count 1 -deallocate prepare stmt; -show status like 'prepared_stmt_count'; -Variable_name Value -Prepared_stmt_count 0 -prepare stmt from "select 1"; -show status like 'prepared_stmt_count'; -Variable_name Value -Prepared_stmt_count 1 -prepare stmt from "select 2"; -show status like 'prepared_stmt_count'; -Variable_name Value -Prepared_stmt_count 1 -show status like 'prepared_stmt_count'; -Variable_name Value -Prepared_stmt_count 1 -select @@max_prepared_stmt_count; -@@max_prepared_stmt_count -1 -set global max_prepared_stmt_count=0; -prepare stmt from "select 1"; -ERROR HY000: Unknown error -execute stmt; -ERROR HY000: Unknown prepared statement handler (stmt) given to EXECUTE -show status like 'prepared_stmt_count'; -Variable_name Value -Prepared_stmt_count 0 -prepare stmt from "select 1"; -ERROR HY000: Unknown error -show status like 'prepared_stmt_count'; -Variable_name Value -Prepared_stmt_count 0 -set global max_prepared_stmt_count=3; -select @@max_prepared_stmt_count; -@@max_prepared_stmt_count -3 -show status like 'prepared_stmt_count'; -Variable_name Value -Prepared_stmt_count 0 -prepare stmt from "select 1"; -prepare stmt from "select 2"; -prepare stmt1 from "select 3"; -prepare stmt2 from "select 4"; -ERROR HY000: Unknown error -prepare stmt2 from "select 4"; -ERROR HY000: Unknown error -select @@max_prepared_stmt_count; -@@max_prepared_stmt_count -3 -show status like 'prepared_stmt_count'; -Variable_name Value -Prepared_stmt_count 3 -deallocate prepare stmt; -set global max_prepared_stmt_count= @old_max_prepared_stmt_count; -drop table if exists t1; -create temporary table if not exists t1 (a1 int); -prepare stmt from "delete t1 from t1 where (cast(a1/3 as unsigned) * 3) = a1"; -drop temporary table t1; -create temporary table if not exists t1 (a1 int); -execute stmt; -drop temporary table t1; -create temporary table if not exists t1 (a1 int); -execute stmt; -drop temporary table t1; -create temporary table if not exists t1 (a1 int); -execute stmt; -drop temporary table t1; -deallocate prepare stmt; -CREATE TABLE t1( -ID int(10) unsigned NOT NULL auto_increment, -Member_ID varchar(15) NOT NULL default '', -Action varchar(12) NOT NULL, -Action_Date datetime NOT NULL, -Track varchar(15) default NULL, -User varchar(12) default NULL, -Date_Updated timestamp NOT NULL default CURRENT_TIMESTAMP on update -CURRENT_TIMESTAMP, -PRIMARY KEY (ID), -KEY Action (Action), -KEY Action_Date (Action_Date) -); -INSERT INTO t1(Member_ID, Action, Action_Date, Track) VALUES -('111111', 'Disenrolled', '2006-03-01', 'CAD' ), -('111111', 'Enrolled', '2006-03-01', 'CAD' ), -('111111', 'Disenrolled', '2006-07-03', 'CAD' ), -('222222', 'Enrolled', '2006-03-07', 'CAD' ), -('222222', 'Enrolled', '2006-03-07', 'CHF' ), -('222222', 'Disenrolled', '2006-08-02', 'CHF' ), -('333333', 'Enrolled', '2006-03-01', 'CAD' ), -('333333', 'Disenrolled', '2006-03-01', 'CAD' ), -('444444', 'Enrolled', '2006-03-01', 'CAD' ), -('555555', 'Disenrolled', '2006-03-01', 'CAD' ), -('555555', 'Enrolled', '2006-07-21', 'CAD' ), -('555555', 'Disenrolled', '2006-03-01', 'CHF' ), -('666666', 'Enrolled', '2006-02-09', 'CAD' ), -('666666', 'Enrolled', '2006-05-12', 'CHF' ), -('666666', 'Disenrolled', '2006-06-01', 'CAD' ); -PREPARE STMT FROM -"SELECT GROUP_CONCAT(Track SEPARATOR ', ') FROM t1 - WHERE Member_ID=? AND Action='Enrolled' AND - (Track,Action_Date) IN (SELECT Track, MAX(Action_Date) FROM t1 - WHERE Member_ID=? - GROUP BY Track - HAVING Track>='CAD' AND - MAX(Action_Date)>'2006-03-01')"; -SET @id='111111'; -EXECUTE STMT USING @id,@id; -GROUP_CONCAT(Track SEPARATOR ', ') -NULL -SET @id='222222'; -EXECUTE STMT USING @id,@id; -GROUP_CONCAT(Track SEPARATOR ', ') -CAD -DEALLOCATE PREPARE STMT; -DROP TABLE t1; -DROP TABLE IF EXISTS t1; -CREATE TABLE t1 (i INT, INDEX(i)); -INSERT INTO t1 VALUES (1); -PREPARE stmt FROM "SELECT (COUNT(i) = 1), COUNT(i) FROM t1 WHERE i = ?"; -SET @a = 0; -EXECUTE stmt USING @a; -(COUNT(i) = 1) COUNT(i) -0 0 -SET @a = 1; -EXECUTE stmt USING @a; -(COUNT(i) = 1) COUNT(i) -1 1 -SET @a = 0; -EXECUTE stmt USING @a; -(COUNT(i) = 1) COUNT(i) -0 0 -PREPARE stmt FROM "SELECT (AVG(i) = 1), AVG(i) FROM t1 WHERE i = ?"; -SET @a = 0; -EXECUTE stmt USING @a; -(AVG(i) = 1) AVG(i) -NULL NULL -SET @a = 1; -EXECUTE stmt USING @a; -(AVG(i) = 1) AVG(i) -1 1.0000 -SET @a = 0; -EXECUTE stmt USING @a; -(AVG(i) = 1) AVG(i) -NULL NULL -PREPARE stmt FROM "SELECT (VARIANCE(i) = 1), VARIANCE(i) FROM t1 WHERE i = ?"; -SET @a = 0; -EXECUTE stmt USING @a; -(VARIANCE(i) = 1) VARIANCE(i) -NULL NULL -SET @a = 1; -EXECUTE stmt USING @a; -(VARIANCE(i) = 1) VARIANCE(i) -0 0.0000 -SET @a = 0; -EXECUTE stmt USING @a; -(VARIANCE(i) = 1) VARIANCE(i) -NULL NULL -PREPARE stmt FROM "SELECT (STDDEV(i) = 1), STDDEV(i) FROM t1 WHERE i = ?"; -SET @a = 0; -EXECUTE stmt USING @a; -(STDDEV(i) = 1) STDDEV(i) -NULL NULL -SET @a = 1; -EXECUTE stmt USING @a; -(STDDEV(i) = 1) STDDEV(i) -0 0.0000 -SET @a = 0; -EXECUTE stmt USING @a; -(STDDEV(i) = 1) STDDEV(i) -NULL NULL -PREPARE stmt FROM "SELECT (BIT_OR(i) = 1), BIT_OR(i) FROM t1 WHERE i = ?"; -SET @a = 0; -EXECUTE stmt USING @a; -(BIT_OR(i) = 1) BIT_OR(i) -0 0 -SET @a = 1; -EXECUTE stmt USING @a; -(BIT_OR(i) = 1) BIT_OR(i) -1 1 -SET @a = 0; -EXECUTE stmt USING @a; -(BIT_OR(i) = 1) BIT_OR(i) -0 0 -PREPARE stmt FROM "SELECT (BIT_AND(i) = 1), BIT_AND(i) FROM t1 WHERE i = ?"; -SET @a = 0; -EXECUTE stmt USING @a; -(BIT_AND(i) = 1) BIT_AND(i) -0 18446744073709551615 -SET @a = 1; -EXECUTE stmt USING @a; -(BIT_AND(i) = 1) BIT_AND(i) -1 1 -SET @a = 0; -EXECUTE stmt USING @a; -(BIT_AND(i) = 1) BIT_AND(i) -0 18446744073709551615 -PREPARE stmt FROM "SELECT (BIT_XOR(i) = 1), BIT_XOR(i) FROM t1 WHERE i = ?"; -SET @a = 0; -EXECUTE stmt USING @a; -(BIT_XOR(i) = 1) BIT_XOR(i) -0 0 -SET @a = 1; -EXECUTE stmt USING @a; -(BIT_XOR(i) = 1) BIT_XOR(i) -1 1 -SET @a = 0; -EXECUTE stmt USING @a; -(BIT_XOR(i) = 1) BIT_XOR(i) -0 0 -DEALLOCATE PREPARE stmt; -DROP TABLE t1; DROP TABLE IF EXISTS t1, t2; CREATE TABLE t1 (i INT); PREPARE st_19182 @@ -1311,7 +1087,7 @@ t1 CREATE TABLE `t1` ( show create table mysqltest.t2; Table Create Table t2 CREATE TABLE `t2` ( - `test` char(4) character set latin1 NOT NULL default '' + `test` varchar(4) character set latin1 NOT NULL default '' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 drop table mysqltest.t1; drop table mysqltest.t2; @@ -1326,7 +1102,7 @@ t1 CREATE TABLE `t1` ( show create table mysqltest.t2; Table Create Table t2 CREATE TABLE `t2` ( - `test` char(4) NOT NULL default '' + `test` varchar(4) NOT NULL default '' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop database mysqltest; deallocate prepare stmt1; @@ -1336,14 +1112,14 @@ show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `c` char(10) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/tmp/' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; execute stmt; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( `c` char(10) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/tmp/' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; deallocate prepare stmt; End of 4.1 tests. @@ -1787,4 +1563,54 @@ Variable_name Value Slow_queries 1 deallocate prepare no_index; deallocate prepare sq; +drop table if exists t1; +create table t1 (s1 char(20)); +prepare stmt from "alter table t1 modify s1 int"; +execute stmt; +execute stmt; +drop table t1; +deallocate prepare stmt; +drop table if exists t1; +create table t1 (a int, b int); +prepare s_6895 from "alter table t1 drop column b"; +execute s_6895; +show columns from t1; +Field Type Null Key Default Extra +a int(11) YES NULL +drop table t1; +create table t1 (a int, b int); +execute s_6895; +show columns from t1; +Field Type Null Key Default Extra +a int(11) YES NULL +drop table t1; +create table t1 (a int, b int); +execute s_6895; +show columns from t1; +Field Type Null Key Default Extra +a int(11) YES NULL +deallocate prepare s_6895; +drop table t1; +create table t1 (i int primary key auto_increment) comment='comment for table t1'; +create table t2 (i int, j int, k int); +prepare stmt from "alter table t1 auto_increment=100"; +execute stmt; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) NOT NULL auto_increment, + PRIMARY KEY (`i`) +) ENGINE=MyISAM AUTO_INCREMENT=100 DEFAULT CHARSET=latin1 COMMENT='comment for table t1' +flush tables; +select * from t2; +i j k +execute stmt; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) NOT NULL auto_increment, + PRIMARY KEY (`i`) +) ENGINE=MyISAM AUTO_INCREMENT=100 DEFAULT CHARSET=latin1 COMMENT='comment for table t1' +deallocate prepare stmt; +drop table t1, t2; End of 5.0 tests. diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 1bb4b3a405b..50ffe55ec02 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -5626,5 +5626,22 @@ Called B Called B drop procedure proc_21462_a| drop procedure proc_21462_b| +drop table if exists t3| +drop procedure if exists proc_bug19733| +create table t3 (s1 int)| +create procedure proc_bug19733() +begin +declare v int default 0; +while v < 100 do +create index i on t3 (s1); +drop index i on t3; +set v = v + 1; +end while; +end| +call proc_bug19733()| +call proc_bug19733()| +call proc_bug19733()| +drop procedure proc_bug19733| +drop table t3| End of 5.0 tests drop table t1,t2; diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index 9afb5c5ba59..e70ceeec077 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -1610,4 +1610,76 @@ execute sq; deallocate prepare no_index; deallocate prepare sq; +# +# Bug#4968 "Stored procedure crash if cursor opened on altered table" +# The bug is not repeatable any more after the fix for +# Bug#15217 "Bug #15217 Using a SP cursor on a table created with PREPARE +# fails with weird error", however ALTER TABLE is not re-execution friendly +# and that caused a valgrind warning. Check that the warning is gone. +# +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (s1 char(20)); +prepare stmt from "alter table t1 modify s1 int"; +execute stmt; +execute stmt; +drop table t1; +deallocate prepare stmt; + +# +# Bug#6895 "Prepared Statements: ALTER TABLE DROP COLUMN does nothing" +# +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int, b int); +prepare s_6895 from "alter table t1 drop column b"; +execute s_6895; +show columns from t1; +drop table t1; +create table t1 (a int, b int); +execute s_6895; +show columns from t1; +drop table t1; +create table t1 (a int, b int); +execute s_6895; +show columns from t1; +deallocate prepare s_6895; +drop table t1; + +# +# Bug #22060 "ALTER TABLE x AUTO_INCREMENT=y in SP crashes server" +# +# 5.0 part of the test. +# + +# ALTER TABLE +create table t1 (i int primary key auto_increment) comment='comment for table t1'; +create table t2 (i int, j int, k int); +prepare stmt from "alter table t1 auto_increment=100"; +execute stmt; +show create table t1; +# Let us trash table-cache's memory +flush tables; +select * from t2; +execute stmt; +show create table t1; +deallocate prepare stmt; +drop table t1, t2; +# 5.1 part of the test. +# CREATE DATABASE +#set @old_character_set_server= @@character_set_server; +#set @@character_set_server= latin1; +#prepare stmt from "create database mysqltest"; +#execute stmt; +#show create database mysqltest; +#drop database mysqltest; +#set @@character_set_server= utf8; +#execute stmt; +#show create database mysqltest; +#drop database mysqltest; +#deallocate prepare stmt; +#set @@character_set_server= @old_character_set_server; + --echo End of 5.0 tests. diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index fc6e8714a65..c0a5f69fd7c 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -6587,6 +6587,34 @@ call proc_21462_b(1)| drop procedure proc_21462_a| drop procedure proc_21462_b| + +# +# Bug#19733 "Repeated alter, or repeated create/drop, fails" +# Check that CREATE/DROP INDEX is re-execution friendly. +# +--disable_warnings +drop table if exists t3| +drop procedure if exists proc_bug19733| +--enable_warnings +create table t3 (s1 int)| + +create procedure proc_bug19733() +begin + declare v int default 0; + while v < 100 do + create index i on t3 (s1); + drop index i on t3; + set v = v + 1; + end while; +end| + +call proc_bug19733()| +call proc_bug19733()| +call proc_bug19733()| + +drop procedure proc_bug19733| +drop table t3| + --echo End of 5.0 tests diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 79e91dc4cb1..24c8e9863dd 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -2620,11 +2620,11 @@ bool select_insert::send_eof() temporary table flag) create_table in Pointer to TABLE_LIST object providing database and name for table to be created or to be open - extra_fields in/out Initial list of fields for table to be created - keys in List of keys for table to be created + alter_info in/out Initial list of columns and indexes for the table + to be created items in List of items which should be used to produce rest of fields for the table (corresponding fields will - be added to the end of 'extra_fields' list) + be added to the end of alter_info->create_list) lock out Pointer to the MYSQL_LOCK object for table created (open) will be returned in this parameter. Since this table is not included in THD::lock caller is @@ -2646,8 +2646,8 @@ bool select_insert::send_eof() static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, TABLE_LIST *create_table, - List *extra_fields, - List *keys, List *items, + Alter_info *alter_info, + List *items, MYSQL_LOCK **lock) { TABLE tmp_table; // Used during 'create_field()' @@ -2686,7 +2686,7 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, DBUG_RETURN(0); if (item->maybe_null) cr_field->flags &= ~NOT_NULL_FLAG; - extra_fields->push_back(cr_field); + alter_info->create_list.push_back(cr_field); } /* create and lock table @@ -2707,8 +2707,7 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, { tmp_disable_binlog(thd); if (!mysql_create_table(thd, create_table->db, create_table->table_name, - create_info, *extra_fields, *keys, 0, - select_field_count)) + create_info, alter_info, 0, select_field_count)) { /* If we are here in prelocked mode we either create temporary table diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index e063db58488..46fa205a25c 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1062,8 +1062,7 @@ Alter_info::Alter_info(const Alter_info &rhs, MEM_ROOT *mem_root) create_list(rhs.create_list, mem_root), flags(rhs.flags), keys_onoff(rhs.keys_onoff), - tablespace_op(rhs.tablespace_op), - is_simple(rhs.is_simple) + tablespace_op(rhs.tablespace_op) {} diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index aa69e3133fc..8cf6e84fc2c 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2908,12 +2908,13 @@ mysql_execute_command(THD *thd) { /* out of memory when creating a copy of alter_info */ res= 1; - goto unsent_create_error; + goto end_with_restore_list; } if ((res= create_table_precheck(thd, select_tables, create_table))) goto end_with_restore_list; + #ifndef HAVE_READLINK create_info.data_file_name= create_info.index_file_name= NULL; #else @@ -2969,7 +2970,7 @@ mysql_execute_command(THD *thd) Is table which we are changing used somewhere in other parts of query */ - if (!(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE)) + if (!(create_info.options & HA_LEX_CREATE_TMP_TABLE)) { TABLE_LIST *duplicate; if ((duplicate= unique_table(thd, create_table, select_tables))) @@ -2980,10 +2981,10 @@ mysql_execute_command(THD *thd) } } /* If we create merge table, we have to test tables in merge, too */ - if (lex->create_info.used_fields & HA_CREATE_USED_UNION) + if (create_info.used_fields & HA_CREATE_USED_UNION) { TABLE_LIST *tab; - for (tab= (TABLE_LIST*) lex->create_info.merge_list.first; + for (tab= (TABLE_LIST*) create_info.merge_list.first; tab; tab= tab->next_local) { @@ -3021,7 +3022,7 @@ mysql_execute_command(THD *thd) /* regular create */ if (lex->name) res= mysql_create_like_table(thd, create_table, &create_info, - (Table_ident *)lex->name); + (Table_ident *)lex->name); else { res= mysql_create_table(thd, create_table->db, @@ -3075,9 +3076,9 @@ end_with_restore_list: create_info.db_type= DB_TYPE_DEFAULT; create_info.default_table_charset= thd->variables.collation_database; - res= mysql_alter_table(thd, first_table->db, first_table->real_name, + res= mysql_alter_table(thd, first_table->db, first_table->table_name, &create_info, first_table, &alter_info, - 0, (ORDER*)0, DUP_ERROR, 0); + 0, (ORDER*) 0, 0); break; } #ifdef HAVE_REPLICATION @@ -3820,6 +3821,7 @@ end_with_restore_list: break; } #endif + if (check_access(thd,CREATE_ACL,lex->name,0,1,0,is_schema_db(lex->name))) break; res= mysql_create_db(thd,(lower_case_table_names == 2 ? alias : lex->name), @@ -4507,7 +4509,7 @@ end_with_restore_list: goto error; } - my_bool nsok= thd->net.no_send_ok; + my_bool save_no_send_ok= thd->net.no_send_ok; thd->net.no_send_ok= TRUE; if (sp->m_flags & sp_head::MULTI_RESULTS) { @@ -4518,7 +4520,7 @@ end_with_restore_list: back */ my_error(ER_SP_BADSELECT, MYF(0), sp->m_qname.str); - thd->net.no_send_ok= nsok; + thd->net.no_send_ok= save_no_send_ok; goto error; } /* @@ -4534,7 +4536,7 @@ end_with_restore_list: if (check_routine_access(thd, EXECUTE_ACL, sp->m_db.str, sp->m_name.str, TRUE, FALSE)) { - thd->net.no_send_ok= nsok; + thd->net.no_send_ok= save_no_send_ok; goto error; } #endif @@ -4561,7 +4563,7 @@ end_with_restore_list: thd->variables.select_limit= select_limit; - thd->net.no_send_ok= nsok; + thd->net.no_send_ok= save_no_send_ok; thd->server_status&= ~bits_to_be_cleared; if (!res) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 56691821ce1..8207a3b7909 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1569,7 +1569,7 @@ void sp_prepare_create_field(THD *thd, create_field *sql_field) create_info [in/out] Create information (like MAX_ROWS) alter_info [in/out] List of columns and indexes to create internal_tmp_table Set to 1 if this is an internal temporary table - (From ALTER TABLE) + (From ALTER TABLE) DESCRIPTION If one creates a temporary table, this is automatically opened @@ -1592,7 +1592,7 @@ void sp_prepare_create_field(THD *thd, create_field *sql_field) bool mysql_create_table(THD *thd,const char *db, const char *table_name, HA_CREATE_INFO *create_info, Alter_info *alter_info, - List &keys,bool internal_tmp_table, + bool internal_tmp_table, uint select_field_count) { char path[FN_REFLEN]; @@ -2327,9 +2327,12 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, (table->table->file->ha_check_for_upgrade(check_opt) == HA_ADMIN_NEEDS_ALTER)) { + my_bool save_no_send_ok= thd->net.no_send_ok; close_thread_tables(thd); tmp_disable_binlog(thd); // binlogging is done by caller if wanted - result_code= mysql_recreate_table(thd, table, 0); + thd->net.no_send_ok= TRUE; + result_code= mysql_recreate_table(thd, table); + thd->net.no_send_ok= save_no_send_ok; reenable_binlog(thd); goto send_result; } @@ -2956,8 +2959,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, HA_CREATE_INFO *create_info, TABLE_LIST *table_list, Alter_info *alter_info, - uint order_num, ORDER *order, - bool ignore) + uint order_num, ORDER *order, bool ignore) { TABLE *table,*new_table=0; int error; @@ -3565,7 +3567,7 @@ view_err: { tmp_disable_binlog(thd); error= mysql_create_table(thd, new_db, tmp_name, - create_info,alter_info, 1, 0); + create_info, &new_info, 1, 0); reenable_binlog(thd); if (error) DBUG_RETURN(error); @@ -4021,20 +4023,18 @@ copy_data_between_tables(TABLE *from,TABLE *to, Like mysql_alter_table(). */ bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list) -int mysql_recreate_table(THD *thd, TABLE_LIST *table_list) { - LEX *lex= thd->lex; HA_CREATE_INFO create_info; Alter_info alter_info; DBUG_ENTER("mysql_recreate_table"); - bzero((char*) &create_info,sizeof(create_info)); + bzero((char*) &create_info, sizeof(create_info)); create_info.db_type=DB_TYPE_DEFAULT; create_info.row_type=ROW_TYPE_NOT_USED; create_info.default_table_charset=default_charset_info; /* Force alter table to recreate table */ - lex->alter_info.flags= ALTER_CHANGE_COLUMN; + alter_info.flags= ALTER_CHANGE_COLUMN; DBUG_RETURN(mysql_alter_table(thd, NullS, NullS, &create_info, table_list, &alter_info, 0, (ORDER *) 0, 0)); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 719d48af33f..abaed88af57 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1190,7 +1190,6 @@ create: TL_OPTION_UPDATING)) YYABORT; lex->alter_info.reset(); - lex->alter_info.is_simple= 0; lex->alter_info.flags= ALTER_ADD_INDEX; lex->col_list.empty(); lex->change=NullS; @@ -3313,7 +3312,7 @@ alter: lex->create_info.db_type= DB_TYPE_DEFAULT; lex->create_info.default_table_charset= NULL; lex->create_info.row_type= ROW_TYPE_NOT_USED; - lex->alter_info.reset(); + lex->alter_info.reset(); } alter_list {} @@ -6076,7 +6075,6 @@ drop: LEX *lex=Lex; lex->sql_command= SQLCOM_DROP_INDEX; lex->alter_info.reset(); - lex->alter_info.is_simple= 0; lex->alter_info.flags= ALTER_DROP_INDEX; lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::KEY, $3.str));