diff options
-rw-r--r-- | db/mr.cpp | 14 | ||||
-rw-r--r-- | shell/collection.js | 2 |
2 files changed, 9 insertions, 7 deletions
diff --git a/db/mr.cpp b/db/mr.cpp index b9d44928db9..ff88d9e75f2 100644 --- a/db/mr.cpp +++ b/db/mr.cpp @@ -467,11 +467,6 @@ namespace mongo { long long finalCount = mr.renameIfNeeded( db ); - if ( finalCount == 0 && shouldHaveData ){ - errmsg = "there were emits but no data!"; - return false; - } - timingBuilder.append( "total" , t.millis() ); result.append( "result" , mr.finalShort ); @@ -479,7 +474,13 @@ namespace mongo { countsBuilder.append( "output" , finalCount ); if ( mr.verbose ) result.append( "timing" , timingBuilder.obj() ); result.append( "counts" , countsBuilder.obj() ); - + + if ( finalCount == 0 && shouldHaveData ){ + result.append( "cmd" , cmd ); + errmsg = "there were emits but no data!"; + return false; + } + return true; } @@ -558,6 +559,7 @@ namespace mongo { continue; } + db.insert( mr.tempLong , reduceValues( values , s.get() , reduceFunction , 1 , finalizeFunction ) ); values.clear(); values.push_back( t ); diff --git a/shell/collection.js b/shell/collection.js index d94bad0514d..d228ba7065b 100644 --- a/shell/collection.js +++ b/shell/collection.js @@ -547,7 +547,7 @@ DBCollection.prototype.mapReduce = function( map , reduce , optional ){ Object.extend( c , optional ); var raw = this._db.runCommand( c ); if ( ! raw.ok ) - throw "map reduce failed: " + raw.errmsg; + throw "map reduce failed: " + tojson( raw ); return new MapReduceResult( this._db , raw ); } |