Bug #59448 incorrect 2-table update
Submitted: 12 Jan 2011 15:04 Modified: 17 Jan 2011 19:17
Reporter: ttt ttt Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:5.0.51 OS:Any
Assigned to: CPU Architecture:Any

[12 Jan 2011 15:04] ttt ttt
Description:
incorrect access order

How to repeat:
CREATE TABLE `test` ( `id` int(11) NOT NULL auto_increment, `a` int(11) NOT NULL, `b` int(11) NOT NULL, PRIMARY KEY  (`id`)) ENGINE=MyISAM

CREATE TABLE `test2` LIKE `test`

REPLACE INTO `test` (`id`, `a`, `b`) VALUES ('1', '1', '1'), ('2', '1', '1');

REPLACE INTO `test2` (`id`, `a`, `b`) VALUES ('1', '1', '1'), ('2', '1', '1');

UPDATE  `test2`,`test` SET `test2`.`a`=`test`.`a`+1, `test2`.`b`=`test2`.`a` WHERE `test2`.`id`=`test`.`id` AND `test`.`id`=2

UPDATE  `test`,`test2` SET `test2`.`a`=`test`.`a`+1, `test2`.`b`=`test2`.`a` WHERE `test2`.`id`=`test`.`id` AND `test`.`id`=1

result

id 	a 	b
1 	2 	1
2 	2 	2
[17 Jan 2011 19:17] Sveta Smirnova
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://dev.mysql.com/doc/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

Please read at http://dev.mysql.com/doc/refman/5.0/en/update.html:

Single-table UPDATE assignments are generally evaluated from left to right. For multiple-table updates, there is no guarantee that assignments are carried out in any particular order.