summaryrefslogtreecommitdiff
path: root/sql/opt_range.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/opt_range.cc')
-rw-r--r--sql/opt_range.cc27
1 files changed, 17 insertions, 10 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 7169a3eda81..a69709bbf03 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -1533,7 +1533,7 @@ end:
if (!head->no_keyread)
{
doing_key_read= 1;
- head->enable_keyread();
+ head->set_keyread(true);
}
head->prepare_for_position();
@@ -10643,7 +10643,7 @@ int read_keys_and_merge_scans(THD *thd,
if (!head->key_read)
{
enabled_keyread= 1;
- head->enable_keyread();
+ head->set_keyread(true);
}
head->prepare_for_position();
@@ -10736,7 +10736,7 @@ int read_keys_and_merge_scans(THD *thd,
index merge currently doesn't support "using index" at all
*/
if (enabled_keyread)
- head->disable_keyread();
+ head->set_keyread(false);
if (init_read_record(read_record, thd, head, (SQL_SELECT*) 0,
&unique->sort, 1 , 1, TRUE))
result= 1;
@@ -10744,7 +10744,7 @@ int read_keys_and_merge_scans(THD *thd,
err:
if (enabled_keyread)
- head->disable_keyread();
+ head->set_keyread(false);
DBUG_RETURN(1);
}
@@ -12071,9 +12071,6 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree, double read_time)
DBUG_RETURN(NULL); /* Cannot execute with correlated conditions. */
/* Check (SA1,SA4) and store the only MIN/MAX argument - the C attribute.*/
- if (join->make_sum_func_list(join->all_fields, join->fields_list, 1))
- DBUG_RETURN(NULL);
-
List_iterator<Item> select_items_it(join->fields_list);
is_agg_distinct = is_indexed_agg_distinct(join, &agg_distinct_flds);
@@ -13108,7 +13105,17 @@ void cost_group_min_max(TABLE* table, KEY *index_info, uint used_key_parts,
num_blocks= (ha_rows)(table_records / keys_per_block) + 1;
/* Compute the number of keys in a group. */
- keys_per_group= (ha_rows) index_info->actual_rec_per_key(group_key_parts - 1);
+ if (!group_key_parts)
+ {
+ /* Summary over the whole table */
+ keys_per_group= table_records;
+ }
+ else
+ {
+ keys_per_group= (ha_rows) index_info->actual_rec_per_key(group_key_parts -
+ 1);
+ }
+
if (keys_per_group == 0) /* If there is no statistics try to guess */
/* each group contains 10% of all records */
keys_per_group= (table_records / 10) + 1;
@@ -13456,7 +13463,7 @@ QUICK_GROUP_MIN_MAX_SELECT::~QUICK_GROUP_MIN_MAX_SELECT()
{
DBUG_ASSERT(file == head->file);
if (doing_key_read)
- head->disable_keyread();
+ head->set_keyread(false);
/*
There may be a code path when the same table was first accessed by index,
then the index is closed, and the table is scanned (order by + loose scan).
@@ -13649,7 +13656,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::reset(void)
if (!head->key_read)
{
doing_key_read= 1;
- head->enable_keyread(); /* We need only the key attributes */
+ head->set_keyread(true); /* We need only the key attributes */
}
if ((result= file->ha_index_init(index,1)))
{