summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTess Avitabile <tess.avitabile@mongodb.com>2016-08-31 15:10:43 -0400
committerTess Avitabile <tess.avitabile@mongodb.com>2016-09-07 17:59:15 -0400
commit5559f16e634af69bcbcc4f8dd6d03e74a40729b9 (patch)
treebcdb4748bde99f33266e74666ff6d3525d3f8b39
parent071065a2969176ad2aa2ac9c3210e5fa9410cea6 (diff)
downloadmongo-5559f16e634af69bcbcc4f8dd6d03e74a40729b9.tar.gz
SERVER-25741 Disallow collection default collation if featureCompatibilityVersion is 3.2
-rw-r--r--jstests/noPassthrough/collation_feature_compatibility_version.js19
-rw-r--r--src/mongo/db/catalog/database.cpp8
2 files changed, 27 insertions, 0 deletions
diff --git a/jstests/noPassthrough/collation_feature_compatibility_version.js b/jstests/noPassthrough/collation_feature_compatibility_version.js
index df3516b2b3e..2f393c2a99a 100644
--- a/jstests/noPassthrough/collation_feature_compatibility_version.js
+++ b/jstests/noPassthrough/collation_feature_compatibility_version.js
@@ -29,6 +29,25 @@
assert.commandWorked(res);
assert.eq("3.2", res.featureCompatibilityVersion);
+ // We cannot create a collection with a default collation when the featureCompatibilityVersion
+ // is 3.2.
+ assert.commandFailed(
+ collationDB.createCollection("collection", {collation: {locale: "fr_CA"}}));
+
+ // We cannot explicitly give a collection the simple collation as its default when the
+ // featureCompatibilityVersion is 3.2.
+ assert.commandFailed(
+ collationDB.createCollection("collection", {collation: {locale: "simple"}}));
+
+ // We cannot create a view with a default collation when the featureCompatibilityVersion is 3.2.
+ assert.commandFailed(collationDB.runCommand(
+ {create: "view", viewOn: "caseInsensitive", collation: {locale: "fr_CA"}}));
+
+ // We cannot explicitly give a view the simple collation as its default when the
+ // featureCompatibilityVersion is 3.2.
+ assert.commandFailed(collationDB.runCommand(
+ {create: "view", viewOn: "caseInsensitive", collation: {locale: "simple"}}));
+
// All operations reject the collation parameter when the featureCompatibilityVersion is 3.2.
assert.throws(function() {
caseInsensitive.aggregate([], {collation: {locale: "en_US"}});
diff --git a/src/mongo/db/catalog/database.cpp b/src/mongo/db/catalog/database.cpp
index feb4111edac..1895acb15f7 100644
--- a/src/mongo/db/catalog/database.cpp
+++ b/src/mongo/db/catalog/database.cpp
@@ -683,6 +683,14 @@ Status userCreateNS(OperationContext* txn,
// Validate the collation, if there is one.
if (!collectionOptions.collation.isEmpty()) {
+ if (serverGlobalParams.featureCompatibilityVersion.load() ==
+ ServerGlobalParams::FeatureCompatibilityVersion_32) {
+ return Status(ErrorCodes::InvalidOptions,
+ "The featureCompatibilityVersion must be 3.4 to create a collection or "
+ "view with a default collation. See "
+ "http://dochub.mongodb.org/core/3.4-feature-compatibility.");
+ }
+
auto collator = CollatorFactoryInterface::get(txn->getServiceContext())
->makeFromBSON(collectionOptions.collation);
if (!collator.isOK()) {