List:Commits« Previous MessageNext Message »
From:Jon Olav Hauglid Date:May 10 2011 8:46am
Subject:bzr commit into mysql-trunk branch (jon.hauglid:3388) Bug#11938817
View as plain text  
#At file:///export/home/x/mysql-trunk-bug11938817/ based on revid:serge.kozlov@stripped

 3388 Jon Olav Hauglid	2011-05-10
      Bug#11938817 ALTER BEHAVIOR DIFFERENT THEN DOCUMENTED
      
      The problem was that ALTER TABLE t1 ENGINE = <engine> did a full
      table copy even if the table was using the given engine already.
      
      This patch fixes the problem by checking if the new and old 
      engines are equal. If they are, the ENGINE clause will be ignored.
      
      Test case added to alter_table.test.

    modified:
      mysql-test/r/alter_table.result
      mysql-test/t/alter_table.test
      sql/sql_table.cc
=== modified file 'mysql-test/r/alter_table.result'
--- a/mysql-test/r/alter_table.result	2011-05-04 07:51:15 +0000
+++ b/mysql-test/r/alter_table.result	2011-05-10 08:46:03 +0000
@@ -1414,3 +1414,13 @@ rename table t2 to t1;
 execute stmt1;
 deallocate prepare stmt1;
 drop table t2;
+#
+# Bug#11938817 ALTER BEHAVIOR DIFFERENT THEN DOCUMENTED
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1(a INT) engine=innodb;
+INSERT INTO t1 VALUES (1), (2);
+ALTER TABLE t1 engine=innodb;
+affected rows: 0
+info: Records: 0  Duplicates: 0  Warnings: 0
+DROP TABLE t1;

=== modified file 'mysql-test/t/alter_table.test'
--- a/mysql-test/t/alter_table.test	2011-05-04 07:51:15 +0000
+++ b/mysql-test/t/alter_table.test	2011-05-10 08:46:03 +0000
@@ -1194,3 +1194,22 @@ rename table t2 to t1;
 execute stmt1;
 deallocate prepare stmt1;
 drop table t2;
+
+
+--echo #
+--echo # Bug#11938817 ALTER BEHAVIOR DIFFERENT THEN DOCUMENTED
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1(a INT) engine=innodb;
+INSERT INTO t1 VALUES (1), (2);
+
+# Check that 0 rows are affected
+--enable_info
+ALTER TABLE t1 engine=innodb;
+--disable_info
+
+DROP TABLE t1;

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2011-05-06 12:56:36 +0000
+++ b/sql/sql_table.cc	2011-05-10 08:46:03 +0000
@@ -6108,6 +6108,10 @@ bool mysql_alter_table(THD *thd,char *ne
     goto err;
   new_db_type= create_info->db_type;
 
+  // Changing to the same engine is not a necessary operation.
+  if (new_db_type == old_db_type)
+    create_info->used_fields &= ~HA_CREATE_USED_ENGINE;
+
   if ((new_db_type != old_db_type ||
        alter_info->flags & ALTER_PARTITION) &&
       !table->file->can_switch_engines())


Attachment: [text/bzr-bundle] bzr/jon.hauglid@oracle.com-20110510084603-pgqn2ahl8f4p2g1g.bundle
Thread
bzr commit into mysql-trunk branch (jon.hauglid:3388) Bug#11938817Jon Olav Hauglid10 May