diff options
author | Eliot Horowitz <eliot@10gen.com> | 2010-10-29 09:49:45 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2010-10-29 09:49:45 -0400 |
commit | dab6e79b37dcdf2d1b58e935370c43e4c91004b4 (patch) | |
tree | 907b9c50c138c8b01e8ff88ef306e04387f66521 | |
parent | 92d0ac477de0b7fc032d6fa0ec1f88623d44cd1f (diff) | |
parent | fa89431e6c97e88a5adf6d09cfb66394cec4ecb4 (diff) | |
download | mongo-dab6e79b37dcdf2d1b58e935370c43e4c91004b4.tar.gz |
Merge branch 'master' of github.com:mongodb/mongo
-rw-r--r-- | client/dbclient.cpp | 4 | ||||
-rw-r--r-- | client/dbclient.h | 3 | ||||
-rw-r--r-- | db/dbcommands.cpp | 28 | ||||
-rw-r--r-- | db/query.cpp | 10 |
4 files changed, 22 insertions, 23 deletions
diff --git a/client/dbclient.cpp b/client/dbclient.cpp index 41b75985bfe..828e4d05c33 100644 --- a/client/dbclient.cpp +++ b/client/dbclient.cpp @@ -478,7 +478,7 @@ namespace mongo { auto_ptr<DBClientCursor> c = this->query(ns, query, 1, 0, fieldsToReturn, queryOptions); - uassert( 10276 , "DBClientBase::findOne: transport error", c.get() ); + uassert( 10276 , str::stream() << "DBClientBase::findOne: transport error: " << getServerAddress() , c.get() ); if ( c->hasResultFlag( ResultFlag_ShardConfigStale ) ) throw StaleConfigException( ns , "findOne has stale config" ); @@ -842,7 +842,7 @@ namespace mongo { if ( !port().call(toSend, response) ) { failed = true; if ( assertOk ) - uassert( 10278 , "dbclient error communicating with server", false); + uasserted( 10278 , str::stream() << "dbclient error communicating with server: " << getServerAddress() ); return false; } } diff --git a/client/dbclient.h b/client/dbclient.h index eaa63944423..8598ae2e32a 100644 --- a/client/dbclient.h +++ b/client/dbclient.h @@ -332,8 +332,6 @@ namespace mongo { /* used by QueryOption_Exhaust. To use that your subclass must implement this. */ virtual void recv( Message& m ) { assert(false); } - - virtual string getServerAddress() const = 0; }; /** @@ -363,6 +361,7 @@ namespace mongo { */ virtual BSONObj findOne(const string &ns, const Query& query, const BSONObj *fieldsToReturn = 0, int queryOptions = 0); + virtual string getServerAddress() const = 0; }; diff --git a/db/dbcommands.cpp b/db/dbcommands.cpp index 41781b9685c..0feccf019c7 100644 --- a/db/dbcommands.cpp +++ b/db/dbcommands.cpp @@ -1359,24 +1359,26 @@ namespace mongo { } else { - Query idQuery = QUERY( "_id" << out["_id"]); - if (cmdObj["remove"].trueValue()){ uassert(12515, "can't remove and update", cmdObj["update"].eoo()); - db.remove(ns, idQuery, 1); + db.remove(ns, QUERY("_id" << out["_id"]), 1); } else { // update - // need to include original query for $ positional operator - BSONObjBuilder b; - b.append(out["_id"]); - BSONObjIterator it(origQuery); - while (it.more()){ - BSONElement e = it.next(); - if (strcmp(e.fieldName(), "_id")) - b.append(e); + BSONElement queryId = origQuery["_id"]; + if (queryId.eoo() || getGtLtOp(queryId) != BSONObj::Equality){ + // need to include original query for $ positional operator + + BSONObjBuilder b; + b.append(out["_id"]); + BSONObjIterator it(origQuery); + while (it.more()){ + BSONElement e = it.next(); + if (strcmp(e.fieldName(), "_id")) + b.append(e); + } + q = Query(b.obj()); } - q = Query(b.obj()); BSONElement update = cmdObj["update"]; uassert(12516, "must specify remove or update", !update.eoo()); @@ -1389,7 +1391,7 @@ namespace mongo { } if (cmdObj["new"].trueValue()) - out = db.findOne(ns, idQuery, fields); + out = db.findOne(ns, QUERY("_id" << out["_id"]), fields); } } diff --git a/db/query.cpp b/db/query.cpp index d83dd054f5d..260fae7f76c 100644 --- a/db/query.cpp +++ b/db/query.cpp @@ -422,13 +422,12 @@ namespace mongo { if ( !ClientCursor::recoverFromYield( _yieldData ) ) { c_.reset(); _cc.reset(); - massert( 13337, "cursor dropped during count", false ); - // TODO maybe we want to prevent recording the winning plan as well? + // we don't fail query since we're fine with returning partial data if collection dropped } } virtual void next() { - if ( !c_->ok() ) { + if ( !c_ || !c_->ok() ) { setComplete(); return; } @@ -665,8 +664,7 @@ namespace mongo { _c.reset(); _cc.reset(); _so.reset(); - massert( 13338, "cursor dropped during query", false ); - // TODO maybe we want to prevent recording the winning plan as well? + // we don't fail query since we're fine with returning partial data if collection dropped } } @@ -689,7 +687,7 @@ namespace mongo { return; } - if ( !_c->ok() ) { + if ( !_c || !_c->ok() ) { finish( false ); return; } |