[SERVER-16830] hint by index name breaks with explain() Created: 13/Jan/15  Updated: 23/Jan/15  Resolved: 15/Jan/15

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.7.8
Fix Version/s: 3.0.0-rc6

Type: Bug Priority: Minor - P4
Reporter: Asya Kamsky Assignee: J Rassi
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

test@local(2.8.0-rc4) > db.foo.getIndexes()
[
	{
		"v" : 1,
		"key" : {
			"_id" : 1
		},
		"name" : "_id_",
		"ns" : "test.foo"
	},
	{
		"v" : 1,
		"key" : {
			"a" : 1
		},
		"name" : "a_1",
		"ns" : "test.foo"
	}
]
test@local(2.8.0-rc4) > db.foo.find({a:1})
{ "_id" : ObjectId("54b588d2d7a7afb83a377935"), "a" : 1 }
test@local(2.8.0-rc4) > db.foo.find({a:1}).hint("a_1")
{ "_id" : ObjectId("54b588d2d7a7afb83a377935"), "a" : 1 }
test@local(2.8.0-rc4) > db.foo.find({a:1}).hint("a_1").explain()
2015-01-13T16:07:09.059-0500 I QUERY    Error: explain failed: {
	"ok" : 0,
	"errmsg" : "error processing query: ns=test.foo limit=0 skip=0\nTree: a == 1.0\nSort: {}\nProj: {}\n planner returned error: bad hint",
	"code" : 2
}
    at Error (<anonymous>)
    at Function.throwOrReturn (src/mongo/shell/explainable.js:34:19)
    at constructor.finish (src/mongo/shell/explain_query.js:188:36)
    at DBQuery.explain (src/mongo/shell/query.js:434:25)
    at (shell):1:32 at src/mongo/shell/explainable.js:34
test@local(2.8.0-rc4) > db.foo.find({a:1}).hint("a_1").explain(true)
2015-01-13T16:07:10.756-0500 I QUERY    Error: explain failed: {
	"ok" : 0,
	"errmsg" : "error processing query: ns=test.foo limit=0 skip=0\nTree: a == 1.0\nSort: {}\nProj: {}\n planner returned error: bad hint",
	"code" : 2
}
    at Error (<anonymous>)
    at Function.throwOrReturn (src/mongo/shell/explainable.js:34:19)
    at constructor.finish (src/mongo/shell/explain_query.js:188:36)
    at DBQuery.explain (src/mongo/shell/query.js:434:25)
    at (shell):1:32 at src/mongo/shell/explainable.js:34

So hint by name works, but with explain() appended it breaks.



 Comments   
Comment by Githook User [ 15/Jan/15 ]

Author:

{u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-16830 Fix LiteParsedQuery find command object "hint" parsing
Branch: master
https://github.com/mongodb/mongo/commit/40f28cd947e8a5227c5a4f6961143ad1b041105f

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