[SERVER-14792] count command with a bad index hint does not fail if the query is empty Created: 05/Aug/14  Updated: 18/Sep/15  Resolved: 05/Feb/15

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.6.3
Fix Version/s: 3.1.0

Type: Bug Priority: Minor - P4
Reporter: Jeffrey Yemin Assignee: David Storch
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-15107 Count behaviour with a bad hint is in... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 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



 Comments   
Comment by Githook User [ 05/Feb/15 ]

Author:

{u'username': u'dstorch', u'name': u'David Storch', u'email': u'david.storch@10gen.com'}

Message: SERVER-14792 count with a bad hint should fail, even if there is no query predicate
Branch: master
https://github.com/mongodb/mongo/commit/c59a144b57d07d7310dc23ad9cc78a1618f37237

Generated at Thu Feb 08 03:36:00 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.