1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

Bug#54416 MAX from JOIN with HAVING returning NULL with 5.1 and Empty set

The problem there is that HAVING condition evaluates const
parts of condition despite the condition has references
on aggregate functions. Table t1 became const tables
after make_join_statistics and table1.pk = 1, HAVING is
transformed into MAX(1) < 7 and taken away from HAVING.
The fix is to skip evaluation of HAVING conts parts if
HAVING condition has references on aggregate functions.
This commit is contained in:
Sergey Glukhov
2010-07-09 14:39:47 +04:00
parent b440125f1c
commit 3c39a56208
3 changed files with 38 additions and 1 deletions

View File

@ -1132,7 +1132,7 @@ JOIN::optimize()
elements may be lost during further having
condition transformation in JOIN::exec.
*/
if (having && const_table_map)
if (having && const_table_map && !having->with_sum_func)
{
having->update_used_tables();
having= remove_eq_conds(thd, having, &having_value);