1
0
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.


mysql-test/r/having.result:
  test case
mysql-test/t/having.test:
  test case
sql/sql_select.cc:
  The fix is to use remove_eq_conds() function instead
  of make_cond_for_table() function.
This commit is contained in:
Sergey Glukhov
2010-04-05 16:10:26 +05:00
parent e2a546aef4
commit c1ad5072b8
3 changed files with 96 additions and 7 deletions

View File

@ -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);
}