[SERVER-4493] v0 indexes store empty arrays as nulls and the documents containing them may be improperly returned or counted when the matcher is bypassed Created: 14/Dec/11  Updated: 03/Dec/15  Resolved: 03/Dec/15

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

Type: Bug Priority: Major - P3
Reporter: Aaron Staple Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-4491 count() on a find() returns scanned c... Closed
Operating System: ALL
Participants:

 Description   

Has been fixed in v1 indexes. Mostly creating a ticket for this so we can track the issue if reported by users.

Here is the problem for v0 indexes:

> c.drop()
true
> c.ensureIndex(

{a:1}

,

{v:0}

)
> c.save(

{a:[]}

)
> c.find(

{a:null}

) // key matching only

{ "_id" : ObjectId("4ee8f8d00cf334c01d36adc3"), "a" : [ ] }

> c.find(

{a:null,b:null}

) // match full doc - [] not matching null
> c.count(

{a:null}

) // fast count bypasses matcher
1
> c.save(

{a:[1,2]}

) // make the index multikey
> c.find(

{a:null}

) // key matching does not occur for multikey indexes, so match full doc
> c.find(

{a:null,b:null}

) // match full doc
> c.count(

{a:null}

) // fast count bypasses matcher
1

We've fixed it for v1 indexes:

> c.drop()
true
> c.ensureIndex(

{a:1}

)
> c.save(

{a:[]}

)
> c.find(

{a:null}

)
> c.find(

{a:null,b:null}

)
> c.count(

{a:null}

)
0
> c.save(

{a:[1,2]}

)
> c.find(

{a:null}

)
> c.find(

{a:null,b:null}

)
> c.count(

{a:null}

)
0
>


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