Description:
I've created a table and disabled it's keys because I want to temporarily ignore unique key constraints inside of a transaction. But nothing I've tried seems to work. All of them result in a "Duplicate key" error message and SHOW INDEXES does not report that they are disabled.
I've tried this on 5.0.41 and it fails there too.
How to repeat:
mysql> CREATE TABLE foo (id int unsigned, bar varchar(255), PRIMARY KEY (id), UNIQUE KEY (bar));
Query OK, 0 rows affected (0.01 sec)
mysql> INSERT INTO foo (id, bar) VALUES (1, 'hello');
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO foo (id, bar) VALUES (2, 'hello');
ERROR 1062 (23000): Duplicate entry 'hello' for key 2
So far so good.
mysql> ALTER TABLE foo DISABLE KEYS;
Query OK, 0 rows affected (0.00 sec)
mysql> INSERT INTO foo (id, bar) VALUES (1, 'hello2');
ERROR 1062 (23000): Duplicate entry '1' for key 1
That should have been allowed.
mysql> SHOW INDEXES FROM foo;
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| foo | 0 | PRIMARY | 1 | id | A | 2 | NULL | NULL | | BTREE | |
| foo | 0 | bar | 1 | bar | A | NULL | NULL | NULL | YES | BTREE | |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
2 rows in set (0.00 sec)