Skip to content

Commit a43bb5d

Browse files
committed
db: adjust Iterator.NextPrefix to error if in error state
Revert the changes to Iterator.nextPrefix in bfd3ee2. Instead, adjust Iterator.NextPrefix to error if the iterator is already an error state. This mirrors the behavior of Iterator.Next. Fix #3597.
1 parent 8633593 commit a43bb5d

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

iterator.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,6 +1720,9 @@ func (i *Iterator) NextPrefix() bool {
17201720
i.iterValidityState = IterExhausted
17211721
return false
17221722
}
1723+
if i.Error() != nil {
1724+
return false
1725+
}
17231726
return i.nextPrefix() == IterValid
17241727
}
17251728

@@ -1740,11 +1743,6 @@ func (i *Iterator) nextPrefix() IterValidityState {
17401743
// key.
17411744
i.rangeKey.updated = i.rangeKey.hasRangeKey && !i.Valid() && i.opts.rangeKeys()
17421745
}
1743-
// NextPrefix from an exhausted position is undefined. We keep the exhausted
1744-
// position, which provides determinism for the metamorphic tests.
1745-
if i.iterValidityState == IterExhausted {
1746-
return i.iterValidityState
1747-
}
17481746

17491747
// Although NextPrefix documents that behavior at IterAtLimit is undefined,
17501748
// this function handles these cases as a simple prefix-agnostic Next. This

0 commit comments

Comments
 (0)