-
-
Save jstanley23/1da85c149e4a930174d15a9f44de7e2e to your computer and use it in GitHub Desktop.
Patch restorage to use INSERT ON DUPLICATE KEY UPDATE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- relstorage/adapters/mover.py.orig 2012-05-25 16:56:17.000000000 -0400 | |
+++ relstorage/adapters/mover.py 2012-05-25 16:57:16.000000000 -0400 | |
@@ -864,11 +864,23 @@ class ObjectMover(object): | |
else: | |
if self.database_name == 'mysql': | |
stmt = """ | |
- REPLACE INTO object_state (zoid, tid, state_size, state) | |
- SELECT zoid, %s, COALESCE(LENGTH(state), 0), state | |
- FROM temp_store | |
+ INSERT INTO object_state (zoid, tid, state_size, state) | |
+ SELECT zoid, %s, COALESCE(LENGTH(state), 0), state | |
+ FROM temp_store | |
+ ON DUPLICATE KEY UPDATE | |
+ tid=%s, | |
+ state_size=COALESCE(LENGTH(temp_store.state), 0), | |
+ state=temp_store.state | |
""" | |
- cursor.execute(stmt, (tid,)) | |
+ cursor.execute(stmt, (tid,tid,)) | |
+ | |
+ # Do not use replace into, dgarcia@zenoss.com | |
+ #stmt = """ | |
+ #REPLACE INTO object_state (zoid, tid, state_size, state) | |
+ #SELECT zoid, %s, COALESCE(LENGTH(state), 0), state | |
+ #FROM temp_store | |
+ #""" | |
+ #cursor.execute(stmt, (tid,)) | |
else: | |
stmt = """ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment