summaryrefslogtreecommitdiff
path: root/src/mongo/db/update
diff options
context:
space:
mode:
authorIrina Yatsenko <irina.yatsenko@mongodb.com>2023-04-21 17:43:38 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-04-21 19:15:26 +0000
commite187a5f91a8bf18fefbae4d7b3003bfe8ee89a6c (patch)
tree457ced8bb9379c45eb065f28c590d8ecb49fa66b /src/mongo/db/update
parent252d3c0001afe2cd5027d1354a6ad012de87ba6b (diff)
downloadmongo-e187a5f91a8bf18fefbae4d7b3003bfe8ee89a6c.tar.gz
SERVER-70984 Remove _affectIndices in UpdateDriver in favor of reporting index impact from updateDocument
Diffstat (limited to 'src/mongo/db/update')
-rw-r--r--src/mongo/db/update/update_driver.cpp5
-rw-r--r--src/mongo/db/update/update_driver.h7
-rw-r--r--src/mongo/db/update/update_driver_test.cpp47
3 files changed, 0 insertions, 59 deletions
diff --git a/src/mongo/db/update/update_driver.cpp b/src/mongo/db/update/update_driver.cpp
index be832127f01..ae0970af76d 100644
--- a/src/mongo/db/update/update_driver.cpp
+++ b/src/mongo/db/update/update_driver.cpp
@@ -241,8 +241,6 @@ Status UpdateDriver::update(OperationContext* opCtx,
FieldRefSetWithStorage* modifiedPaths) {
// TODO: assert that update() is called at most once in a !_multi case.
- _affectIndices = _updateType == UpdateType::kReplacement && _indexedFields != nullptr;
-
_logDoc.reset();
UpdateExecutor::ApplyParams applyParams(doc->root(), immutablePaths);
@@ -273,9 +271,6 @@ Status UpdateDriver::update(OperationContext* opCtx,
invariant(_updateExecutor);
auto applyResult = _updateExecutor->applyUpdate(applyParams);
- if (applyResult.indexesAffected) {
- _affectIndices = true;
- }
if (docWasModified) {
*docWasModified = !applyResult.noop;
}
diff --git a/src/mongo/db/update/update_driver.h b/src/mongo/db/update/update_driver.h
index 94d1f73c8d4..3887d8d0222 100644
--- a/src/mongo/db/update/update_driver.h
+++ b/src/mongo/db/update/update_driver.h
@@ -150,9 +150,6 @@ public:
return _updateType;
}
- bool modsAffectIndices() const {
- return _affectIndices;
- }
void refreshIndexKeys(const UpdateIndexData* indexedFields) {
_indexedFields = indexedFields;
}
@@ -244,10 +241,6 @@ private:
boost::intrusive_ptr<ExpressionContext> _expCtx;
- // Are any of the fields mentioned in the mods participating in any index? Is set anew
- // at each call to update.
- bool _affectIndices = false;
-
// Do any of the mods require positional match details when calling 'prepare'?
bool _positional = false;
diff --git a/src/mongo/db/update/update_driver_test.cpp b/src/mongo/db/update/update_driver_test.cpp
index 7cf7888671c..11ddee3878a 100644
--- a/src/mongo/db/update/update_driver_test.cpp
+++ b/src/mongo/db/update/update_driver_test.cpp
@@ -681,52 +681,5 @@ TEST_F(ModifiedPathsTestFixture, ReplaceFullDocumentAlwaysAffectsIndex) {
ASSERT_EQ(_modifiedPaths, "{}");
}
-
-TEST_F(ModifiedPathsTestFixture, PipelineUpdatesAlwaysAffectsIndex) {
- BSONObj spec = fromjson("{$set: {'a.1.b': 1}}");
- mutablebson::Document doc(fromjson("{a: [{b: 0}]}"));
- runUpdate(&doc, std::vector<BSONObj>{spec});
- ASSERT(_driver->modsAffectIndices());
-}
-
-TEST_F(ModifiedPathsTestFixture, DeltaUpdateNotAffectingIndex) {
- BSONObj spec = fromjson("{d: {a: false}}");
- mutablebson::Document doc(fromjson("{a: [{b: 0}]}"));
- runUpdate(&doc,
- write_ops::UpdateModification::parseFromV2Delta(
- spec, write_ops::UpdateModification::DiffOptions{}),
- ""_sd,
- {},
- true /* fromOplog */);
- ASSERT(!_driver->modsAffectIndices());
-
- UpdateIndexData indexData;
- indexData.addPath(FieldRef("p"));
- runUpdate(&doc,
- write_ops::UpdateModification::parseFromV2Delta(
- spec, write_ops::UpdateModification::DiffOptions{}),
- ""_sd,
- {},
- true /* fromOplog */,
- &indexData);
- ASSERT(!_driver->modsAffectIndices());
-}
-
-TEST_F(ModifiedPathsTestFixture, DeltaUpdateAffectingIndex) {
- BSONObj spec = fromjson("{u: {a: 1}}");
- mutablebson::Document doc(fromjson("{a: [{b: 0}]}"));
- UpdateIndexData indexData;
- indexData.addPath(FieldRef("q"));
- indexData.addPath(FieldRef("a.p"));
- runUpdate(&doc,
- write_ops::UpdateModification::parseFromV2Delta(
- spec, write_ops::UpdateModification::DiffOptions{}),
- ""_sd,
- {},
- true /* fromOplog */,
- &indexData);
- ASSERT(_driver->modsAffectIndices());
-}
-
} // namespace
} // namespace mongo