summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2021-04-02 15:35:53 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-04-02 20:26:52 +0000
commitf850e882ade7d59c39f76c675f5e77ca8c80ac1a (patch)
treeedd115bb8474c0612273d89c3ecb21752aacc798
parent6cd150680b8b8af5204e5f442d7685323e82cb3b (diff)
downloadmongo-f850e882ade7d59c39f76c675f5e77ca8c80ac1a.tar.gz
SERVER-55708 remove unused parameter from index_key_validate::validateIndexSpec()
-rw-r--r--src/mongo/db/catalog/index_key_validate.cpp5
-rw-r--r--src/mongo/db/catalog/index_key_validate.h6
-rw-r--r--src/mongo/db/catalog/index_key_validate_test.cpp28
-rw-r--r--src/mongo/db/catalog/index_spec_validate_test.cpp149
-rw-r--r--src/mongo/db/commands/create_command.cpp4
-rw-r--r--src/mongo/db/commands/create_indexes.cpp5
-rw-r--r--src/mongo/db/system_index.cpp11
7 files changed, 64 insertions, 144 deletions
diff --git a/src/mongo/db/catalog/index_key_validate.cpp b/src/mongo/db/catalog/index_key_validate.cpp
index 14221132d28..4dce6720ada 100644
--- a/src/mongo/db/catalog/index_key_validate.cpp
+++ b/src/mongo/db/catalog/index_key_validate.cpp
@@ -252,10 +252,7 @@ BSONObj removeUnknownFields(const BSONObj& indexSpec) {
return builder.obj();
}
-StatusWith<BSONObj> validateIndexSpec(
- OperationContext* opCtx,
- const BSONObj& indexSpec,
- const ServerGlobalParams::FeatureCompatibility& featureCompatibility) {
+StatusWith<BSONObj> validateIndexSpec(OperationContext* opCtx, const BSONObj& indexSpec) {
bool hasKeyPatternField = false;
bool hasIndexNameField = false;
bool hasNamespaceField = false;
diff --git a/src/mongo/db/catalog/index_key_validate.h b/src/mongo/db/catalog/index_key_validate.h
index d4341ae779c..b170550b0e7 100644
--- a/src/mongo/db/catalog/index_key_validate.h
+++ b/src/mongo/db/catalog/index_key_validate.h
@@ -32,7 +32,6 @@
#include <functional>
#include "mongo/db/index/index_descriptor.h"
-#include "mongo/db/server_options.h"
namespace mongo {
class BSONObj;
@@ -55,10 +54,7 @@ Status validateKeyPattern(const BSONObj& key, IndexDescriptor::IndexVersion inde
* has any missing attributes filled in. If the index specification is malformed, then an error
* status is returned.
*/
-StatusWith<BSONObj> validateIndexSpec(
- OperationContext* opCtx,
- const BSONObj& indexSpec,
- const ServerGlobalParams::FeatureCompatibility& featureCompatibility);
+StatusWith<BSONObj> validateIndexSpec(OperationContext* opCtx, const BSONObj& indexSpec);
/**
* Returns a new index spec with any unknown field names removed from 'indexSpec'.
diff --git a/src/mongo/db/catalog/index_key_validate_test.cpp b/src/mongo/db/catalog/index_key_validate_test.cpp
index 2f5bef59cba..2c25d1b8791 100644
--- a/src/mongo/db/catalog/index_key_validate_test.cpp
+++ b/src/mongo/db/catalog/index_key_validate_test.cpp
@@ -294,42 +294,28 @@ TEST(IndexKeyValidateTest, KeyElementNameWildcardFailsWhenValueIsPluginNameWithV
TEST(IndexKeyValidateTest, CompoundHashedIndex) {
// Validation succeeds with hashed prefix in the index.
ASSERT_OK(index_key_validate::validateIndexSpec(
- nullptr,
- fromjson("{key: {a : 'hashed', b: 1}, name: 'index'}"),
- ServerGlobalParams::FeatureCompatibility()));
+ nullptr, fromjson("{key: {a : 'hashed', b: 1}, name: 'index'}")));
// Validation succeeds with non-hashed prefix in the index.
ASSERT_OK(index_key_validate::validateIndexSpec(
- nullptr,
- fromjson("{key: {b: 1, a : 'hashed', c: 1}, name: 'index'}"),
- ServerGlobalParams::FeatureCompatibility()));
+ nullptr, fromjson("{key: {b: 1, a : 'hashed', c: 1}, name: 'index'}")));
}
TEST(IndexKeyValidateTest, Background) {
ASSERT_OK(index_key_validate::validateIndexSpec(
- nullptr,
- fromjson("{key: {a: 1}, name: 'index', background: true}"),
- ServerGlobalParams::FeatureCompatibility()));
+ nullptr, fromjson("{key: {a: 1}, name: 'index', background: true}")));
ASSERT_OK(index_key_validate::validateIndexSpec(
- nullptr,
- fromjson("{key: {a: 1}, name: 'index', background: 1}"),
- ServerGlobalParams::FeatureCompatibility()));
+ nullptr, fromjson("{key: {a: 1}, name: 'index', background: 1}")));
ASSERT_OK(index_key_validate::validateIndexSpec(
- nullptr,
- fromjson("{key: {a: 1}, name: 'index', background: 0}"),
- ServerGlobalParams::FeatureCompatibility()));
+ nullptr, fromjson("{key: {a: 1}, name: 'index', background: 0}")));
ASSERT_NOT_OK(index_key_validate::validateIndexSpec(
- nullptr,
- fromjson("{key: {a: 1}, name: 'index', background: 'foo'}"),
- ServerGlobalParams::FeatureCompatibility()));
+ nullptr, fromjson("{key: {a: 1}, name: 'index', background: 'foo'}")));
ASSERT_NOT_OK(index_key_validate::validateIndexSpec(
- nullptr,
- fromjson("{key: {a: 1}, name: 'index', background: []}"),
- ServerGlobalParams::FeatureCompatibility()));
+ nullptr, fromjson("{key: {a: 1}, name: 'index', background: []}")));
}
} // namespace
diff --git a/src/mongo/db/catalog/index_spec_validate_test.cpp b/src/mongo/db/catalog/index_spec_validate_test.cpp
index a24f0a5fce8..f18165b170a 100644
--- a/src/mongo/db/catalog/index_spec_validate_test.cpp
+++ b/src/mongo/db/catalog/index_spec_validate_test.cpp
@@ -71,65 +71,54 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfKeyPatternIsNotAnObject) {
ASSERT_EQ(ErrorCodes::TypeMismatch,
validateIndexSpec(kDefaultOpCtx,
BSON("key" << 1 << "name"
- << "indexName"),
- serverGlobalParams.featureCompatibility));
+ << "indexName")));
ASSERT_EQ(ErrorCodes::TypeMismatch,
validateIndexSpec(kDefaultOpCtx,
BSON("key"
<< "not an object"
<< "name"
- << "indexName"),
- serverGlobalParams.featureCompatibility));
+ << "indexName")));
ASSERT_EQ(ErrorCodes::TypeMismatch,
validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSONArray() << "name"
- << "indexName"),
- serverGlobalParams.featureCompatibility));
+ << "indexName")));
}
TEST(IndexSpecValidateTest, ReturnsAnErrorIfFieldRepeatedInKeyPattern) {
ASSERT_EQ(ErrorCodes::BadValue,
validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1 << "field" << 1) << "name"
- << "indexName"),
- serverGlobalParams.featureCompatibility));
+ << "indexName")));
ASSERT_EQ(ErrorCodes::BadValue,
validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1 << "otherField" << -1 << "field"
<< "2dsphere")
<< "name"
- << "indexName"),
- serverGlobalParams.featureCompatibility));
+ << "indexName")));
}
TEST(IndexSpecValidateTest, ReturnsAnErrorIfKeyPatternIsNotPresent) {
ASSERT_EQ(ErrorCodes::FailedToParse,
validateIndexSpec(kDefaultOpCtx,
BSON("name"
- << "indexName"),
- serverGlobalParams.featureCompatibility));
+ << "indexName")));
}
TEST(IndexSpecValidateTest, ReturnsAnErrorIfNameIsNotAString) {
ASSERT_EQ(ErrorCodes::TypeMismatch,
- validateIndexSpec(kDefaultOpCtx,
- BSON("key" << BSON("field" << 1) << "name" << 1),
- serverGlobalParams.featureCompatibility));
+ validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1) << "name" << 1)));
}
TEST(IndexSpecValidateTest, ReturnsAnErrorIfNameIsNotPresent) {
ASSERT_EQ(ErrorCodes::FailedToParse,
- validateIndexSpec(kDefaultOpCtx,
- BSON("key" << BSON("field" << 1)),
- serverGlobalParams.featureCompatibility));
+ validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1))));
}
TEST(IndexSpecValidateTest, ReturnsIndexSpecUnchangedIfVersionIsPresent) {
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
<< "indexName"
- << "v" << 1),
- serverGlobalParams.featureCompatibility);
+ << "v" << 1));
ASSERT_OK(result.getStatus());
// We don't care about the order of the fields in the resulting index specification.
@@ -145,14 +134,12 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfVersionIsNotANumber) {
BSON("key" << BSON("field" << 1) << "name"
<< "indexName"
<< "v"
- << "not a number"),
- serverGlobalParams.featureCompatibility));
+ << "not a number")));
ASSERT_EQ(ErrorCodes::TypeMismatch,
validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
<< "indexName"
- << "v" << BSONObj()),
- serverGlobalParams.featureCompatibility));
+ << "v" << BSONObj())));
}
TEST(IndexSpecValidateTest, ReturnsAnErrorIfVersionIsNotRepresentableAsInt) {
@@ -160,26 +147,22 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfVersionIsNotRepresentableAsInt) {
validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
<< "indexName"
- << "v" << 2.2),
- serverGlobalParams.featureCompatibility));
+ << "v" << 2.2)));
ASSERT_EQ(ErrorCodes::BadValue,
validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
<< "indexName"
- << "v" << std::nan("1")),
- serverGlobalParams.featureCompatibility));
+ << "v" << std::nan("1"))));
ASSERT_EQ(ErrorCodes::BadValue,
validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
<< "indexName"
- << "v" << std::numeric_limits<double>::infinity()),
- serverGlobalParams.featureCompatibility));
+ << "v" << std::numeric_limits<double>::infinity())));
ASSERT_EQ(ErrorCodes::BadValue,
validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
<< "indexName"
- << "v" << std::numeric_limits<long long>::max()),
- serverGlobalParams.featureCompatibility));
+ << "v" << std::numeric_limits<long long>::max())));
}
TEST(IndexSpecValidateTest, ReturnsAnErrorIfVersionIsV0) {
@@ -187,8 +170,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfVersionIsV0) {
validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
<< "indexName"
- << "v" << 0),
- serverGlobalParams.featureCompatibility));
+ << "v" << 0)));
}
TEST(IndexSpecValidateTest, ReturnsAnErrorIfVersionIsUnsupported) {
@@ -198,23 +180,20 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfVersionIsUnsupported) {
<< "indexName"
<< "v" << 3 << "collation"
<< BSON("locale"
- << "en")),
- serverGlobalParams.featureCompatibility));
+ << "en"))));
ASSERT_EQ(ErrorCodes::CannotCreateIndex,
validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
<< "indexName"
- << "v" << -3LL),
- serverGlobalParams.featureCompatibility));
+ << "v" << -3LL)));
}
TEST(IndexSpecValidateTest, AcceptsIndexVersionsThatAreAllowedForCreation) {
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
<< "indexName"
- << "v" << 1),
- serverGlobalParams.featureCompatibility);
+ << "v" << 1));
ASSERT_OK(result.getStatus());
// We don't care about the order of the fields in the resulting index specification.
@@ -226,8 +205,7 @@ TEST(IndexSpecValidateTest, AcceptsIndexVersionsThatAreAllowedForCreation) {
result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
<< "indexName"
- << "v" << 2LL),
- serverGlobalParams.featureCompatibility);
+ << "v" << 2LL));
ASSERT_OK(result.getStatus());
// We don't care about the order of the fields in the resulting index specification.
@@ -240,8 +218,7 @@ TEST(IndexSpecValidateTest, AcceptsIndexVersionsThatAreAllowedForCreation) {
TEST(IndexSpecValidateTest, DefaultIndexVersionIsV2) {
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
- << "indexName"),
- serverGlobalParams.featureCompatibility);
+ << "indexName"));
ASSERT_OK(result.getStatus());
// We don't care about the order of the fields in the resulting index specification.
@@ -251,16 +228,14 @@ TEST(IndexSpecValidateTest, DefaultIndexVersionIsV2) {
sorted(result.getValue()));
// Verify that the index specification we returned is still considered valid.
- ASSERT_OK(validateIndexSpec(
- kDefaultOpCtx, result.getValue(), serverGlobalParams.featureCompatibility));
+ ASSERT_OK(validateIndexSpec(kDefaultOpCtx, result.getValue()));
}
TEST(IndexSpecValidateTest, AcceptsIndexVersionV1) {
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
<< "indexName"
- << "v" << 1),
- serverGlobalParams.featureCompatibility);
+ << "v" << 1));
ASSERT_OK(result.getStatus());
// We don't care about the order of the fields in the resulting index specification.
@@ -275,21 +250,18 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfCollationIsNotAnObject) {
validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
<< "indexName"
- << "collation" << 1),
- serverGlobalParams.featureCompatibility));
+ << "collation" << 1)));
ASSERT_EQ(ErrorCodes::TypeMismatch,
validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
<< "indexName"
<< "collation"
- << "not an object"),
- serverGlobalParams.featureCompatibility));
+ << "not an object")));
ASSERT_EQ(ErrorCodes::TypeMismatch,
validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
<< "indexName"
- << "collation" << BSONArray()),
- serverGlobalParams.featureCompatibility));
+ << "collation" << BSONArray())));
}
TEST(IndexSpecValidateTest, ReturnsAnErrorIfCollationIsEmpty) {
@@ -297,8 +269,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfCollationIsEmpty) {
validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
<< "indexName"
- << "collation" << BSONObj()),
- serverGlobalParams.featureCompatibility));
+ << "collation" << BSONObj())));
}
TEST(IndexSpecValidateTest, ReturnsAnErrorIfCollationIsPresentAndVersionIsLessThanV2) {
@@ -309,8 +280,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfCollationIsPresentAndVersionIsLessTh
<< "collation"
<< BSON("locale"
<< "simple")
- << "v" << 1),
- serverGlobalParams.featureCompatibility));
+ << "v" << 1)));
}
TEST(IndexSpecValidateTest, AcceptsAnyNonEmptyObjectValueForCollation) {
@@ -319,8 +289,7 @@ TEST(IndexSpecValidateTest, AcceptsAnyNonEmptyObjectValueForCollation) {
<< "indexName"
<< "v" << 2 << "collation"
<< BSON("locale"
- << "simple")),
- serverGlobalParams.featureCompatibility);
+ << "simple")));
ASSERT_OK(result.getStatus());
// We don't care about the order of the fields in the resulting index specification.
@@ -335,8 +304,7 @@ TEST(IndexSpecValidateTest, AcceptsAnyNonEmptyObjectValueForCollation) {
BSON("key" << BSON("field" << 1) << "name"
<< "indexName"
<< "v" << 2 << "collation"
- << BSON("unknownCollationOption" << true)),
- serverGlobalParams.featureCompatibility);
+ << BSON("unknownCollationOption" << true)));
ASSERT_OK(result.getStatus());
// We don't care about the order of the fields in the resulting index specification.
@@ -353,8 +321,7 @@ TEST(IndexSpecValidateTest, AcceptsIndexSpecIfCollationIsPresentAndVersionIsEqua
<< "indexName"
<< "v" << 2 << "collation"
<< BSON("locale"
- << "en")),
- serverGlobalParams.featureCompatibility);
+ << "en")));
ASSERT_OK(result.getStatus());
// We don't care about the order of the fields in the resulting index specification.
@@ -370,8 +337,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfUnknownFieldIsPresentInSpecV2) {
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
<< "indexName"
- << "v" << 2 << "unknownField" << 1),
- serverGlobalParams.featureCompatibility);
+ << "v" << 2 << "unknownField" << 1));
ASSERT_EQ(ErrorCodes::InvalidIndexSpecificationOption, result);
}
@@ -379,8 +345,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfUnknownFieldIsPresentInSpecV1) {
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
<< "indexName"
- << "v" << 1 << "unknownField" << 1),
- serverGlobalParams.featureCompatibility);
+ << "v" << 1 << "unknownField" << 1));
ASSERT_EQ(ErrorCodes::InvalidIndexSpecificationOption, result);
}
@@ -527,8 +492,7 @@ TEST(IndexSpecPartialFilterTest, FailsIfPartialFilterIsNotAnObject) {
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
<< "indexName"
- << "partialFilterExpression" << 1),
- serverGlobalParams.featureCompatibility);
+ << "partialFilterExpression" << 1));
ASSERT_EQ(result.getStatus(), ErrorCodes::TypeMismatch);
}
@@ -537,8 +501,7 @@ TEST(IndexSpecPartialFilterTest, FailsIfPartialFilterContainsBannedFeature) {
BSON("key" << BSON("field" << 1) << "name"
<< "indexName"
<< "partialFilterExpression"
- << BSON("$jsonSchema" << BSONObj())),
- serverGlobalParams.featureCompatibility);
+ << BSON("$jsonSchema" << BSONObj())));
ASSERT_EQ(result.getStatus(), ErrorCodes::QueryFeatureNotAllowed);
}
@@ -546,8 +509,7 @@ TEST(IndexSpecPartialFilterTest, AcceptsValidPartialFilterExpression) {
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("field" << 1) << "name"
<< "indexName"
- << "partialFilterExpression" << BSON("a" << 1)),
- serverGlobalParams.featureCompatibility);
+ << "partialFilterExpression" << BSON("a" << 1)));
ASSERT_OK(result.getStatus());
}
@@ -556,8 +518,7 @@ TEST(IndexSpecWildcard, SucceedsWithInclusion) {
validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("$**" << 1) << "name"
<< "indexName"
- << "wildcardProjection" << BSON("a" << 1 << "b" << 1)),
- serverGlobalParams.featureCompatibility);
+ << "wildcardProjection" << BSON("a" << 1 << "b" << 1)));
ASSERT_OK(result.getStatus());
}
@@ -566,8 +527,7 @@ TEST(IndexSpecWildcard, SucceedsWithExclusion) {
validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("$**" << 1) << "name"
<< "indexName"
- << "wildcardProjection" << BSON("a" << 0 << "b" << 0)),
- serverGlobalParams.featureCompatibility);
+ << "wildcardProjection" << BSON("a" << 0 << "b" << 0)));
ASSERT_OK(result.getStatus());
}
@@ -576,8 +536,7 @@ TEST(IndexSpecWildcard, SucceedsWithExclusionIncludingId) {
BSON("key" << BSON("$**" << 1) << "name"
<< "indexName"
<< "wildcardProjection"
- << BSON("_id" << 1 << "a" << 0 << "b" << 0)),
- serverGlobalParams.featureCompatibility);
+ << BSON("_id" << 1 << "a" << 0 << "b" << 0)));
ASSERT_OK(result.getStatus());
}
@@ -586,8 +545,7 @@ TEST(IndexSpecWildcard, SucceedsWithInclusionExcludingId) {
BSON("key" << BSON("$**" << 1) << "name"
<< "indexName"
<< "wildcardProjection"
- << BSON("_id" << 0 << "a" << 1 << "b" << 1)),
- serverGlobalParams.featureCompatibility);
+ << BSON("_id" << 0 << "a" << 1 << "b" << 1)));
ASSERT_OK(result.getStatus());
}
@@ -596,8 +554,7 @@ TEST(IndexSpecWildcard, FailsWithInclusionExcludingIdSubfield) {
BSON("key" << BSON("$**" << 1) << "name"
<< "indexName"
<< "wildcardProjection"
- << BSON("_id.field" << 0 << "a" << 1 << "b" << 1)),
- serverGlobalParams.featureCompatibility);
+ << BSON("_id.field" << 0 << "a" << 1 << "b" << 1)));
ASSERT_EQ(result.getStatus().code(), 31253);
}
@@ -606,8 +563,7 @@ TEST(IndexSpecWildcard, FailsWithExclusionIncludingIdSubfield) {
BSON("key" << BSON("$**" << 1) << "name"
<< "indexName"
<< "wildcardProjection"
- << BSON("_id.field" << 1 << "a" << 0 << "b" << 0)),
- serverGlobalParams.featureCompatibility);
+ << BSON("_id.field" << 1 << "a" << 0 << "b" << 0)));
ASSERT_EQ(result.getStatus().code(), 31254);
}
@@ -616,8 +572,7 @@ TEST(IndexSpecWildcard, FailsWithMixedProjection) {
validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("$**" << 1) << "name"
<< "indexName"
- << "wildcardProjection" << BSON("a" << 1 << "b" << 0)),
- serverGlobalParams.featureCompatibility);
+ << "wildcardProjection" << BSON("a" << 1 << "b" << 0)));
ASSERT_EQ(result.getStatus().code(), 31254);
}
@@ -627,8 +582,7 @@ TEST(IndexSpecWildcard, FailsWithComputedFieldsInProjection) {
<< "indexName"
<< "wildcardProjection"
<< BSON("a" << 1 << "b"
- << "string")),
- serverGlobalParams.featureCompatibility);
+ << "string")));
ASSERT_EQ(result.getStatus().code(), 51271);
}
@@ -636,8 +590,7 @@ TEST(IndexSpecWildcard, FailsWhenProjectionPluginNotWildcard) {
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("a" << 1) << "name"
<< "indexName"
- << "wildcardProjection" << BSON("a" << 1)),
- serverGlobalParams.featureCompatibility);
+ << "wildcardProjection" << BSON("a" << 1)));
ASSERT_EQ(result.getStatus().code(), ErrorCodes::BadValue);
}
@@ -645,8 +598,7 @@ TEST(IndexSpecWildcard, FailsWhenProjectionIsNotAnObject) {
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("$**" << 1) << "name"
<< "indexName"
- << "wildcardProjection" << 4),
- serverGlobalParams.featureCompatibility);
+ << "wildcardProjection" << 4));
ASSERT_EQ(result.getStatus().code(), ErrorCodes::TypeMismatch);
}
@@ -654,8 +606,7 @@ TEST(IndexSpecWildcard, FailsWithEmptyProjection) {
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("$**" << 1) << "name"
<< "indexName"
- << "wildcardProjection" << BSONObj()),
- serverGlobalParams.featureCompatibility);
+ << "wildcardProjection" << BSONObj()));
ASSERT_EQ(result.getStatus().code(), ErrorCodes::FailedToParse);
}
@@ -663,8 +614,7 @@ TEST(IndexSpecWildcard, FailsWhenInclusionWithSubpath) {
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("a.$**" << 1) << "name"
<< "indexName"
- << "wildcardProjection" << BSON("a" << 1)),
- serverGlobalParams.featureCompatibility);
+ << "wildcardProjection" << BSON("a" << 1)));
ASSERT_EQ(result.getStatus().code(), ErrorCodes::FailedToParse);
}
@@ -672,8 +622,7 @@ TEST(IndexSpecWildcard, FailsWhenExclusionWithSubpath) {
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("a.$**" << 1) << "name"
<< "indexName"
- << "wildcardProjection" << BSON("b" << 0)),
- serverGlobalParams.featureCompatibility);
+ << "wildcardProjection" << BSON("b" << 0)));
ASSERT_EQ(result.getStatus().code(), ErrorCodes::FailedToParse);
}
diff --git a/src/mongo/db/commands/create_command.cpp b/src/mongo/db/commands/create_command.cpp
index a1201e7a7e1..160c466f765 100644
--- a/src/mongo/db/commands/create_command.cpp
+++ b/src/mongo/db/commands/create_command.cpp
@@ -225,8 +225,8 @@ public:
!cmd.getAutoIndexId());
// Perform index spec validation.
- idIndexSpec = uassertStatusOK(index_key_validate::validateIndexSpec(
- opCtx, idIndexSpec, serverGlobalParams.featureCompatibility));
+ idIndexSpec =
+ uassertStatusOK(index_key_validate::validateIndexSpec(opCtx, idIndexSpec));
uassertStatusOK(index_key_validate::validateIdIndexSpec(idIndexSpec));
// Validate or fill in _id index collation.
diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp
index b865dab3ab7..c0f52f4d125 100644
--- a/src/mongo/db/commands/create_indexes.cpp
+++ b/src/mongo/db/commands/create_indexes.cpp
@@ -58,7 +58,6 @@
#include "mongo/db/s/collection_sharding_state.h"
#include "mongo/db/s/database_sharding_state.h"
#include "mongo/db/s/operation_sharding_state.h"
-#include "mongo/db/server_options.h"
#include "mongo/db/storage/two_phase_index_build_knobs_gen.h"
#include "mongo/db/timeseries/timeseries_index_schema_conversion_functions.h"
#include "mongo/db/timeseries/timeseries_lookup.h"
@@ -101,7 +100,6 @@ std::vector<BSONObj> parseAndValidateIndexSpecs(OperationContext* opCtx,
constexpr auto k_id_ = "_id_"_sd;
constexpr auto kStar = "*"_sd;
- const auto& featureCompatability = serverGlobalParams.featureCompatibility;
const auto ns = cmd.getNamespace();
const bool ignoreUnknownIndexOptions = cmd.getIgnoreUnknownIndexOptions();
@@ -112,8 +110,7 @@ std::vector<BSONObj> parseAndValidateIndexSpecs(OperationContext* opCtx,
parsedIndexSpec = index_key_validate::removeUnknownFields(parsedIndexSpec);
}
- auto indexSpecStatus =
- index_key_validate::validateIndexSpec(opCtx, parsedIndexSpec, featureCompatability);
+ auto indexSpecStatus = index_key_validate::validateIndexSpec(opCtx, parsedIndexSpec);
uassertStatusOK(indexSpecStatus.getStatus().withContext(
str::stream() << "Error in specification " << parsedIndexSpec.toString()));
diff --git a/src/mongo/db/system_index.cpp b/src/mongo/db/system_index.cpp
index c2eedda74ea..3cfb424ab45 100644
--- a/src/mongo/db/system_index.cpp
+++ b/src/mongo/db/system_index.cpp
@@ -101,8 +101,7 @@ void generateSystemIndexForExistingCollection(OperationContext* opCtx,
invariant(!opCtx->lockState()->inAWriteUnitOfWork());
try {
- auto indexSpecStatus = index_key_validate::validateIndexSpec(
- opCtx, spec.toBSON(), serverGlobalParams.featureCompatibility);
+ auto indexSpecStatus = index_key_validate::validateIndexSpec(opCtx, spec.toBSON());
BSONObj indexSpec = fassert(40452, indexSpecStatus);
LOGV2(22488,
@@ -204,15 +203,11 @@ void createSystemIndexes(OperationContext* opCtx, CollectionWriter& collection)
BSONObj indexSpec;
if (ns == AuthorizationManager::usersCollectionNamespace) {
indexSpec = fassert(
- 40455,
- index_key_validate::validateIndexSpec(
- opCtx, v3SystemUsersIndexSpec.toBSON(), serverGlobalParams.featureCompatibility));
+ 40455, index_key_validate::validateIndexSpec(opCtx, v3SystemUsersIndexSpec.toBSON()));
} else if (ns == AuthorizationManager::rolesCollectionNamespace) {
indexSpec = fassert(
- 40457,
- index_key_validate::validateIndexSpec(
- opCtx, v3SystemRolesIndexSpec.toBSON(), serverGlobalParams.featureCompatibility));
+ 40457, index_key_validate::validateIndexSpec(opCtx, v3SystemRolesIndexSpec.toBSON()));
}
if (!indexSpec.isEmpty()) {
auto fromMigrate = false;