summaryrefslogtreecommitdiff
path: root/src/mongo/db/storage/index_entry_comparison.cpp
diff options
context:
space:
mode:
authorGeert Bosch <geert@mongodb.com>2020-04-22 01:00:21 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-06-10 16:19:05 +0000
commitb63e8cc9ba5c3897c47a33a6aec9981f2e3c53de (patch)
tree0aab1c0364cc481eb1b5f0d25851e3d8214919f3 /src/mongo/db/storage/index_entry_comparison.cpp
parent07169364c2aece0fb99f4a97b796196edb033efa (diff)
downloadmongo-b63e8cc9ba5c3897c47a33a6aec9981f2e3c53de.tar.gz
SERVER-47873 Eliminate the Collection* saved in IndexDescriptor
Diffstat (limited to 'src/mongo/db/storage/index_entry_comparison.cpp')
-rw-r--r--src/mongo/db/storage/index_entry_comparison.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mongo/db/storage/index_entry_comparison.cpp b/src/mongo/db/storage/index_entry_comparison.cpp
index 86e0e502290..face7000937 100644
--- a/src/mongo/db/storage/index_entry_comparison.cpp
+++ b/src/mongo/db/storage/index_entry_comparison.cpp
@@ -255,4 +255,23 @@ Status buildDupKeyErrorStatus(const KeyString::Value& keyString,
return buildDupKeyErrorStatus(key, collectionNamespace, indexName, keyPattern, indexCollation);
}
+Status buildDupKeyErrorStatus(OperationContext* opCtx,
+ const KeyString::Value& keyString,
+ const Ordering& ordering,
+ const IndexDescriptor* desc) {
+ const BSONObj key = KeyString::toBson(
+ keyString.getBuffer(), keyString.getSize(), ordering, keyString.getTypeBits());
+ return buildDupKeyErrorStatus(opCtx, key, desc);
+}
+
+Status buildDupKeyErrorStatus(OperationContext* opCtx,
+ const BSONObj& key,
+ const IndexDescriptor* desc) {
+ NamespaceString nss;
+ // In testing these may be nullptr, and being a bit more lenient during error handling is OK.
+ if (desc && desc->getEntry())
+ nss = desc->getEntry()->getNSSFromCatalog(opCtx);
+ return buildDupKeyErrorStatus(
+ key, nss, desc->indexName(), desc->keyPattern(), desc->collation());
+}
} // namespace mongo