Commit 9e04ebfa authored by unknown's avatar unknown
Browse files

Fix for Bug #9246 Condition pushdown and left join, wrong result

parent 848611b5
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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;
+2 −0
Original line number Diff line number Diff line
@@ -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;
+3 −1
Original line number Diff line number Diff line
@@ -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)
            {