Skip to content

Commit

Permalink
add "ok" to commands result
Browse files Browse the repository at this point in the history
  • Loading branch information
erh committed Dec 1, 2009
1 parent c72e870 commit 49b5972
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 17 deletions.
2 changes: 2 additions & 0 deletions db/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ namespace mongo {
ok = c->run(ns, jsobj, errmsg, anObjBuilder, false);
}

anObjBuilder.append( "ok" , ok ? 1 : 0 );

if ( !ok ) {
anObjBuilder.append("errmsg", errmsg);
uassert_nothrow(errmsg.c_str());
Expand Down
1 change: 1 addition & 0 deletions db/dbcommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ namespace mongo {
if ( p != 1 )
return false;
dropDatabase(ns);
result.append( "dropped" , ns );
return true;
}
} cmdDropDatabase;
Expand Down
17 changes: 0 additions & 17 deletions s/commands_admin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ namespace mongo {
}

result.appendArray( "commands" , arr.done() );
result.append("ok" , 1 );
return true;
}
} listGridCommands;
Expand Down Expand Up @@ -187,7 +186,6 @@ namespace mongo {
fromconn->dropDatabase( dbname.c_str() );
fromconn.done();

result << "ok" << 1;
result << "primary" << to;

conn.done();
Expand Down Expand Up @@ -219,7 +217,6 @@ namespace mongo {
config->enableSharding();
config->save( true );

result << "ok" << 1;
return true;
}
} enableShardingCmd;
Expand Down Expand Up @@ -291,7 +288,6 @@ namespace mongo {
config->save( true );

result << "collectionsharded" << ns;
result << "ok" << 1;
return true;
}
} shardCollectionCmd;
Expand Down Expand Up @@ -388,7 +384,6 @@ namespace mongo {

result.append( "middle" , middle );

result << "ok" << 1;
return true;
}

Expand All @@ -407,7 +402,6 @@ namespace mongo {
else
old.split( middle );

result << "ok" << 1;
return true;
}

Expand Down Expand Up @@ -462,7 +456,6 @@ namespace mongo {
if ( ! c.moveAndCommit( to , errmsg ) )
return false;

result << "ok" << 1;
return true;
}
} moveChunkCmd;
Expand All @@ -486,7 +479,6 @@ namespace mongo {
}

result.append("shards" , all );
result.append("ok" , 1 );
conn.done();

return true;
Expand Down Expand Up @@ -534,7 +526,6 @@ namespace mongo {

BSONObj old = conn->findOne( "config.shards" , shard );
if ( ! old.isEmpty() ){
result.append( "ok" , 0.0 );
result.append( "msg" , "already exists" );
conn.done();
return false;
Expand All @@ -549,15 +540,13 @@ namespace mongo {
errmsg = "couldn't connect to new shard";
result.append( "host" , host );
result.append( "exception" , e.what() );
result.append( "ok" , 0 );
conn.done();
return false;
}



conn->insert( "config.shards" , shard );
result.append( "ok", 1 );
result.append( "added" , shard["host"].valuestrsafe() );
conn.done();
return true;
Expand Down Expand Up @@ -598,7 +587,6 @@ namespace mongo {
bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool) {
result.append("isdbgrid", 1);
result.append("hostname", ourHostname);
result << "ok" << 1;
return true;
}
} isdbgrid;
Expand All @@ -616,7 +604,6 @@ namespace mongo {
virtual bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool) {
result.append("ismaster", 1.0 );
result.append("msg", "isdbgrid");
result.append("ok" , 1 );
return true;
}
} ismaster;
Expand All @@ -633,7 +620,6 @@ namespace mongo {
CmdShardingGetPrevError() : Command("getpreverror") { }
virtual bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool) {
errmsg += "getpreverror not supported for sharded environments";
result << "ok" << 0;
return false;
}
} cmdGetPrevError;
Expand All @@ -659,7 +645,6 @@ namespace mongo {

if ( shards->size() == 0 ){
result.appendNull( "err" );
result.append( "ok" , 1 );
return true;
}

Expand All @@ -686,7 +671,6 @@ namespace mongo {

if ( errors.size() == 0 ){
result.appendNull( "err" );
result.append( "ok" , 1 );
return true;
}

Expand All @@ -697,7 +681,6 @@ namespace mongo {
all.append( all.numStr( i ).c_str() , errors[i].c_str() );
}
result.appendArray( "errs" , all.obj() );
result.append( "ok" , 1 );
return true;
}
} cmdGetLastError;
Expand Down

0 comments on commit 49b5972

Please sign in to comment.