diff options
author | Eliot Horowitz <eliot@10gen.com> | 2011-03-01 13:20:54 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2011-03-01 13:21:04 -0500 |
commit | e295d14d1d6ca0ed1508ed5a844a167430abf721 (patch) | |
tree | b1e06f4cbaa45d6f05ba9ac59b86c105fbe27e5f /s/d_split.cpp | |
parent | 244655b2ad204f8462b8f3ecfdd6f0cbbaa1dc16 (diff) | |
download | mongo-e295d14d1d6ca0ed1508ed5a844a167430abf721.tar.gz |
null is ok in shard key, blank is not SERVER-2648
Diffstat (limited to 's/d_split.cpp')
-rw-r--r-- | s/d_split.cpp | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/s/d_split.cpp b/s/d_split.cpp index 1db1c29b0e0..a2e92f9be3e 100644 --- a/s/d_split.cpp +++ b/s/d_split.cpp @@ -178,18 +178,37 @@ namespace mongo { } // for now, the only check is that all shard keys are filled + // null is ok, // TODO if $exist for nulls were picking the index, it could be used instead efficiently while ( cc->ok() ) { BSONObj currKey = c->currKey(); - BSONForEach(key, currKey) { - if ( key.type() == jstNULL ) { - ostringstream os; - os << "found null value in key " << bc->prettyKey( currKey ); - log() << "checkShardingIndex for '" << ns << "' failed: " << os.str() << endl; + + BSONObjIterator i( currKey ); + int n = 0; + while ( i.more() ) { + BSONElement key = i.next(); + n++; + + if ( key.type() && key.type() != jstNULL ) + continue; + + BSONObj obj = c->current(); + BSONObjIterator j( keyPattern ); + BSONElement real; + for ( int x=0; x<n; x++ ) + real = j.next(); + + real = obj.getFieldDotted( real.fieldName() ); - errmsg = os.str(); - return false; - } + if ( real.type() ) + continue; + + ostringstream os; + os << "found null value in key " << bc->prettyKey( currKey ) << " for doc: " << real["_id"]; + log() << "checkShardingIndex for '" << ns << "' failed: " << os.str() << endl; + + errmsg = os.str(); + return false; } cc->advance(); } |