diff --git a/db/clientcursor.h b/db/clientcursor.h index 6f79dcff372..b895c1769ac 100644 --- a/db/clientcursor.h +++ b/db/clientcursor.h @@ -138,17 +138,18 @@ namespace mongo { /*const*/ CursorId cursorid; const string ns; const shared_ptr c; - int pos; // # objects into the cursor so far - BSONObj query; + int pos; // # objects into the cursor so far + const BSONObj query; // used for logging diags only; optional in constructor const int _queryOptions; // see enum QueryOptions dbclient.h OpTime _slaveReadTill; Database * const _db; - ClientCursor(int queryOptions, shared_ptr& _c, const string& _ns) : + ClientCursor(int queryOptions, shared_ptr& _c, const string& _ns, BSONObj _query = BSONObj()) : _idleAgeMillis(0), _pinValue(0), _doingDeletes(false), _yieldSometimesTracker(128,10), ns(_ns), c(_c), - pos(0), _queryOptions(queryOptions), + pos(0), query(_query), + _queryOptions(queryOptions), _db( cc().database() ) { assert( _db ); diff --git a/db/oplog.h b/db/oplog.h index d1e49900dc9..34c345f31e0 100644 --- a/db/oplog.h +++ b/db/oplog.h @@ -195,7 +195,7 @@ namespace mongo { // Use a ClientCursor here so we can release db mutex while scanning // oplog (can take quite a while with large oplogs). shared_ptr c = _qp.newReverseCursor(); - _findingStartCursor = new ClientCursor(QueryOption_NoCursorTimeout, c, _qp.ns()); + _findingStartCursor = new ClientCursor(QueryOption_NoCursorTimeout, c, _qp.ns(), BSONObj()); _findingStartTimer.reset(); _findingStartMode = Initial; BSONElement tsElt = _qp.originalQuery()[ "ts" ]; diff --git a/db/query.cpp b/db/query.cpp index 60b58998bc0..baf49df03d8 100644 --- a/db/query.cpp +++ b/db/query.cpp @@ -1063,13 +1063,12 @@ namespace mongo { if ( moreClauses ) { // this MultiCursor will use a dumb NoOp to advance(), so no need to specify mayYield shared_ptr< Cursor > multi( new MultiCursor( mps, cursor, dqo.matcher(), dqo ) ); - cc = new ClientCursor(queryOptions, multi, ns); + cc = new ClientCursor(queryOptions, multi, ns, jsobj.getOwned()); } else { cursor->setMatcher( dqo.matcher() ); - cc = new ClientCursor( queryOptions, cursor, ns ); + cc = new ClientCursor( queryOptions, cursor, ns, jsobj.getOwned() ); } cursorid = cc->cursorid; - cc->query = jsobj.getOwned(); DEV tlog(2) << "query has more, cursorid: " << cursorid << endl; cc->pos = n; cc->pq = pq_shared;