summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMickey. J Winters <mickey.winters@mongodb.com>2022-03-15 22:45:20 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-03-16 00:05:44 +0000
commit04d14e9675539103de563ffa250380538206ee93 (patch)
treecb37d1ec7a8f77de36cf202e59acafeb3d01ea36
parent30f48983c02e18b8af6303526582d05c8bff865b (diff)
downloadmongo-04d14e9675539103de563ffa250380538206ee93.tar.gz
SERVER-63050 add ability to check if no foreign namespaces are involved in an aggregation
-rw-r--r--src/mongo/db/namespace_string.h3
-rw-r--r--src/mongo/db/pipeline/expression_context.h9
2 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo/db/namespace_string.h b/src/mongo/db/namespace_string.h
index 505eb9d3130..f511a6a3f04 100644
--- a/src/mongo/db/namespace_string.h
+++ b/src/mongo/db/namespace_string.h
@@ -452,6 +452,9 @@ public:
return coll().startsWith("$cmd."_sd);
}
+ /**
+ * NOTE an aggregate could still refer to another collection using a stage like $out.
+ */
bool isCollectionlessAggregateNS() const;
bool isListCollectionsCursorNS() const;
diff --git a/src/mongo/db/pipeline/expression_context.h b/src/mongo/db/pipeline/expression_context.h
index 9334cd4ecff..15a0d15ed48 100644
--- a/src/mongo/db/pipeline/expression_context.h
+++ b/src/mongo/db/pipeline/expression_context.h
@@ -290,6 +290,15 @@ public:
};
/**
+ * Returns true if there are no namespaces in the query other than the namespace the query was
+ * issued against. eg if there is no $out, $lookup ect. If namespaces have not yet been resolved
+ * then it will also return false.
+ */
+ bool noForeignNamespaces() const {
+ return _resolvedNamespaces.empty();
+ }
+
+ /**
* Convenience call that returns true if the tailableMode indicates a tailable and awaitData
* query.
*/