1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-31 22:22:30 +03:00
A query with a group by and having clauses could return a wrong
result set if the having condition contained a constant conjunct 
evaluated to FALSE.
It happened because the pushdown condition for table with
grouping columns lost its constant conjuncts.
Pushdown conditions are always built by the function make_cond_for_table
that ignores constant conjuncts. This is apparently not correct when
constant false conjuncts are present.
This commit is contained in:
igor@rurik.mysql.com
2006-01-31 21:48:32 -08:00
parent 7e5108392d
commit d6370b48a7
6 changed files with 57 additions and 11 deletions

View File

@@ -501,12 +501,18 @@ JOIN::optimize()
DBUG_RETURN(1);
}
if (cond_value == Item::COND_FALSE ||
(!unit->select_limit_cnt && !(select_options & OPTION_FOUND_ROWS)))
{ /* Impossible cond */
zero_result_cause= "Impossible WHERE";
error= 0;
DBUG_RETURN(0);
{
Item::cond_result having_value;
having= optimize_cond(thd, having, &having_value);
if (cond_value == Item::COND_FALSE || having_value == Item::COND_FALSE ||
(!unit->select_limit_cnt && !(select_options & OPTION_FOUND_ROWS)))
{ /* Impossible cond */
zero_result_cause= having_value == Item::COND_FALSE ?
"Impossible HAVING" : "Impossible WHERE";
error= 0;
DBUG_RETURN(0);
}
}
/* Optimize count(*), min() and max() */
@@ -4611,10 +4617,8 @@ optimize_cond(THD *thd, COND *conds, Item::cond_result *cond_value)
DBUG_EXECUTE("info", print_where(conds, "after remove"););
}
else
{
*cond_value= Item::COND_TRUE;
select->prep_where= 0;
}
DBUG_RETURN(conds);
}