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
5c830565
Commit
5c830565
authored
Sep 26, 2011
by
Sergey Petrunya
Browse files
Options
Browse Files
Download
Plain Diff
Merge
parents
5c4d7c66
4908d27b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
93 additions
and
1 deletion
+93
-1
mysql-test/r/subselect_sj2.result
mysql-test/r/subselect_sj2.result
+23
-0
mysql-test/r/subselect_sj2_jcl6.result
mysql-test/r/subselect_sj2_jcl6.result
+23
-0
mysql-test/r/subselect_sj2_mat.result
mysql-test/r/subselect_sj2_mat.result
+23
-0
mysql-test/t/subselect_sj2.test
mysql-test/t/subselect_sj2.test
+23
-0
sql/opt_subselect.cc
sql/opt_subselect.cc
+1
-1
No files found.
mysql-test/r/subselect_sj2.result
View file @
5c830565
...
...
@@ -764,4 +764,27 @@ a b c
1 r r
DROP VIEW v1;
DROP TABLE t1, t2;
#
# BUG#858732: Wrong result with semijoin + loosescan + comma join
#
CREATE TABLE t1 (f13 int(11) NOT NULL , PRIMARY KEY (f13)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (16),(24);
CREATE TABLE t2 (f14 int(11) NOT NULL, f12 varchar(1) NOT NULL, KEY (f12,f14)) ENGINE=InnoDB;
INSERT INTO t2 VALUES (6,'y');
CREATE TABLE t3 (f12 varchar(1) NOT NULL) ENGINE=InnoDB;
INSERT INTO t3 VALUES ('r'),('s'),('t'),('v'),('w'),('x'),('y');
# The following must use LooseScan but not join buffering
explain
SELECT * FROM t3
WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1.f13 = 24);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY alias1 const PRIMARY PRIMARY 4 const 1 Using index
1 PRIMARY alias2 index f12 f12 7 NULL 1 Using index; LooseScan
1 PRIMARY t1 index NULL PRIMARY 4 NULL 2 Using index; FirstMatch(alias2)
1 PRIMARY t3 ALL NULL NULL NULL NULL 7 Using where; Using join buffer (flat, BNL join)
SELECT * FROM t3
WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1.f13 = 24);
f12
y
DROP TABLE t1,t2,t3;
set optimizer_switch=@subselect_sj2_tmp;
mysql-test/r/subselect_sj2_jcl6.result
View file @
5c830565
...
...
@@ -775,6 +775,29 @@ a b c
1 r r
DROP VIEW v1;
DROP TABLE t1, t2;
#
# BUG#858732: Wrong result with semijoin + loosescan + comma join
#
CREATE TABLE t1 (f13 int(11) NOT NULL , PRIMARY KEY (f13)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (16),(24);
CREATE TABLE t2 (f14 int(11) NOT NULL, f12 varchar(1) NOT NULL, KEY (f12,f14)) ENGINE=InnoDB;
INSERT INTO t2 VALUES (6,'y');
CREATE TABLE t3 (f12 varchar(1) NOT NULL) ENGINE=InnoDB;
INSERT INTO t3 VALUES ('r'),('s'),('t'),('v'),('w'),('x'),('y');
# The following must use LooseScan but not join buffering
explain
SELECT * FROM t3
WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1.f13 = 24);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY alias1 const PRIMARY PRIMARY 4 const 1 Using index
1 PRIMARY alias2 index f12 f12 7 NULL 1 Using index; LooseScan
1 PRIMARY t1 index NULL PRIMARY 4 NULL 2 Using index; FirstMatch(alias2)
1 PRIMARY t3 ALL NULL NULL NULL NULL 7 Using where; Using join buffer (flat, BNL join)
SELECT * FROM t3
WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1.f13 = 24);
f12
y
DROP TABLE t1,t2,t3;
set optimizer_switch=@subselect_sj2_tmp;
set join_cache_level=default;
show variables like 'join_cache_level';
...
...
mysql-test/r/subselect_sj2_mat.result
View file @
5c830565
...
...
@@ -777,6 +777,29 @@ a b c
1 r r
DROP VIEW v1;
DROP TABLE t1, t2;
#
# BUG#858732: Wrong result with semijoin + loosescan + comma join
#
CREATE TABLE t1 (f13 int(11) NOT NULL , PRIMARY KEY (f13)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (16),(24);
CREATE TABLE t2 (f14 int(11) NOT NULL, f12 varchar(1) NOT NULL, KEY (f12,f14)) ENGINE=InnoDB;
INSERT INTO t2 VALUES (6,'y');
CREATE TABLE t3 (f12 varchar(1) NOT NULL) ENGINE=InnoDB;
INSERT INTO t3 VALUES ('r'),('s'),('t'),('v'),('w'),('x'),('y');
# The following must use LooseScan but not join buffering
explain
SELECT * FROM t3
WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1.f13 = 24);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY alias1 const PRIMARY PRIMARY 4 const 1 Using index
1 PRIMARY alias2 index f12 f12 7 NULL 1 Using index; LooseScan
1 PRIMARY t1 index NULL PRIMARY 4 NULL 2 Using index; FirstMatch(alias2)
1 PRIMARY t3 ALL NULL NULL NULL NULL 7 Using where; Using join buffer (flat, BNL join)
SELECT * FROM t3
WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1.f13 = 24);
f12
y
DROP TABLE t1,t2,t3;
set optimizer_switch=@subselect_sj2_tmp;
set optimizer_switch=default;
select @@optimizer_switch like '%materialization=on%';
...
...
mysql-test/t/subselect_sj2.test
View file @
5c830565
...
...
@@ -962,4 +962,27 @@ EXECUTE st1;
DROP
VIEW
v1
;
DROP
TABLE
t1
,
t2
;
--
echo
#
--
echo
# BUG#858732: Wrong result with semijoin + loosescan + comma join
--
echo
#
CREATE
TABLE
t1
(
f13
int
(
11
)
NOT
NULL
,
PRIMARY
KEY
(
f13
))
ENGINE
=
InnoDB
;
INSERT
INTO
t1
VALUES
(
16
),(
24
);
CREATE
TABLE
t2
(
f14
int
(
11
)
NOT
NULL
,
f12
varchar
(
1
)
NOT
NULL
,
KEY
(
f12
,
f14
))
ENGINE
=
InnoDB
;
INSERT
INTO
t2
VALUES
(
6
,
'y'
);
CREATE
TABLE
t3
(
f12
varchar
(
1
)
NOT
NULL
)
ENGINE
=
InnoDB
;
INSERT
INTO
t3
VALUES
(
'r'
),(
's'
),(
't'
),(
'v'
),(
'w'
),(
'x'
),(
'y'
);
--
echo
# The following must use LooseScan but not join buffering
explain
SELECT
*
FROM
t3
WHERE
f12
IN
(
SELECT
alias2
.
f12
FROM
t1
AS
alias1
,
t2
AS
alias2
,
t1
WHERE
alias1
.
f13
=
24
);
SELECT
*
FROM
t3
WHERE
f12
IN
(
SELECT
alias2
.
f12
FROM
t1
AS
alias1
,
t2
AS
alias2
,
t1
WHERE
alias1
.
f13
=
24
);
DROP
TABLE
t1
,
t2
,
t3
;
set
optimizer_switch
=@
subselect_sj2_tmp
;
sql/opt_subselect.cc
View file @
5c830565
...
...
@@ -3834,7 +3834,7 @@ int setup_semijoin_dups_elimination(JOIN *join, ulonglong options,
{
/* We jump from the last table to the first one */
tab
->
loosescan_match_tab
=
tab
+
pos
->
n_sj_tables
-
1
;
for
(
uint
j
=
i
;
j
<
pos
->
n_sj_tables
;
j
++
)
for
(
uint
j
=
i
;
j
<
i
+
pos
->
n_sj_tables
;
j
++
)
join
->
join_tab
[
j
].
inside_loosescan_range
=
TRUE
;
/* Calculate key length */
...
...
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