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

Shell should return error when user requests count on non-countable cursor

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Minor - P4 Minor - P4
    • None
    • None
    • Querying, Shell
    • Server Tooling & Methods
    • ALL

    Description

      When a user requests a count on a cursor in the shell, all query options unsupported by the count command are ignored, and an incorrect result is delivered to the user. The shell should instead return an error to the user when a count is requested on such a cursor.

      Reproduce as follows:

      > db.foo.drop()
      false
      > db.foo.ensureIndex({a: 1})
      {
      	"createdCollectionAutomatically" : true,
      	"numIndexesBefore" : 1,
      	"numIndexesAfter" : 2,
      	"ok" : 1
      }
      > db.foo.insert({a: 1})
      WriteResult({ "nInserted" : 1 })
      > db.foo.insert({a: 2})
      WriteResult({ "nInserted" : 1 })
      > db.foo.insert({a: 3})
      WriteResult({ "nInserted" : 1 })
      > db.foo.find({}).max({a: 2}).itcount()
      1
      > db.foo.find({}).max({a: 2}).count()
      3  // Unexpected: should return error.
      > db.foo.find({}).min({a: 2}).itcount()
      2
      > db.foo.find({}).min({a: 2}).count()
      3  // Unexpected: should return error.
      > db.foo.find({}).maxScan(1).itcount()
      1
      > db.foo.find({}).maxScan(1).count()
      3  // Unexpected: should return error.
      >
      

      Attachments

        Activity

          People

            backlog-server-stm Backlog - Server Tooling and Methods (STM) (Inactive)
            rassi J Rassi
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: