diff options
author | Evgeny Potemkin <epotemkin@mysql.com> | 2008-08-13 22:24:55 +0400 |
---|---|---|
committer | Evgeny Potemkin <epotemkin@mysql.com> | 2008-08-13 22:24:55 +0400 |
commit | b789b4f33cdf245d1f582aa755410754b197a693 (patch) | |
tree | 6a2142b5a1c13190cc1dd86dae1bcb64ad1cf741 /sql/sql_select.cc | |
parent | 8ed209b21ddd1f46dfeaaae34a60cbd18e47d4e7 (diff) | |
download | mariadb-git-b789b4f33cdf245d1f582aa755410754b197a693.tar.gz |
Bug#38195: Incorrect handling of aggregate functions when loose index scan is
used causes server crash.
When the loose index scan access method is used values of aggregated functions
are precomputed by it. Aggregation of such functions shouldn't be performed
in this case and functions should be treated as normal ones.
The create_tmp_table function wasn't taking this into account and this led to
a crash if a query has MIN/MAX aggregate functions and employs temporary table
and loose index scan.
Now the JOIN::exec and the create_tmp_table functions treat MIN/MAX aggregate
functions as normal ones when the loose index scan is used.
mysql-test/r/group_min_max.result:
Added a test case for the bug#38195.
mysql-test/t/group_min_max.test:
Added a test case for the bug#38195.
sql/sql_select.cc:
Bug#38195: Incorrect handling of aggregate functions when loose index scan is
used causes server crash.
Now the JOIN::exec and the create_tmp_table functions treat MIN/MAX aggregate
functions as normal ones when the loose index scan is used.
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 6de4b296d34..6928effc1a5 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1724,7 +1724,8 @@ JOIN::exec() if (!items1) { items1= items0 + all_fields.elements; - if (sort_and_group || curr_tmp_table->group) + if (sort_and_group || curr_tmp_table->group || + tmp_table_param.precomputed_group_by) { if (change_to_use_tmp_fields(thd, items1, tmp_fields_list1, tmp_all_fields1, @@ -9259,6 +9260,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &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, |