diff options
author | Eliot Horowitz <eliot@10gen.com> | 2014-03-06 23:50:11 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2014-04-03 13:31:49 -0400 |
commit | b01c395962d13784af8f7a9055dfd6aa7a53bdef (patch) | |
tree | a4040fb5784598c8176e4e8c1278f174cb7195aa /src/mongo/db/index | |
parent | 17458452bd0ccc6b86a372e9ccc9fd7163af94a4 (diff) | |
download | mongo-b01c395962d13784af8f7a9055dfd6aa7a53bdef.tar.gz |
SERVER-13084: more IndexDetails and header work
Diffstat (limited to 'src/mongo/db/index')
-rw-r--r-- | src/mongo/db/index/index_descriptor.h | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/mongo/db/index/index_descriptor.h b/src/mongo/db/index/index_descriptor.h index 18cf465a060..8c9e82e7fbe 100644 --- a/src/mongo/db/index/index_descriptor.h +++ b/src/mongo/db/index/index_descriptor.h @@ -32,9 +32,7 @@ #include <string> -#include "mongo/db/structure/catalog/index_details.h" // For IndexDetails. #include "mongo/db/jsobj.h" -#include "mongo/db/structure/catalog/namespace_details.h" // For NamespaceDetails. #include "mongo/db/catalog/collection.h" #include "mongo/util/stacktrace.h" @@ -67,7 +65,7 @@ namespace mongo { _keyPattern(infoObj.getObjectField("key").getOwned()), _indexName(infoObj.getStringField("name")), _parentNS(infoObj.getStringField("ns")), - _isIdIndex(IndexDetails::isIdIndexPattern( _keyPattern )), + _isIdIndex(isIdIndexPattern( _keyPattern )), _sparse(infoObj["sparse"].trueValue()), _dropDups(infoObj["dropDups"].trueValue()), _unique( _isIdIndex || infoObj["unique"].trueValue() ), @@ -160,6 +158,18 @@ namespace mongo { bool areIndexOptionsEquivalent( const IndexDescriptor* other ) const; + static bool isIdIndexPattern( const BSONObj &pattern ) { + BSONObjIterator i(pattern); + BSONElement e = i.next(); + //_id index must have form exactly {_id : 1} or {_id : -1}. + //Allows an index of form {_id : "hashed"} to exist but + //do not consider it to be the primary _id index + if(! ( strcmp(e.fieldName(), "_id") == 0 + && (e.numberInt() == 1 || e.numberInt() == -1))) + return false; + return i.next().eoo(); + } + private: void _checkOk() const { |