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

MatchExpressionParser can discard sibling predicates of certain match expressions

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.6.0-rc0
    • Affects Version/s: 3.5.12
    • Component/s: Querying
    • Labels:
      None
    • Fully Compatible
    • ALL
    • Query 2017-10-02

      MatchExpressionParser::_parse() is intended to iterate through each top-level element of the match expression, parse that element, and add the result to an AndMatchExpression. In several cases, however, we instead return the result without adding it to the AndMatchExpression. One such case handles the $jsonSchema expression:

      https://github.com/mongodb/mongo/blob/master/src/mongo/db/matcher/expression_parser.cpp#L586-L600

      As a result, the MatchExpression is parsed incorrectly and will return extra results. In this example, the document with a equal to 1 is returned incorrectly:

      > db.c.drop()
      true
      > db.c.insert({a: 1})
      WriteResult({ "nInserted" : 1 })
      > db.c.insert({a: 2})
      WriteResult({ "nInserted" : 1 })
      > db.c.find({$jsonSchema: {}, a: 2})
      { "_id" : ObjectId("59b6fbbfd29495ce436648f2"), "a" : 1 }
      { "_id" : ObjectId("59b6fbc0d29495ce436648f3"), "a" : 2 }
      

      This was introduced during development of the JSON Schema project, and therefore does not affect any stable version of the server.

            Assignee:
            david.storch@mongodb.com David Storch
            Reporter:
            david.storch@mongodb.com David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: