{"action":"opened","issue":{"url":"https://api.github.com/repos/facebook/mysql-5.6/issues/209","repository_url":"https://api.github.com/repos/facebook/mysql-5.6","labels_url":"https://api.github.com/repos/facebook/mysql-5.6/issues/209/labels{/name}","comments_url":"https://api.github.com/repos/facebook/mysql-5.6/issues/209/comments","events_url":"https://api.github.com/repos/facebook/mysql-5.6/issues/209/events","html_url":"https://github.com/facebook/mysql-5.6/issues/209","id":141959684,"number":209,"title":"After a \"ALTER TABLE t1 ADD PRIMARY KEY\" command failed, the table has two extra rows","user":{"login":"dleeyh","id":9353914,"avatar_url":"https://avatars.githubusercontent.com/u/9353914?v=3","gravatar_id":"","url":"https://api.github.com/users/dleeyh","html_url":"https://github.com/dleeyh","followers_url":"https://api.github.com/users/dleeyh/followers","following_url":"https://api.github.com/users/dleeyh/following{/other_user}","gists_url":"https://api.github.com/users/dleeyh/gists{/gist_id}","starred_url":"https://api.github.com/users/dleeyh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dleeyh/subscriptions","organizations_url":"https://api.github.com/users/dleeyh/orgs","repos_url":"https://api.github.com/users/dleeyh/repos","events_url":"https://api.github.com/users/dleeyh/events{/privacy}","received_events_url":"https://api.github.com/users/dleeyh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-03-18T19:35:20Z","updated_at":"2016-03-18T19:35:20Z","closed_at":null,"body":"Build tested:\r\n\r\nmyrocks@rocksdb:~/builds/reptest/mysql-5.6$ git show\r\ncommit d3054d2915ffcde166cd67760ac6a618c6d02b82\r\nAuthor: Peng Tian <pengt@fb.com>\r\nDate:   Mon Feb 15 10:09:36 2016 -0800\r\n\r\nAfter executing the statements from lines 22 to 972, I got:\r\n\r\nmysql> desc t1;\r\n+-------+---------+------+-----+---------+-------+\r\n| Field | Type    | Null | Key | Default | Extra |\r\n+-------+---------+------+-----+---------+-------+\r\n| col4  | text    | YES  |     | NULL    |       |\r\n| col2  | int(11) | YES  |     | NULL    |       |\r\n| col1  | int(11) | YES  | MUL | NULL    |       |\r\n| col3  | int(11) | YES  |     | NULL    |       |\r\n+-------+---------+------+-----+---------+-------+\r\n4 rows in set (0.00 sec)\r\n\r\nmysql> select * from t1;\r\n+------+------+------+------+\r\n| col4 | col2 | col1 | col3 |\r\n+------+------+------+------+\r\n| NULL |    2 |    3 |    3 |\r\n| NULL |    2 |    3 |    3 |\r\n| NULL |    2 |    3 |    3 |\r\n| NULL |    3 |    3 |    3 |\r\n| NULL |    3 |    3 |    3 |\r\n| NULL |    3 |    3 |    3 |\r\n| NULL |    2 |    3 |    3 |\r\n| NULL |    3 |    3 |    3 |\r\n| NULL |    3 |    3 |    3 |\r\n| NULL |    3 |    3 |    3 |\r\n| NULL |    3 |    3 |    3 |\r\n+------+------+------+------+\r\n11 rows in set (0.00 sec)\r\n\r\nI then execute the \"ALTER TABLE t1 ADD PRIMARY KEY ( col4(10), col2 );\", which failed.  I check the table again and got two extra rows.\r\n\r\nmysql> ALTER TABLE t1 ADD PRIMARY KEY ( col4(10), col2 );\r\nERROR 1062 (23000): Duplicate entry '2' for key 'PRIMARY'\r\nmysql> select * from t1;\r\n+------+------+------+------+\r\n| col4 | col2 | col1 | col3 |\r\n+------+------+------+------+\r\n| NULL |    2 |    2 |    2 |\r\n| NULL |    2 |    2 |    2 |\r\n| NULL |    2 |    3 |    3 |\r\n| NULL |    2 |    3 |    3 |\r\n| NULL |    2 |    3 |    3 |\r\n| NULL |    3 |    3 |    3 |\r\n| NULL |    3 |    3 |    3 |\r\n| NULL |    3 |    3 |    3 |\r\n| NULL |    2 |    3 |    3 |\r\n| NULL |    3 |    3 |    3 |\r\n| NULL |    3 |    3 |    3 |\r\n| NULL |    3 |    3 |    3 |\r\n| NULL |    3 |    3 |    3 |\r\n+------+------+------+------+\r\n13 rows in set (0.00 sec)\r\n\r\nI spent some time trying to pinpoint where the two rows came from and was unable to do so.  I assume that they were either delete rows, or rows that were inserted and rolled back.\r\n\r\n[exec.txt](https://github.com/facebook/mysql-5.6/files/180264/exec.txt)"}}