summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMihai Andrei <mihai.andrei@mongodb.com>2019-11-19 14:39:37 +0000
committerevergreen <evergreen@mongodb.com>2019-11-19 14:39:37 +0000
commit0a870f14f902b7c002ed0d12fbf44be97f08a8a4 (patch)
treeaeba88a6f048b0ed812e64f4dbae270e87653953
parent5075945096ab03b81277450c0ea7b24bb727c0cf (diff)
downloadmongo-0a870f14f902b7c002ed0d12fbf44be97f08a8a4.tar.gz
SERVER-44348 Add deprecation warning for , in mapReduce
-rw-r--r--src/mongo/db/commands/mr.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp
index 31e848d80fd..5edc6a426aa 100644
--- a/src/mongo/db/commands/mr.cpp
+++ b/src/mongo/db/commands/mr.cpp
@@ -96,8 +96,11 @@ namespace mr {
namespace {
Rarely mapParamsDeprecationSampler; // Used to occasionally log deprecation messages.
-// Used to log occassional deprecation warnings when CodeWScope is used in MapReduce.
+// Used to log occasional deprecation warnings when CodeWScope is used in MapReduce.
Rarely mapReduceCodeWScopeSampler;
+// Used to log occasional deprecation warnings when $near or $where are used in MapReduce.
+Rarely mapReduceNearSampler;
+Rarely mapReduceWhereSampler;
/**
@@ -225,6 +228,22 @@ void dropTempCollections(OperationContext* cleanupOpCtx,
ShardConnection::forgetNS(incLong.ns());
}
}
+/**
+ * Recursive method which verifies that the query option specified to mapReduce does not use the
+ * specified match type.
+ */
+bool queryContainsMatchType(MatchExpression* root, MatchExpression::MatchType match) {
+ if (root->matchType() == match) {
+ return false;
+ } else if (root->numChildren() > 0) {
+ for (auto&& child : *(root->getChildVector())) {
+ if (!queryContainsMatchType(child, match)) {
+ return false;
+ }
+ }
+ }
+ return true;
+}
} // namespace
@@ -1545,6 +1564,15 @@ public:
MatchExpressionParser::kAllowAllSpecialFeatures),
str::stream() << "Can't canonicalize query " << config.filter);
+ if (!queryContainsMatchType(cq->root(), MatchExpression::MatchType::GEO_NEAR) &&
+ mapReduceNearSampler.tick()) {
+ warning() << "The use of $near in the query option to MapReduce is deprecated";
+ }
+ if (!queryContainsMatchType(cq->root(), MatchExpression::MatchType::WHERE) &&
+ mapReduceWhereSampler.tick()) {
+ warning() << "The use of $where in the query option to MapReduce is deprecated";
+ }
+
auto exec = uassertStatusOK(getExecutor(opCtx,
scopedAutoColl->getCollection(),
std::move(cq),