Commit 51995dde authored by Julien Muchembled's avatar Julien Muchembled

wip

parent d9200f28
...@@ -623,13 +623,15 @@ class MySQLDatabaseManager(MVCCDatabaseManager): ...@@ -623,13 +623,15 @@ class MySQLDatabaseManager(MVCCDatabaseManager):
sql = ["REPLACE INTO %s VALUES " % obj_table] sql = ["REPLACE INTO %s VALUES " % obj_table]
values_max = self._max_allowed_packet - len(sql[0]) values_max = self._max_allowed_packet - len(sql[0])
values_size = 0 values_size = 0
row_list = []
for oid, data_id, value_serial in object_list: for oid, data_id, value_serial in object_list:
oid = u64(oid) oid = u64(oid)
partition = self._getPartition(oid) row_list.append((self._getPartition(oid), oid,
value = "(%s,%s,%s,%s,%s)," % (
partition, oid, tid,
'NULL' if data_id is None else data_id, 'NULL' if data_id is None else data_id,
u64(value_serial) if value_serial else 'NULL') u64(value_serial) if value_serial else 'NULL'))
row_list.sort()
row_list = map(("(%%s,%%s,%s,%%s,%%s)," % tid).__mod__, row_list)
for value in row_list:
values_size += len(value) values_size += len(value)
# actually: max_values < values_size + EXTRA - len(final comma) # actually: max_values < values_size + EXTRA - len(final comma)
# (test_max_allowed_packet checks that EXTRA == 2) # (test_max_allowed_packet checks that EXTRA == 2)
......
...@@ -488,21 +488,23 @@ class SQLiteDatabaseManager(DatabaseManager): ...@@ -488,21 +488,23 @@ class SQLiteDatabaseManager(DatabaseManager):
T = 't' if temporary else '' T = 't' if temporary else ''
obj_sql = "INSERT OR FAIL INTO %sobj VALUES (?,?,?,?,?)" % T obj_sql = "INSERT OR FAIL INTO %sobj VALUES (?,?,?,?,?)" % T
q = self.query q = self.query
row_list = []
for oid, data_id, value_serial in object_list: for oid, data_id, value_serial in object_list:
oid = u64(oid) oid = u64(oid)
partition = self._getPartition(oid) row_list.append((self._getPartition(oid), oid, tid, data_id,
if value_serial: value_serial and u64(value_serial)))
value_serial = u64(value_serial) row_list.sort()
for row in row_list:
try: try:
q(obj_sql, (partition, oid, tid, data_id, value_serial)) q(obj_sql, row)
except sqlite3.IntegrityError: except sqlite3.IntegrityError:
# This may happen if a previous replication of 'obj' was # This may happen if a previous replication of 'obj' was
# interrupted. # interrupted.
if not T: if not T:
r, = q("SELECT data_id, value_tid FROM obj" r, = q("SELECT data_id, value_tid FROM obj"
" WHERE partition=? AND oid=? AND tid=?", " WHERE partition=? AND oid=? AND tid=?",
(partition, oid, tid)) row[:3])
if r == (data_id, value_serial): if r == row[3:]:
continue continue
raise raise
if transaction: if transaction:
......
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