diff options
Diffstat (limited to 'src/mongo')
| -rw-r--r-- | src/mongo/db/catalog/coll_mod.cpp | 2 | ||||
| -rw-r--r-- | src/mongo/db/catalog/index_key_validate.cpp | 11 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/mongo/db/catalog/coll_mod.cpp b/src/mongo/db/catalog/coll_mod.cpp index 5e23537afde..713c967a0b2 100644 --- a/src/mongo/db/catalog/coll_mod.cpp +++ b/src/mongo/db/catalog/coll_mod.cpp @@ -1055,7 +1055,7 @@ Status _collModInternal(OperationContext* opCtx, writableColl->repairInvalidIndexOptions(opCtx); for (const auto& indexWithInvalidOptions : indexesWithInvalidOptions) { const IndexDescriptor* desc = - coll->getIndexCatalog()->findIndexByName(opCtx, indexWithInvalidOptions); + writableColl->getIndexCatalog()->findIndexByName(opCtx, indexWithInvalidOptions); invariant(desc); // Notify the index catalog that the definition of this index changed. diff --git a/src/mongo/db/catalog/index_key_validate.cpp b/src/mongo/db/catalog/index_key_validate.cpp index 67b907f80fd..a16116e4604 100644 --- a/src/mongo/db/catalog/index_key_validate.cpp +++ b/src/mongo/db/catalog/index_key_validate.cpp @@ -100,6 +100,7 @@ namespace { // names will be disabled. This will allow for creation of indexes with invalid field names in their // specification. MONGO_FAIL_POINT_DEFINE(skipIndexCreateFieldNameValidation); +MONGO_FAIL_POINT_DEFINE(skipIndexCreateWeightsFieldValidation); // When the skipTTLIndexExpireAfterSecondsValidation failpoint is enabled, // validation for TTL index 'expireAfterSeconds' will be disabled in certain codepaths. @@ -706,10 +707,12 @@ StatusWith<BSONObj> validateIndexSpec(OperationContext* opCtx, const BSONObj& in } if (indexType != IndexNames::TEXT && hasWeightsField) { - return {ErrorCodes::CannotCreateIndex, - str::stream() << "Invalid index specification " << indexSpec << "; the field '" - << IndexDescriptor::kWeightsFieldName - << "' can only be specified with text indexes"}; + if (!skipIndexCreateWeightsFieldValidation.shouldFail()) { + return {ErrorCodes::CannotCreateIndex, + str::stream() << "Invalid index specification " << indexSpec << "; the field '" + << IndexDescriptor::kWeightsFieldName + << "' can only be specified with text indexes"}; + } } if (unique && prepareUnique) { |
