Commit 98d62acf authored by Jeremy Hylton's avatar Jeremy Hylton

Check that transaction id matches object serialnos.

This test wasn't part of read_index(), but seems good and cheap.

XXX Needs test case.
parent 945a31a6
......@@ -135,7 +135,7 @@ def check_trec(path, file, pos, ltid, file_size):
i = 0
while pos < tend:
_pos = pos
pos, oid = check_drec(path, file, pos, tpos)
pos, oid = check_drec(path, file, pos, tpos, tid)
if pos > tend:
raise FormatError("%s has data records that extend beyond"
" the transaction record; end at %s" %
......@@ -152,7 +152,7 @@ def check_trec(path, file, pos, ltid, file_size):
pos = tend + 8
return pos, tid
def check_drec(path, file, pos, tpos):
def check_drec(path, file, pos, tpos, tid):
"""Check a data record for the current transaction record"""
h = file.read(DREC_HDR_LEN)
......@@ -165,6 +165,11 @@ def check_drec(path, file, pos, tpos):
plen = U64(_plen)
dlen = DREC_HDR_LEN + (plen or 8)
if serial != tid:
raise FormatError("%s object serialno %s does not match"
"transaction id %s" % (pos, hexify(serial),
hexify(tid)))
if vlen:
dlen = dlen + 16 + vlen
file.seek(8, 1)
......
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