diff options
author | David Storch <david.storch@10gen.com> | 2016-07-19 17:40:02 -0400 |
---|---|---|
committer | David Storch <david.storch@10gen.com> | 2016-07-20 16:22:05 -0400 |
commit | 60379c1daaaf50d90d240a0ae5b4c6fdad7b4c36 (patch) | |
tree | 45353f17a3a8ee311621a4e65132c66b41789b94 /src/mongo/db/catalog | |
parent | dd26139af00fb1af308d579de6aee802f3856578 (diff) | |
download | mongo-60379c1daaaf50d90d240a0ae5b4c6fdad7b4c36.tar.gz |
SERVER-25136 allow index types which do not support collation on a collection with a non-simple default collation
The application must use {locale: "simple"} to override the
default in this case.
Diffstat (limited to 'src/mongo/db/catalog')
-rw-r--r-- | src/mongo/db/catalog/index_catalog.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/mongo/db/catalog/index_catalog.cpp b/src/mongo/db/catalog/index_catalog.cpp index a0653ba6661..7d51b2b7d01 100644 --- a/src/mongo/db/catalog/index_catalog.cpp +++ b/src/mongo/db/catalog/index_catalog.cpp @@ -544,13 +544,6 @@ Status IndexCatalog::_isSpecOk(OperationContext* txn, const BSONObj& spec) const std::unique_ptr<CollatorInterface> collator; BSONElement collationElement = spec.getField("collation"); if (collationElement) { - string pluginName = IndexNames::findPluginName(key); - if ((pluginName != IndexNames::BTREE) && (pluginName != IndexNames::GEO_2DSPHERE) && - (pluginName != IndexNames::HASHED)) { - return Status(ErrorCodes::CannotCreateIndex, - str::stream() << "\"collation\" not supported for index type " - << pluginName); - } if (collationElement.type() != BSONType::Object) { return Status(ErrorCodes::CannotCreateIndex, "\"collation\" for an index must be a document"); @@ -561,6 +554,15 @@ Status IndexCatalog::_isSpecOk(OperationContext* txn, const BSONObj& spec) const return statusWithCollator.getStatus(); } collator = std::move(statusWithCollator.getValue()); + + string pluginName = IndexNames::findPluginName(key); + if (collator && (pluginName != IndexNames::BTREE) && + (pluginName != IndexNames::GEO_2DSPHERE) && (pluginName != IndexNames::HASHED)) { + return Status(ErrorCodes::CannotCreateIndex, + str::stream() << "Index type '" << pluginName + << "' does not support collation: " + << collator->getSpec().toBSON()); + } } const bool isSparse = spec["sparse"].trueValue(); |