diff options
author | Tess Avitabile <tess.avitabile@mongodb.com> | 2016-06-22 18:19:31 -0400 |
---|---|---|
committer | Tess Avitabile <tess.avitabile@mongodb.com> | 2016-07-08 10:16:56 -0400 |
commit | 99d405ae814d9840c029bcb6916cc94aa03b9b68 (patch) | |
tree | e313172e17b1a66ad840afa1b3cce0e7582de3c2 /src/mongo/db/query | |
parent | 44599a88f8f230d110363f638eb942ea7e071bf6 (diff) | |
download | mongo-99d405ae814d9840c029bcb6916cc94aa03b9b68.tar.gz |
SERVER-23924 Make _id index inherit the collection's default collation
Diffstat (limited to 'src/mongo/db/query')
-rw-r--r-- | src/mongo/db/query/get_executor.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/mongo/db/query/get_executor.cpp b/src/mongo/db/query/get_executor.cpp index 2e9189c87e3..8130ac57e4d 100644 --- a/src/mongo/db/query/get_executor.cpp +++ b/src/mongo/db/query/get_executor.cpp @@ -58,6 +58,7 @@ #include "mongo/db/matcher/extensions_callback_real.h" #include "mongo/db/ops/update_lifecycle.h" #include "mongo/db/query/canonical_query.h" +#include "mongo/db/query/collation/collator_factory_interface.h" #include "mongo/db/query/explain.h" #include "mongo/db/query/index_bounds_builder.h" #include "mongo/db/query/internal_plans.h" @@ -272,7 +273,7 @@ StatusWith<PrepareExecutionResult> prepareExecution(OperationContext* opCtx, const IndexDescriptor* descriptor = collection->getIndexCatalog()->findIdIndex(opCtx); // If we have an _id index we can use an idhack plan. - if (descriptor && IDHackStage::supportsQuery(*canonicalQuery)) { + if (descriptor && IDHackStage::supportsQuery(collection, *canonicalQuery)) { LOG(2) << "Using idhack: " << canonicalQuery->toStringShort(); root = make_unique<IDHackStage>(opCtx, collection, canonicalQuery.get(), ws, descriptor); @@ -743,8 +744,21 @@ StatusWith<unique_ptr<PlanExecutor>> getExecutorDelete(OperationContext* txn, const IndexDescriptor* descriptor = collection->getIndexCatalog()->findIdIndex(txn); + // Construct delete request collator. + std::unique_ptr<CollatorInterface> collator; + if (!request->getCollation().isEmpty()) { + auto statusWithCollator = CollatorFactoryInterface::get(txn->getServiceContext()) + ->makeFromBSON(request->getCollation()); + if (!statusWithCollator.isOK()) { + return statusWithCollator.getStatus(); + } + collator = std::move(statusWithCollator.getValue()); + } + const bool hasCollectionDefaultCollation = request->getCollation().isEmpty() || + CollatorInterface::collatorsMatch(collator.get(), collection->getDefaultCollator()); + if (descriptor && CanonicalQuery::isSimpleIdQuery(unparsedQuery) && - request->getProj().isEmpty()) { + request->getProj().isEmpty() && hasCollectionDefaultCollation) { LOG(2) << "Using idhack: " << unparsedQuery.toString(); PlanStage* idHackStage = @@ -896,8 +910,11 @@ StatusWith<unique_ptr<PlanExecutor>> getExecutorUpdate(OperationContext* txn, const IndexDescriptor* descriptor = collection->getIndexCatalog()->findIdIndex(txn); + const bool hasCollectionDefaultCollation = CollatorInterface::collatorsMatch( + parsedUpdate->getCollator(), collection->getDefaultCollator()); + if (descriptor && CanonicalQuery::isSimpleIdQuery(unparsedQuery) && - request->getProj().isEmpty()) { + request->getProj().isEmpty() && hasCollectionDefaultCollation) { LOG(2) << "Using idhack: " << unparsedQuery.toString(); PlanStage* idHackStage = |