Fix the failure of stringappend_test caused by PartialMergeMulti.

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
main
Yueh-Hsuan Chiang 11 years ago
parent ebaff6f9e2
commit 34f9da1cef
  1. 6
      db/merge_operator.cc

@ -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;
}

Loading…
Cancel
Save