summaryrefslogtreecommitdiff
path: root/src/mongo/db/update
diff options
context:
space:
mode:
authorRui Liu <rui.liu@mongodb.com>2022-02-09 16:42:49 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-02-22 16:30:10 +0000
commita3158ab422e4d8091203166c5f2601f9bfa0099d (patch)
treee77ce6c99e6a1077bdcebb9ace2ec1e94c75f50e /src/mongo/db/update
parent6ca25c9e65eeb1420a4dce3cba9ae4991d6106e7 (diff)
downloadmongo-a3158ab422e4d8091203166c5f2601f9bfa0099d.tar.gz
SERVER-63428 Robustify oplog applying code for update operation
Diffstat (limited to 'src/mongo/db/update')
-rw-r--r--src/mongo/db/update/update_driver.cpp12
-rw-r--r--src/mongo/db/update/update_driver.h2
2 files changed, 3 insertions, 11 deletions
diff --git a/src/mongo/db/update/update_driver.cpp b/src/mongo/db/update/update_driver.cpp
index f2eded44c39..5ce9dc8aa84 100644
--- a/src/mongo/db/update/update_driver.cpp
+++ b/src/mongo/db/update/update_driver.cpp
@@ -154,12 +154,12 @@ void UpdateDriver::parse(
uassert(51198, "Constant values may only be specified for pipeline updates", !constants);
// Check if the update expression is a full object replacement.
- if (isDocReplacement(updateMod)) {
+ if (updateMod.type() == write_ops::UpdateModification::Type::kReplacement) {
uassert(ErrorCodes::FailedToParse,
"multi update is not supported for replacement-style update",
!multi);
- _updateExecutor = std::make_unique<ObjectReplaceExecutor>(updateMod.getUpdateClassic());
+ _updateExecutor = std::make_unique<ObjectReplaceExecutor>(updateMod.getUpdateReplacement());
// Register the fact that this driver will only do full object replacements.
_updateType = UpdateType::kReplacement;
@@ -185,7 +185,7 @@ void UpdateDriver::parse(
// checked whether this is a delta update so we check that the $v field isn't present, or has a
// value of 1.
- auto updateExpr = updateMod.getUpdateClassic();
+ auto updateExpr = updateMod.getUpdateModifier();
BSONElement versionElement = updateExpr[kUpdateOplogEntryVersionFieldName];
if (versionElement) {
uassert(ErrorCodes::FailedToParse,
@@ -321,10 +321,4 @@ void UpdateDriver::setCollator(const CollatorInterface* collator) {
}
}
-bool UpdateDriver::isDocReplacement(const write_ops::UpdateModification& updateMod) {
- return (updateMod.type() == write_ops::UpdateModification::Type::kClassic &&
- *updateMod.getUpdateClassic().firstElementFieldName() != '$') ||
- updateMod.type() == write_ops::UpdateModification::Type::kPipeline;
-}
-
} // namespace mongo
diff --git a/src/mongo/db/update/update_driver.h b/src/mongo/db/update/update_driver.h
index d512d89b1cf..94d1f73c8d4 100644
--- a/src/mongo/db/update/update_driver.h
+++ b/src/mongo/db/update/update_driver.h
@@ -150,8 +150,6 @@ public:
return _updateType;
}
- static bool isDocReplacement(const write_ops::UpdateModification& updateMod);
-
bool modsAffectIndices() const {
return _affectIndices;
}