diff options
author | Sergey Petrunya <psergey@askmonty.org> | 2009-08-21 09:48:22 +0200 |
---|---|---|
committer | Sergey Petrunya <psergey@askmonty.org> | 2009-08-21 09:48:22 +0200 |
commit | 9c1336801ec49f772f62bb3943432523c4f37aa9 (patch) | |
tree | 4aa7b2ab6147aa0b667df260f55326a7328397a5 | |
parent | 3f5b4949003d0cc41646eefbb3d7e7d1021406ea (diff) | |
download | mariadb-git-9c1336801ec49f772f62bb3943432523c4f37aa9.tar.gz |
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.
-rw-r--r-- | mysql-test/r/table_elim.result | 15 | ||||
-rw-r--r-- | mysql-test/t/table_elim.test | 11 | ||||
-rw-r--r-- | sql/opt_table_elimination.cc | 27 |
3 files changed, 42 insertions, 11 deletions
diff --git a/mysql-test/r/table_elim.result b/mysql-test/r/table_elim.result index d26959ee527..5aad6ea45bd 100644 --- a/mysql-test/r/table_elim.result +++ b/mysql-test/r/table_elim.result @@ -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 diff --git a/mysql-test/t/table_elim.test b/mysql-test/t/table_elim.test index 6ef9731e212..f4ea009f09a 100644 --- a/mysql-test/t/table_elim.test +++ b/mysql-test/t/table_elim.test @@ -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 # diff --git a/sql/opt_table_elimination.cc b/sql/opt_table_elimination.cc index b29cecfe1cc..e3597de2c51 100644 --- a/sql/opt_table_elimination.cc +++ b/sql/opt_table_elimination.cc @@ -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) |