Commit ed54ec7e authored by Sergey Petrunya's avatar Sergey Petrunya

Make semi-joins work with outer joins:

- evaluate_null_complemented_join_record() should perform FirstMatch checks.
parent eea95a15
......@@ -1414,6 +1414,17 @@ select * from t0 where a in (select t1.a from t1 left join t2 on t1.a=t2.a);
a
1
2
set optimizer_switch='firstmatch=on';
explain
select * from t0 where a in (select t1.a from t1 left join t2 on t1.a=t2.a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t0 ALL NULL NULL NULL NULL 2
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t0)
select * from t0 where a in (select t1.a from t1 left join t2 on t1.a=t2.a);
a
1
2
set @@join_cache_level=@tmp_jcl_20110622;
set @@optimizer_switch=@tmp_20110622;
drop table t0, t1, t2;
......
......@@ -1422,6 +1422,17 @@ select * from t0 where a in (select t1.a from t1 left join t2 on t1.a=t2.a);
a
1
2
set optimizer_switch='firstmatch=on';
explain
select * from t0 where a in (select t1.a from t1 left join t2 on t1.a=t2.a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t0 ALL NULL NULL NULL NULL 2
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t0)
select * from t0 where a in (select t1.a from t1 left join t2 on t1.a=t2.a);
a
1
2
set @@join_cache_level=@tmp_jcl_20110622;
set @@optimizer_switch=@tmp_20110622;
drop table t0, t1, t2;
......
......@@ -1291,6 +1291,12 @@ explain
select * from t0 where a in (select t1.a from t1 left join t2 on t1.a=t2.a);
select * from t0 where a in (select t1.a from t1 left join t2 on t1.a=t2.a);
set optimizer_switch='firstmatch=on';
explain
select * from t0 where a in (select t1.a from t1 left join t2 on t1.a=t2.a);
select * from t0 where a in (select t1.a from t1 left join t2 on t1.a=t2.a);
set @@join_cache_level=@tmp_jcl_20110622;
set @@optimizer_switch=@tmp_20110622;
......
......@@ -15220,6 +15220,15 @@ evaluate_null_complemented_join_record(JOIN *join, JOIN_TAB *join_tab)
else if (res == 1)
return NESTED_LOOP_OK;
}
else if (join_tab->do_firstmatch)
{
/*
We should return to the join_tab->do_firstmatch after we have
enumerated all the suffixes for current prefix row combination
*/
if (join_tab->do_firstmatch < join->return_tab)
join->return_tab= join_tab->do_firstmatch;
}
/*
Send the row complemented by nulls to be joined with the
......
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