diff options
author | David Percy <david.percy@mongodb.com> | 2020-10-05 20:48:19 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-11-20 23:03:16 +0000 |
commit | 3637210a683c8f264c334efd246228d217508cd1 (patch) | |
tree | 0040c096ead88d9143d89afaf5e9d48b40d293b6 /src | |
parent | 50b1baeb68b061638303ed54a11eb4e84afde4b9 (diff) | |
download | mongo-3637210a683c8f264c334efd246228d217508cd1.tar.gz |
SERVER-51454 Ensure agg parser is initialized before defaultProfileFilter
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/pipeline/expression.cpp | 7 | ||||
-rw-r--r-- | src/mongo/db/pipeline/expression.h | 18 | ||||
-rw-r--r-- | src/mongo/db/profile_filter_impl.cpp | 2 |
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 { |