summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog/index_key_validate.cpp
diff options
context:
space:
mode:
authorJames Wahlin <james@mongodb.com>2018-10-01 16:05:08 -0400
committerJames Wahlin <james@mongodb.com>2018-10-02 09:56:37 -0400
commitf7ddb89c8caf438781de9191d690d03f711b63fe (patch)
tree9244266869d8c17de23d5e0c817a2fddc2bc849a /src/mongo/db/catalog/index_key_validate.cpp
parent5a6ee566f608c46654133de17a4e8bb3464d680d (diff)
downloadmongo-f7ddb89c8caf438781de9191d690d03f711b63fe.tar.gz
SERVER-37188 Rename "All Paths" index to "Wildcard" index
Diffstat (limited to 'src/mongo/db/catalog/index_key_validate.cpp')
-rw-r--r--src/mongo/db/catalog/index_key_validate.cpp44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/mongo/db/catalog/index_key_validate.cpp b/src/mongo/db/catalog/index_key_validate.cpp
index 8a0bcc191c1..ceca0d444c5 100644
--- a/src/mongo/db/catalog/index_key_validate.cpp
+++ b/src/mongo/db/catalog/index_key_validate.cpp
@@ -38,8 +38,8 @@
#include "mongo/base/status.h"
#include "mongo/base/status_with.h"
#include "mongo/db/field_ref.h"
-#include "mongo/db/index/all_paths_key_generator.h"
#include "mongo/db/index/index_descriptor.h"
+#include "mongo/db/index/wildcard_key_generator.h"
#include "mongo/db/index_names.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/matcher/expression_parser.h"
@@ -121,11 +121,11 @@ 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.
+ if (pluginName == IndexNames::WILDCARD && !internalQueryAllowAllPathsIndexes.load()) {
+ // TODO: SERVER-36198 remove this check once wildcard indexes are complete.
return Status(
ErrorCodes::NotImplemented,
- "Cannot use an allPaths index without enabling internalQueryAllowAllPathsIndexes");
+ "Cannot use a wildcard index without enabling internalQueryAllowAllPathsIndexes");
}
BSONObjIterator it(key);
@@ -142,7 +142,7 @@ Status validateKeyPattern(const BSONObj& key, IndexDescriptor::IndexVersion inde
<< static_cast<int>(indexVersion)};
}
- if (pluginName == IndexNames::ALLPATHS) {
+ if (pluginName == IndexNames::WILDCARD) {
return {code,
str::stream() << "'" << pluginName
<< "' index plugin is not allowed with index version v:"
@@ -174,20 +174,20 @@ Status validateKeyPattern(const BSONObj& key, IndexDescriptor::IndexVersion inde
if (keyElement.type() == String && pluginName != keyElement.str()) {
return Status(code, "Can't use more than one index plugin for a single index.");
- } else if (keyElement.type() == String && keyElement.str() == IndexNames::ALLPATHS) {
+ } else if (keyElement.type() == String && keyElement.str() == IndexNames::WILDCARD) {
return Status(code,
- str::stream() << "The key pattern value for an '" << IndexNames::ALLPATHS
+ str::stream() << "The key pattern value for an '" << IndexNames::WILDCARD
<< "' index must be a non-zero number, not a string.");
}
- // Check if the all paths index is compounded. If it is the key is invalid because
- // compounded all paths indexes are disallowed.
- if (pluginName == IndexNames::ALLPATHS && key.nFields() != 1) {
- return Status(code, "all paths indexes do not allow compounding");
+ // Check if the wildcard index is compounded. If it is the key is invalid because
+ // compounded wildcard indexes are disallowed.
+ if (pluginName == IndexNames::WILDCARD && key.nFields() != 1) {
+ return Status(code, "wildcard indexes do not allow compounding");
}
// Ensure that the fields on which we are building the index are valid: a field must not
- // begin with a '$' unless it is part of an allPaths, DBRef or text index, and a field path
+ // begin with a '$' unless it is part of a wildcard, DBRef or text index, and a field path
// cannot contain an empty field. If a field cannot be created or updated, it should not be
// indexable.
@@ -198,7 +198,7 @@ Status validateKeyPattern(const BSONObj& key, IndexDescriptor::IndexVersion inde
return Status(code, "Index keys cannot be an empty field.");
}
- // "$**" is acceptable for a text index or all paths index.
+ // "$**" is acceptable for a text index or wildcard index.
if (mongoutils::str::equals(keyElement.fieldName(), "$**") &&
((keyElement.isNumber()) || (keyElement.valuestrsafe() == IndexNames::TEXT)))
continue;
@@ -225,10 +225,10 @@ Status validateKeyPattern(const BSONObj& key, IndexDescriptor::IndexVersion inde
const bool mightBePartOfDbRef =
(i != 0) && (part == "$db" || part == "$id" || part == "$ref");
- const bool isPartOfAllPaths =
- (i == numParts - 1) && (part == "$**") && (pluginName == IndexNames::ALLPATHS);
+ const bool isPartOfWildcard =
+ (i == numParts - 1) && (part == "$**") && (pluginName == IndexNames::WILDCARD);
- if (!mightBePartOfDbRef && !isPartOfAllPaths) {
+ if (!mightBePartOfDbRef && !isPartOfWildcard) {
return Status(code,
"Index key contains an illegal field name: "
"field name starts with '$'.");
@@ -290,10 +290,10 @@ StatusWith<BSONObj> validateIndexSpec(
if ((featureCompatibility.getVersion() <
ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42) &&
(IndexNames::findPluginName(indexSpec.getObjectField(
- IndexDescriptor::kKeyPatternFieldName)) == IndexNames::ALLPATHS)) {
+ IndexDescriptor::kKeyPatternFieldName)) == IndexNames::WILDCARD)) {
return {ErrorCodes::CannotCreateIndex,
mongoutils::str::stream() << "Unknown index plugin '"
- << IndexNames::ALLPATHS
+ << IndexNames::WILDCARD
<< "'"};
}
hasKeyPatternField = true;
@@ -404,11 +404,11 @@ StatusWith<BSONObj> validateIndexSpec(
}
} else if (IndexDescriptor::kPathProjectionFieldName == indexSpecElemFieldName) {
const auto key = indexSpec.getObjectField(IndexDescriptor::kKeyPatternFieldName);
- if (IndexNames::findPluginName(key) != IndexNames::ALLPATHS) {
+ if (IndexNames::findPluginName(key) != IndexNames::WILDCARD) {
return {ErrorCodes::BadValue,
str::stream() << "The field '" << IndexDescriptor::kPathProjectionFieldName
<< "' is only allowed in an '"
- << IndexNames::ALLPATHS
+ << IndexNames::WILDCARD
<< "' index"};
}
if (indexSpecElem.type() != BSONType::Object) {
@@ -431,9 +431,9 @@ StatusWith<BSONObj> validateIndexSpec(
<< "' field can't be an empty object"};
}
try {
- // We use AllPathsKeyGenerator::createProjectionExec to parse and validate the path
+ // We use WildcardKeyGenerator::createProjectionExec to parse and validate the path
// projection spec.
- AllPathsKeyGenerator::createProjectionExec(key, indexSpecElem.embeddedObject());
+ WildcardKeyGenerator::createProjectionExec(key, indexSpecElem.embeddedObject());
} catch (const DBException& ex) {
return ex.toStatus(str::stream() << "Failed to parse: "
<< IndexDescriptor::kPathProjectionFieldName);