Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
eea95a15
Commit
eea95a15
authored
Jun 22, 2011
by
Sergey Petrunya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make semi-joins work with outer joins part #2:
- Do make the DuplicateWeedout check for outer joins.
parent
038be989
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
118 additions
and
0 deletions
+118
-0
mysql-test/r/subselect_sj.result
mysql-test/r/subselect_sj.result
+37
-0
mysql-test/r/subselect_sj_jcl6.result
mysql-test/r/subselect_sj_jcl6.result
+38
-0
mysql-test/t/subselect_sj.test
mysql-test/t/subselect_sj.test
+32
-0
sql/sql_select.cc
sql/sql_select.cc
+11
-0
No files found.
mysql-test/r/subselect_sj.result
View file @
eea95a15
...
...
@@ -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;
mysql-test/r/subselect_sj_jcl6.result
View file @
eea95a15
...
...
@@ -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);
...
...
mysql-test/t/subselect_sj.test
View file @
eea95a15
...
...
@@ -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
;
sql/sql_select.cc
View file @
eea95a15
...
...
@@ -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.
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment