mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 04:22:27 +01:00
Make semi-joins work with outer joins part #2:
- Do make the DuplicateWeedout check for outer joins.
This commit is contained in:
parent
038be98979
commit
eea95a15d3
4 changed files with 118 additions and 0 deletions
|
@ -1380,4 +1380,41 @@ LEFT JOIN t1 SUBQUERY3_t2 ON SUBQUERY3_t1 .col_varchar_key
|
|||
);
|
||||
col_date_key
|
||||
drop table t2, t1;
|
||||
#
|
||||
# No BUG#: Duplicate weedout check is not done for outer joins
|
||||
#
|
||||
create table t1 (a int);
|
||||
create table t2 (a int);
|
||||
insert into t1 values (1),(1),(2),(2);
|
||||
insert into t2 values (1);
|
||||
create table t0 (a int);
|
||||
insert into t0 values (1),(2);
|
||||
set @tmp_20110622= @@optimizer_switch;
|
||||
set optimizer_switch='firstmatch=off,loosescan=off,materialization=off';
|
||||
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 Start temporary
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Using where; End temporary
|
||||
select * from t0 where a in (select t1.a from t1 left join t2 on t1.a=t2.a);
|
||||
a
|
||||
1
|
||||
2
|
||||
# Try also without join buffer
|
||||
set @tmp_jcl_20110622= @@join_cache_level;
|
||||
set join_cache_level= 0;
|
||||
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; Start temporary
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Using where; End temporary
|
||||
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;
|
||||
set @@optimizer_switch=@save_optimizer_switch;
|
||||
|
|
|
@ -1389,6 +1389,44 @@ LEFT JOIN t1 SUBQUERY3_t2 ON SUBQUERY3_t1 .col_varchar_key
|
|||
col_date_key
|
||||
drop table t2, t1;
|
||||
#
|
||||
# No BUG#: Duplicate weedout check is not done for outer joins
|
||||
#
|
||||
create table t1 (a int);
|
||||
create table t2 (a int);
|
||||
insert into t1 values (1),(1),(2),(2);
|
||||
insert into t2 values (1);
|
||||
create table t0 (a int);
|
||||
insert into t0 values (1),(2);
|
||||
set @tmp_20110622= @@optimizer_switch;
|
||||
set optimizer_switch='firstmatch=off,loosescan=off,materialization=off';
|
||||
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 Start temporary
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Using where; End temporary; Using join buffer (incremental, BNL join)
|
||||
select * from t0 where a in (select t1.a from t1 left join t2 on t1.a=t2.a);
|
||||
a
|
||||
1
|
||||
2
|
||||
# Try also without join buffer
|
||||
set @tmp_jcl_20110622= @@join_cache_level;
|
||||
set join_cache_level= 0;
|
||||
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; Start temporary
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Using where; End temporary
|
||||
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;
|
||||
set @@optimizer_switch=@save_optimizer_switch;
|
||||
#
|
||||
# BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off
|
||||
#
|
||||
CREATE TABLE t0 (a INT);
|
||||
|
|
|
@ -1265,5 +1265,37 @@ WHERE 5 IN (
|
|||
);
|
||||
drop table t2, t1;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # No BUG#: Duplicate weedout check is not done for outer joins
|
||||
--echo #
|
||||
create table t1 (a int);
|
||||
create table t2 (a int);
|
||||
|
||||
insert into t1 values (1),(1),(2),(2);
|
||||
insert into t2 values (1);
|
||||
|
||||
create table t0 (a int);
|
||||
insert into t0 values (1),(2);
|
||||
|
||||
set @tmp_20110622= @@optimizer_switch;
|
||||
set optimizer_switch='firstmatch=off,loosescan=off,materialization=off';
|
||||
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);
|
||||
|
||||
--echo # Try also without join buffer
|
||||
set @tmp_jcl_20110622= @@join_cache_level;
|
||||
set join_cache_level= 0;
|
||||
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;
|
||||
|
||||
drop table t0, t1, t2;
|
||||
|
||||
|
||||
# The following command must be the last one the file
|
||||
set @@optimizer_switch=@save_optimizer_switch;
|
||||
|
|
|
@ -15211,6 +15211,17 @@ evaluate_null_complemented_join_record(JOIN *join, JOIN_TAB *join_tab)
|
|||
/*
|
||||
The row complemented by nulls satisfies all conditions
|
||||
attached to inner tables.
|
||||
*/
|
||||
if (join_tab->check_weed_out_table)
|
||||
{
|
||||
int res= do_sj_dups_weedout(join->thd, join_tab->check_weed_out_table);
|
||||
if (res == -1)
|
||||
return NESTED_LOOP_ERROR;
|
||||
else if (res == 1)
|
||||
return NESTED_LOOP_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
Send the row complemented by nulls to be joined with the
|
||||
remaining tables.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue