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

[SBE] SizeMatchExpression can produce wrong results in some cases involving nesting

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 4.9.0
    • None
    • Querying
    • Fully Compatible
    • ALL
    • Hide

      > db.coll.insert({a: 1, b: "foo"})
      > db.coll.insert({a: 1, b: [7,8,9]})
      > db.coll.find({}, {_id: 0})
      { "a" : 1, "b" : "foo" }
      { "a" : 1, "b" : [ 7, 8, 9 ] }

      > db.adminCommand({setParameter:1, internalQueryEnableSlotBasedExecutionEngine:false})
      > db.coll.find({$or: [{$and: [{b: {$size: 3}}, {a: 1}]}, {a: 0}]}, {_id: 0})
      { "a" : 1, "b" : [ 7, 8, 9 ] }

      > db.adminCommand({setParameter:1, internalQueryEnableSlotBasedExecutionEngine:true})
      > db.coll.find({$or: [{$and: [{b: {$size: 3}}, {a: 1}]}, {a: 0}]}, {_id: 0})
      { "a" : 1, "b" : "foo" }
      { "a" : 1, "b" : [ 7, 8, 9 ] }

      Show
      > db.coll.insert({a: 1, b: "foo"}) > db.coll.insert({a: 1, b: [7,8,9]}) > db.coll.find({}, {_id: 0}) { "a" : 1, "b" : "foo" } { "a" : 1, "b" : [ 7, 8, 9 ] } > db.adminCommand({setParameter:1, internalQueryEnableSlotBasedExecutionEngine:false}) > db.coll.find({$or: [{$and: [{b: {$size: 3}}, {a: 1}]}, {a: 0}]}, {_id: 0}) { "a" : 1, "b" : [ 7, 8, 9 ] } > db.adminCommand({setParameter:1, internalQueryEnableSlotBasedExecutionEngine:true}) > db.coll.find({$or: [{$and: [{b: {$size: 3}}, {a: 1}]}, {a: 0}]}, {_id: 0}) { "a" : 1, "b" : "foo" } { "a" : 1, "b" : [ 7, 8, 9 ] }
    • Query 2020-11-16

    Description

      See the "Steps to Reproduce" section for an example where using the $size operator in the find() command can produce incorrect results when SBE mode is enabled.

      Attachments

        Activity

          People

            melodee.li@mongodb.com Melodee Li
            andrew.paroski@mongodb.com Drew Paroski
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: