diff options
-rw-r--r-- | src/mongo/db/index/index_access_method.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/index/index_access_method.h | 4 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/mongo/db/index/index_access_method.cpp b/src/mongo/db/index/index_access_method.cpp index f88d721ae16..b37c38e713c 100644 --- a/src/mongo/db/index/index_access_method.cpp +++ b/src/mongo/db/index/index_access_method.cpp @@ -183,6 +183,10 @@ Status AbstractIndexAccessMethod::insertKeys(OperationContext* opCtx, const InsertDeleteOptions& options, KeyHandlerFn&& onDuplicateKey, int64_t* numInserted) { + // Initialize the 'numInserted' out-parameter to zero in case the caller did not already do so. + if (numInserted) { + *numInserted = 0; + } // Add all new keys into the index. The RecordId for each is already encoded in the KeyString. for (const auto& keyString : keys) { bool unique = _descriptor->unique(); diff --git a/src/mongo/db/index/index_access_method.h b/src/mongo/db/index/index_access_method.h index 63be0cf3186..3a58f512159 100644 --- a/src/mongo/db/index/index_access_method.h +++ b/src/mongo/db/index/index_access_method.h @@ -109,7 +109,9 @@ public: /** * Inserts the specified keys into the index. Does not attempt to determine whether the - * insertion of these keys should cause the index to become multikey. + * insertion of these keys should cause the index to become multikey. The 'numInserted' output + * parameter, if non-nullptr, will be reset to the number of keys inserted by this function + * call, or to zero in the case of either a non-OK return Status or an empty 'keys' argument. */ virtual Status insertKeys(OperationContext* opCtx, const KeyStringSet& keys, |