summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/dependencies.h
diff options
context:
space:
mode:
authorDavid Storch <david.storch@mongodb.com>2019-12-18 03:28:25 +0000
committerevergreen <evergreen@mongodb.com>2019-12-18 03:28:25 +0000
commit1b75fcdcaf9c320ef8b916204d1eb51c4bab8a5f (patch)
tree237bb5cddc47f6918992d10f343ede42acf204e0 /src/mongo/db/pipeline/dependencies.h
parente83c51c61fa9907459e1cfac9e4bb3517445612f (diff)
downloadmongo-1b75fcdcaf9c320ef8b916204d1eb51c4bab8a5f.tar.gz
SERVER-43816 Push $text and $meta:"textScore" sort into the PlanStage layer.
This change involves unifying the behavior of find and agg for validation of $meta:"textScore". In particular, find operations no longer require a "textScore" $meta projection in order to specify a "textScore" $meta sort. This brings find into alignment with agg, which never had such a restriction. It is also now legal for a find command to sort on the field overridden by a $meta:"textScore" projection without specifying the $meta operator in the sort pattern. In addition: - Tightens validation around uses of "textScore" $meta projections for queries that do not specify a $text predicate. - Fixes a bug in which $natural sort/hint were not correctly validated.
Diffstat (limited to 'src/mongo/db/pipeline/dependencies.h')
-rw-r--r--src/mongo/db/pipeline/dependencies.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/mongo/db/pipeline/dependencies.h b/src/mongo/db/pipeline/dependencies.h
index aab2e21bfb4..8b75439db53 100644
--- a/src/mongo/db/pipeline/dependencies.h
+++ b/src/mongo/db/pipeline/dependencies.h
@@ -162,10 +162,15 @@ struct DepsTracker {
}
/**
- * Request that all metadata in the given QueryMetadataBitSet be added as dependencies.
+ * Request that all metadata in the given QueryMetadataBitSet be added as dependencies. Throws a
+ * UserException if any of the requested metadata fields have been marked as unavailable.
*/
void requestMetadata(const QueryMetadataBitSet& metadata) {
- _metadataDeps |= metadata;
+ for (size_t i = 1; i < DocumentMetadataFields::kNumFields; ++i) {
+ if (metadata[i]) {
+ setNeedsMetadata(static_cast<DocumentMetadataFields::MetaType>(i), true);
+ }
+ }
}
std::set<std::string> fields; // Names of needed fields in dotted notation.