mirror of
https://github.com/MariaDB/server.git
synced 2026-05-09 16:44:29 +02: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. mysql-test/r/having.result: test case mysql-test/t/having.test: test case sql/sql_select.cc: skip evaluation of HAVING conts parts if HAVING condition has references on aggregate functions.
This commit is contained in:
parent
625ae7185a
commit
013136364c
3 changed files with 38 additions and 1 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue