"Could there ever be a case when some parts of VALUES managed to get up / updated in the database, but the rest did not insert / update, possibly due to some kind of db / fail / memory-running- error, etc. .?
Late answer, but perhaps interesting: [ON DUPLICATE KEY] UPDATE not strictly atomic for single strings (neither for MyISAM nor for InnoDB ), but it will be atomic with respect to errors.
What's the difference? This illustrates a potential problem with strict atomicity:
CREATE TABLE `updateTest` ( `bar` INT(11) NOT NULL, `foo` INT(11) NOT NULL, `baz` INT(11) NOT NULL, `boom` INT(11) NOT NULL, PRIMARY KEY (`bar`) ) COMMENT='Testing' ENGINE=MyISAM; INSERT INTO `updateTest` (`bar`, `foo`, `baz`, `boom`) VALUES (47, 1, 450, 2); INSERT `updateTest` (`bar`, `foo`, `baz`, `boom`) VALUES (47, 0, 400, 5) ON DUPLICATE KEY UPDATE `foo` = IF(`foo` = 1, VALUES(`foo`), `foo`), `baz` = IF(`foo` = 1, VALUES(`baz`), `baz`), `boom` = IF(`foo` = 1, VALUES(`boom`), `boom`);
(47, 1, 450, 2) will turn into (47, 0, 450, 2) , not (47, 0, 400, 5) . If you assume strict atomicity (which does not mean that you should, you may prefer this behavior), this should not be the case - foo will certainly not change before other column values ββare evaluated. foo should change along with the other columns - all or nothing.
If I talk about atoms in relation to errors, I mean that if you remove the IF() condition in the above example to highlight a more stringent situation, for example ...
INSERT INTO `updateTest` (`bar`, `foo`, `baz`, `boom`) VALUES (48, 1, 450, 2); INSERT `updateTest` (`bar`, `foo`, `baz`, `boom`) VALUES (48, 0, 400, 5) ON DUPLICATE KEY UPDATE `foo` = VALUES(`foo`), `baz` = VALUES(`baz`), `boom` = VALUES(`boom`);
... you always either end with (48, 1, 450, 2) or (48, 0, 400, 5) after your statement completes / works, and not some intermediate state, for example (48, 0, 450, 2) .
The same is true for UPDATE behavior, but there are even fewer reasons to juggle IF() , since you can just put your conditional expressions in your WHERE there.
In conclusion: outside of extreme cases, you have atomicity for single-line statements, even using MyISAM . See Johannes H. for more information .