diff options
author | Alexander Barkov <bar@mariadb.org> | 2015-03-12 18:12:15 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2015-03-12 18:12:15 +0400 |
commit | bb3115b256113097bcfd0d80213e160339e4b00b (patch) | |
tree | 2130426378c4762344bda6aad5f8e5d16d6cf770 /sql/opt_range.cc | |
parent | 129c82bb5916d05ece4efad55e8dede3005559b4 (diff) | |
download | mariadb-git-bb3115b256113097bcfd0d80213e160339e4b00b.tar.gz |
MDEV-6990 GROUP_MIN_MAX optimization is not applied in some cases when it could
Diffstat (limited to 'sql/opt_range.cc')
-rw-r--r-- | sql/opt_range.cc | 34 |
1 files changed, 4 insertions, 30 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 3cac6e5139e..8f691f4e5dc 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -13412,39 +13412,13 @@ check_group_min_max_predicates(Item *cond, Item_field *min_max_arg_item, if (!simple_pred(pred, args, &inv)) DBUG_RETURN(FALSE); - /* Check for compatible string comparisons - similar to get_mm_leaf. */ if (args[0] && args[1] && !args[2]) // this is a binary function { - if (args[1]->cmp_type() == TIME_RESULT && - min_max_arg_item->field->cmp_type() != TIME_RESULT) + DBUG_ASSERT(pred->is_bool_type()); + Item_bool_func *bool_func= (Item_bool_func*) pred; + if (!bool_func->can_optimize_group_min_max(min_max_arg_item, + args[1])) DBUG_RETURN(FALSE); - - /* - Can't use GROUP_MIN_MAX optimization for ENUM and SET, - because the values are stored as numbers in index, - while MIN() and MAX() work as strings. - It would return the records with min and max enum numeric indexes. - "Bug#45300 MAX() and ENUM type" should be fixed first. - */ - if (min_max_arg_item->field->real_type() == MYSQL_TYPE_ENUM || - min_max_arg_item->field->real_type() == MYSQL_TYPE_SET) - DBUG_RETURN(FALSE); - - if (min_max_arg_item->result_type() == STRING_RESULT && - /* - Don't use an index when comparing strings of different collations. - */ - ((args[1]->result_type() == STRING_RESULT && - image_type == Field::itRAW && - min_max_arg_item->field->charset() != - pred->compare_collation()) || - /* - We can't always use indexes when comparing a string index to a - number. - */ - (args[1]->result_type() != STRING_RESULT && - min_max_arg_item->field->cmp_type() != args[1]->result_type()))) - DBUG_RETURN(FALSE); } } else |