diff options
author | unknown <timour@mysql.com> | 2006-03-31 12:39:33 +0300 |
---|---|---|
committer | unknown <timour@mysql.com> | 2006-03-31 12:39:33 +0300 |
commit | 2c5bd770e5e8947c519da23c8a1e88a112a9c97c (patch) | |
tree | 88258692d6bed7dc04376eda6523507dc716bcd6 /sql/opt_range.cc | |
parent | c3365e87edb09dabf565f9eb8c600b91e0ef8a3d (diff) | |
parent | bb839d3af33ae89b55c7dca3d9b97fb2c50809fd (diff) | |
download | mariadb-git-2c5bd770e5e8947c519da23c8a1e88a112a9c97c.tar.gz |
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
Diffstat (limited to 'sql/opt_range.cc')
-rw-r--r-- | sql/opt_range.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 634c9db18a8..d76495a0678 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -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; + } } /* |