summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/sharding/shard_collection_basic.js2
-rw-r--r--src/mongo/db/s/config/configsvr_shard_collection_command.cpp3
-rw-r--r--src/mongo/s/request_types/shard_collection.idl8
3 files changed, 12 insertions, 1 deletions
diff --git a/jstests/sharding/shard_collection_basic.js b/jstests/sharding/shard_collection_basic.js
index ccefece75f7..648fb4370bb 100644
--- a/jstests/sharding/shard_collection_basic.js
+++ b/jstests/sharding/shard_collection_basic.js
@@ -109,7 +109,7 @@ jsTestLog('Command should still verify index even if implicitlyCreateIndex is fa
assert.commandFailedWithCode(
mongos.adminCommand(
{shardCollection: kDbName + '.foo', key: {x: 1}, implicitlyCreateIndex: false}),
- 6373200);
+ [6373200, 6373201]);
//
// Test shardCollection's idempotency
diff --git a/src/mongo/db/s/config/configsvr_shard_collection_command.cpp b/src/mongo/db/s/config/configsvr_shard_collection_command.cpp
index b8fae536f71..853cc3aac70 100644
--- a/src/mongo/db/s/config/configsvr_shard_collection_command.cpp
+++ b/src/mongo/db/s/config/configsvr_shard_collection_command.cpp
@@ -339,6 +339,9 @@ public:
shardsvrShardCollectionRequest.setCollation(request.getCollation());
shardsvrShardCollectionRequest.setGetUUIDfromPrimaryShard(
request.getGetUUIDfromPrimaryShard());
+ shardsvrShardCollectionRequest.setImplicitlyCreateIndex(request.getImplicitlyCreateIndex());
+ shardsvrShardCollectionRequest.setEnforceUniquenessCheck(
+ request.getEnforceUniquenessCheck());
auto cmdResponse = uassertStatusOK(primaryShard->runCommandWithFixedRetryAttempts(
opCtx,
diff --git a/src/mongo/s/request_types/shard_collection.idl b/src/mongo/s/request_types/shard_collection.idl
index 3ad8dda88d2..cd0b9962c81 100644
--- a/src/mongo/s/request_types/shard_collection.idl
+++ b/src/mongo/s/request_types/shard_collection.idl
@@ -70,6 +70,14 @@ structs:
type: bool
description: "Whether the collection should be created on the primary shard. This should only be false when used in mapReduce."
default: true
+ implicitlyCreateIndex:
+ description: "Creates an index on the shard key pattern if the collection is empty."
+ type: optionalBool
+ enforceUniquenessCheck:
+ description: >-
+ Controls whether this command verifies that any unique indexes are prefixed by the shard
+ key pattern if unique is true. If true then it will verify and if false then it won't.
+ type: optionalBool
ConfigsvrShardCollectionResponse:
description: "The response format of the internal shardCollection command on the config server"