diff options
author | Marcos José Grillo Ramirez <marcos.grillo@mongodb.com> | 2021-03-26 12:51:17 +0100 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-03-29 13:39:19 +0000 |
commit | 057657f0613e2fec34ac2e00b8d943ac05058896 (patch) | |
tree | eece2b32e37661948035de4f5aefe59d44c8b083 /src/mongo/db/s/shard_key_util.h | |
parent | 83fdf9063cfd3a69aa1c3dc2b9566142dc51d634 (diff) | |
download | mongo-057657f0613e2fec34ac2e00b8d943ac05058896.tar.gz |
SERVER-54587 Added resilience to the new create collection path
Diffstat (limited to 'src/mongo/db/s/shard_key_util.h')
-rw-r--r-- | src/mongo/db/s/shard_key_util.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/mongo/db/s/shard_key_util.h b/src/mongo/db/s/shard_key_util.h index 619ced60915..6d7a41db58e 100644 --- a/src/mongo/db/s/shard_key_util.h +++ b/src/mongo/db/s/shard_key_util.h @@ -149,6 +149,19 @@ void validateShardKeyIndexExistsOrCreateIfPossible(OperationContext* opCtx, const boost::optional<BSONObj>& defaultCollation, bool unique, const ShardKeyValidationBehaviors& behaviors); - +/** + * Compares the proposed shard key with the collection's existing indexes to ensure they are a legal + * combination. + * + * Returns true if the shard key is valid and already exists. Steps 1, 2 and 3 of the previous + * function. + * + */ +bool validShardKeyIndexExists(OperationContext* opCtx, + const NamespaceString& nss, + const ShardKeyPattern& shardKeyPattern, + const boost::optional<BSONObj>& defaultCollation, + bool unique, + const ShardKeyValidationBehaviors& behaviors); } // namespace shardkeyutil } // namespace mongo |