Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-24546

Explain() fails if negative batchSize value is specified

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • None
    • Query
    • ALL

      The documentation says that cursor.batchSize() takes negative arguments.

      "3.2.6"
      > db.version()
      3.2.6
      > version()
      3.2.6
      > db.testcol.find().batchSize(-5)
      Error: error: {
      	"waitedMS" : NumberLong(0),
      	"ok" : 0,
      	"errmsg" : "batchSize value must be non-negative",
      	"code" : 2
      }
      > db.testcol1.explain().find().batchSize(-5)
      2016-06-14T13:56:00.545+1000 E QUERY    [thread1] Error: explain failed: { "ok" : 0, "errmsg" : "batchSize value must be non-negative", "code" : 2 } :
      _getErrorWithCode@src/mongo/shell/utils.js:25:13
      throwOrReturn@src/mongo/shell/explainable.js:31:1
      constructor/this.finish@src/mongo/shell/explain_query.js:176:24
      constructor/this.shellPrint@src/mongo/shell/explain_query.js:215:26
      shellPrintHelper@src/mongo/shell/utils.js:489:1
      @(shell2):1:1
      
      "3.0.12"
      > db.testcol.find().batchSize(-10)
      { "_id" : ObjectId("575f809faa700ec9ca969857"), "a" : 0, "b" : "text" }
      { "_id" : ObjectId("575f809faa700ec9ca969858"), "a" : 1, "b" : "text" }
      { "_id" : ObjectId("575f809faa700ec9ca969859"), "a" : 2, "b" : "text" }
      { "_id" : ObjectId("575f809faa700ec9ca96985a"), "a" : 3, "b" : "text" }
      { "_id" : ObjectId("575f809faa700ec9ca96985b"), "a" : 4, "b" : "text" }
      { "_id" : ObjectId("575f809faa700ec9ca96985c"), "a" : 5, "b" : "text" }
      { "_id" : ObjectId("575f809faa700ec9ca96985d"), "a" : 6, "b" : "text" }
      { "_id" : ObjectId("575f809faa700ec9ca96985e"), "a" : 7, "b" : "text" }
      { "_id" : ObjectId("575f809faa700ec9ca96985f"), "a" : 8, "b" : "text" }
      { "_id" : ObjectId("575f809faa700ec9ca969860"), "a" : 9, "b" : "text" }
      > db.testcol.explain().find().batchSize(-10)
      2016-06-14T13:58:06.721+1000 E QUERY    Error: explain failed: { "ok" : 0, "errmsg" : "batchSize value must be positive", "code" : 2 }
          at Error (<anonymous>)
          at Function.throwOrReturn (src/mongo/shell/explainable.js:34:19)
          at constructor.finish (src/mongo/shell/explain_query.js:188:36)
          at constructor.shellPrint (src/mongo/shell/explain_query.js:228:31)
          at shellPrintHelper (src/mongo/shell/utils.js:396:18)
          at (shell2):1:19 at src/mongo/shell/explainable.js:34
      

      I am not sure if which behaviour is desired, if it's the one we have with 3.2 please move this ticket into DOCS.

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            dmitry.ryabtsev@mongodb.com Dmitry Ryabtsev
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: