diff options
author | Nick Zolnierz <nicholas.zolnierz@mongodb.com> | 2019-05-15 12:48:54 -0400 |
---|---|---|
committer | Nick Zolnierz <nicholas.zolnierz@mongodb.com> | 2019-05-16 10:49:20 -0400 |
commit | 87c686b32ae4e59bea88f42e4a1d6fcb90c4f146 (patch) | |
tree | fcd9bfcae914b446baf99174a412fc685faacf47 /src/mongo/db/ops | |
parent | 06c7e27f2e7a668d81baf02d89f422cdda205fce (diff) | |
download | mongo-87c686b32ae4e59bea88f42e4a1d6fcb90c4f146.tar.gz |
SERVER-41022 Remove dependency on expressions_mongod_only in parsed_update library
Diffstat (limited to 'src/mongo/db/ops')
-rw-r--r-- | src/mongo/db/ops/SConscript | 1 | ||||
-rw-r--r-- | src/mongo/db/ops/parsed_update.cpp | 12 | ||||
-rw-r--r-- | src/mongo/db/ops/parsed_update.h | 11 | ||||
-rw-r--r-- | src/mongo/db/ops/update.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/ops/write_ops_exec.cpp | 7 |
5 files changed, 22 insertions, 13 deletions
diff --git a/src/mongo/db/ops/SConscript b/src/mongo/db/ops/SConscript index 9e679932d08..8f1df866c99 100644 --- a/src/mongo/db/ops/SConscript +++ b/src/mongo/db/ops/SConscript @@ -56,7 +56,6 @@ env.Library( source='parsed_update.cpp', LIBDEPS=[ '$BUILD_DIR/mongo/base', - '$BUILD_DIR/mongo/db/matcher/expressions_mongod_only', '$BUILD_DIR/mongo/db/update/update_driver', ], ) diff --git a/src/mongo/db/ops/parsed_update.cpp b/src/mongo/db/ops/parsed_update.cpp index 5e489071cf5..acedfc48d8a 100644 --- a/src/mongo/db/ops/parsed_update.cpp +++ b/src/mongo/db/ops/parsed_update.cpp @@ -31,7 +31,6 @@ #include "mongo/db/ops/parsed_update.h" -#include "mongo/db/matcher/extensions_callback_real.h" #include "mongo/db/ops/update_request.h" #include "mongo/db/query/canonical_query.h" #include "mongo/db/query/collation/collator_factory_interface.h" @@ -40,11 +39,14 @@ namespace mongo { -ParsedUpdate::ParsedUpdate(OperationContext* opCtx, const UpdateRequest* request) +ParsedUpdate::ParsedUpdate(OperationContext* opCtx, + const UpdateRequest* request, + const ExtensionsCallback& extensionsCallback) : _opCtx(opCtx), _request(request), _driver(new ExpressionContext(opCtx, nullptr)), - _canonicalQuery() {} + _canonicalQuery(), + _extensionsCallback(extensionsCallback) {} Status ParsedUpdate::parseRequest() { // It is invalid to request that the UpdateStage return the prior or newly-updated version @@ -95,8 +97,6 @@ Status ParsedUpdate::parseQuery() { Status ParsedUpdate::parseQueryToCQ() { dassert(!_canonicalQuery.get()); - const ExtensionsCallbackReal extensionsCallback(_opCtx, &_request->getNamespaceString()); - // The projection needs to be applied after the update operation, so we do not specify a // projection during canonicalization. auto qr = stdx::make_unique<QueryRequest>(_request->getNamespaceString()); @@ -125,7 +125,7 @@ Status ParsedUpdate::parseQueryToCQ() { boost::intrusive_ptr<ExpressionContext> expCtx; auto statusWithCQ = CanonicalQuery::canonicalize( - _opCtx, std::move(qr), std::move(expCtx), extensionsCallback, allowedMatcherFeatures); + _opCtx, std::move(qr), std::move(expCtx), _extensionsCallback, allowedMatcherFeatures); if (statusWithCQ.isOK()) { _canonicalQuery = std::move(statusWithCQ.getValue()); } diff --git a/src/mongo/db/ops/parsed_update.h b/src/mongo/db/ops/parsed_update.h index da983db9f1f..3764b5f85d2 100644 --- a/src/mongo/db/ops/parsed_update.h +++ b/src/mongo/db/ops/parsed_update.h @@ -71,10 +71,12 @@ public: /** * Constructs a parsed update. * - * The object pointed to by "request" must stay in scope for the life of the constructed - * ParsedUpdate. + * The objects pointed to by "request" and "extensionsCallback" must stay in scope for the life + * of the constructed ParsedUpdate. */ - ParsedUpdate(OperationContext* opCtx, const UpdateRequest* request); + ParsedUpdate(OperationContext* opCtx, + const UpdateRequest* request, + const ExtensionsCallback& extensionsCallback); /** * Parses the update request to a canonical query and an update driver. On success, the @@ -167,6 +169,9 @@ private: // Parsed query object, or NULL if the query proves to be an id hack query. std::unique_ptr<CanonicalQuery> _canonicalQuery; + + // Reference to an extensions callback used when parsing to a canonical query. + const ExtensionsCallback& _extensionsCallback; }; } // namespace mongo diff --git a/src/mongo/db/ops/update.cpp b/src/mongo/db/ops/update.cpp index e42c6786f2a..a506bb88c0c 100644 --- a/src/mongo/db/ops/update.cpp +++ b/src/mongo/db/ops/update.cpp @@ -41,6 +41,7 @@ #include "mongo/db/concurrency/d_concurrency.h" #include "mongo/db/concurrency/write_conflict_exception.h" #include "mongo/db/exec/update_stage.h" +#include "mongo/db/matcher/extensions_callback_real.h" #include "mongo/db/op_observer.h" #include "mongo/db/query/explain.h" #include "mongo/db/query/get_executor.h" @@ -92,7 +93,8 @@ UpdateResult update(OperationContext* opCtx, Database* db, const UpdateRequest& } // Parse the update, get an executor for it, run the executor, get stats out. - ParsedUpdate parsedUpdate(opCtx, &request); + const ExtensionsCallbackReal extensionsCallback(opCtx, &request.getNamespaceString()); + ParsedUpdate parsedUpdate(opCtx, &request, extensionsCallback); uassertStatusOK(parsedUpdate.parseRequest()); OpDebug* const nullOpDebug = nullptr; diff --git a/src/mongo/db/ops/write_ops_exec.cpp b/src/mongo/db/ops/write_ops_exec.cpp index 2f01873221a..3bab66af9ae 100644 --- a/src/mongo/db/ops/write_ops_exec.cpp +++ b/src/mongo/db/ops/write_ops_exec.cpp @@ -50,6 +50,7 @@ #include "mongo/db/exec/update_stage.h" #include "mongo/db/introspect.h" #include "mongo/db/lasterror.h" +#include "mongo/db/matcher/extensions_callback_real.h" #include "mongo/db/ops/delete_request.h" #include "mongo/db/ops/insert.h" #include "mongo/db/ops/parsed_delete.h" @@ -590,7 +591,8 @@ static SingleWriteResult performSingleUpdateOp(OperationContext* opCtx, const NamespaceString& ns, StmtId stmtId, const UpdateRequest& updateRequest) { - ParsedUpdate parsedUpdate(opCtx, &updateRequest); + const ExtensionsCallbackReal extensionsCallback(opCtx, &updateRequest.getNamespaceString()); + ParsedUpdate parsedUpdate(opCtx, &updateRequest, extensionsCallback); uassertStatusOK(parsedUpdate.parseRequest()); CurOpFailpointHelpers::waitWhileFailPointEnabled( @@ -724,7 +726,8 @@ static SingleWriteResult performSingleUpdateOpWithDupKeyRetry(OperationContext* try { return performSingleUpdateOp(opCtx, ns, stmtId, request); } catch (ExceptionFor<ErrorCodes::DuplicateKey>& ex) { - ParsedUpdate parsedUpdate(opCtx, &request); + const ExtensionsCallbackReal extensionsCallback(opCtx, &request.getNamespaceString()); + ParsedUpdate parsedUpdate(opCtx, &request, extensionsCallback); uassertStatusOK(parsedUpdate.parseRequest()); if (!parsedUpdate.hasParsedQuery()) { |