diff options
author | Pavi Vetriselvan <pavithra.vetriselvan@mongodb.com> | 2022-02-24 15:20:53 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-02-24 16:22:57 +0000 |
commit | a23d9da0518f79325b7dda04796dba0f856a08cd (patch) | |
tree | d31b1cd5ec01588521cb59860b0135d1f2e0612e /src/mongo/db/index | |
parent | 07ec8eb7a18490026a8a716f359a2d5c416e0006 (diff) | |
download | mongo-a23d9da0518f79325b7dda04796dba0f856a08cd.tar.gz |
SERVER-63664 Rename disallowNewDuplicateKeys option to prepareUnique
Diffstat (limited to 'src/mongo/db/index')
-rw-r--r-- | src/mongo/db/index/index_access_method.cpp | 8 | ||||
-rw-r--r-- | src/mongo/db/index/index_descriptor.cpp | 9 | ||||
-rw-r--r-- | src/mongo/db/index/index_descriptor.h | 8 |
3 files changed, 12 insertions, 13 deletions
diff --git a/src/mongo/db/index/index_access_method.cpp b/src/mongo/db/index/index_access_method.cpp index aa0f401c91c..be710445eb1 100644 --- a/src/mongo/db/index/index_access_method.cpp +++ b/src/mongo/db/index/index_access_method.cpp @@ -268,7 +268,7 @@ Status SortedDataIndexAccessMethod::insertKeys(OperationContext* opCtx, *numInserted = 0; } bool unique = _descriptor->unique(); - bool disallowNewDuplicateKeys = _descriptor->disallowNewDuplicateKeys(); + bool prepareUnique = _descriptor->prepareUnique(); bool dupsAllowed; if (!_descriptor->isIdIndex() && !opCtx->isEnforcingConstraints() && coll->isIndexReady(_descriptor->indexName())) { @@ -280,7 +280,7 @@ Status SortedDataIndexAccessMethod::insertKeys(OperationContext* opCtx, // Additionally, unique indexes conflict checking can cause out-of-order updates in // wiredtiger. See SERVER-59831. dupsAllowed = true; - } else if (disallowNewDuplicateKeys) { + } else if (prepareUnique) { // This currently is only used by collMod command when converting a regular index to a // unique index. The regular index will start rejecting duplicates even before the // conversion finishes. @@ -295,7 +295,7 @@ Status SortedDataIndexAccessMethod::insertKeys(OperationContext* opCtx, // When duplicates are encountered and allowed, retry with dupsAllowed. Call // onDuplicateKey() with the inserted duplicate key. if (ErrorCodes::DuplicateKey == result.getStatus().code() && options.dupsAllowed && - !disallowNewDuplicateKeys) { + !prepareUnique) { invariant(unique); result = _newInterface->insert(opCtx, keyString, true /* dupsAllowed */); @@ -542,7 +542,7 @@ Status SortedDataIndexAccessMethod::doUpdate(OperationContext* opCtx, // Add all new data keys into the index. for (const auto& keyString : ticket.added) { - bool dupsAllowed = !_descriptor->disallowNewDuplicateKeys() && ticket.dupsAllowed; + bool dupsAllowed = !_descriptor->prepareUnique() && ticket.dupsAllowed; auto result = _newInterface->insert(opCtx, keyString, dupsAllowed); if (!result.isOK()) return result.getStatus(); diff --git a/src/mongo/db/index/index_descriptor.cpp b/src/mongo/db/index/index_descriptor.cpp index b276fb9b38c..3f4dbd088ed 100644 --- a/src/mongo/db/index/index_descriptor.cpp +++ b/src/mongo/db/index/index_descriptor.cpp @@ -107,7 +107,7 @@ constexpr StringData IndexDescriptor::kTextVersionFieldName; constexpr StringData IndexDescriptor::kUniqueFieldName; constexpr StringData IndexDescriptor::kHiddenFieldName; constexpr StringData IndexDescriptor::kWeightsFieldName; -constexpr StringData IndexDescriptor::kDisallowNewDuplicateKeysFieldName; +constexpr StringData IndexDescriptor::kPrepareUniqueFieldName; IndexDescriptor::IndexDescriptor(const std::string& accessMethodName, BSONObj infoObj) : _accessMethodName(accessMethodName), @@ -136,13 +136,12 @@ IndexDescriptor::IndexDescriptor(const std::string& accessMethodName, BSONObj in _collation = collationElement.Obj().getOwned(); } - if (BSONElement disallowNewDuplicateKeysElement = - _infoObj[kDisallowNewDuplicateKeysFieldName]) { + if (BSONElement prepareUniqueElement = _infoObj[kPrepareUniqueFieldName]) { uassert( ErrorCodes::InvalidOptions, - "Index does not support the 'disallowNewDuplicateKeys' field", + "Index does not support the 'prepareUnique' field", feature_flags::gCollModIndexUnique.isEnabled(serverGlobalParams.featureCompatibility)); - _disallowNewDuplicateKeys = disallowNewDuplicateKeysElement.trueValue(); + _prepareUnique = prepareUniqueElement.trueValue(); } } diff --git a/src/mongo/db/index/index_descriptor.h b/src/mongo/db/index/index_descriptor.h index 35a005371b4..f4f48cb35b9 100644 --- a/src/mongo/db/index/index_descriptor.h +++ b/src/mongo/db/index/index_descriptor.h @@ -88,7 +88,7 @@ public: static constexpr StringData kUniqueFieldName = "unique"_sd; static constexpr StringData kWeightsFieldName = "weights"_sd; static constexpr StringData kOriginalSpecFieldName = "originalSpec"_sd; - static constexpr StringData kDisallowNewDuplicateKeysFieldName = "disallowNewDuplicateKeys"_sd; + static constexpr StringData kPrepareUniqueFieldName = "prepareUnique"_sd; /** * infoObj is a copy of the index-describing BSONObj contained in the catalog. @@ -227,8 +227,8 @@ public: return _partialFilterExpression; } - bool disallowNewDuplicateKeys() const { - return _disallowNewDuplicateKeys; + bool prepareUnique() const { + return _prepareUnique; } /** @@ -280,7 +280,7 @@ private: IndexVersion _version; BSONObj _collation; BSONObj _partialFilterExpression; - bool _disallowNewDuplicateKeys = false; + bool _prepareUnique = false; // Many query stages require going from an IndexDescriptor to its IndexCatalogEntry, so for // now we need this. |