1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Merge mysql.com:/home/timka/mysql/src/5.0-virgin

into  mysql.com:/home/timka/mysql/src/5.0-bug-16710


mysql-test/r/group_min_max.result:
  Auto merged
mysql-test/t/group_min_max.test:
  Auto merged
sql/item.cc:
  Auto merged
sql/item.h:
  Auto merged
sql/opt_range.cc:
  Auto merged
This commit is contained in:
unknown
2006-03-31 12:39:33 +03:00
5 changed files with 78 additions and 1 deletions

View File

@ -6895,6 +6895,7 @@ cost_group_min_max(TABLE* table, KEY *index_info, uint used_key_parts,
bool have_min, bool have_max,
double *read_cost, ha_rows *records);
/*
Test if this access method is applicable to a GROUP query with MIN/MAX
functions, and if so, construct a new TRP object.
@ -7301,11 +7302,36 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
}
else if (min_max_arg_part &&
(min_max_arg_part - first_non_group_part > 0))
{
/*
There is a gap but no range tree, thus no predicates at all for the
non-group keyparts.
*/
goto next_index;
}
else if (first_non_group_part && join->conds)
{
/*
If there is no MIN/MAX function in the query, but some index
key part is referenced in the WHERE clause, then this index
cannot be used because the WHERE condition over the keypart's
field cannot be 'pushed' to the index (because there is no
range 'tree'), and the WHERE clause must be evaluated before
GROUP BY/DISTINCT.
*/
/*
Store the first and last keyparts that need to be analyzed
into one array that can be passed as parameter.
*/
KEY_PART_INFO *key_part_range[2];
key_part_range[0]= first_non_group_part;
key_part_range[1]= last_part;
/* Check if cur_part is referenced in the WHERE clause. */
if (join->conds->walk(&Item::find_item_in_field_list_processor,
(byte*) key_part_range))
goto next_index;
}
}
/*