Commit 82267fb4 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 b41a53de
...@@ -135,7 +135,7 @@ def check_trec(path, file, pos, ltid, file_size): ...@@ -135,7 +135,7 @@ def check_trec(path, file, pos, ltid, file_size):
i = 0 i = 0
while pos < tend: while pos < tend:
_pos = pos _pos = pos
pos, oid = check_drec(path, file, pos, tpos) pos, oid = check_drec(path, file, pos, tpos, tid)
if pos > tend: if pos > tend:
raise FormatError("%s has data records that extend beyond" raise FormatError("%s has data records that extend beyond"
" the transaction record; end at %s" % " the transaction record; end at %s" %
...@@ -152,7 +152,7 @@ def check_trec(path, file, pos, ltid, file_size): ...@@ -152,7 +152,7 @@ def check_trec(path, file, pos, ltid, file_size):
pos = tend + 8 pos = tend + 8
return pos, tid 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""" """Check a data record for the current transaction record"""
h = file.read(DREC_HDR_LEN) h = file.read(DREC_HDR_LEN)
...@@ -165,6 +165,11 @@ def check_drec(path, file, pos, tpos): ...@@ -165,6 +165,11 @@ def check_drec(path, file, pos, tpos):
plen = U64(_plen) plen = U64(_plen)
dlen = DREC_HDR_LEN + (plen or 8) 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: if vlen:
dlen = dlen + 16 + vlen dlen = dlen + 16 + vlen
file.seek(8, 1) 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