e3: history iterator shortcut fix (#960)

This commit is contained in:
Alex Sharov 2023-03-30 09:51:59 +07:00 committed by GitHub
parent b29550fd20
commit 9431fe1b94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1862,6 +1862,7 @@ func (hc *HistoryContext) iterateChangedFrozen(fromTxNum, toTxNum int, asc order
if len(hc.ic.files) == 0 { if len(hc.ic.files) == 0 {
return iter.EmptyKV, nil return iter.EmptyKV, nil
} }
if fromTxNum >= 0 && hc.ic.files[len(hc.ic.files)-1].endTxNum <= uint64(fromTxNum) { if fromTxNum >= 0 && hc.ic.files[len(hc.ic.files)-1].endTxNum <= uint64(fromTxNum) {
return iter.EmptyKV, nil return iter.EmptyKV, nil
} }
@ -1897,10 +1898,11 @@ func (hc *HistoryContext) iterateChangedFrozen(fromTxNum, toTxNum int, asc order
} }
func (hc *HistoryContext) iterateChangedRecent(fromTxNum, toTxNum int, asc order.By, limit int, roTx kv.Tx) (iter.KV, error) { func (hc *HistoryContext) iterateChangedRecent(fromTxNum, toTxNum int, asc order.By, limit int, roTx kv.Tx) (iter.KV, error) {
if asc == false { if asc == order.Desc {
panic("not supported yet") panic("not supported yet")
} }
if len(hc.ic.files) > 0 && (fromTxNum >= 0 && hc.ic.files[len(hc.ic.files)-1].endTxNum >= uint64(fromTxNum)) { rangeIsInFiles := toTxNum >= 0 && len(hc.ic.files) > 0 && hc.ic.files[len(hc.ic.files)-1].endTxNum >= uint64(toTxNum)
if rangeIsInFiles {
return iter.EmptyKV, nil return iter.EmptyKV, nil
} }
if hc.h.largeValues { if hc.h.largeValues {