summaryrefslogtreecommitdiff
path: root/src/mongo/db/index/index_descriptor.cpp
diff options
context:
space:
mode:
authorSulabh Mahajan <sulabh.mahajan@mongodb.com>2018-03-12 10:03:42 +1100
committerSulabh Mahajan <sulabh.mahajan@mongodb.com>2018-03-12 10:03:42 +1100
commit421c1e82b30a14b3bca8e2bf5ef9df2745c5ee7a (patch)
treea63ce70d9d793193301cd11f430d736a7c20149d /src/mongo/db/index/index_descriptor.cpp
parentffde025012ca20c0376a22e3a0f52c1887d03a70 (diff)
downloadmongo-421c1e82b30a14b3bca8e2bf5ef9df2745c5ee7a.tar.gz
SERVER-33607 Use kV2Unique version for new Unique indexes only
Diffstat (limited to 'src/mongo/db/index/index_descriptor.cpp')
-rw-r--r--src/mongo/db/index/index_descriptor.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/mongo/db/index/index_descriptor.cpp b/src/mongo/db/index/index_descriptor.cpp
index 9c72069f191..ca9ea36ece0 100644
--- a/src/mongo/db/index/index_descriptor.cpp
+++ b/src/mongo/db/index/index_descriptor.cpp
@@ -130,11 +130,19 @@ Status IndexDescriptor::isIndexVersionAllowedForCreation(
}
IndexVersion IndexDescriptor::getDefaultIndexVersion(
- ServerGlobalParams::FeatureCompatibility::Version featureCompatibilityVersion) {
+ ServerGlobalParams::FeatureCompatibility::Version featureCompatibilityVersion,
+ bool isUniqueIndex) {
// The gating variable would allow creation of V2 format unique index when set to true.
+ // Note: Here "isUniqueIndex" only considers whether or not "unique" field is specified
+ // and that its value evaluates to true. "_id" index for instance is unique, but the
+ // index spec for it doesn't carry a "unique" field. "isUniqueIndex" being false for
+ // "_id" indexes is on purpose, and in future if we were to make "_id" index specs
+ // include "unique:true", then we would need to change the logic here to preserve its
+ // behavior.
const bool useV2UniqueIndexFormat = false;
- if (useV2UniqueIndexFormat)
+ if (useV2UniqueIndexFormat && isUniqueIndex) {
return IndexVersion::kV2Unique;
+ }
return IndexVersion::kV2;
}