From 4b2dd02552a30e5af04d32e474fa595a637a268e Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Tue, 19 Aug 2008 13:36:24 +0300 Subject: [PATCH] Bug#38195: Incorrect handling of aggregate functions when loose index scan is used causes server crash. Revert the fix : unstable test case revealed by pushbuild --- mysql-test/r/group_min_max.result | 25 ------------------------- mysql-test/t/group_min_max.test | 12 ------------ sql/sql_select.cc | 5 +---- 3 files changed, 1 insertion(+), 41 deletions(-) diff --git a/mysql-test/r/group_min_max.result b/mysql-test/r/group_min_max.result index c417a8d3528..5982931e677 100644 --- a/mysql-test/r/group_min_max.result +++ b/mysql-test/r/group_min_max.result @@ -2353,28 +2353,3 @@ a MIN(b) MAX(b) AVG(b) 2 1 3 2.0000 1 1 3 2.0000 DROP TABLE t1; -create table t1 (a int, b int, primary key (a,b), key `index` (a,b)) engine=MyISAM; -insert into t1 (a,b) values (0,0),(0,1),(0,2),(0,3),(0,4),(0,5),(0,6),(0,7), -(0,8),(0,9),(0,10),(0,11); -insert into t1 (a,b) select a, max(b)+1 from t1 where a = 0 group by a; -select * from t1; -a b -0 0 -0 1 -0 2 -0 3 -0 4 -0 5 -0 6 -0 7 -0 8 -0 9 -0 10 -0 11 -0 12 -explain extended select sql_buffer_result a, max(b)+1 from t1 where a = 0 group by a; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY,index PRIMARY 4 NULL 5 Using where; Using index for group-by; Using temporary -Warnings: -Note 1003 select sql_buffer_result `test`.`t1`.`a` AS `a`,(max(`test`.`t1`.`b`) + 1) AS `max(b)+1` from `test`.`t1` where (`test`.`t1`.`a` = 0) group by `test`.`t1`.`a` -drop table t1; diff --git a/mysql-test/t/group_min_max.test b/mysql-test/t/group_min_max.test index 60a80ecf9d5..7f2607b513d 100644 --- a/mysql-test/t/group_min_max.test +++ b/mysql-test/t/group_min_max.test @@ -916,15 +916,3 @@ SELECT a, MIN(b), MAX(b), AVG(b) FROM t1 GROUP BY a ORDER BY a DESC; SELECT a, MIN(b), MAX(b), AVG(b) FROM t1 GROUP BY a ORDER BY a DESC; DROP TABLE t1; - -# -# Bug#38195: Incorrect handling of aggregate functions when loose index scan is -# used causes server crash. -# -create table t1 (a int, b int, primary key (a,b), key `index` (a,b)) engine=MyISAM; -insert into t1 (a,b) values (0,0),(0,1),(0,2),(0,3),(0,4),(0,5),(0,6),(0,7), -(0,8),(0,9),(0,10),(0,11); -insert into t1 (a,b) select a, max(b)+1 from t1 where a = 0 group by a; -select * from t1; -explain extended select sql_buffer_result a, max(b)+1 from t1 where a = 0 group by a; -drop table t1; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 6928effc1a5..6de4b296d34 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1724,8 +1724,7 @@ JOIN::exec() if (!items1) { items1= items0 + all_fields.elements; - if (sort_and_group || curr_tmp_table->group || - tmp_table_param.precomputed_group_by) + if (sort_and_group || curr_tmp_table->group) { if (change_to_use_tmp_fields(thd, items1, tmp_fields_list1, tmp_all_fields1, @@ -9260,8 +9259,6 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, MI_COLUMNDEF *recinfo; uint total_uneven_bit_length= 0; bool force_copy_fields= param->force_copy_fields; - /* Treat sum functions as normal ones when loose index scan is used. */ - save_sum_fields|= param->precomputed_group_by; DBUG_ENTER("create_tmp_table"); DBUG_PRINT("enter",("distinct: %d save_sum_fields: %d rows_limit: %lu group: %d", (int) distinct, (int) save_sum_fields,