Commit 1ab67408 authored by Yuchen Pei's avatar Yuchen Pei

[wip] MDEV-34911

parent fe3432b3
......@@ -221,6 +221,14 @@ class Item_bool_func :public Item_int_func,
if (field->type() == Item::FIELD_ITEM && !field->const_item() &&
(!value || !value->is_expensive()))
DBUG_RETURN(get_full_func_mm_tree(param, (Item_field *) field, value));
if ((field->type() == Item::FUNC_ITEM &&
!strcmp(((Item_func *) field)->func_name(), "substr") &&
((Item_func *) field)->arguments()[1]->val_int() == 1) &&
!field->const_item() && (!value || !value->is_expensive()))
DBUG_RETURN(get_full_func_mm_tree(
param,
(Item_field *) ((Item_func *) field)->arguments()[0],
value));
DBUG_RETURN(NULL);
}
SEL_TREE *get_mm_parts(RANGE_OPT_PARAM *param, Field *field,
......
......@@ -7080,6 +7080,15 @@ Item_bool_func2::add_key_fields_optimize_op(JOIN *join, KEY_FIELD **key_fields,
(Item_field*) args[0]->real_item(), equal_func,
args + 1, 1, usable_tables, sargables);
}
else if (args[0]->type() == FUNC_ITEM && args[1]->type() == CONST_ITEM &&
equal_func)
{
if (!strcmp(((Item_func *) args[0])->func_name(), "substr") &&
((Item_func_substr *) args[0])->arguments()[1]->val_int() == 1)
add_key_equal_fields(join, key_fields, *and_level, this,
((Item_func_substr *) args[0])->arguments()[0]->real_item(),
false, args + 1, 1, usable_tables, sargables);
}
if (is_local_field(args[1]))
{
add_key_equal_fields(join, key_fields, *and_level, this,
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment