mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
Merge branch 'master' of git@github.com:mongodb/mongo
This commit is contained in:
commit
befa6fb41f
@ -328,6 +328,15 @@ namespace mongo {
|
||||
return names;
|
||||
}
|
||||
|
||||
bool DBClientWithCommands::exists( const string& ns ){
|
||||
list<string> names;
|
||||
|
||||
string db = nsGetDB( ns ) + ".system.namespaces";
|
||||
BSONObj q = BSON( "name" << ns );
|
||||
return count( db.c_str() , q );
|
||||
}
|
||||
|
||||
|
||||
void testSort() {
|
||||
DBClientConnection c;
|
||||
string err;
|
||||
|
@ -522,6 +522,8 @@ namespace mongo {
|
||||
*/
|
||||
list<string> getCollectionNames( const string& db );
|
||||
|
||||
bool exists( const string& ns );
|
||||
|
||||
virtual string toString() = 0;
|
||||
|
||||
/** @return the database name portion of an ns string */
|
||||
|
10
db/mr.cpp
10
db/mr.cpp
@ -240,7 +240,13 @@ namespace mongo {
|
||||
|
||||
string ns = database->name + '.' + cmdObj.firstElement().valuestr();
|
||||
log(1) << "mr ns: " << ns << endl;
|
||||
|
||||
|
||||
if ( ! db.exists( ns ) ){
|
||||
errmsg = "ns doesn't exist";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
auto_ptr<Scope> s = globalScriptEngine->getPooledScope( ns );
|
||||
s->localConnect( database->name.c_str() );
|
||||
|
||||
@ -337,7 +343,7 @@ namespace mongo {
|
||||
result.append( "numObjects" , num );
|
||||
result.append( "timeMillis" , t.millis() );
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -25,6 +25,7 @@ r = function( key , values ){
|
||||
};
|
||||
|
||||
res = db.runCommand( { mapreduce : "mr1" , map : m , reduce : r } );
|
||||
assert( res.ok , "not ok" );
|
||||
assert.eq( 4 , res.numObjects , "A" );
|
||||
x = db[res.result];
|
||||
|
||||
@ -82,3 +83,10 @@ print( Date.timeFunc(
|
||||
function(){
|
||||
db.runCommand( { mapreduce : "mr1" , map : m , reduce : r } );
|
||||
} , 10 ) );
|
||||
|
||||
|
||||
|
||||
// test doesn't exist
|
||||
res = db.runCommand( { mapreduce : "lasjdlasjdlasjdjasldjalsdj12e" , map : m , reduce : r } );
|
||||
assert( ! res.ok , "should be not ok" );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user