Skip to content

Commit

Permalink
Fix the failure of stringappend_test caused by PartialMergeMulti.
Browse files Browse the repository at this point in the history
Summary:
Fix a bug that PartialMergeMulti will try to merge the first operand
with an empty slice.

Test Plan: run stringappend_test and merge_test.

Reviewers: haobo, igor

Reviewed By: haobo

CC: leveldb

Differential Revision: https://reviews.facebook.net/D17157
  • Loading branch information
yhchiang committed Mar 25, 2014
1 parent ebaff6f commit 34f9da1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions db/merge_operator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ bool MergeOperator::PartialMergeMulti(const Slice& key,
Logger* logger) const {
// Simply loop through the operands
std::string temp_value;
Slice temp_slice;
for (const auto& operand : operand_list) {
Slice temp_slice(operand_list[0]);

for (int i = 1; i < operand_list.size(); ++i) {
auto& operand = operand_list[i];
if (!PartialMerge(key, temp_slice, operand, &temp_value, logger)) {
return false;
}
Expand Down

0 comments on commit 34f9da1

Please sign in to comment.