Commit cd196702 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Do not commit the current transaction then begin another when calling setXXX()...

Do not commit the current transaction then begin another when calling setXXX() methods from a transaction.
This avoid commit partial queries that may put the relational database in a inconsistent state (eg. a new partition table but not the last PTID).

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1380 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 7845f37c
......@@ -85,6 +85,18 @@ class DatabaseManager(object):
"""
Set a configuration value
"""
if self._under_transaction:
self._setConfiguration(key, value)
else:
self.begin()
try:
self._setConfiguration(key, value)
except:
self.rollback()
raise
self.commit()
def _setConfiguration(self, key, value):
raise NotImplementedError
def getUUID(self):
......
......@@ -175,18 +175,12 @@ class MySQLDatabaseManager(DatabaseManager):
except IndexError:
return None
def setConfiguration(self, key, value):
self.begin()
try:
q = self.query
e = self.escape
key = e(str(key))
value = e(str(value))
q("""REPLACE INTO config VALUES ('%s', '%s')""" % (key, value))
except:
self.rollback()
raise
self.commit()
def _setConfiguration(self, key, value):
q = self.query
e = self.escape
key = e(str(key))
value = e(str(value))
q("""REPLACE INTO config VALUES ('%s', '%s')""" % (key, value))
def getPartitionTable(self):
q = self.query
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment