summaryrefslogtreecommitdiff
path: root/odoo/sql_db.py
diff options
context:
space:
mode:
Diffstat (limited to 'odoo/sql_db.py')
-rw-r--r--odoo/sql_db.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/odoo/sql_db.py b/odoo/sql_db.py
index 4cc6163a96f..74575c4e810 100644
--- a/odoo/sql_db.py
+++ b/odoo/sql_db.py
@@ -432,16 +432,18 @@ class TestCursor(Cursor):
"""
def __init__(self, *args, **kwargs):
super(TestCursor, self).__init__(*args, **kwargs)
- # in order to simulate commit and rollback, the cursor maintains a
- # savepoint at its last commit
- self.execute("SAVEPOINT test_cursor")
# we use a lock to serialize concurrent requests
self._lock = threading.RLock()
def acquire(self):
self._lock.acquire()
+ # the cursor maintains a savepoint at its last commit point
+ self.execute("SAVEPOINT test_cursor")
def release(self):
+ # the cursor should be right after the savepoint; release it to make
+ # former savepoints directly accessible
+ self.execute("RELEASE SAVEPOINT test_cursor")
self._lock.release()
def force_close(self):
@@ -456,12 +458,13 @@ class TestCursor(Cursor):
_logger.debug("TestCursor.autocommit(%r) does nothing", on)
def commit(self):
+ # move the savepoint to the current position
self.execute("RELEASE SAVEPOINT test_cursor")
self.execute("SAVEPOINT test_cursor")
def rollback(self):
+ # this does not release the savepoint; release() will do it
self.execute("ROLLBACK TO SAVEPOINT test_cursor")
- self.execute("SAVEPOINT test_cursor")
class LazyCursor(object):
""" A proxy object to a cursor. The cursor itself is allocated only if it is