mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
FIxed bug #14927.
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:
@ -1665,10 +1665,11 @@ int mysql_stmt_prepare(THD *thd, char *packet, uint packet_length,
|
||||
for (; sl; sl= sl->next_select_in_list())
|
||||
{
|
||||
/*
|
||||
Save WHERE clause pointers, because they may be changed
|
||||
Save WHERE, HAVING clause pointers, because they may be changed
|
||||
during query optimisation.
|
||||
*/
|
||||
sl->prep_where= sl->where;
|
||||
sl->prep_having= sl->having;
|
||||
/*
|
||||
Switch off a temporary flag that prevents evaluation of
|
||||
subqueries in statement prepare.
|
||||
@ -1694,13 +1695,18 @@ static void reset_stmt_for_execute(Prepared_statement *stmt)
|
||||
/* remove option which was put by mysql_explain_union() */
|
||||
sl->options&= ~SELECT_DESCRIBE;
|
||||
/*
|
||||
Copy WHERE clause pointers to avoid damaging they by optimisation
|
||||
Copy WHERE, HAVING clause pointers to avoid damaging they by optimisation
|
||||
*/
|
||||
if (sl->prep_where)
|
||||
{
|
||||
sl->where= sl->prep_where->copy_andor_structure(thd);
|
||||
sl->where->cleanup();
|
||||
}
|
||||
if (sl->prep_having)
|
||||
{
|
||||
sl->having= sl->prep_having->copy_andor_structure(thd);
|
||||
sl->having->cleanup();
|
||||
}
|
||||
DBUG_ASSERT(sl->join == 0);
|
||||
ORDER *order;
|
||||
/* Fix GROUP list */
|
||||
|
Reference in New Issue
Block a user