diff options
author | Gregory Noma <gregory.noma@gmail.com> | 2022-02-24 19:33:56 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-02-24 20:34:37 +0000 |
commit | ab0af4dc877ea795069b720b5900e313f7e36f02 (patch) | |
tree | 650d3eb8b3826017a35c3c44f70957ecd8df7ba7 /src/mongo/db/storage/index_entry_comparison.cpp | |
parent | 972d3f082e84c82002c15b9ad3bbed05d77db514 (diff) | |
download | mongo-ab0af4dc877ea795069b720b5900e313f7e36f02.tar.gz |
SERVER-60562 Include cursor value in duplicate key error when testing is enabled
Diffstat (limited to 'src/mongo/db/storage/index_entry_comparison.cpp')
-rw-r--r-- | src/mongo/db/storage/index_entry_comparison.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/mongo/db/storage/index_entry_comparison.cpp b/src/mongo/db/storage/index_entry_comparison.cpp index 1e5d53eecf7..feceb088a38 100644 --- a/src/mongo/db/storage/index_entry_comparison.cpp +++ b/src/mongo/db/storage/index_entry_comparison.cpp @@ -34,7 +34,6 @@ #include "mongo/db/jsobj.h" #include "mongo/db/namespace_string.h" -#include "mongo/db/storage/duplicate_key_error_info.h" #include "mongo/db/storage/key_string.h" #include "mongo/util/hex.h" #include "mongo/util/text.h" @@ -188,7 +187,8 @@ Status buildDupKeyErrorStatus(const BSONObj& key, const NamespaceString& collectionNamespace, const std::string& indexName, const BSONObj& keyPattern, - const BSONObj& indexCollation) { + const BSONObj& indexCollation, + DuplicateKeyErrorInfo::FoundValue&& foundValue) { const bool hasCollation = !indexCollation.isEmpty(); StringBuilder sb; @@ -250,8 +250,22 @@ Status buildDupKeyErrorStatus(const BSONObj& key, sb << builderForErrmsg.obj(); - return Status(DuplicateKeyErrorInfo(keyPattern, builderForErrorExtraInfo.obj(), indexCollation), - sb.str()); + stdx::visit( + visit_helper::Overloaded{ + [](stdx::monostate) {}, + [&sb](const RecordId& rid) { sb << " found value: " << rid; }, + [&sb](const BSONObj& obj) { + if (obj.objsize() < BSONObjMaxUserSize / 2) { + sb << " found value: " << obj; + } + }, + }, + foundValue); + + return Status( + DuplicateKeyErrorInfo( + keyPattern, builderForErrorExtraInfo.obj(), indexCollation, std::move(foundValue)), + sb.str()); } Status buildDupKeyErrorStatus(const KeyString::Value& keyString, |