From f7a0b45f5aeed08d8e46fc24d313f013af6e55ed Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Mon, 21 Feb 2011 12:30:08 +0100 Subject: Bug #11754461 CANNOT ALTER TABLE WHEN KEY PREFIX TOO LONG The problem was that doing ALTER TABLE on a table which had a key on a TEXT/BLOB column with a prefix longer than the maximum number of characteres in this column (as per the character set), by mistake, caused an error (Error 1170 - ER_BLOB_KEY_WITHOUT_LENGTH). This bug not repeatable in 5.5. This patch adds a regression test to alter_table.test and contains no code changes. --- mysql-test/t/alter_table.test | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'mysql-test/t/alter_table.test') diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index 5b5fdf50c16..5d71eead642 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -1144,3 +1144,18 @@ INSERT INTO t1 VALUES (1, 1), (2, 2); ALTER TABLE t1 CHANGE a id INT; --disable_info DROP TABLE t1; + + +--echo # +--echo # Bug#11754461 CANNOT ALTER TABLE WHEN KEY PREFIX TOO LONG +--echo # + +--disable_warnings +DROP DATABASE IF EXISTS db1; +--enable_warnings + +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; -- cgit v1.2.1 From c7337ef4d924e29f6d0cd0b887f09d8a0301cd9f Mon Sep 17 00:00:00 2001 From: Dmitry Lenev Date: Wed, 13 Apr 2011 10:16:40 +0400 Subject: 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. mysql-test/r/alter_table.result: Added test case for bug#11938039 "RE-EXECUTION OF FRM-ONLY ALTER TABLE WITH RENAME CLAUSE FAILS OR ABORTS SERVER". mysql-test/t/alter_table.test: Added test case for bug#11938039 "RE-EXECUTION OF FRM-ONLY ALTER TABLE WITH RENAME CLAUSE FAILS OR ABORTS SERVER". sql/sql_table.cc: Changed mysql_alter_table() not to modify table list element for the table being altered while re-opening table after .FRM-only changes. Doing this made .FRM-only ALTER TABLE which also had RENAME clause unsafe for re-execution. --- mysql-test/t/alter_table.test | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'mysql-test/t/alter_table.test') diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index 5d71eead642..38d0d08808a 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -1159,3 +1159,20 @@ CREATE TABLE db1.t1 (bar TINYTEXT, KEY (bar(100))); 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; -- cgit v1.2.1