mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug#52336 Segfault / crash in 5.1 copy_fields (param=0x9872980) at sql_select.cc:15355
The problem is that we can not use make_cond_for_table(). This function relies on used_tables() condition which is not set properly for subqueries. As result subquery is not filtered out. The fix is to use remove_eq_conds() function instead of make_cond_for_table() func. 'remove_eq_conds()' algorithm relies on const_item() value and it allows to handle subqueries in right way.
This commit is contained in:
@ -1125,13 +1125,13 @@ JOIN::optimize()
|
||||
elements may be lost during further having
|
||||
condition transformation in JOIN::exec.
|
||||
*/
|
||||
if (having && !having->with_sum_func)
|
||||
if (having && const_table_map)
|
||||
{
|
||||
COND *const_cond= make_cond_for_table(having, const_table_map, 0);
|
||||
DBUG_EXECUTE("where", print_where(const_cond, "const_having_cond",
|
||||
QT_ORDINARY););
|
||||
if (const_cond && !const_cond->val_int())
|
||||
having->update_used_tables();
|
||||
having= remove_eq_conds(thd, having, &having_value);
|
||||
if (having_value == Item::COND_FALSE)
|
||||
{
|
||||
having= new Item_int((longlong) 0,1);
|
||||
zero_result_cause= "Impossible HAVING noticed after reading const tables";
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user