Commit 7fc94582 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Storage IDs (UUID, LOID, LPTID) in hex format to help read values stored in

database, copy/paste from sql to command line and so on.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@1259 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 40f18533
...@@ -26,6 +26,7 @@ from struct import pack, unpack ...@@ -26,6 +26,7 @@ from struct import pack, unpack
from neo.storage.database import DatabaseManager from neo.storage.database import DatabaseManager
from neo.exception import DatabaseFailure from neo.exception import DatabaseFailure
from neo.protocol import DISCARDED_STATE from neo.protocol import DISCARDED_STATE
from neo import util
LOG_QUERIES = False LOG_QUERIES = False
...@@ -198,9 +199,11 @@ class MySQLDatabaseManager(DatabaseManager): ...@@ -198,9 +199,11 @@ class MySQLDatabaseManager(DatabaseManager):
self.commit() self.commit()
def getUUID(self): def getUUID(self):
return self.getConfiguration('uuid') uuid = self.getConfiguration('uuid')
return util.bin(uuid)
def setUUID(self, uuid): def setUUID(self, uuid):
uuid = util.dump(uuid)
self.setConfiguration('uuid', uuid) self.setConfiguration('uuid', uuid)
def getNumPartitions(self): def getNumPartitions(self):
...@@ -226,20 +229,29 @@ class MySQLDatabaseManager(DatabaseManager): ...@@ -226,20 +229,29 @@ class MySQLDatabaseManager(DatabaseManager):
self.setConfiguration('name', name) self.setConfiguration('name', name)
def getPTID(self): def getPTID(self):
return self.getConfiguration('ptid') ptid = self.getConfiguration('ptid')
return util.bin(ptid)
def setPTID(self, ptid): def setPTID(self, ptid):
ptid = util.dump(ptid)
self.setConfiguration('ptid', ptid) self.setConfiguration('ptid', ptid)
def getLastOID(self): def getLastOID(self):
return self.getConfiguration('loid') loid = self.getConfiguration('loid')
return util.bin(loid)
def setLastOID(self, loid): def setLastOID(self, loid):
loid = util.dump(loid)
self.setConfiguration('loid', loid) self.setConfiguration('loid', loid)
def getPartitionTable(self): def getPartitionTable(self):
q = self.query q = self.query
return q("""SELECT rid, uuid, state FROM pt""") cell_list = q("""SELECT rid, uuid, state FROM pt""")
pt = []
for offset, uuid, state in cell_list:
uuid = util.bin(uuid)
pt.append((offset, uuid, state))
return pt
def getLastTID(self, all = True): def getLastTID(self, all = True):
# XXX this does not consider serials in obj. # XXX this does not consider serials in obj.
...@@ -349,7 +361,7 @@ class MySQLDatabaseManager(DatabaseManager): ...@@ -349,7 +361,7 @@ class MySQLDatabaseManager(DatabaseManager):
if reset: if reset:
q("""TRUNCATE pt""") q("""TRUNCATE pt""")
for offset, uuid, state in cell_list: for offset, uuid, state in cell_list:
uuid = e(uuid) uuid = e(util.dump(uuid))
if state == DISCARDED_STATE: if state == DISCARDED_STATE:
q("""DELETE FROM pt WHERE rid = %d AND uuid = '%s'""" \ q("""DELETE FROM pt WHERE rid = %d AND uuid = '%s'""" \
% (offset, uuid)) % (offset, uuid))
......
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