Commit f0f92fe4 authored by hf@deer.(none)'s avatar hf@deer.(none)

Proposed fix for #674

This crash happens in rather exotic case when we try to run 
SELECT DISTINCT some_func(SUM(some_field)) GROUP BY another_field;
on a table with single row.
Optimizer marks this table as const, sets group=NULL (with remove_const)
thus, create_tmp_table makes mistake collecting columns for temporary table
and then crashes because the field_count gets less than hidden_columns_count.
parent 55102bfa
...@@ -453,6 +453,9 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds, ...@@ -453,6 +453,9 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
goto err; goto err;
thd->proc_info="preparing"; thd->proc_info="preparing";
select_distinct= select_distinct && (join.const_tables != join.tables);
if (result->initialize_tables(&join)) if (result->initialize_tables(&join))
goto err; goto err;
if (join.const_table_map != join.found_const_table_map && if (join.const_table_map != join.found_const_table_map &&
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment