summaryrefslogtreecommitdiff
path: root/src/mongo/db/ops/write_ops_parsers.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/ops/write_ops_parsers.h')
-rw-r--r--src/mongo/db/ops/write_ops_parsers.h34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/mongo/db/ops/write_ops_parsers.h b/src/mongo/db/ops/write_ops_parsers.h
index 900740b271b..22608793005 100644
--- a/src/mongo/db/ops/write_ops_parsers.h
+++ b/src/mongo/db/ops/write_ops_parsers.h
@@ -84,23 +84,27 @@ public:
/**
* Used to indicate that a certain type of update is being passed to the constructor.
*/
- struct DiffTag {};
+ struct DiffOptions {
+ bool mustCheckExistenceForInsertOperations = true;
+ };
struct ClassicTag {};
// Given the 'o' field of an update oplog entry, will return an UpdateModification that can be
- // applied.
- static UpdateModification parseFromOplogEntry(const BSONObj& oField);
+ // applied. The `options` parameter will be applied only in the case a Delta update is parsed.
+ static UpdateModification parseFromOplogEntry(const BSONObj& oField,
+ const DiffOptions& options);
static UpdateModification parseFromClassicUpdate(const BSONObj& modifiers) {
return UpdateModification(modifiers, ClassicTag{});
}
- static UpdateModification parseFromV2Delta(const doc_diff::Diff& diff) {
- return UpdateModification(diff, DiffTag{});
+ static UpdateModification parseFromV2Delta(const doc_diff::Diff& diff,
+ DiffOptions const& options) {
+ return UpdateModification(diff, options);
}
UpdateModification() = default;
UpdateModification(BSONElement update);
UpdateModification(std::vector<BSONObj> pipeline);
- UpdateModification(doc_diff::Diff, DiffTag);
+ UpdateModification(doc_diff::Diff, DiffOptions);
// This constructor exists only to provide a fast-path for constructing classic-style updates.
UpdateModification(const BSONObj& update, ClassicTag);
@@ -143,7 +147,12 @@ public:
doc_diff::Diff getDiff() const {
invariant(type() == Type::kDelta);
- return stdx::get<doc_diff::Diff>(_update);
+ return stdx::get<DeltaUpdate>(_update).diff;
+ }
+
+ bool mustCheckExistenceForInsertOperations() const {
+ invariant(type() == Type::kDelta);
+ return stdx::get<DeltaUpdate>(_update).options.mustCheckExistenceForInsertOperations;
}
std::string toString() const {
@@ -157,8 +166,9 @@ public:
sb << "{type: Pipeline, update: "
<< Value(pipeline).toString() << "}";
},
- [&sb](const doc_diff::Diff& diff) {
- sb << "{type: Delta, update: " << diff << "}";
+ [&sb](const DeltaUpdate& delta) {
+ sb << "{type: Delta, update: " << delta.diff
+ << "}";
}},
_update);
@@ -171,7 +181,11 @@ private:
BSONObj bson;
};
using PipelineUpdate = std::vector<BSONObj>;
- stdx::variant<ClassicUpdate, PipelineUpdate, doc_diff::Diff> _update;
+ struct DeltaUpdate {
+ doc_diff::Diff diff;
+ DiffOptions options;
+ };
+ stdx::variant<ClassicUpdate, PipelineUpdate, DeltaUpdate> _update;
};
} // namespace write_ops