diff options
author | Bernard Gorman <bernard.gorman@gmail.com> | 2019-05-22 13:10:17 +0100 |
---|---|---|
committer | Bernard Gorman <bernard.gorman@gmail.com> | 2019-05-24 15:27:25 +0100 |
commit | ec6f2325a99b6ddd13af6903eed12ced95e4bea8 (patch) | |
tree | f225a28dc123f6e1ca0f32b1fee4202cee051db5 /src/mongo/db/ops | |
parent | 8d5727273585524a38d4a663b61403a263f7cf3d (diff) | |
download | mongo-ec6f2325a99b6ddd13af6903eed12ced95e4bea8.tar.gz |
SERVER-41238 Allow $$NOW and $$CLUSTER_TIME to be used in the find command
Diffstat (limited to 'src/mongo/db/ops')
-rw-r--r-- | src/mongo/db/ops/delete_request.h | 4 | ||||
-rw-r--r-- | src/mongo/db/ops/parsed_delete.cpp | 20 | ||||
-rw-r--r-- | src/mongo/db/ops/parsed_delete.h | 3 | ||||
-rw-r--r-- | src/mongo/db/ops/parsed_update.cpp | 8 | ||||
-rw-r--r-- | src/mongo/db/ops/update_request.h | 4 |
5 files changed, 16 insertions, 23 deletions
diff --git a/src/mongo/db/ops/delete_request.h b/src/mongo/db/ops/delete_request.h index 937297b95ae..a49e6eb37b9 100644 --- a/src/mongo/db/ops/delete_request.h +++ b/src/mongo/db/ops/delete_request.h @@ -61,8 +61,8 @@ public: void setSort(const BSONObj& sort) { _sort = sort; } - void setRuntimeConstants(const RuntimeConstants& runtimeConstants) { - _runtimeConstants = runtimeConstants; + void setRuntimeConstants(RuntimeConstants runtimeConstants) { + _runtimeConstants = std::move(runtimeConstants); } void setCollation(const BSONObj& collation) { _collation = collation; diff --git a/src/mongo/db/ops/parsed_delete.cpp b/src/mongo/db/ops/parsed_delete.cpp index 0ce2cbe557a..c0b757fe69e 100644 --- a/src/mongo/db/ops/parsed_delete.cpp +++ b/src/mongo/db/ops/parsed_delete.cpp @@ -39,7 +39,6 @@ #include "mongo/db/matcher/extensions_callback_real.h" #include "mongo/db/ops/delete_request.h" #include "mongo/db/query/canonical_query.h" -#include "mongo/db/query/collation/collator_factory_interface.h" #include "mongo/db/query/get_executor.h" #include "mongo/db/query/query_planner_common.h" #include "mongo/util/assert_util.h" @@ -61,17 +60,6 @@ Status ParsedDelete::parseRequest() { // DeleteStage would not return the deleted document. invariant(_request->getProj().isEmpty() || _request->shouldReturnDeleted()); - // Parse the delete request's collation, if present. This will subsequently be used to - // initialize an ExpressionContext for the query. - if (!_request->getCollation().isEmpty()) { - auto collator = CollatorFactoryInterface::get(_opCtx->getServiceContext()) - ->makeFromBSON(_request->getCollation()); - if (!collator.isOK()) { - return collator.getStatus(); - } - _collator = std::move(collator.getValue()); - } - if (CanonicalQuery::isSimpleIdQuery(_request->getQuery())) { return Status::OK(); } @@ -102,8 +90,12 @@ Status ParsedDelete::parseQueryToCQ() { qr->setLimit(1); } - auto expCtx = - make_intrusive<ExpressionContext>(_opCtx, _collator.get(), _request->getRuntimeConstants()); + // If the delete request has runtime constants attached to it, pass them to the QueryRequest. + if (auto& runtimeConstants = _request->getRuntimeConstants()) { + qr->setRuntimeConstants(*runtimeConstants); + } + + const boost::intrusive_ptr<ExpressionContext> expCtx; auto statusWithCQ = CanonicalQuery::canonicalize(_opCtx, std::move(qr), diff --git a/src/mongo/db/ops/parsed_delete.h b/src/mongo/db/ops/parsed_delete.h index 724c4a48656..73f4bef19e4 100644 --- a/src/mongo/db/ops/parsed_delete.h +++ b/src/mongo/db/ops/parsed_delete.h @@ -107,9 +107,6 @@ private: // Unowned pointer to the request object that this executor will process. const DeleteRequest* const _request; - // The collator for the parsed delete's expression context. - std::unique_ptr<CollatorInterface> _collator; - // Parsed query object, or NULL if the query proves to be an id hack query. std::unique_ptr<CanonicalQuery> _canonicalQuery; }; diff --git a/src/mongo/db/ops/parsed_update.cpp b/src/mongo/db/ops/parsed_update.cpp index 79e1d9ed692..67215128ce0 100644 --- a/src/mongo/db/ops/parsed_update.cpp +++ b/src/mongo/db/ops/parsed_update.cpp @@ -123,8 +123,12 @@ Status ParsedUpdate::parseQueryToCQ() { allowedMatcherFeatures &= ~MatchExpressionParser::AllowedFeatures::kExpr; } - auto expCtx = - make_intrusive<ExpressionContext>(_opCtx, _collator.get(), _request->getRuntimeConstants()); + // If the update request has runtime constants attached to it, pass them to the QueryRequest. + if (auto& runtimeConstants = _request->getRuntimeConstants()) { + qr->setRuntimeConstants(*runtimeConstants); + } + + boost::intrusive_ptr<ExpressionContext> expCtx; auto statusWithCQ = CanonicalQuery::canonicalize( _opCtx, std::move(qr), std::move(expCtx), _extensionsCallback, allowedMatcherFeatures); if (statusWithCQ.isOK()) { diff --git a/src/mongo/db/ops/update_request.h b/src/mongo/db/ops/update_request.h index e0f99abf1d4..ee30cc6a827 100644 --- a/src/mongo/db/ops/update_request.h +++ b/src/mongo/db/ops/update_request.h @@ -119,8 +119,8 @@ public: return _updateConstants; } - inline void setRuntimeConstants(const RuntimeConstants& runtimeConstants) { - _runtimeConstants = runtimeConstants; + inline void setRuntimeConstants(RuntimeConstants runtimeConstants) { + _runtimeConstants = std::move(runtimeConstants); } inline const boost::optional<RuntimeConstants>& getRuntimeConstants() const { |