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

Expression::optimize() is used incorrectly when trying to convert $group to streaming for time-series

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 7.1.0-rc0
    • None
    • None
    • Query Execution
    • Fully Compatible
    • QE 2023-08-07

    Description

      This line of code incorrectly discards the return value. It's written like so:

      idFields[i]->optimize();  // We optimize here to make use of constant folding.
      

      But it should be this:

      idFields[i] = idFields[i]->optimize();  // We optimize here to make use of constant folding.
      

      The reason is that the Expression::optimize() function does not optimize the expression in place but rather returns a pointer to the optimized expression.

      While we're at it, we should consider adding the "[[nodiscard]]" attribute to Expression::optimize() in order to try to prevent this kind of mistake in the future.

      Attachments

        Activity

          People

            foteini.alvanaki@mongodb.com Foteini Alvanaki
            david.storch@mongodb.com David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: