From 9400700b995d00021819f4c483a07975a3ce60d7 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Tue, 25 Aug 2009 12:27:50 +0300 Subject: [PATCH] MWL#17: Table elimination - Add more testcases. - Fix trivial compile failure - Remove handling of "column IN (one_element)". This is converted to equality elsewhere mysql-test/r/table_elim.result: MWL#17: Table elimination - Add more testcases. - Fix trivial compile failure mysql-test/t/table_elim.test: MWL#17: Table elimination - Add more testcases sql/mysqld.cc: MWL#17: Table elimination - Fix trivial compile failure sql/opt_table_elimination.cc: MWL#17: Table elimination - Add more testcases. - Remove handling of "column IN (one_element)".This is converted to equality elsewhere --- mysql-test/r/table_elim.result | 38 ++++++++++++++++++++++++++++++++++ mysql-test/t/table_elim.test | 27 ++++++++++++++++++++++++ sql/mysqld.cc | 2 ++ sql/opt_table_elimination.cc | 13 +++--------- 4 files changed, 70 insertions(+), 10 deletions(-) diff --git a/mysql-test/r/table_elim.result b/mysql-test/r/table_elim.result index 8ce03b06cab..4e53f4892bc 100644 --- a/mysql-test/r/table_elim.result +++ b/mysql-test/r/table_elim.result @@ -307,3 +307,41 @@ a b select * from t2; a b drop table t1, t2; +# +# Tests with various edge-case ON expressions +# +create table t1 (a int, b int, c int, d int); +insert into t1 values (0,0,0,0),(1,1,1,1),(2,2,2,2),(3,3,3,3); +create table t2 (pk int primary key, b int) +as select a as pk, a as b from t1 where a in (1,2); +create table t3 (pk int primary key, b int) +as select a as pk, a as b from t1 where a in (1,3); +explain select t1.a from t1 left join t2 on t2.pk=t1.a and t2.barguments(); switch (cond_func->functype()) { - case Item_func::IN_FUNC: - { - if (cond_func->argument_count() == 2) - { - add_eq_mod(fda, eq_mod, *and_level, cond_func, args[0], args[1]); - add_eq_mod(fda, eq_mod, *and_level, cond_func, args[1], args[0]); - } - break; - } case Item_func::BETWEEN: { Item *fld; @@ -837,7 +828,7 @@ static Table_value *get_table_value(Func_dep_analyzer *fda, TABLE *table) { Table_value *tbl_dep; if (!(tbl_dep= new Table_value(table))) - return NULL; + return NULL; /* purecov: inspected */ Key_module **key_list= &(tbl_dep->keys); /* Add dependencies for unique keys */ @@ -1499,6 +1490,7 @@ static void mark_as_eliminated(JOIN *join, TABLE_LIST *tbl) #ifndef DBUG_OFF +/* purecov: begin inspected */ static void dbug_print_deps(Func_dep_analyzer *fda) { @@ -1559,6 +1551,7 @@ void dbug_print_deps(Func_dep_analyzer *fda) DBUG_UNLOCK_FILE; DBUG_VOID_RETURN; } +/* purecov: end */ #endif /**