diff --git a/mysql-test/r/ndb_condition_pushdown.result b/mysql-test/r/ndb_condition_pushdown.result index 7f769154212..4ddfa5817d8 100644 --- a/mysql-test/r/ndb_condition_pushdown.result +++ b/mysql-test/r/ndb_condition_pushdown.result @@ -1139,5 +1139,10 @@ explain select * from t2 where (attr1 < 2) = (attr2 < 2) order by pk1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 6 Using where; Using filesort +explain +select * from t3 left join t4 on t4.attr2 = t3.attr2 where t4.attr1 > 1 and t4.attr3 < 5 or t4.attr1 is null order by t4.pk1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort +1 SIMPLE t4 ALL NULL NULL NULL NULL 6 Using where set engine_condition_pushdown = @old_ecpd; DROP TABLE t1,t2,t3,t4; diff --git a/mysql-test/t/ndb_condition_pushdown.test b/mysql-test/t/ndb_condition_pushdown.test index 1d201a94c95..c6f3f67a65f 100644 --- a/mysql-test/t/ndb_condition_pushdown.test +++ b/mysql-test/t/ndb_condition_pushdown.test @@ -1044,6 +1044,8 @@ explain select auto from t1 where string = "aaaa" collate latin1_general_ci order by auto; explain select * from t2 where (attr1 < 2) = (attr2 < 2) order by pk1; +explain +select * from t3 left join t4 on t4.attr2 = t3.attr2 where t4.attr1 > 1 and t4.attr3 < 5 or t4.attr1 is null order by t4.pk1; set engine_condition_pushdown = @old_ecpd; DROP TABLE t1,t2,t3,t4; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 47c7de6eba7..72fc407692b 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -5401,10 +5401,12 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) if (!(tmp= add_found_match_trig_cond(first_inner_tab, tmp, 0))) DBUG_RETURN(1); tab->select_cond=sel->cond=tmp; + /* Push condition to storage engine if this is enabled + and the condition is not guarded */ if (thd->variables.engine_condition_pushdown) { COND *push_cond= - make_cond_for_table(cond,current_map,current_map); + make_cond_for_table(tmp,current_map,current_map); tab->table->file->pushed_cond= NULL; if (push_cond) {