[SERVER-49720] [SBE] Query comparison operators traverse one level too deep Created: 19/Jul/20  Updated: 29/Oct/23  Resolved: 21/Jul/20

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

Type: Bug Priority: Major - P3
Reporter: Drew Paroski Assignee: Drew Paroski
Resolution: Fixed Votes: 0
Labels: qexec-team
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

> db.adminCommand({setParameter: 1, internalQueryEnableSlotBasedExecutionEngine: false})
{ "was" : false, "ok" : 1 }
> db.c.find({}, {_id: 0})
{ "a" : "foo" }
{ "a" : [ "foo" ] }
{ "a" : [ [ "foo" ] ] }
{ "a" : [ [ [ "foo" ] ] ] }
> db.c.find({a: {$eq: "foo"}}, {_id: 0})
{ "a" : "foo" }
{ "a" : [ "foo" ] }
> db.c.find({a: {$regex: "foo"}}, {_id: 0})
{ "a" : "foo" }
{ "a" : [ "foo" ] }

> db.adminCommand({setParameter: 1, internalQueryEnableSlotBasedExecutionEngine: true})
{ "was" : false, "ok" : 1 }
> db.c.find({a: {$eq: "foo"}}, {_id: 0})
{ "a" : "foo" }
{ "a" : [ "foo" ] }
{ "a" : [ [ "foo" ] ] }
> db.c.find({a: {$regex: "foo"}}, {_id: 0})
{ "a" : "foo" }
{ "a" : [ "foo" ] }
{ "a" : [ [ "foo" ] ] }

Sprint: Query 2020-07-27
Participants:

 Description   

When working onĀ SERVER-49686, I noticed that when a field in a collection contains arrays of arrays, in some cases when using the basic query comparison operators ($eq, $lt, $gt, etc.) the find() command can return documents that it shouldn't. Specifically, it appears the query comparison operators traverse one level too deep when dealing with fields whose values are arrays. It appears the $regex operator is also affected by this bug. For examples of the bug, see the "Steps to Reproduce" section of this ticket.



 Comments   
Comment by Githook User [ 21/Jul/20 ]

Author:

{'name': 'Drew Paroski', 'email': 'drew.paroski@mongodb.com', 'username': 'paroski'}

Message: SERVER-49720 [SBE] Query comparison operators traverse one level too deep
Branch: master
https://github.com/mongodb/mongo/commit/d3a0a1b63b35f0f1f00378fd4ef6129d5ce78ba7

Generated at Thu Feb 08 05:20:37 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.