Commit b2c83e7f authored by serg@serg.mylan's avatar serg@serg.mylan

workaround for IN's special treatment of first argument. Not for 4.1

parent 31b337fe
...@@ -253,4 +253,10 @@ explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 0 and t2.x <= t1.y; ...@@ -253,4 +253,10 @@ explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 0 and t2.x <= t1.y;
table type possible_keys key key_len ref rows Extra table type possible_keys key key_len ref rows Extra
t1 ref y y 5 const 1 Using where t1 ref y y 5 const 1 Using where
t2 range x x 5 NULL 2 Using where t2 range x x 5 NULL 2 Using where
explain select count(*) from t1 where x in (1);
table type possible_keys key key_len ref rows Extra
t1 range x x 5 NULL 1 Using where; Using index
explain select count(*) from t1 where x in (1,2);
table type possible_keys key key_len ref rows Extra
t1 range x x 5 NULL 2 Using where; Using index
drop table t1; drop table t1;
...@@ -198,5 +198,8 @@ explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= t1.y-1 and t2.x <= t1 ...@@ -198,5 +198,8 @@ explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= t1.y-1 and t2.x <= t1
# equation propagation # equation propagation
explain select * from t1, t1 t2 where t1.y = 2 and t2.x between 0 and t1.y; explain select * from t1, t1 t2 where t1.y = 2 and t2.x between 0 and t1.y;
explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 0 and t2.x <= t1.y; explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 0 and t2.x <= t1.y;
# testing IN
explain select count(*) from t1 where x in (1);
explain select count(*) from t1 where x in (1,2);
drop table t1; drop table t1;
...@@ -1556,7 +1556,13 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level, ...@@ -1556,7 +1556,13 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level,
if (cond_func->key_item()->type() == Item::FIELD_ITEM) if (cond_func->key_item()->type() == Item::FIELD_ITEM)
add_key_field(key_fields,*and_level, add_key_field(key_fields,*and_level,
((Item_field*) (cond_func->key_item()))->field, 0, ((Item_field*) (cond_func->key_item()))->field, 0,
#ifndef TO_BE_REMOVED_IN_4_1
/* special treatment for IN. Not necessary in 4.1 */
cond_func->arguments() + (cond_func->functype() != Item_func::IN_FUNC),
cond_func->argument_count() - (cond_func->functype() != Item_func::IN_FUNC),
#else
cond_func->arguments()+1, cond_func->argument_count()-1, cond_func->arguments()+1, cond_func->argument_count()-1,
#endif
usable_tables); usable_tables);
break; break;
case Item_func::OPTIMIZE_OP: case Item_func::OPTIMIZE_OP:
......
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