History for RelationalStorageSQLCallsByMethod
??changed:- Artifact RelationalStorageSQLCallsByMethod Database: Interbase 6.0 beta Class: InterbaseStorage(BaseStorage) Imports: 'struct', 'TimeStamp', 'POSException', 'BaseStorage' Methods: __init__(self, conn, name="", zodb_data="zodb_data", zodb_trans="zodb_trans", zodb_pack="zodb_pack") [testConn] GetLastOid __len__(self) GetNumberOfCurrentRecords abortVersion(self, version, transaction) GetCurrentOidsInVersion InsertAbortedVersionAsNew MakeCurrentVersionRecordsHistorical commitVersion(self, source, destination, transaction) GetCurrentOidsInVersion InsertCommittedVersionAsNew MakeCurrentVersionRecordsHistorical load(self, oid, version) GetCurrent GetHistorical store(self, oid, serial, data, version, transaction) GetCurrent InsertObject SetStatus close(self) pass getSize(self) <pre> def getSize(self): if self._debug: print "getSize" dcs = self._doCommittedSQL tables = self._tables cmd = ("SELECT SUM(%(data)s.z_datalen) FROM %(data)s" % tables) datasize = int(dcs(cmd=cmd, fetch="one")[0]) cmd = ("SELECT COUNT(*) FROM %(data)s" % tables) numrecs = int(dcs(cmd=cmd, fetch="one")[0]) cmd = ("SELECT COUNT(*) FROM %(trans)s" % tables) numtrans = int(dcs(cmd=cmd, fetch="one")[0]) data_overhead = (12 + 12 + 12 + 1 + 32 + 12) * numrecs trans_overhead = (12 + 1 + 255 + 255 + 255) * numtrans overhead = data_overhead + trans_overhead wag_size = overhead + datasize return wag_size # seems to be about 1/2 the diskfile size </pre> loadSerial GetHistorical history <pre> SELECT %(data)s.z_serial,%(trans)s.z_user,%(trans)s.z_desc, %(data)s.z_version,%(data)s.z_datalen FROM %(data)s, %(trans)s WHERE %(data)s.z_oid = ? AND %(data)s.z_status IN ('c', 'h') AND (%(data)s.z_version = '' OR %(data)s.z_version = ?) AND %(data)s.z_serial = %(trans)s.z_serial ORDER BY %(data)s.z_serial DESCENDING </pre> modifiedInVersion GetCurrent supportsUndo Return 1 supportsVersions Return 1 _begin(self, tid, u, d, e) - Start a new DB transaction _finish(self, tid, u, d, e) InsertTrans undo TransactionExists TransactionIsUndoable GetCurrentOidsWithAPre MarkOldRecordsAsCurrent DeleteDataRecords DeleteTransactionRecord undoLog <pre> SELECT z_serial, z_status, z_user, z_desc, z_ext FROM %(trans)s </pre> versionEmpty <pre> SELECT * FROM %(data)s WHERE z_version = ? AND z_status = 'c' </pre> versions <pre> SELECT DISTINCT z_version FROM %(data)s </pre> pack Insert potentially packable data into pack table <pre> INSERT INTO %(pack)s (z_oid, z_serial) SELECT z_oid, MAX(z_serial) FROM %(data)s WHERE z_serial < ? GROUP BY z_oid </pre> while rootl: <pre> INSERT INTO %(pack)s (z_oid, z_serial) SELECT z_oid, MAX(z_serial) FROM %(data)s WHERE z_serial < ? GROUP BY z_oid </pre> for each object with forward references: <pre> DELETE FROM %(pack)s WHERE z_oid = ? </pre> all the records left in the pack table get deleted from the data table <pre> DELETE FROM %(data)s WHERE z_oid IN (SELECT z_oid FROM zodb_pack) AND z_serial < ? </pre> delete all the records from the trans table earlier than stop time. <pre> DELETE FROM %(trans)s WHERE z_serial < ? </pre> clean up the pack table <pre> DELETE FROM %(pack)s </pre>