2009年(86)
分类: Mysql/postgreSQL
2009-10-24 11:50:38
I then realized that about my test table not having a primary key was the reason that I was seeing the behaviour that I had been seeing.
My original test case was failing, expecting to see a DELETE + an INSERT, when a REPLACE INTO was issued against a table. When I placed the PRIMARY KEY on the table in my test case and re-ran the test case, it still failed because the DELETE still was not in the transaction log. Well, it turns out that the reason was because ha_update_row() was actually called and not ha_delete_row() + ha_write_row(). And, because of the documentation for the REPLACE command, I wasn't checking that ha_update_row() may have been called — since I didn't realize a REPLACE could actually do an UPDATE.
Anyway, I wanted to post to say that most of this whole was my fault. Though I think that both the online and code documentation should reflect the fact that a REPLACE can do an UPDATE, the source of the failure was not what I originally wrote. In contrast, ha_write_row() does indeed return ER_FOUND_DUPP_KEY appropriately during a REPLACE call.
Mmmmm, that piece of humble pie was delicious.