summaryrefslogtreecommitdiff
path: root/src/mongo/db/ops
diff options
context:
space:
mode:
authorBernard Gorman <bernard.gorman@gmail.com>2019-05-13 20:02:34 +0100
committerBernard Gorman <bernard.gorman@gmail.com>2019-05-19 11:25:13 +0100
commit209ea38bcc2cfb68e0374e14814fc18461cebc58 (patch)
tree8bd4b6b66901c35b6514918d1c70032f8dc17f42 /src/mongo/db/ops
parentb7a30e03816491a43887ed69a99b95481e83f0fd (diff)
downloadmongo-209ea38bcc2cfb68e0374e14814fc18461cebc58.tar.gz
SERVER-40407 Add support for $$NOW and $$CLUSTER_TIME in the findAndModify command
Diffstat (limited to 'src/mongo/db/ops')
-rw-r--r--src/mongo/db/ops/delete_request.h8
-rw-r--r--src/mongo/db/ops/parsed_delete.cpp17
-rw-r--r--src/mongo/db/ops/parsed_delete.h3
-rw-r--r--src/mongo/db/ops/update_request.h8
4 files changed, 30 insertions, 6 deletions
diff --git a/src/mongo/db/ops/delete_request.h b/src/mongo/db/ops/delete_request.h
index 23b3bc81e42..937297b95ae 100644
--- a/src/mongo/db/ops/delete_request.h
+++ b/src/mongo/db/ops/delete_request.h
@@ -33,6 +33,7 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/namespace_string.h"
+#include "mongo/db/pipeline/runtime_constants_gen.h"
#include "mongo/db/query/plan_executor.h"
namespace mongo {
@@ -60,6 +61,9 @@ public:
void setSort(const BSONObj& sort) {
_sort = sort;
}
+ void setRuntimeConstants(const RuntimeConstants& runtimeConstants) {
+ _runtimeConstants = runtimeConstants;
+ }
void setCollation(const BSONObj& collation) {
_collation = collation;
}
@@ -94,6 +98,9 @@ public:
const BSONObj& getSort() const {
return _sort;
}
+ const boost::optional<RuntimeConstants>& getRuntimeConstants() const {
+ return _runtimeConstants;
+ }
const BSONObj& getCollation() const {
return _collation;
}
@@ -130,6 +137,7 @@ private:
BSONObj _proj;
BSONObj _sort;
BSONObj _collation;
+ boost::optional<RuntimeConstants> _runtimeConstants;
// The statement id of this request.
StmtId _stmtId = kUninitializedStmtId;
bool _multi;
diff --git a/src/mongo/db/ops/parsed_delete.cpp b/src/mongo/db/ops/parsed_delete.cpp
index ad6ec0c25e0..0ce2cbe557a 100644
--- a/src/mongo/db/ops/parsed_delete.cpp
+++ b/src/mongo/db/ops/parsed_delete.cpp
@@ -39,6 +39,7 @@
#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"
@@ -60,6 +61,17 @@ 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();
}
@@ -90,11 +102,12 @@ Status ParsedDelete::parseQueryToCQ() {
qr->setLimit(1);
}
- const boost::intrusive_ptr<ExpressionContext> expCtx;
+ auto expCtx =
+ make_intrusive<ExpressionContext>(_opCtx, _collator.get(), _request->getRuntimeConstants());
auto statusWithCQ =
CanonicalQuery::canonicalize(_opCtx,
std::move(qr),
- expCtx,
+ std::move(expCtx),
extensionsCallback,
MatchExpressionParser::kAllowAllSpecialFeatures);
diff --git a/src/mongo/db/ops/parsed_delete.h b/src/mongo/db/ops/parsed_delete.h
index 73f4bef19e4..724c4a48656 100644
--- a/src/mongo/db/ops/parsed_delete.h
+++ b/src/mongo/db/ops/parsed_delete.h
@@ -107,6 +107,9 @@ 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/update_request.h b/src/mongo/db/ops/update_request.h
index 2e84c575f11..763307a9260 100644
--- a/src/mongo/db/ops/update_request.h
+++ b/src/mongo/db/ops/update_request.h
@@ -219,10 +219,6 @@ public:
builder << " updateModification: " << _updateMod.toString();
builder << " stmtId: " << _stmtId;
- if (_runtimeConstants) {
- builder << "runtimeConstants: " << _runtimeConstants->toBSON().toString();
- }
-
builder << " arrayFilters: [";
bool first = true;
for (auto arrayFilter : _arrayFilters) {
@@ -234,6 +230,10 @@ public:
}
builder << "]";
+ if (_runtimeConstants) {
+ builder << " runtimeConstants: " << _runtimeConstants->toBSON().toString();
+ }
+
builder << " god: " << _god;
builder << " upsert: " << _upsert;
builder << " multi: " << _multi;