summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Percy <david.percy@mongodb.com>2020-10-05 20:48:19 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-11-20 23:03:16 +0000
commit3637210a683c8f264c334efd246228d217508cd1 (patch)
tree0040c096ead88d9143d89afaf5e9d48b40d293b6 /src
parent50b1baeb68b061638303ed54a11eb4e84afde4b9 (diff)
downloadmongo-3637210a683c8f264c334efd246228d217508cd1.tar.gz
SERVER-51454 Ensure agg parser is initialized before defaultProfileFilter
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/pipeline/expression.cpp7
-rw-r--r--src/mongo/db/pipeline/expression.h18
-rw-r--r--src/mongo/db/profile_filter_impl.cpp2
3 files changed, 18 insertions, 9 deletions
diff --git a/src/mongo/db/pipeline/expression.cpp b/src/mongo/db/pipeline/expression.cpp
index 518bc8638ca..8d72d2da5dc 100644
--- a/src/mongo/db/pipeline/expression.cpp
+++ b/src/mongo/db/pipeline/expression.cpp
@@ -6568,4 +6568,11 @@ void ExpressionRandom::_doAddDependencies(DepsTracker* deps) const {
Value ExpressionRandom::serialize(const bool explain) const {
return Value(DOC(getOpName() << Document()));
}
+
+MONGO_INITIALIZER(expressionParserMap)(InitializerContext*) {
+ // Nothing to do. This initializer exists to tie together all the individual initializers
+ // defined by REGISTER_EXPRESSION / REGISTER_EXPRESSION_WITH_MIN_VERSION.
+ return Status::OK();
+}
+
} // namespace mongo
diff --git a/src/mongo/db/pipeline/expression.h b/src/mongo/db/pipeline/expression.h
index 527cee413c2..3eb35d8d98e 100644
--- a/src/mongo/db/pipeline/expression.h
+++ b/src/mongo/db/pipeline/expression.h
@@ -68,10 +68,11 @@ class DocumentSource;
*
* An expression registered this way can be used in any featureCompatibilityVersion.
*/
-#define REGISTER_EXPRESSION(key, parser) \
- MONGO_INITIALIZER(addToExpressionParserMap_##key)(InitializerContext*) { \
- Expression::registerExpression("$" #key, (parser), boost::none); \
- return Status::OK(); \
+#define REGISTER_EXPRESSION(key, parser) \
+ MONGO_INITIALIZER_GENERAL(addToExpressionParserMap_##key, (), ("expressionParserMap")) \
+ (InitializerContext*) { \
+ Expression::registerExpression("$" #key, (parser), boost::none); \
+ return Status::OK(); \
}
/**
@@ -83,10 +84,11 @@ class DocumentSource;
* compatibility version >= X, you would add this line:
* REGISTER_EXPRESSION_WITH_MIN_VERSION(foo, ExpressionFoo::parse, X);
*/
-#define REGISTER_EXPRESSION_WITH_MIN_VERSION(key, parser, minVersion) \
- MONGO_INITIALIZER(addToExpressionParserMap_##key)(InitializerContext*) { \
- Expression::registerExpression("$" #key, (parser), (minVersion)); \
- return Status::OK(); \
+#define REGISTER_EXPRESSION_WITH_MIN_VERSION(key, parser, minVersion) \
+ MONGO_INITIALIZER_GENERAL(addToExpressionParserMap_##key, (), ("expressionParserMap")) \
+ (InitializerContext*) { \
+ Expression::registerExpression("$" #key, (parser), (minVersion)); \
+ return Status::OK(); \
}
class Expression : public RefCountable {
diff --git a/src/mongo/db/profile_filter_impl.cpp b/src/mongo/db/profile_filter_impl.cpp
index 92c44a916a4..7f76083bd22 100644
--- a/src/mongo/db/profile_filter_impl.cpp
+++ b/src/mongo/db/profile_filter_impl.cpp
@@ -76,7 +76,7 @@ bool ProfileFilterImpl::matches(OperationContext* opCtx,
// PathlessOperatorMap is required for parsing a MatchExpression.
MONGO_INITIALIZER_GENERAL(ProfileFilterDefault,
- ("PathlessOperatorMap", "MatchExpressionParser"),
+ ("PathlessOperatorMap", "MatchExpressionParser", "expressionParserMap"),
())
(InitializerContext*) {
try {