Commit 9c133680 authored by Sergey Petrunya's avatar Sergey Petrunya

MWL#17: Table elimination

- More testcases
- Set correct dependencies for non-bound multi-equalities.

mysql-test/r/table_elim.result:
  MWL#17: Table elimination
  - More testcases
mysql-test/t/table_elim.test:
  MWL#17: Table elimination
  - More testcases
sql/opt_table_elimination.cc:
  MWL#17: Table elimination
  - Set correct dependencies for non-bound multi-equalities.
parent 3f5b4949
......@@ -218,6 +218,21 @@ select t1.*, t2.* from t1 left join (t2 left join t3 on t3.pk=t2.col) on t2.pk=t
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.col 1
explain select t1.*
from
t1 left join ( t2 left join t3 on t3.pk=t2.col or t3.pk=t2.col)
on t2.col=t1.col or t2.col=t1.col;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
1 SIMPLE t2 ALL NULL NULL NULL NULL 2
explain select t1.*, t2.*
from
t1 left join
(t2 left join t3 on t3.pk=t2.col or t3.pk=t2.col)
on t2.pk=t1.col or t2.pk=t1.col;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.col 1
drop table t1, t2, t3;
#
# Check things that look like functional dependencies but really are not
......
......@@ -175,6 +175,17 @@ select t1.* from t1 left join ( t2 left join t3 on t3.pk=t2.col) on t2.col=t1.co
explain
select t1.*, t2.* from t1 left join (t2 left join t3 on t3.pk=t2.col) on t2.pk=t1.col;
explain select t1.*
from
t1 left join ( t2 left join t3 on t3.pk=t2.col or t3.pk=t2.col)
on t2.col=t1.col or t2.col=t1.col;
explain select t1.*, t2.*
from
t1 left join
(t2 left join t3 on t3.pk=t2.col or t3.pk=t2.col)
on t2.pk=t1.col or t2.pk=t1.col;
drop table t1, t2, t3;
--echo #
......
......@@ -454,8 +454,6 @@ void build_eq_mods_for_cond(Func_dep_analyzer *fda, Equality_module **eq_mod,
case Item_func::MULT_EQUAL_FUNC:
{
Item_equal *item_equal= (Item_equal*)cond;
// const item is 'item', field -> NULL. mult_equal_fields <-- an ordered
// list of
List<Field_value> *fvl;
if (!(fvl= new List<Field_value>))
break;
......@@ -1001,17 +999,24 @@ bool setup_equality_modules_deps(Func_dep_analyzer *fda,
deps_recorder.expr_offset= eq_mod - fda->equality_mods;
deps_recorder.saw_other_tbl= FALSE;
eq_mod->unknown_args= 0;
if (eq_mod->field)
{
/* Regular tbl.col=expr(tblX1.col1, tblY1.col2, ...) */
eq_mod->expression->walk(&Item::check_column_usage_processor, FALSE,
(uchar*)&deps_recorder);
if (!eq_mod->field)
eq_mod->expression->walk(&Item::check_column_usage_processor, FALSE,
(uchar*)&deps_recorder);
}
else
{
if (eq_mod->unknown_args)
eq_mod->unknown_args= 1;
if (deps_recorder.saw_other_tbl)
eq_mod->unknown_args= 0;
/* It's a multi-equality*/
eq_mod->unknown_args= !test(eq_mod->expression);
List_iterator<Field_value> it(*eq_mod->mult_equal_fields);
Field_value* field_val;
while ((field_val= it++))
{
uint offs= field_val->bitmap_offset + eq_mod - fda->equality_mods;
bitmap_set_bit(&fda->expr_deps, offs);
}
}
if (!eq_mod->unknown_args)
......
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