summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/create_indexes.cpp
diff options
context:
space:
mode:
authorMax Hirschhorn <max.hirschhorn@mongodb.com>2016-09-07 17:37:46 -0400
committerMax Hirschhorn <max.hirschhorn@mongodb.com>2016-09-07 17:37:46 -0400
commit071065a2969176ad2aa2ac9c3210e5fa9410cea6 (patch)
tree0e77b2ace8c9507bcd95a3b6c0dd73e347bcef1b /src/mongo/db/commands/create_indexes.cpp
parent5133e213c79378893f6bc7671e57789e1f6a9874 (diff)
downloadmongo-071065a2969176ad2aa2ac9c3210e5fa9410cea6.tar.gz
SERVER-25156 Add support for building v=2 indexes.
We use index version v=2 as the default index version when the featureCompatibilityVersion is 3.4, and we use index version v=1 as the default index version when the featureCompatibilityVersion is 3.2. The "collation" index option can only be used with v=2 indexes.
Diffstat (limited to 'src/mongo/db/commands/create_indexes.cpp')
-rw-r--r--src/mongo/db/commands/create_indexes.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp
index e0f0aec18dc..fc0c78b8e3a 100644
--- a/src/mongo/db/commands/create_indexes.cpp
+++ b/src/mongo/db/commands/create_indexes.cpp
@@ -48,6 +48,7 @@
#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/s/collection_metadata.h"
#include "mongo/db/s/collection_sharding_state.h"
+#include "mongo/db/server_options.h"
#include "mongo/db/service_context.h"
#include "mongo/db/views/view_catalog.h"
#include "mongo/s/shard_key_pattern.h"
@@ -66,8 +67,10 @@ const StringData kIndexesFieldName = "indexes"_sd;
* specifications that have any missing attributes filled in. If any index specification is
* malformed, then an error status is returned.
*/
-StatusWith<std::vector<BSONObj>> parseAndValidateIndexSpecs(const NamespaceString& ns,
- const BSONObj& cmdObj) {
+StatusWith<std::vector<BSONObj>> parseAndValidateIndexSpecs(
+ const NamespaceString& ns,
+ const BSONObj& cmdObj,
+ ServerGlobalParams::FeatureCompatibilityVersions featureCompatibilityVersion) {
bool hasIndexesField = false;
std::vector<BSONObj> indexSpecs;
@@ -90,7 +93,8 @@ StatusWith<std::vector<BSONObj>> parseAndValidateIndexSpecs(const NamespaceStrin
<< typeName(indexesElem.type())};
}
- auto indexSpec = validateIndexSpec(indexesElem.Obj(), ns);
+ auto indexSpec =
+ validateIndexSpec(indexesElem.Obj(), ns, featureCompatibilityVersion);
if (!indexSpec.isOK()) {
return indexSpec.getStatus();
}
@@ -156,7 +160,9 @@ public:
if (!status.isOK())
return appendCommandStatus(result, status);
- auto specsWithStatus = parseAndValidateIndexSpecs(ns, cmdObj);
+ const auto featureCompatibilityVersion =
+ serverGlobalParams.featureCompatibilityVersion.load();
+ auto specsWithStatus = parseAndValidateIndexSpecs(ns, cmdObj, featureCompatibilityVersion);
if (!specsWithStatus.isOK()) {
return appendCommandStatus(result, specsWithStatus.getStatus());
}