diff --git a/db/db_iter.cc b/db/db_iter.cc index 0c4f2b685..eb89d167f 100644 --- a/db/db_iter.cc +++ b/db/db_iter.cc @@ -658,7 +658,8 @@ bool DBIter::FindValueForCurrentKey() { return false; case kTypeMerge: current_entry_is_merged_ = true; - if (last_not_merge_type == kTypeDeletion) { + if (last_not_merge_type == kTypeDeletion || + last_not_merge_type == kTypeSingleDeletion) { MergeHelper::TimedFullMerge(merge_operator_, saved_key_.GetKey(), nullptr, merge_context_.GetOperands(), &saved_value_, logger_, statistics_, env_, diff --git a/db/db_iter_test.cc b/db/db_iter_test.cc index c500ab5c5..35da751fd 100644 --- a/db/db_iter_test.cc +++ b/db/db_iter_test.cc @@ -1129,6 +1129,26 @@ TEST_F(DBIteratorTest, DBIterator5) { db_iter->Prev(); ASSERT_TRUE(!db_iter->Valid()); } + + { + // put, singledelete, merge + TestIterator* internal_iter = new TestIterator(BytewiseComparator()); + internal_iter->AddPut("a", "val_a"); + internal_iter->AddSingleDeletion("a"); + internal_iter->AddMerge("a", "merge_1"); + internal_iter->AddMerge("a", "merge_2"); + internal_iter->AddPut("b", "val_b"); + internal_iter->Finish(); + std::unique_ptr db_iter(NewDBIterator( + env_, ImmutableCFOptions(options), BytewiseComparator(), internal_iter, + 10, options.max_sequential_skip_in_iterations, 0)); + db_iter->Seek("b"); + ASSERT_TRUE(db_iter->Valid()); + ASSERT_EQ(db_iter->key().ToString(), "b"); + db_iter->Prev(); + ASSERT_TRUE(db_iter->Valid()); + ASSERT_EQ(db_iter->key().ToString(), "a"); + } } TEST_F(DBIteratorTest, DBIterator6) {