summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeir Magnusson Jr <geir@geir-magnusson-jrs-mac-pro.local>2008-04-30 08:47:50 -0400
committerGeir Magnusson Jr <geir@geir-magnusson-jrs-mac-pro.local>2008-04-30 08:47:50 -0400
commitb740de9c3b583cad95dfff3160dc525653392a13 (patch)
treee98343d5f78ed93e30470c5eadde94a82ab35a62
parentc6c693fdcc1bf49b8cc8065d7a5b2cfac6f27e6d (diff)
parent9b01407c9fd32d3c208346857499e745b2f5c6e8 (diff)
downloadmongo-b740de9c3b583cad95dfff3160dc525653392a13.tar.gz
Merge branch 'master' of ssh://git.10gen.com/data/gitroot/p
-rw-r--r--db/query.cpp34
1 files changed, 27 insertions, 7 deletions
diff --git a/db/query.cpp b/db/query.cpp
index 6aeb680fdcf..109257408f6 100644
--- a/db/query.cpp
+++ b/db/query.cpp
@@ -448,14 +448,12 @@ bool dbEval(JSObj& cmd, JSObjBuilder& result) {
//
// returns true if ran a cmd
//
-inline bool runCommands(const char *ns, JSObj& jsobj, stringstream& ss, BufBuilder &b, JSObjBuilder& anObjBuilderForYa) {
+inline bool _runCommands(const char *ns, JSObj& jsobj, stringstream& ss, BufBuilder &b, JSObjBuilder& anObjBuilderForYa) {
const char *p = strchr(ns, '.');
if( !p ) return false;
if( strcmp(p, ".$cmd") != 0 ) return false;
-// ss << "\n $cmd: " << jsobj.toString();
-
bool ok = false;
bool valid = false;
@@ -464,8 +462,6 @@ inline bool runCommands(const char *ns, JSObj& jsobj, stringstream& ss, BufBuild
Element e;
e = jsobj.firstElement();
-// assert(false);
-
if( e.eoo() ) goto done;
if( e.type() == Code ) {
valid = true;
@@ -474,8 +470,17 @@ inline bool runCommands(const char *ns, JSObj& jsobj, stringstream& ss, BufBuild
else if( e.type() == Number ) {
if( strcmp(e.fieldName(), "profile") == 0 ) {
anObjBuilderForYa.append("was", (double) client->profile);
- client->profile = (int) e.number();
- valid = ok = true;
+ int p = (int) e.number();
+ valid = true;
+ if( p == -1 )
+ ok = true;
+ else if( p >= 0 && p <= 2 ) {
+ ok = true;
+ client->profile = p;
+ }
+ else {
+ ok = false;
+ }
}
else {
if( strncmp(ns, "admin", p-ns) != 0 ) // admin only
@@ -594,6 +599,21 @@ done:
return true;
}
+bool runCommands(const char *ns, JSObj& jsobj, stringstream& ss, BufBuilder &b, JSObjBuilder& anObjBuilderForYa) {
+ try {
+ return _runCommands(ns, jsobj, ss, b, anObjBuilderForYa);
+ }
+ catch( AssertionException ) {
+ ;
+ }
+ ss << " assertion ";
+ anObjBuilderForYa.append("errmsg", "db assertion failure");
+ anObjBuilderForYa.append("ok", 0.0);
+ JSObj x = anObjBuilderForYa.done();
+ b.append((void*) x.objdata(), x.objsize());
+ return true;
+}
+
int nCaught = 0;
void killCursors(int n, long long *ids) {