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

wip

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