Yesterday, I posed a question to the ZanyWeb about what exactly a REPLACE statement does behind the scenes in the storage engine. There were many excellent comments and these comments exposed some misunderstandings (including some of my own misconceptions) about the REPLACE statement itself and what goes on behind the scenes in the storage engine.
The question I asked was this: if I execute the following statements in a client, what would you expect would happen behind the scenes in the storage engine?
CREATE TABLE t1 ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY , padding VARCHAR(200) NOT NULL ); INSERT INTO t1 VALUES (1, "I love testing."); INSERT INTO t1 VALUES (2, "I hate testing."); REPLACE INTO t1 VALUE (2, "I love testing.");
Based purely on the manual, one would expect, as …
[Read more]