summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/get_executor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/query/get_executor.cpp')
-rw-r--r--src/mongo/db/query/get_executor.cpp33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/mongo/db/query/get_executor.cpp b/src/mongo/db/query/get_executor.cpp
index db04d6a276a..bd22078b7c9 100644
--- a/src/mongo/db/query/get_executor.cpp
+++ b/src/mongo/db/query/get_executor.cpp
@@ -216,10 +216,15 @@ IndexEntry indexEntryFromIndexCatalogEntry(OperationContext* opCtx,
MultikeyMetadataAccessStats mkAccessStats;
if (canonicalQuery) {
- stdx::unordered_set<std::string> fields;
- QueryPlannerIXSelect::getFields(canonicalQuery->root(), &fields);
- const auto projectedFields = projection_executor_utils::applyProjectionToFields(
- wildcardProjection->exec(), fields);
+ RelevantFieldIndexMap fieldIndexProps;
+ QueryPlannerIXSelect::getFields(canonicalQuery->root(), &fieldIndexProps);
+ stdx::unordered_set<std::string> projectedFields;
+ for (auto&& [fieldName, _] : fieldIndexProps) {
+ if (projection_executor_utils::applyProjectionToOneField(
+ wildcardProjection->exec(), fieldName)) {
+ projectedFields.insert(fieldName);
+ }
+ }
multikeyPathSet =
getWildcardMultikeyPathSet(wam, opCtx, projectedFields, &mkAccessStats);
@@ -284,7 +289,8 @@ void fillOutIndexEntries(OperationContext* opCtx,
const CanonicalQuery* canonicalQuery,
const CollectionPtr& collection,
std::vector<IndexEntry>& entries) {
- auto ii = collection->getIndexCatalog()->getIndexIterator(opCtx, false);
+ auto ii = collection->getIndexCatalog()->getIndexIterator(
+ opCtx, IndexCatalog::InclusionPolicy::kReady);
while (ii->more()) {
const IndexCatalogEntry* ice = ii->next();
@@ -1526,6 +1532,13 @@ StatusWith<std::unique_ptr<PlanExecutor, PlanExecutor::Deleter>> getExecutorDele
expCtx->setIsCappedDelete();
}
+ // If the parsed delete does not have a user-specified collation, set it from the collection
+ // default.
+ if (collection && parsedDelete->getRequest()->getCollation().isEmpty() &&
+ collection->getDefaultCollator()) {
+ parsedDelete->setCollator(collection->getDefaultCollator()->clone());
+ }
+
if (collection && collection->isCapped() && opCtx->inMultiDocumentTransaction()) {
// This check is duplicated from CollectionImpl::deleteDocument() for two reasons:
// - Performing a remove on an empty capped collection would not call
@@ -1662,9 +1675,9 @@ StatusWith<std::unique_ptr<PlanExecutor, PlanExecutor::Deleter>> getExecutorDele
deleteStageParams->canonicalQuery = cq.get();
const bool batchDelete =
- (deleteStageParams->isMulti && !deleteStageParams->fromMigrate &&
- !deleteStageParams->returnDeleted && deleteStageParams->sort.isEmpty() &&
- !deleteStageParams->numStatsForDoc) &&
+ (deleteStageParams->isMulti && !opCtx->inMultiDocumentTransaction() &&
+ !deleteStageParams->fromMigrate && !deleteStageParams->returnDeleted &&
+ deleteStageParams->sort.isEmpty() && !deleteStageParams->numStatsForDoc) &&
((gInternalBatchUserMultiDeletesForTest.load() &&
nss.ns() == "__internalBatchedDeletesTesting.Collection0") ||
(batchDeletesByDefault.shouldFail()));
@@ -2393,8 +2406,8 @@ QueryPlannerParams fillOutPlannerParamsForDistinct(OperationContext* opCtx,
// If the caller did not request a "strict" distinct scan then we may choose a plan which
// unwinds arrays and treats each element in an array as its own key.
const bool mayUnwindArrays = !(plannerOptions & QueryPlannerParams::STRICT_DISTINCT_ONLY);
- std::unique_ptr<IndexCatalog::IndexIterator> ii =
- collection->getIndexCatalog()->getIndexIterator(opCtx, false);
+ auto ii = collection->getIndexCatalog()->getIndexIterator(
+ opCtx, IndexCatalog::InclusionPolicy::kReady);
auto query = parsedDistinct.getQuery()->getFindCommandRequest().getFilter();
while (ii->more()) {
const IndexCatalogEntry* ice = ii->next();