-
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. mysql-test/r/group_by.result: Fix for bug#52051: Aggregate functions incorrectly returns NULL from outer join query - test result. mysql-test/t/group_by.test: Fix for bug#52051: Aggregate functions incorrectly returns NULL from outer join query - test case. sql/opt_sum.cc: Fix for bug#52051: Aggregate functions incorrectly returns NULL from outer join query - optimising MIN/MAX() queries without GROUP BY clause by replacing them with a constant, take into account that there're may be outer joins involved. - repeated code for MIN/MAX optimization in the opt_sum_query() eliminated by introducing new functions that read MIN/MAX values using index and combining MIN/MAX cases to one.
18e4d1ae