Permalink
Browse files

fix crash in filemd5 without correct index SERVER-3913

  • Loading branch information...
1 parent a0288e5 commit 68773c1816e297500c0727ea8037e5377550d171 @erh erh committed Sep 23, 2011
Showing with 15 additions and 0 deletions.
  1. +4 −0 db/dbcommands.cpp
  2. +11 −0 jstests/filemd5.js
View
@@ -1102,6 +1102,10 @@ namespace mongo {
BSONObj sort = BSON( "files_id" << 1 << "n" << 1 );
shared_ptr<Cursor> cursor = bestGuessCursor(ns.c_str(), query, sort);
+ if ( ! cursor ) {
+ errmsg = "need an index on { files_id : 1 , n : 1 }";
+ return false;
+ }
auto_ptr<ClientCursor> cc (new ClientCursor(QueryOption_NoCursorTimeout, cursor, ns.c_str()));
int n = 0;
View
@@ -0,0 +1,11 @@
+
+db.fs.chunks.drop();
+db.fs.chunks.insert({files_id:1,n:0,data:new BinData(0,"test")})
+
+x = db.runCommand({"filemd5":1,"root":"fs"});
+assert( ! x.ok , tojson(x) )
+
+db.fs.chunks.ensureIndex({files_id:1,n:1})
+x = db.runCommand({"filemd5":1,"root":"fs"});
+assert( x.ok , tojson(x) )
+

0 comments on commit 68773c1

Please sign in to comment.