diff options
author | Benety Goh <benety@mongodb.com> | 2021-06-03 18:22:55 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-06-03 22:57:37 +0000 |
commit | 368d6ce6986680211fd4c09bb23431d08bb4e297 (patch) | |
tree | 0299e238c6430c5ff733631a8dbe4f334f19c572 /src/mongo/db/commands/dbcommands.cpp | |
parent | ccdda22e09a877afb86de220ccbb5434ea596367 (diff) | |
download | mongo-368d6ce6986680211fd4c09bb23431d08bb4e297.tar.gz |
SERVER-57127 IndexCatalog::findShardKeyPrefixedIndex() accepts CollectionPtr
Diffstat (limited to 'src/mongo/db/commands/dbcommands.cpp')
-rw-r--r-- | src/mongo/db/commands/dbcommands.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/mongo/db/commands/dbcommands.cpp b/src/mongo/db/commands/dbcommands.cpp index 888ead550e0..a8831db8fed 100644 --- a/src/mongo/db/commands/dbcommands.cpp +++ b/src/mongo/db/commands/dbcommands.cpp @@ -409,23 +409,24 @@ public: keyPattern = Helpers::inferKeyPattern(min); } - const IndexDescriptor* idx = - collection->getIndexCatalog()->findShardKeyPrefixedIndex(opCtx, - keyPattern, - true); // requireSingleKey + auto catalog = collection->getIndexCatalog(); + auto shardKeyIdx = catalog->findShardKeyPrefixedIndex(opCtx, + *collection, + keyPattern, + /*requireSingleKey=*/true); - if (idx == nullptr) { + if (shardKeyIdx == nullptr) { errmsg = "couldn't find valid index containing key pattern"; return false; } // If both min and max non-empty, append MinKey's to make them fit chosen index - KeyPattern kp(idx->keyPattern()); + KeyPattern kp(shardKeyIdx->keyPattern()); min = Helpers::toKeyFormat(kp.extendRangeBound(min, false)); max = Helpers::toKeyFormat(kp.extendRangeBound(max, false)); exec = InternalPlanner::indexScan(opCtx, &collection.getCollection(), - idx, + shardKeyIdx, min, max, BoundInclusion::kIncludeStartKeyOnly, |