diff options
-rw-r--r-- | jstests/core/shelllimit.js | 21 | ||||
-rw-r--r-- | src/mongo/scripting/mozjs/cursor.cpp | 12 | ||||
-rw-r--r-- | src/mongo/scripting/mozjs/cursor.h | 3 | ||||
-rw-r--r-- | src/mongo/shell/query.js | 20 |
4 files changed, 3 insertions, 53 deletions
diff --git a/jstests/core/shelllimit.js b/jstests/core/shelllimit.js deleted file mode 100644 index cc7e7359ef6..00000000000 --- a/jstests/core/shelllimit.js +++ /dev/null @@ -1,21 +0,0 @@ -// This checks to make sure that cursors with a limit get killed by the shell -// after all their results have been returned. See SERVER-17792. -(function() { - "use strict"; - - var t = db.cursor_limit_test; - t.drop(); - var pre = db.serverStatus().metrics.cursor.open.total; - - for (var i=1; i<=5; i++) { - t.save( { a : i } ); - } - - var c = t.find().limit(3); - while(c.hasNext()) { - var v = c.next(); - } - - assert.eq(pre,db.serverStatus().metrics.cursor.open.total); - t.drop(); -}()); diff --git a/src/mongo/scripting/mozjs/cursor.cpp b/src/mongo/scripting/mozjs/cursor.cpp index cceecba98bb..8f6bb7b540c 100644 --- a/src/mongo/scripting/mozjs/cursor.cpp +++ b/src/mongo/scripting/mozjs/cursor.cpp @@ -38,12 +38,11 @@ namespace mongo { namespace mozjs { -const JSFunctionSpec CursorInfo::methods[6] = { +const JSFunctionSpec CursorInfo::methods[5] = { MONGO_ATTACH_JS_FUNCTION(hasNext), MONGO_ATTACH_JS_FUNCTION(next), MONGO_ATTACH_JS_FUNCTION(objsLeftInBatch), MONGO_ATTACH_JS_FUNCTION(readOnly), - MONGO_ATTACH_JS_FUNCTION(kill), JS_FS_END, }; @@ -119,14 +118,5 @@ void CursorInfo::Functions::readOnly(JSContext* cx, JS::CallArgs args) { args.rval().set(args.thisv()); } -void CursorInfo::Functions::kill(JSContext* cx, JS::CallArgs args) { - auto cursor = getCursor(args); - - if (cursor) - cursor->kill(); - - args.rval().setUndefined(); -} - } // namespace mozjs } // namespace mongo diff --git a/src/mongo/scripting/mozjs/cursor.h b/src/mongo/scripting/mozjs/cursor.h index 5316f2c3a68..39c8ba56295 100644 --- a/src/mongo/scripting/mozjs/cursor.h +++ b/src/mongo/scripting/mozjs/cursor.h @@ -47,13 +47,12 @@ struct CursorInfo : public BaseInfo { struct Functions { MONGO_DEFINE_JS_FUNCTION(hasNext); - MONGO_DEFINE_JS_FUNCTION(kill); MONGO_DEFINE_JS_FUNCTION(next); MONGO_DEFINE_JS_FUNCTION(objsLeftInBatch); MONGO_DEFINE_JS_FUNCTION(readOnly); }; - static const JSFunctionSpec methods[6]; + static const JSFunctionSpec methods[5]; static const char* const className; static const unsigned classFlags = JSCLASS_HAS_PRIVATE; diff --git a/src/mongo/shell/query.js b/src/mongo/shell/query.js index 668d3a5c1b5..e9317052163 100644 --- a/src/mongo/shell/query.js +++ b/src/mongo/shell/query.js @@ -51,7 +51,6 @@ DBQuery.prototype.help = function () { print("\t.map( func )") print("\t.hasNext()") print("\t.next()") - print("\t.kill()") print("\t.objsLeftInBatch() - returns count of docs left in current batch (when exhausted, a new getMore will be issued)") print("\t.itcount() - iterates through documents and counts them") print("\t.getQueryPlan() - get query plans associated with shape. To get more info on query plans, " + @@ -256,10 +255,8 @@ DBQuery.prototype.skip = function( skip ){ DBQuery.prototype.hasNext = function(){ this._exec(); - if ( this._limit > 0 && this._cursorSeen >= this._limit ) { - this._cursor.kill(); + if ( this._limit > 0 && this._cursorSeen >= this._limit ) return false; - } var o = this._cursor.hasNext(); return o; } @@ -668,21 +665,6 @@ function DBCommandCursor(mongo, cmdResult, batchSize) { DBCommandCursor.prototype = {}; -DBCommandCursor.prototype.kill = function() { - if (!this._useReadCommands) { - this._cursor.kill(); - } else { - var killCursorCmd = { - killCursors: this._collName, - cursors: [ this._cursorid ], - }; - var cmdRes = this._db.runCommand(killCursorCmd); - assert.commandWorked(cmdRes); - - this._cursorHandle.zeroCursorId(); - } -} - /** * Fills out this._batch by running a getMore command. If the cursor is exhausted, also resets * this._cursorid to 0. |