Bug #69684 | The update and select behave differently under the same conditions. | ||
---|---|---|---|
Submitted: | 7 Jul 2013 10:44 | Modified: | 20 May 2014 0:10 |
Reporter: | yu hongyu | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: DML | Severity: | S2 (Serious) |
Version: | 5.5, 5.6 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | UPDATE |
[7 Jul 2013 10:44]
yu hongyu
[11 Jul 2013 17:35]
MySQL Verification Team
Please upload the mysqldump of the table only ... Thanks in advance ...
[12 Jul 2013 14:26]
MySQL Verification Team
I repeated the behavior with the same version of 5.5 that you are using. Now, testing with latest 5.5 and 5.6.
[12 Jul 2013 14:37]
MySQL Verification Team
Bug exists also in latest versions of 5.5 and 5.6. Hence, verified !!!! Thank you for your contribution !!!
[20 May 2014 0:10]
Paul DuBois
Noted in 5.6.19, 5.7.5 changelogs. Updates could fail to update all applicable rows in cases where multiple key values were identical except for trailing spaces.
[2 Jun 2014 14:33]
Laurynas Biveinis
$ bzr log -r 5910 ------------------------------------------------------------ revno: 5910 committer: mithun <mithun.c.y@oracle.com> branch nick: mysql-5.6 timestamp: Wed 2014-04-30 16:20:10 +0530 message: Bug #17156940 : THE UPDATE AND SELECT BEHAVE DIFFERENTLY UNDER THE SAME CONDITIONS. ISSUE : In myisam, Suppose in btree index of varchar type we have keys with and without trailing spaces example keys 'abc', 'abc ', 'abc '. During index search based on same key, length of the lastkey get changed if lastkey read is the one with trailing spaces. If x is the length of key 'abc'. After reading 'abc ' length will be x + 1. And, last_rkey_length should be recalculated as accordingly whenever lastkey changes. But in function mi_rnext_same during BTREE search when we tried to copy lastkey to lastkey2 we have used non updated last_rkey_length even though lastkey and its length might have been changed as explained above. And, last_rkey_length is computed only once during mi_rkey. Because of this invalid length usage compare_key failed and scan got terminated. And, hence Update command ended before updating further tuples which will satisfy the condition. SOLUTION : In function mi_rnext_same the input key lastkey2 can remain constant if we use a separate buffer other than lastkey2. And, we can fill this key just for one time for the complete scan in mi_rnext_same. Since key and length is computed only once for the entire scan, issues related to invalid length during compare keys will not arise.