• Gleb Shchepa's avatar
    Backport bug #37348 fix 5.1 --> 5.0. · 02884a4d
    Gleb Shchepa authored
    Original commentary:
    
    Bug #37348: Crash in or immediately after JOIN::make_sum_func_list
                
    The optimizer pulls up aggregate functions which should be aggregated in
    an outer select. At some point it may substitute such a function for a field
    in the temporary table. The setup_copy_fields function doesn't take this
    into account and may overrun the copy_field buffer.
                
    Fixed by filtering out the fields referenced through the specialized
    reference for aggregates (Item_aggregate_ref).
    Added an assertion to make sure bugs that cause similar discrepancy 
    don't go undetected.
    
    
    mysql-test/r/func_group.result:
      Backport bug #37348 fix 5.1 --> 5.0.
    mysql-test/t/func_group.test:
      Backport bug #37348 fix 5.1 --> 5.0.
    sql/item.cc:
      Backport bug #37348 fix 5.1 --> 5.0.
    sql/item.h:
      Backport bug #37348 fix 5.1 --> 5.0.
    sql/sql_select.cc:
      Backport bug #37348 fix 5.1 --> 5.0.
    02884a4d
func_group.test 31.5 KB