summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/core/all_paths_validindex.js144
-rw-r--r--jstests/noPassthroughWithMongod/all_paths_validindex.js161
-rw-r--r--src/mongo/db/catalog/index_key_validate.cpp8
-rw-r--r--src/mongo/db/catalog/index_key_validate_test.cpp58
-rw-r--r--src/mongo/db/catalog/index_spec_validate_test.cpp7
-rw-r--r--src/mongo/db/query/query_knobs.cpp2
-rw-r--r--src/mongo/db/query/query_knobs.h6
7 files changed, 218 insertions, 168 deletions
diff --git a/jstests/core/all_paths_validindex.js b/jstests/core/all_paths_validindex.js
deleted file mode 100644
index 23a7ade5b0c..00000000000
--- a/jstests/core/all_paths_validindex.js
+++ /dev/null
@@ -1,144 +0,0 @@
-/**
- * Tests parsing and validaiton of allPaths indexes.
- * @tags: [
- * # Uses index building in background
- * requires_background_index,
- * ]
- */
-(function() {
- "use strict";
- const kCollectionName = "all_paths_validindex";
- const coll = db.getCollection(kCollectionName);
-
- const kIndexName = "all_paths_validindex";
-
- const createIndexHelper = function(key, parameters) {
- return db.runCommand(
- {createIndexes: kCollectionName, indexes: [Object.assign({key: key}, parameters)]});
- };
-
- const createIndexAndVerifyWithDrop = function(key, parameters) {
- coll.dropIndexes();
- createIndexHelper(key, parameters);
- assert.eq(coll.getIndexes()
- .filter((index) => {
- return index.name == parameters.name;
- })
- .length,
- 1);
- };
-
- // Can create a valid allPaths index.
- createIndexAndVerifyWithDrop({"$**": 1}, {name: kIndexName});
-
- // Can create a valid allPaths index with subpaths.
- createIndexAndVerifyWithDrop({"a.$**": 1}, {name: kIndexName});
-
- // Can create an allPaths index with partialFilterExpression.
- createIndexAndVerifyWithDrop({"$**": 1},
- {name: kIndexName, partialFilterExpression: {a: {"$gt": 0}}});
-
- // Can create an allPaths index with foreground & background construction.
- createIndexAndVerifyWithDrop({"$**": 1}, {background: false, name: kIndexName});
- createIndexAndVerifyWithDrop({"$**": 1}, {background: true, name: kIndexName});
-
- // Can create an allPaths index with index level collation.
- createIndexAndVerifyWithDrop({"$**": 1}, {collation: {locale: "fr"}, name: kIndexName});
-
- // Can create an allPaths index with an inclusion projection.
- createIndexAndVerifyWithDrop({"$**": 1},
- {starPathsTempName: {a: 1, b: 1, c: 1}, name: kIndexName});
- // Can create an allPaths index with an exclusion projection.
- createIndexAndVerifyWithDrop({"$**": 1},
- {starPathsTempName: {a: 0, b: 0, c: 0}, name: kIndexName});
- // Can include _id in an exclusion.
- createIndexAndVerifyWithDrop({"$**": 1},
- {starPathsTempName: {_id: 1, a: 0, b: 0, c: 0}, name: kIndexName});
- // Can exclude _id in an exclusion.
- createIndexAndVerifyWithDrop({"$**": 1},
- {starPathsTempName: {_id: 0, a: 1, b: 1, c: 1}, name: kIndexName});
-
- // Cannot create an allPaths index with sparse option.
- coll.dropIndexes();
- assert.commandFailedWithCode(coll.createIndex({"$**": 1}, {sparse: true}),
- ErrorCodes.CannotCreateIndex);
-
- // Cannot create an allPaths index with a v0 or v1 index.
- assert.commandFailedWithCode(coll.createIndex({"$**": 1}, {v: 0}),
- ErrorCodes.CannotCreateIndex);
- assert.commandFailedWithCode(coll.createIndex({"$**": 1}, {v: 1}),
- ErrorCodes.CannotCreateIndex);
-
- // Cannot create a unique index.
- assert.commandFailedWithCode(coll.createIndex({"$**": 1}, {unique: true}),
- ErrorCodes.CannotCreateIndex);
-
- // Cannot create a hashed all paths index.
- assert.commandFailedWithCode(coll.createIndex({"$**": "hashed"}), ErrorCodes.CannotCreateIndex);
-
- // Cannot create a TTL all paths index.
- assert.commandFailedWithCode(coll.createIndex({"$**": 1}, {expireAfterSeconds: 3600}),
- ErrorCodes.CannotCreateIndex);
-
- // Cannot create a geoSpatial all paths index.
- assert.commandFailedWithCode(coll.createIndex({"$**": "2dsphere"}),
- ErrorCodes.CannotCreateIndex);
- assert.commandFailedWithCode(coll.createIndex({"$**": "2d"}), ErrorCodes.CannotCreateIndex);
-
- // Cannot create a text all paths index using single sub-path syntax.
- assert.commandFailedWithCode(coll.createIndex({"a.$**": "text"}), ErrorCodes.CannotCreateIndex);
-
- // Cannot specify plugin by string.
- assert.commandFailedWithCode(coll.createIndex({"a": "allPaths"}), ErrorCodes.CannotCreateIndex);
- assert.commandFailedWithCode(coll.createIndex({"$**": "allPaths"}),
- ErrorCodes.CannotCreateIndex);
-
- // Cannot create a compound all paths index.
- assert.commandFailedWithCode(coll.createIndex({"$**": 1, "a": 1}),
- ErrorCodes.CannotCreateIndex);
- assert.commandFailedWithCode(coll.createIndex({"a": 1, "$**": 1}),
- ErrorCodes.CannotCreateIndex);
-
- // Cannot create an all paths index with an invalid spec.
- assert.commandFailedWithCode(coll.createIndex({"a.$**.$**": 1}), ErrorCodes.CannotCreateIndex);
- assert.commandFailedWithCode(coll.createIndex({"$**.$**": 1}), ErrorCodes.CannotCreateIndex);
- assert.commandFailedWithCode(coll.createIndex({"$**": "hello"}), ErrorCodes.CannotCreateIndex);
-
- // Cannot create an all paths index with mixed inclusion exclusion.
- assert.commandFailedWithCode(
- createIndexHelper({"$**": 1}, {name: kIndexName, starPathsTempName: {a: 1, b: 0}}), 40178);
- // Cannot create an all paths index with computed fields.
- assert.commandFailedWithCode(
- createIndexHelper({"$**": 1}, {name: kIndexName, starPathsTempName: {a: 1, b: "string"}}),
- ErrorCodes.FailedToParse);
- // Cannot create an all paths index with an empty projection.
- assert.commandFailedWithCode(
- createIndexHelper({"$**": 1}, {name: kIndexName, starPathsTempName: {}}),
- ErrorCodes.FailedToParse);
- // Cannot create another index type with "starPathsTempName" projection.
- assert.commandFailedWithCode(
- createIndexHelper({"a": 1}, {name: kIndexName, starPathsTempName: {a: 1, b: 1}}),
- ErrorCodes.BadValue);
- // Cannot create a text index with a "starPathsTempName" projection.
- assert.commandFailedWithCode(
- createIndexHelper({"$**": "text"}, {name: kIndexName, starPathsTempName: {a: 1, b: 1}}),
- ErrorCodes.BadValue);
- // Cannot create an all paths index with a non-object "starPathsTempName" projection.
- assert.commandFailedWithCode(
- createIndexHelper({"a.$**": 1}, {name: kIndexName, starPathsTempName: "string"}),
- ErrorCodes.TypeMismatch);
- // Cannot exclude an subfield of _id in an inclusion.
- assert.commandFailedWithCode(createIndexHelper({"_id.id": 0, a: 1, b: 1, c: 1}),
- ErrorCodes.CannotCreateIndex);
- // Cannot include an subfield of _id in an exclusion.
- assert.commandFailedWithCode(createIndexHelper({"_id.id": 1, a: 0, b: 0, c: 0}),
- ErrorCodes.CannotCreateIndex);
-
- // Cannot specify both a subpath and a projection.
- assert.commandFailedWithCode(
- createIndexHelper({"a.$**": 1}, {name: kIndexName, starPathsTempName: {a: 1}}),
- ErrorCodes.FailedToParse);
- assert.commandFailedWithCode(
- createIndexHelper({"a.$**": 1}, {name: kIndexName, starPathsTempName: {b: 0}}),
- ErrorCodes.FailedToParse);
-})();
diff --git a/jstests/noPassthroughWithMongod/all_paths_validindex.js b/jstests/noPassthroughWithMongod/all_paths_validindex.js
new file mode 100644
index 00000000000..dc2802ce143
--- /dev/null
+++ b/jstests/noPassthroughWithMongod/all_paths_validindex.js
@@ -0,0 +1,161 @@
+/**
+ * Tests parsing and validation of allPaths indexes.
+ * @tags: [
+ * # Uses index building in background
+ * requires_background_index,
+ * ]
+ * TODO: SERVER-36198: Move this test back to jstests/core/
+ */
+(function() {
+ "use strict";
+
+ const kCollectionName = "all_paths_validindex";
+ const coll = db.getCollection(kCollectionName);
+
+ const kIndexName = "all_paths_validindex";
+
+ const createIndexHelper = function(key, parameters) {
+ return db.runCommand(
+ {createIndexes: kCollectionName, indexes: [Object.assign({key: key}, parameters)]});
+ };
+
+ const createIndexAndVerifyWithDrop = function(key, parameters) {
+ coll.dropIndexes();
+ createIndexHelper(key, parameters);
+ assert.eq(coll.getIndexes()
+ .filter((index) => {
+ return index.name == parameters.name;
+ })
+ .length,
+ 1);
+ };
+
+ assert.commandWorked(
+ db.adminCommand({setParameter: 1, internalQueryAllowAllPathsIndexes: true}));
+ try {
+ // Can create a valid allPaths index.
+ createIndexAndVerifyWithDrop({"$**": 1}, {name: kIndexName});
+
+ // Can create a valid allPaths index with subpaths.
+ createIndexAndVerifyWithDrop({"a.$**": 1}, {name: kIndexName});
+
+ // Can create an allPaths index with partialFilterExpression.
+ createIndexAndVerifyWithDrop({"$**": 1},
+ {name: kIndexName, partialFilterExpression: {a: {"$gt": 0}}});
+
+ // Can create an allPaths index with foreground & background construction.
+ createIndexAndVerifyWithDrop({"$**": 1}, {background: false, name: kIndexName});
+ createIndexAndVerifyWithDrop({"$**": 1}, {background: true, name: kIndexName});
+
+ // Can create an allPaths index with index level collation.
+ createIndexAndVerifyWithDrop({"$**": 1}, {collation: {locale: "fr"}, name: kIndexName});
+
+ // Can create an allPaths index with an inclusion projection.
+ createIndexAndVerifyWithDrop({"$**": 1},
+ {starPathsTempName: {a: 1, b: 1, c: 1}, name: kIndexName});
+ // Can create an allPaths index with an exclusion projection.
+ createIndexAndVerifyWithDrop({"$**": 1},
+ {starPathsTempName: {a: 0, b: 0, c: 0}, name: kIndexName});
+ // Can include _id in an exclusion.
+ createIndexAndVerifyWithDrop(
+ {"$**": 1}, {starPathsTempName: {_id: 1, a: 0, b: 0, c: 0}, name: kIndexName});
+ // Can exclude _id in an exclusion.
+ createIndexAndVerifyWithDrop(
+ {"$**": 1}, {starPathsTempName: {_id: 0, a: 1, b: 1, c: 1}, name: kIndexName});
+
+ // Cannot create an allPaths index with sparse option.
+ coll.dropIndexes();
+ assert.commandFailedWithCode(coll.createIndex({"$**": 1}, {sparse: true}),
+ ErrorCodes.CannotCreateIndex);
+
+ // Cannot create an allPaths index with a v0 or v1 index.
+ assert.commandFailedWithCode(coll.createIndex({"$**": 1}, {v: 0}),
+ ErrorCodes.CannotCreateIndex);
+ assert.commandFailedWithCode(coll.createIndex({"$**": 1}, {v: 1}),
+ ErrorCodes.CannotCreateIndex);
+
+ // Cannot create a unique index.
+ assert.commandFailedWithCode(coll.createIndex({"$**": 1}, {unique: true}),
+ ErrorCodes.CannotCreateIndex);
+
+ // Cannot create a hashed all paths index.
+ assert.commandFailedWithCode(coll.createIndex({"$**": "hashed"}),
+ ErrorCodes.CannotCreateIndex);
+
+ // Cannot create a TTL all paths index.
+ assert.commandFailedWithCode(coll.createIndex({"$**": 1}, {expireAfterSeconds: 3600}),
+ ErrorCodes.CannotCreateIndex);
+
+ // Cannot create a geoSpatial all paths index.
+ assert.commandFailedWithCode(coll.createIndex({"$**": "2dsphere"}),
+ ErrorCodes.CannotCreateIndex);
+ assert.commandFailedWithCode(coll.createIndex({"$**": "2d"}), ErrorCodes.CannotCreateIndex);
+
+ // Cannot create a text all paths index using single sub-path syntax.
+ assert.commandFailedWithCode(coll.createIndex({"a.$**": "text"}),
+ ErrorCodes.CannotCreateIndex);
+
+ // Cannot specify plugin by string.
+ assert.commandFailedWithCode(coll.createIndex({"a": "allPaths"}),
+ ErrorCodes.CannotCreateIndex);
+ assert.commandFailedWithCode(coll.createIndex({"$**": "allPaths"}),
+ ErrorCodes.CannotCreateIndex);
+
+ // Cannot create a compound all paths index.
+ assert.commandFailedWithCode(coll.createIndex({"$**": 1, "a": 1}),
+ ErrorCodes.CannotCreateIndex);
+ assert.commandFailedWithCode(coll.createIndex({"a": 1, "$**": 1}),
+ ErrorCodes.CannotCreateIndex);
+
+ // Cannot create an all paths index with an invalid spec.
+ assert.commandFailedWithCode(coll.createIndex({"a.$**.$**": 1}),
+ ErrorCodes.CannotCreateIndex);
+ assert.commandFailedWithCode(coll.createIndex({"$**.$**": 1}),
+ ErrorCodes.CannotCreateIndex);
+ assert.commandFailedWithCode(coll.createIndex({"$**": "hello"}),
+ ErrorCodes.CannotCreateIndex);
+
+ // Cannot create an all paths index with mixed inclusion exclusion.
+ assert.commandFailedWithCode(
+ createIndexHelper({"$**": 1}, {name: kIndexName, starPathsTempName: {a: 1, b: 0}}),
+ 40178);
+ // Cannot create an all paths index with computed fields.
+ assert.commandFailedWithCode(
+ createIndexHelper({"$**": 1},
+ {name: kIndexName, starPathsTempName: {a: 1, b: "string"}}),
+ ErrorCodes.FailedToParse);
+ // Cannot create an all paths index with an empty projection.
+ assert.commandFailedWithCode(
+ createIndexHelper({"$**": 1}, {name: kIndexName, starPathsTempName: {}}),
+ ErrorCodes.FailedToParse);
+ // Cannot create another index type with "starPathsTempName" projection.
+ assert.commandFailedWithCode(
+ createIndexHelper({"a": 1}, {name: kIndexName, starPathsTempName: {a: 1, b: 1}}),
+ ErrorCodes.BadValue);
+ // Cannot create a text index with a "starPathsTempName" projection.
+ assert.commandFailedWithCode(
+ createIndexHelper({"$**": "text"}, {name: kIndexName, starPathsTempName: {a: 1, b: 1}}),
+ ErrorCodes.BadValue);
+ // Cannot create an all paths index with a non-object "starPathsTempName" projection.
+ assert.commandFailedWithCode(
+ createIndexHelper({"a.$**": 1}, {name: kIndexName, starPathsTempName: "string"}),
+ ErrorCodes.TypeMismatch);
+ // Cannot exclude an subfield of _id in an inclusion.
+ assert.commandFailedWithCode(createIndexHelper({"_id.id": 0, a: 1, b: 1, c: 1}),
+ ErrorCodes.CannotCreateIndex);
+ // Cannot include an subfield of _id in an exclusion.
+ assert.commandFailedWithCode(createIndexHelper({"_id.id": 1, a: 0, b: 0, c: 0}),
+ ErrorCodes.CannotCreateIndex);
+
+ // Cannot specify both a subpath and a projection.
+ assert.commandFailedWithCode(
+ createIndexHelper({"a.$**": 1}, {name: kIndexName, starPathsTempName: {a: 1}}),
+ ErrorCodes.FailedToParse);
+ assert.commandFailedWithCode(
+ createIndexHelper({"a.$**": 1}, {name: kIndexName, starPathsTempName: {b: 0}}),
+ ErrorCodes.FailedToParse);
+ } finally {
+ assert.commandWorked(
+ db.adminCommand({"setParameter": 1, "internalQueryAllowAllPathsIndexes": false}));
+ }
+})();
diff --git a/src/mongo/db/catalog/index_key_validate.cpp b/src/mongo/db/catalog/index_key_validate.cpp
index e4b86cf0a3d..3feddcaf30d 100644
--- a/src/mongo/db/catalog/index_key_validate.cpp
+++ b/src/mongo/db/catalog/index_key_validate.cpp
@@ -45,6 +45,7 @@
#include "mongo/db/matcher/expression_parser.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/query/collation/collator_factory_interface.h"
+#include "mongo/db/query/query_knobs.h"
#include "mongo/db/service_context.h"
#include "mongo/util/fail_point_service.h"
#include "mongo/util/mongoutils/str.h"
@@ -118,6 +119,13 @@ Status validateKeyPattern(const BSONObj& key, IndexDescriptor::IndexVersion inde
code, mongoutils::str::stream() << "Unknown index plugin '" << pluginName << '\'');
}
+ if (pluginName == IndexNames::ALLPATHS && !internalQueryAllowAllPathsIndexes.load()) {
+ // TODO: SERVER-36198 remove this check once AllPaths indexes are complete.
+ return Status(
+ ErrorCodes::NotImplemented,
+ "Cannot use an allPaths index without enabling internalQueryAllowAllPathsIndexes");
+ }
+
BSONObjIterator it(key);
while (it.more()) {
BSONElement keyElement = it.next();
diff --git a/src/mongo/db/catalog/index_key_validate_test.cpp b/src/mongo/db/catalog/index_key_validate_test.cpp
index cc8978d0673..1d170fbbde7 100644
--- a/src/mongo/db/catalog/index_key_validate_test.cpp
+++ b/src/mongo/db/catalog/index_key_validate_test.cpp
@@ -36,6 +36,7 @@
#include "mongo/bson/bsonmisc.h"
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/db/index/index_descriptor.h"
+#include "mongo/db/query/query_knobs.h"
#include "mongo/unittest/unittest.h"
namespace mongo {
@@ -45,6 +46,31 @@ namespace {
using IndexVersion = IndexDescriptor::IndexVersion;
using index_key_validate::validateKeyPattern;
+/**
+ * Helper class to ensure proper FCV & test commands enabled.
+ * TODO: Remove test command enabling/disabling in SERVER-36198
+ */
+class TestCommandQueryKnobGuard {
+
+public:
+ TestCommandQueryKnobGuard() {
+ _prevEnabled = getTestCommandsEnabled();
+ setTestCommandsEnabled(true);
+
+ _prevKnobEnabled = internalQueryAllowAllPathsIndexes.load();
+ internalQueryAllowAllPathsIndexes.store(true);
+ }
+
+ ~TestCommandQueryKnobGuard() {
+ setTestCommandsEnabled(_prevEnabled);
+ internalQueryAllowAllPathsIndexes.store(_prevKnobEnabled);
+ }
+
+private:
+ bool _prevEnabled;
+ bool _prevKnobEnabled;
+};
+
TEST(IndexKeyValidateTest, KeyElementValueOfSmallPositiveIntSucceeds) {
for (auto indexVersion : IndexDescriptor::getSupportedIndexVersions()) {
ASSERT_OK(validateKeyPattern(BSON("x" << 1), indexVersion));
@@ -237,77 +263,61 @@ TEST(IndexKeyValidateTest, KeyElementNameTextSucceedsOnTextIndex) {
}
TEST(IndexKeyValidateTest, KeyElementNameAllPathsSucceedsOnSubPath) {
- const bool temp = getTestCommandsEnabled();
- setTestCommandsEnabled(true);
+ TestCommandQueryKnobGuard guard;
ASSERT_OK(validateKeyPattern(BSON("a.$**" << 1), IndexVersion::kV2));
- setTestCommandsEnabled(temp);
}
TEST(IndexKeyValidateTest, KeyElementNameAllPathsSucceeds) {
- const bool temp = getTestCommandsEnabled();
- setTestCommandsEnabled(true);
+ TestCommandQueryKnobGuard guard;
ASSERT_OK(validateKeyPattern(BSON("$**" << 1), IndexVersion::kV2));
- setTestCommandsEnabled(temp);
}
TEST(IndexKeyValidateTest, KeyElementNameAllPathsFailsOnRepeat) {
- const bool temp = getTestCommandsEnabled();
- setTestCommandsEnabled(true);
+ TestCommandQueryKnobGuard guard;
auto status = validateKeyPattern(BSON("$**.$**" << 1), IndexVersion::kV2);
ASSERT_NOT_OK(status);
ASSERT_EQ(status, ErrorCodes::CannotCreateIndex);
- setTestCommandsEnabled(temp);
}
TEST(IndexKeyValidateTest, KeyElementNameAllPathsFailsOnSubPathRepeat) {
- const bool temp = getTestCommandsEnabled();
- setTestCommandsEnabled(true);
+ TestCommandQueryKnobGuard guard;
auto status = validateKeyPattern(BSON("a.$**.$**" << 1), IndexVersion::kV2);
ASSERT_NOT_OK(status);
ASSERT_EQ(status, ErrorCodes::CannotCreateIndex);
- setTestCommandsEnabled(temp);
}
TEST(IndexKeyValidateTest, KeyElementNameAllPathsFailsOnCompound) {
- const bool temp = getTestCommandsEnabled();
- setTestCommandsEnabled(true);
+ TestCommandQueryKnobGuard guard;
auto status = validateKeyPattern(BSON("$**" << 1 << "a" << 1), IndexVersion::kV2);
ASSERT_NOT_OK(status);
ASSERT_EQ(status, ErrorCodes::CannotCreateIndex);
- setTestCommandsEnabled(temp);
}
TEST(IndexKeyValidateTest, KeyElementNameAllPathsFailsOnIncorrectValue) {
- const bool temp = getTestCommandsEnabled();
- setTestCommandsEnabled(true);
+ TestCommandQueryKnobGuard guard;
auto status = validateKeyPattern(BSON("$**" << false), IndexVersion::kV2);
ASSERT_NOT_OK(status);
ASSERT_EQ(status, ErrorCodes::CannotCreateIndex);
- setTestCommandsEnabled(temp);
}
TEST(IndexKeyValidateTest, KeyElementNameAllPathsFailsWhenValueIsPluginNameWithInvalidKeyName) {
// TODO: Remove test command enabling/disabling in SERVER-36198
- const bool temp = getTestCommandsEnabled();
- setTestCommandsEnabled(true);
+ TestCommandQueryKnobGuard guard;
auto status = validateKeyPattern(BSON("a"
<< "allPaths"),
IndexVersion::kV2);
ASSERT_NOT_OK(status);
ASSERT_EQ(status, ErrorCodes::CannotCreateIndex);
- setTestCommandsEnabled(temp);
}
TEST(IndexKeyValidateTest, KeyElementNameAllPathsFailsWhenValueIsPluginNameWithValidKeyName) {
// TODO: Remove test command enabling/disabling in SERVER-36198
- const bool temp = getTestCommandsEnabled();
- setTestCommandsEnabled(true);
+ TestCommandQueryKnobGuard guard;
auto status = validateKeyPattern(BSON("$**"
<< "allPaths"),
IndexVersion::kV2);
ASSERT_NOT_OK(status);
ASSERT_EQ(status, ErrorCodes::CannotCreateIndex);
- setTestCommandsEnabled(temp);
}
} // namespace
diff --git a/src/mongo/db/catalog/index_spec_validate_test.cpp b/src/mongo/db/catalog/index_spec_validate_test.cpp
index e49d09eb675..35dfc7adbe9 100644
--- a/src/mongo/db/catalog/index_spec_validate_test.cpp
+++ b/src/mongo/db/catalog/index_spec_validate_test.cpp
@@ -40,6 +40,7 @@
#include "mongo/db/commands/test_commands_enabled.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/query/collation/collator_interface_mock.h"
+#include "mongo/db/query/query_knobs.h"
#include "mongo/db/query/query_test_service_context.h"
#include "mongo/db/server_options.h"
#include "mongo/unittest/unittest.h"
@@ -67,15 +68,21 @@ public:
// TODO: Remove test command enabling/disabling in SERVER-36198
_prevEnabled = getTestCommandsEnabled();
setTestCommandsEnabled(true);
+
+ // TODO: Remove knob enabling/disabling in SERVER-36198.
+ _prevKnobEnabled = internalQueryAllowAllPathsIndexes.load();
+ internalQueryAllowAllPathsIndexes.store(true);
}
~TestCommandFcvGuard() {
serverGlobalParams.featureCompatibility.setVersion(_prevVersion);
setTestCommandsEnabled(_prevEnabled);
+ internalQueryAllowAllPathsIndexes.store(_prevKnobEnabled);
}
private:
bool _prevEnabled;
+ bool _prevKnobEnabled;
ServerGlobalParams::FeatureCompatibility::Version _prevVersion;
};
diff --git a/src/mongo/db/query/query_knobs.cpp b/src/mongo/db/query/query_knobs.cpp
index 920b04af17d..2ab5f838e4e 100644
--- a/src/mongo/db/query/query_knobs.cpp
+++ b/src/mongo/db/query/query_knobs.cpp
@@ -92,4 +92,6 @@ MONGO_EXPORT_SERVER_PARAMETER(internalQueryPlannerGenerateCoveredWholeIndexScans
MONGO_EXPORT_SERVER_PARAMETER(internalQueryIgnoreUnknownJSONSchemaKeywords, bool, false);
MONGO_EXPORT_SERVER_PARAMETER(internalQueryProhibitBlockingMergeOnMongoS, bool, false);
+
+MONGO_EXPORT_SERVER_PARAMETER(internalQueryAllowAllPathsIndexes, bool, false);
} // namespace mongo
diff --git a/src/mongo/db/query/query_knobs.h b/src/mongo/db/query/query_knobs.h
index a361e875dcc..e17502d0bd7 100644
--- a/src/mongo/db/query/query_knobs.h
+++ b/src/mongo/db/query/query_knobs.h
@@ -130,4 +130,10 @@ extern AtomicInt32 internalDocumentSourceCursorBatchSizeBytes;
extern AtomicInt32 internalDocumentSourceLookupCacheSizeBytes;
extern AtomicBool internalQueryProhibitBlockingMergeOnMongoS;
+
+//
+// In-progress features.
+//
+// TODO: Remove in SERVER-36198.
+extern AtomicBool internalQueryAllowAllPathsIndexes;
} // namespace mongo