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

XMLWordPrintableJSON

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

      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
              Reporter:
              Jeffrey Yemin
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: