[SERVER-15107] Count behaviour with a bad hint is inconsistent Created: 01/Sep/14  Updated: 02/Sep/14  Resolved: 02/Sep/14

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.6.4
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Ross Lawley Assignee: Ramon Fernandez Marina
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-14792 count command with a bad index hint d... Closed
Operating System: ALL
Steps To Reproduce:

collection = db.jstests_count_hint;
collection.drop();
 
assert.throws( function() { collection.find( { i: 1 } ).hint( "BAD HINT" ).count(); }, [], "A");
assert.throws( function() { collection.find().hint( "BAD HINT" ).count(); }, [], "B");
 
collection.save({i: 1});
assert.throws( function() { collection.find({ i: 1 }).hint( "BAD HINT" ).count(); }, [], "C");

Participants:

 Description   

Running a count with an invalid hint may or may not error.

1. If there are no documents in the collection it won't error
2. If there are documents but no filter it won't error
3. If there are documents and a filter it will error

collection = db.jstests_count_hint;
collection.drop();
 
assert.throws( function() { collection.find( { i: 1 } ).hint( "BAD HINT" ).count(); }, [], "A");
assert.throws( function() { collection.find().hint( "BAD HINT" ).count(); }, [], "B");
 
collection.save({i: 1});
assert.throws( function() { collection.find({ i: 1 }).hint( "BAD HINT" ).count(); }, [], "C");

Only "C" will error.


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