[SERVER-12026] index bounds exclude Infinity for $or query Created: 10/Dec/13  Updated: 11/Jul/16  Resolved: 11/Dec/13

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

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

Operating System: ALL
Steps To Reproduce:

> t = db.t
test.t
> t.drop()
true
> t.ensureIndex({a: 1})
> t.insert({a: Infinity})
Insert WriteResult({ "ok" : 1, "n" : 1 })
> t.find()
{ "_id" : ObjectId("52a73a410ae4a72f57475846"), "a" : Infinity }
> t.find({a: {$gt: 1}})
{ "_id" : ObjectId("52a73a410ae4a72f57475846"), "a" : Infinity }
> t.find({$or: [{a: {$gt: 1}}, {a: {$lt: 3}}]})
// The previous query should return the document, but it returns nothing.

Participants:

 Description   

Consider the query

{$or: [{a: {$gt: 1}}, {a: {$lt: 3}}]}

with an index on field 'a'. The first branch of the $or has index bounds

(1, Infinity]

and the second branch of the $or has index bounds

[-Infinity, 3)

. Since these two branches are children of an $or, the final index bounds should be the union of these two intervals, which is

[-Infinity, Infinity]

However, the actual index bounds are

[-Infinity, Infinity)

The bug is that the upper bound should be inclusive, but instead it is exclusive.



 Comments   
Comment by Githook User [ 11/Dec/13 ]

Author:

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

Message: SERVER-12026 fix index bounds unionize inclusive vs. exclusive

Signed-off-by: Matt Kangas <matt.kangas@mongodb.com>
Branch: master
https://github.com/mongodb/mongo/commit/f0b52231c208586413137b6c7c4854918a482b31

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