e3: ots underflow fixes (#860)

This commit is contained in:
Alex Sharov 2023-01-27 14:40:29 +07:00 committed by GitHub
parent 3f234f90d0
commit 040fefda7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -558,21 +558,10 @@ func (it *InvertedIterator) advanceInDb() {
//Asc: [from, to) AND from > to //Asc: [from, to) AND from > to
//Desc: [from, to) AND from < to //Desc: [from, to) AND from < to
var keyBytes [8]byte var keyBytes [8]byte
if it.startTxNum < 0 { if it.startTxNum > 0 {
if it.orderAscend {
_, v, err = it.cursor.First()
if err != nil {
// TODO pass error properly around
panic(err)
}
} else {
_, v, err = it.cursor.Last()
if err != nil {
panic(err)
}
}
} else {
binary.BigEndian.PutUint64(keyBytes[:], uint64(it.startTxNum)) binary.BigEndian.PutUint64(keyBytes[:], uint64(it.startTxNum))
}
k, v, err = it.cursor.SeekExact(it.key)
if v, err = it.cursor.SeekBothRange(it.key, keyBytes[:]); err != nil { if v, err = it.cursor.SeekBothRange(it.key, keyBytes[:]); err != nil {
panic(err) panic(err)
} }
@ -588,7 +577,6 @@ func (it *InvertedIterator) advanceInDb() {
return return
} }
} }
}
} else { } else {
if it.orderAscend { if it.orderAscend {
_, v, err = it.cursor.NextDup() _, v, err = it.cursor.NextDup()