Skip to content

Commit

Permalink
db: adjust Iterator.NextPrefix to error if in error state
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jbowens committed May 9, 2024
1 parent 8633593 commit a43bb5d
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1720,6 +1720,9 @@ func (i *Iterator) NextPrefix() bool {
i.iterValidityState = IterExhausted
return false
}
if i.Error() != nil {
return false
}
return i.nextPrefix() == IterValid
}

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

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

0 comments on commit a43bb5d

Please sign in to comment.