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

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.1.0
    • Affects Version/s: 2.6.3
    • Component/s: Querying
    • None
    • Fully Compatible
    • ALL

      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
      

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

              Created:
              Updated:
              Resolved: