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

Move method access out of loop.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2323 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 5f7a9142
...@@ -662,6 +662,7 @@ class MySQLDatabaseManager(DatabaseManager): ...@@ -662,6 +662,7 @@ class MySQLDatabaseManager(DatabaseManager):
updateObjectDataForPack): updateObjectDataForPack):
q = self.query q = self.query
p64 = util.p64 p64 = util.p64
getPartition = self.getPartition
# Before deleting this objects revision, see if there is any # Before deleting this objects revision, see if there is any
# transaction referencing its value at max_serial or above. # transaction referencing its value at max_serial or above.
# If there is, copy value to the first future transaction. Any further # If there is, copy value to the first future transaction. Any further
...@@ -673,7 +674,7 @@ class MySQLDatabaseManager(DatabaseManager): ...@@ -673,7 +674,7 @@ class MySQLDatabaseManager(DatabaseManager):
'AND serial >= %(max_serial)d AND ' 'AND serial >= %(max_serial)d AND '
'value_serial = %(orig_serial)d ORDER BY serial ASC' % { 'value_serial = %(orig_serial)d ORDER BY serial ASC' % {
'table': table, 'table': table,
'partition': self.getPartition(oid), 'partition': getPartition(oid),
'oid': oid, 'oid': oid,
'orig_serial': orig_serial, 'orig_serial': orig_serial,
'max_serial': max_serial, 'max_serial': max_serial,
...@@ -689,7 +690,7 @@ class MySQLDatabaseManager(DatabaseManager): ...@@ -689,7 +690,7 @@ class MySQLDatabaseManager(DatabaseManager):
'AND serial = %(orig_serial)d' \ 'AND serial = %(orig_serial)d' \
% { % {
'table': table, 'table': table,
'partition': self.getPartition(oid), 'partition': getPartition(oid),
'oid': oid, 'oid': oid,
'serial': serial, 'serial': serial,
'orig_serial': orig_serial, 'orig_serial': orig_serial,
...@@ -699,7 +700,7 @@ class MySQLDatabaseManager(DatabaseManager): ...@@ -699,7 +700,7 @@ class MySQLDatabaseManager(DatabaseManager):
'VALUES (%(partition)d, %(oid)d, %(serial)d, ' 'VALUES (%(partition)d, %(oid)d, %(serial)d, '
'%(value_serial)d)' % { '%(value_serial)d)' % {
'table': table, 'table': table,
'partition': self.getPartition(oid), 'partition': getPartition(oid),
'oid': oid, 'oid': oid,
'serial': serial, 'serial': serial,
'value_serial': value_serial, 'value_serial': value_serial,
...@@ -709,7 +710,7 @@ class MySQLDatabaseManager(DatabaseManager): ...@@ -709,7 +710,7 @@ class MySQLDatabaseManager(DatabaseManager):
return q('SELECT compression, checksum, value FROM obj WHERE ' return q('SELECT compression, checksum, value FROM obj WHERE '
'partition = %(partition)d AND oid = %(oid)d ' 'partition = %(partition)d AND oid = %(oid)d '
'AND serial = %(orig_serial)d' % { 'AND serial = %(orig_serial)d' % {
'partition': self.getPartition(oid), 'partition': getPartition(oid),
'oid': oid, 'oid': oid,
'orig_serial': orig_serial, 'orig_serial': orig_serial,
})[0] })[0]
...@@ -723,6 +724,7 @@ class MySQLDatabaseManager(DatabaseManager): ...@@ -723,6 +724,7 @@ class MySQLDatabaseManager(DatabaseManager):
q = self.query q = self.query
tid = util.u64(tid) tid = util.u64(tid)
updatePackFuture = self._updatePackFuture updatePackFuture = self._updatePackFuture
getPartition = self.getPartition
self.begin() self.begin()
try: try:
self._setPackTID(tid) self._setPackTID(tid)
...@@ -733,7 +735,7 @@ class MySQLDatabaseManager(DatabaseManager): ...@@ -733,7 +735,7 @@ class MySQLDatabaseManager(DatabaseManager):
'%(partition)s AND oid = %(oid)d AND ' '%(partition)s AND oid = %(oid)d AND '
'serial = %(max_serial)d' % { 'serial = %(max_serial)d' % {
'oid': oid, 'oid': oid,
'partition': self.getPartition(oid), 'partition': getPartition(oid),
'max_serial': max_serial, 'max_serial': max_serial,
})[0][0] == 0: })[0][0] == 0:
count += 1 count += 1
...@@ -744,14 +746,14 @@ class MySQLDatabaseManager(DatabaseManager): ...@@ -744,14 +746,14 @@ class MySQLDatabaseManager(DatabaseManager):
'partition=%(partition)d AND oid=%(oid)d AND ' 'partition=%(partition)d AND oid=%(oid)d AND '
'serial < %(max_serial)d' % { 'serial < %(max_serial)d' % {
'oid': oid, 'oid': oid,
'partition': self.getPartition(oid), 'partition': getPartition(oid),
'max_serial': max_serial, 'max_serial': max_serial,
}): }):
updatePackFuture(oid, serial, max_serial, updatePackFuture(oid, serial, max_serial,
updateObjectDataForPack) updateObjectDataForPack)
q('DELETE FROM obj WHERE partition=%(partition)d ' q('DELETE FROM obj WHERE partition=%(partition)d '
'AND oid=%(oid)d AND serial=%(serial)d' % { 'AND oid=%(oid)d AND serial=%(serial)d' % {
'partition': self.getPartition(oid), 'partition': getPartition(oid),
'oid': oid, 'oid': oid,
'serial': serial 'serial': serial
}) })
......
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