diff options
author | Scott Hernandez <scotthernandez@gmail.com> | 2013-11-13 23:29:54 -0500 |
---|---|---|
committer | Scott Hernandez <scotthernandez@gmail.com> | 2013-11-13 23:30:02 -0500 |
commit | 423a65720edb43703cca9aef04592c709afbd9b7 (patch) | |
tree | b18ca3dbe82711e05e6d72cf89dd4633e63a275c /src | |
parent | b88b6e6c6e783d10bf3f73f4778f45cbe848cff6 (diff) | |
download | mongo-423a65720edb43703cca9aef04592c709afbd9b7.tar.gz |
SERVER-11324: Allow unique index if prefixed by hashed shard key
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/keypattern.h | 8 | ||||
-rw-r--r-- | src/mongo/s/shardkey.cpp | 4 | ||||
-rw-r--r-- | src/mongo/s/shardkey.h | 6 | ||||
-rw-r--r-- | src/mongo/s/strategy_shard.cpp | 2 |
4 files changed, 1 insertions, 19 deletions
diff --git a/src/mongo/db/keypattern.h b/src/mongo/db/keypattern.h index 7e79f7fbb08..b5ba777cecd 100644 --- a/src/mongo/db/keypattern.h +++ b/src/mongo/db/keypattern.h @@ -84,14 +84,6 @@ namespace mongo { */ BSONElement getField( const char* fieldname ) const { return _pattern[ fieldname ]; } - /* - * Returns true if the key described by this KeyPattern is a prefix of - * the (potentially) compound key described by 'other' - */ - bool isPrefixOf( const KeyPattern& other ) const { - return _pattern.isPrefixOf( other.toBSON() ); - } - /** * Is the provided key pattern the index over the ID field? * The always required ID index is always {_id: 1} or {_id: -1}. diff --git a/src/mongo/s/shardkey.cpp b/src/mongo/s/shardkey.cpp index 7d436cd4ee5..3b838b9fc6e 100644 --- a/src/mongo/s/shardkey.cpp +++ b/src/mongo/s/shardkey.cpp @@ -73,10 +73,6 @@ namespace mongo { return true; } - bool ShardKeyPattern::isPrefixOf( const KeyPattern& otherPattern ) const { - return pattern.isPrefixOf( otherPattern ); - } - bool ShardKeyPattern::isUniqueIndexCompatible( const KeyPattern& uniqueIndexPattern ) const { return mongo::isUniqueIndexCompatible( pattern.toBSON(), uniqueIndexPattern.toBSON() ); } diff --git a/src/mongo/s/shardkey.h b/src/mongo/s/shardkey.h index 0ba077ed87f..aa63fe9ec3c 100644 --- a/src/mongo/s/shardkey.h +++ b/src/mongo/s/shardkey.h @@ -104,12 +104,6 @@ namespace mongo { /** * @return - * true if 'this' is a prefix (not necessarily contained) of 'otherPattern'. - */ - bool isPrefixOf( const KeyPattern& otherPattern ) const; - - /** - * @return * true if this shard key is compatible with a unique index on 'uniqueIndexPattern'. * Primarily this just checks whether 'this' is a prefix of 'uniqueIndexPattern', * However it does not need to be an exact syntactic prefix due to "hashed" diff --git a/src/mongo/s/strategy_shard.cpp b/src/mongo/s/strategy_shard.cpp index 8e1e12b93a6..1eaa6974518 100644 --- a/src/mongo/s/strategy_shard.cpp +++ b/src/mongo/s/strategy_shard.cpp @@ -1413,7 +1413,7 @@ namespace mongo { " key: " + o["key"].embeddedObjectUserCheck().toString() , IndexDetails::isIdIndexPattern( newIndexKey ) || ! o["unique"].trueValue() || - r.getConfig()->getChunkManager( ns )->getShardKey().isPrefixOf( newIndexKey ) ); + r.getConfig()->getChunkManager( ns )->getShardKey().isUniqueIndexCompatible( newIndexKey ) ); ChunkManagerPtr cm = r.getConfig()->getChunkManager( ns ); verify( cm ); |