[Commits] Rev 3003: ALTER TABLE IGNORE didn't ignore duplicates for unique add index for InnoDB in lp:maria/5.1

Michael Widenius monty at askmonty.org
Wed Jan 5 15:09:07 EET 2011


At lp:maria/5.1

------------------------------------------------------------
revno: 3003
revision-id: monty at askmonty.org-20110105130906-1keqat4xx3rnfq9o
parent: monty at askmonty.org-20110105125008-9lxxtgqua5x45v01
committer: Michael Widenius <monty at askmonty.org>
branch nick: maria-5.1
timestamp: Wed 2011-01-05 15:09:06 +0200
message:
  ALTER TABLE IGNORE didn't ignore duplicates for unique add index for InnoDB
-------------- next part --------------
=== modified file 'mysql-test/suite/innodb/r/innodb_mysql.result'
--- a/mysql-test/suite/innodb/r/innodb_mysql.result	2010-12-08 13:34:08 +0000
+++ b/mysql-test/suite/innodb/r/innodb_mysql.result	2011-01-05 13:09:06 +0000
@@ -2617,6 +2617,13 @@ rows	3
 Extra   Using index
 DROP TABLE t1;
 #
+# ALTER TABLE IGNORE didn't ignore duplicates for unique add index
+#
+create table t1 (a int primary key, b int) engine = innodb;
+insert into t1 values (1,1),(2,1);
+alter ignore table t1 add unique `main` (b);
+drop table t1;
+#
 End of 5.1 tests
 #
 # Test for bug #39932 "create table fails if column for FK is in different

=== modified file 'mysql-test/suite/innodb/t/innodb_mysql.test'
--- a/mysql-test/suite/innodb/t/innodb_mysql.test	2010-11-23 21:39:59 +0000
+++ b/mysql-test/suite/innodb/t/innodb_mysql.test	2011-01-05 13:09:06 +0000
@@ -841,6 +841,15 @@ CREATE INDEX b ON t1(a,b,c,d);
 DROP TABLE t1;
 
 --echo #
+--echo # ALTER TABLE IGNORE didn't ignore duplicates for unique add index
+--echo #
+
+create table t1 (a int primary key, b int) engine = innodb;
+insert into t1 values (1,1),(2,1);
+alter ignore table t1 add unique `main` (b);
+drop table t1;
+
+--echo #
 
 
 --echo End of 5.1 tests

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2010-11-24 22:57:34 +0000
+++ b/sql/sql_table.cc	2011-01-05 13:09:06 +0000
@@ -7136,6 +7136,16 @@ bool mysql_alter_table(THD *thd,char *ne
           /* Non-primary unique key. */
           needed_online_flags|=  HA_ONLINE_ADD_UNIQUE_INDEX;
           needed_fast_flags|= HA_ONLINE_ADD_UNIQUE_INDEX_NO_WRITES;
+          if (ignore)
+          {
+            /*
+              If ignore is used, we have to remove all duplicate rows,
+              which require a full table copy.
+            */
+            need_copy_table= ALTER_TABLE_DATA_CHANGED;
+            pk_changed= 2;                      // Don't change need_copy_table
+            break;
+          }
         }
       }
       else



More information about the commits mailing list