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

count command with a bad index hint does not fail if the query is empty

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • 3.1.0
    • 2.6.3
    • Querying
    • None
    • Fully Compatible
    • ALL

    Description

      There is a small inconsistency between count with an index hint and a regular query with an index hint. A regular query with an empty find() that hints a non-existent index will report an error:

      > db.test.find().hint('BAD HINT')
      error: {
      	"$err" : "Unable to execute query: error processing query: ns=test.test limit=0 skip=0\nTree: $and\nSort: {}\nProj: {}\n planner returned error: bad hint",
      	"code" : 17007
      }

      while count does not:

      > db.test.find().hint( "BAD HINT" ).count();
      2

      Though it does if query criteria is specified

      > db.test.find( { i: 1 } ).hint( "BAD HINT" ).count();
      2014-08-05T13:09:25.719-0400 count failed: {
      	"errmsg" : "exception: error processing query: ns=test.test limit=0 skip=0\nTree: i == 1.0\nSort: {}\nProj: {}\n planner returned error: bad hint",
      	"code" : 2,
      	"ok" : 0
      } at src/mongo/shell/query.js:191

      Attachments

        Activity

          People

            david.storch@mongodb.com David Storch
            jeff.yemin@mongodb.com Jeffrey Yemin
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: