Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-49720

[SBE] Query comparison operators traverse one level too deep

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.7.0
    • Affects Version/s: None
    • Component/s: Querying
    • Labels:
    • Fully Compatible
    • ALL
    • Hide
      > 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" ] ] }
      Show
      > 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" ] ] }
    • Query 2020-07-27

      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.

            Assignee:
            andrew.paroski@mongodb.com Drew Paroski
            Reporter:
            andrew.paroski@mongodb.com Drew Paroski
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: