From 34f9da1ceff202921509ff055711cdc6e34ec577 Mon Sep 17 00:00:00 2001 From: Yueh-Hsuan Chiang Date: Tue, 25 Mar 2014 11:50:09 -0700 Subject: [PATCH] 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 --- db/merge_operator.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/db/merge_operator.cc b/db/merge_operator.cc index 43a8df371..d96b165a6 100644 --- a/db/merge_operator.cc +++ b/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; }