diff --git a/db/db_test2.cc b/db/db_test2.cc index 7f724ac72..e74344410 100644 --- a/db/db_test2.cc +++ b/db/db_test2.cc @@ -4355,6 +4355,10 @@ TEST_F(DBTest2, BlockBasedTablePrefixIndexSeekForPrev) { if (iterator->Valid()) { ASSERT_EQ("a1", iterator->key().ToString()); } + + iterator->SeekForPrev("y3"); + ASSERT_TRUE(iterator->Valid()); + ASSERT_EQ("y1", iterator->key().ToString()); } } diff --git a/table/block_based/block.cc b/table/block_based/block.cc index cfa042d6e..1aa5bfe54 100644 --- a/table/block_based/block.cc +++ b/table/block_based/block.cc @@ -390,6 +390,7 @@ void IndexBlockIter::Seek(const Slice& target) { if (data_ == nullptr) { // Not init yet return; } + status_ = Status::OK(); uint32_t index = 0; bool ok = false; if (prefix_index_) { @@ -470,6 +471,7 @@ void IndexBlockIter::SeekToFirst() { if (data_ == nullptr) { // Not init yet return; } + status_ = Status::OK(); SeekToRestartPoint(0); ParseNextIndexKey(); } @@ -488,6 +490,7 @@ void IndexBlockIter::SeekToLast() { if (data_ == nullptr) { // Not init yet return; } + status_ = Status::OK(); SeekToRestartPoint(num_restarts_ - 1); while (ParseNextIndexKey() && NextEntryOffset() < restarts_) { // Keep skipping