• Ramil Kalimullin's avatar
    Fix for bug#52051: Aggregate functions incorrectly returns · a882f7e6
    Ramil Kalimullin authored
          NULL from outer join query
          
          Problem: optimising MIN/MAX() queries without GROUP BY clause
          by replacing the aggregate expression with a constant, we may set it
          to NULL disregarding the fact that there may be outer joins involved.
          
          Fix: don't replace MIN/MAX() with NULL if there're outer joins.
          
          Note: the fix itself is just
          - if (!count)
          + if (!count && !outer_tables)
              set to NULL
          
          The rest of the patch eliminates repeated code to improve speed
          and for easy maintenance of the code.
    a882f7e6
group_by.test 43.8 KB