Comment 1 for bug 944504

Revision history for this message
Sergey Petrunia (sergefp) wrote :

The crash itself happens on these lines:

  15035 if (join->table_count)
  15036 {
  15037 join->join_tab[join->top_join_tab_count - 1].next_select= end_select;
  15038 join_tab=join->join_tab+join->const_tables;
  15039 }

because

(gdb) p join->top_join_tab_count
  $82 = 0

If one looks at the source of the problem, they will find that the execution is an odd state. Here is the stack trace of the crash, with unneeded details removed:

(gdb) wher
  #0 in do_select (join=$JOIN1, fields=0x9f68b14, table=0x0, procedure=0x0)
  #1 in JOIN::exec (this=$JOIN1)
  #2 in subselect_single_select_engine::exec ()
  #3 in Item_subselect::exec ()
  #4 in Item_singlerow_subselect::val_str ()
  #5 in Item_func_conv_charset::Item_func_conv_charset ()
  #6 in Item::safe_charset_converter ()
  #7 in agg_item_set_converter ()
  #8 in agg_item_charsets ()
  #9 in Item_func::agg_arg_charsets ()
  #10 in Item_bool_func2::fix_length_and_dec ()
  #11 in Item_func::fix_fields ()
  #12 in Item_allany_subselect::transform_into_max_min (this=0x9f3a1f8, join=$JOIN1)
  #13 in JOIN::transform_max_min_subquery (this=$JOIN1)
  #14 in JOIN::optimize (this=$JOIN1)
  #15 in st_select_lex::optimize_unflattened_subqueries (this=0x9f30198)
  #16 in JOIN::optimize_unflattened_subqueries (this=$JOIN2)
  #17 in JOIN::optimize (this=$JOIN2)
  #18 in mysql_select ()

Note that we're inside JOIN::optimize (this=$JOIN1) , #14. And what we're trying to do is to call JOIN::exec (this=$JOIN1) for the same join object. This is wrong: optimization of a join should not involve attempts to execute the join we're trying to optimize.

I think, something is wrong with type conversions and/or MIN/MAX transformations.