summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog/collection_write_path.cpp
diff options
context:
space:
mode:
authorAlberto Massari <alberto.massari@mongodb.com>2022-12-21 19:56:54 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-12-21 21:14:53 +0000
commit5977e706431fd5705b59115ec0e0d2d7a2203246 (patch)
tree2161b9d853c2e7453a19d12b88bd39bc9bf87dd5 /src/mongo/db/catalog/collection_write_path.cpp
parent9ac3279cc3459b31a597ed4659e07ad93f073d8f (diff)
downloadmongo-5977e706431fd5705b59115ec0e0d2d7a2203246.tar.gz
SERVER-65364 Allow fine-grained selection of indexes to update
Diffstat (limited to 'src/mongo/db/catalog/collection_write_path.cpp')
-rw-r--r--src/mongo/db/catalog/collection_write_path.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/mongo/db/catalog/collection_write_path.cpp b/src/mongo/db/catalog/collection_write_path.cpp
index 266f31f42eb..a3fab3026e3 100644
--- a/src/mongo/db/catalog/collection_write_path.cpp
+++ b/src/mongo/db/catalog/collection_write_path.cpp
@@ -400,7 +400,7 @@ RecordId updateDocument(OperationContext* opCtx,
const RecordId& oldLocation,
const Snapshotted<BSONObj>& oldDoc,
const BSONObj& newDoc,
- bool indexesAffected,
+ const BSONObj* opDiff,
OpDebug* opDebug,
CollectionUpdateArgs* args) {
{
@@ -473,7 +473,8 @@ RecordId updateDocument(OperationContext* opCtx,
uassertStatusOK(collection->getRecordStore()->updateRecord(
opCtx, oldLocation, newDoc.objdata(), newDoc.objsize()));
- if (indexesAffected) {
+ // don't update the indexes if kUpdateNoIndexes has been specified.
+ if (opDiff != kUpdateNoIndexes) {
int64_t keysInserted = 0;
int64_t keysDeleted = 0;
@@ -481,6 +482,7 @@ RecordId updateDocument(OperationContext* opCtx,
collection,
args->preImageDoc,
newDoc,
+ opDiff,
oldLocation,
&keysInserted,
&keysDeleted));
@@ -512,7 +514,7 @@ StatusWith<BSONObj> updateDocumentWithDamages(OperationContext* opCtx,
const Snapshotted<BSONObj>& oldDoc,
const char* damageSource,
const mutablebson::DamageVector& damages,
- bool indexesAffected,
+ const BSONObj* opDiff,
OpDebug* opDebug,
CollectionUpdateArgs* args) {
dassert(opCtx->lockState()->isCollectionLockedForMode(collection->ns(), MODE_IX));
@@ -551,12 +553,19 @@ StatusWith<BSONObj> updateDocumentWithDamages(OperationContext* opCtx,
args->changeStreamPreAndPostImagesEnabledForCollection =
collection->isChangeStreamPreAndPostImagesEnabled();
- if (indexesAffected) {
+ // don't update the indexes if kUpdateNoIndexes has been specified.
+ if (opDiff != kUpdateNoIndexes) {
int64_t keysInserted = 0;
int64_t keysDeleted = 0;
- uassertStatusOK(collection->getIndexCatalog()->updateRecord(
- opCtx, collection, oldDoc.value(), args->updatedDoc, loc, &keysInserted, &keysDeleted));
+ uassertStatusOK(collection->getIndexCatalog()->updateRecord(opCtx,
+ collection,
+ oldDoc.value(),
+ args->updatedDoc,
+ opDiff,
+ loc,
+ &keysInserted,
+ &keysDeleted));
if (opDebug) {
opDebug->additiveMetrics.incrementKeysInserted(keysInserted);