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

Make ExpressionSetUnion::isCommutative() collation aware

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 4.4.13, 5.0.7, 4.2.20, 6.0.0-rc5, 6.1.0-rc0
    • 4.2.23, 4.4.17, 6.0.1, 5.0.11, 6.1.0-rc0
    • None
    • None
    • Fully Compatible
    • ALL
    • v6.0, v5.0, v4.4, v4.2
    • Hide

      To reproduce run the following:

      db.coll.drop();
      var coll = db.coll;
       
      coll.insertOne({_id: 0, time: new Date("2019-10-18T18:40:14.299Z") });
       
      const pl = [ {$group: {_id: {$setUnion: [["\u0019"], [{$reduce: {input: ["xyz"], initialValue: "aaa", in: ""}}], [[{}]]]}}} ];
      const collation = {locale: 'en_US', strength: 2, }
       
      db.adminCommand({'configureFailPoint': 'disablePipelineOptimization', 'mode': 'off'});
       
      db.runCommand({aggregate: "coll", pipeline: pl, cursor: {}, collation: collation});
      db.runCommand({aggregate: "coll", pipeline: pl, cursor: {}, collation: collation, explain: true});
       
      db.adminCommand({'configureFailPoint': 'disablePipelineOptimization', 'mode': 'alwaysOn'});
      db.runCommand({aggregate: "coll", pipeline: pl, cursor: {}, collation: collation});
      db.runCommand({aggregate: "coll", pipeline: pl, cursor: {}, collation: collation, explain: true});
      

      Show
      To reproduce run the following: db.coll.drop(); var coll = db.coll; coll.insertOne({_id: 0, time: new Date("2019-10-18T18:40:14.299Z") }); const pl = [ {$group: {_id: {$setUnion: [["\u0019"], [{$reduce: {input: ["xyz"], initialValue: "aaa", in: ""}}], [[{}]]]}}} ]; const collation = {locale: 'en_US', strength: 2, }   db.adminCommand({'configureFailPoint': 'disablePipelineOptimization', 'mode': 'off'}); db.runCommand({aggregate: "coll", pipeline: pl, cursor: {}, collation: collation}); db.runCommand({aggregate: "coll", pipeline: pl, cursor: {}, collation: collation, explain: true}); db.adminCommand({'configureFailPoint': 'disablePipelineOptimization', 'mode': 'alwaysOn'}); db.runCommand({aggregate: "coll", pipeline: pl, cursor: {}, collation: collation}); db.runCommand({aggregate: "coll", pipeline: pl, cursor: {}, collation: collation, explain: true});
    • QO 2022-05-16, QO 2022-05-30
    • 18

    Description

      The $setUnion aggregation expression is currently defined to be always commutative. This breaks down a collation is in place that can compare 2 different binary values as being the same. We should consider making ExpressionSetUnion::isCommutative() return false when a non-simple collation is in place.

      Attachments

        Activity

          People

            james.wahlin@mongodb.com James Wahlin
            timour.katchaounov@mongodb.com Timour Katchaounov
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: