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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
176ce9e9
Commit
176ce9e9
authored
Oct 14, 2013
by
Igor Babaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug mdev-5135.
The patch for bug mdev-5105 incorrectly counted conditions in nested joins.
parent
b47707f3
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
93 additions
and
6 deletions
+93
-6
mysql-test/r/subselect_sj2.result
mysql-test/r/subselect_sj2.result
+15
-0
mysql-test/r/subselect_sj2_jcl6.result
mysql-test/r/subselect_sj2_jcl6.result
+15
-0
mysql-test/r/subselect_sj2_mat.result
mysql-test/r/subselect_sj2_mat.result
+15
-0
mysql-test/t/subselect_sj2.test
mysql-test/t/subselect_sj2.test
+20
-0
sql/sql_select.cc
sql/sql_select.cc
+28
-6
No files found.
mysql-test/r/subselect_sj2.result
View file @
176ce9e9
...
@@ -1097,5 +1097,20 @@ COUNT(*)
...
@@ -1097,5 +1097,20 @@ COUNT(*)
3724
3724
set optimizer_prune_level=@tmp_951283;
set optimizer_prune_level=@tmp_951283;
DROP TABLE t1,t2;
DROP TABLE t1,t2;
#
# Bug mdev-5135: crash on semijoin with nested outer joins
#
CREATE TABLE t1 (i1 int) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (i2 int, INDEX(i2)) ENGINE=MyISAM;
CREATE TABLE t3 (i3 int, c varchar(1), INDEX(i3), INDEX(c)) ENGINE=MyISAM;
INSERT INTO t3 VALUES (3,'x'),(4,'y');
SELECT * FROM t1 WHERE ( 1, 1 ) IN (
SELECT i2, i2 FROM t2 LEFT OUTER JOIN (
t3 AS t3a INNER JOIN t3 AS t3b ON ( t3a.i3 = t3b.i3 )
) ON ( t3a.c = t3b.c )
);
i1
DROP TABLE t1,t2,t3;
# This must be the last in the file:
# This must be the last in the file:
set optimizer_switch=@subselect_sj2_tmp;
set optimizer_switch=@subselect_sj2_tmp;
mysql-test/r/subselect_sj2_jcl6.result
View file @
176ce9e9
...
@@ -1112,6 +1112,21 @@ COUNT(*)
...
@@ -1112,6 +1112,21 @@ COUNT(*)
3724
3724
set optimizer_prune_level=@tmp_951283;
set optimizer_prune_level=@tmp_951283;
DROP TABLE t1,t2;
DROP TABLE t1,t2;
#
# Bug mdev-5135: crash on semijoin with nested outer joins
#
CREATE TABLE t1 (i1 int) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (i2 int, INDEX(i2)) ENGINE=MyISAM;
CREATE TABLE t3 (i3 int, c varchar(1), INDEX(i3), INDEX(c)) ENGINE=MyISAM;
INSERT INTO t3 VALUES (3,'x'),(4,'y');
SELECT * FROM t1 WHERE ( 1, 1 ) IN (
SELECT i2, i2 FROM t2 LEFT OUTER JOIN (
t3 AS t3a INNER JOIN t3 AS t3b ON ( t3a.i3 = t3b.i3 )
) ON ( t3a.c = t3b.c )
);
i1
DROP TABLE t1,t2,t3;
# This must be the last in the file:
# This must be the last in the file:
set optimizer_switch=@subselect_sj2_tmp;
set optimizer_switch=@subselect_sj2_tmp;
#
#
...
...
mysql-test/r/subselect_sj2_mat.result
View file @
176ce9e9
...
@@ -1099,6 +1099,21 @@ COUNT(*)
...
@@ -1099,6 +1099,21 @@ COUNT(*)
3724
3724
set optimizer_prune_level=@tmp_951283;
set optimizer_prune_level=@tmp_951283;
DROP TABLE t1,t2;
DROP TABLE t1,t2;
#
# Bug mdev-5135: crash on semijoin with nested outer joins
#
CREATE TABLE t1 (i1 int) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (i2 int, INDEX(i2)) ENGINE=MyISAM;
CREATE TABLE t3 (i3 int, c varchar(1), INDEX(i3), INDEX(c)) ENGINE=MyISAM;
INSERT INTO t3 VALUES (3,'x'),(4,'y');
SELECT * FROM t1 WHERE ( 1, 1 ) IN (
SELECT i2, i2 FROM t2 LEFT OUTER JOIN (
t3 AS t3a INNER JOIN t3 AS t3b ON ( t3a.i3 = t3b.i3 )
) ON ( t3a.c = t3b.c )
);
i1
DROP TABLE t1,t2,t3;
# This must be the last in the file:
# This must be the last in the file:
set optimizer_switch=@subselect_sj2_tmp;
set optimizer_switch=@subselect_sj2_tmp;
set optimizer_switch=default;
set optimizer_switch=default;
...
...
mysql-test/t/subselect_sj2.test
View file @
176ce9e9
...
@@ -1229,5 +1229,25 @@ WHERE alias3.d IN (
...
@@ -1229,5 +1229,25 @@ WHERE alias3.d IN (
set
optimizer_prune_level
=@
tmp_951283
;
set
optimizer_prune_level
=@
tmp_951283
;
DROP
TABLE
t1
,
t2
;
DROP
TABLE
t1
,
t2
;
--
echo
#
--
echo
# Bug mdev-5135: crash on semijoin with nested outer joins
--
echo
#
CREATE
TABLE
t1
(
i1
int
)
ENGINE
=
MyISAM
;
INSERT
INTO
t1
VALUES
(
1
),(
2
);
CREATE
TABLE
t2
(
i2
int
,
INDEX
(
i2
))
ENGINE
=
MyISAM
;
CREATE
TABLE
t3
(
i3
int
,
c
varchar
(
1
),
INDEX
(
i3
),
INDEX
(
c
))
ENGINE
=
MyISAM
;
INSERT
INTO
t3
VALUES
(
3
,
'x'
),(
4
,
'y'
);
SELECT
*
FROM
t1
WHERE
(
1
,
1
)
IN
(
SELECT
i2
,
i2
FROM
t2
LEFT
OUTER
JOIN
(
t3
AS
t3a
INNER
JOIN
t3
AS
t3b
ON
(
t3a
.
i3
=
t3b
.
i3
)
)
ON
(
t3a
.
c
=
t3b
.
c
)
);
DROP
TABLE
t1
,
t2
,
t3
;
--
echo
# This must be the last in the file:
--
echo
# This must be the last in the file:
set
optimizer_switch
=@
subselect_sj2_tmp
;
set
optimizer_switch
=@
subselect_sj2_tmp
;
sql/sql_select.cc
View file @
176ce9e9
...
@@ -4703,6 +4703,33 @@ static void add_key_fields_for_nj(JOIN *join, TABLE_LIST *nested_join_table,
...
@@ -4703,6 +4703,33 @@ static void add_key_fields_for_nj(JOIN *join, TABLE_LIST *nested_join_table,
}
}
void
count_cond_for_nj
(
SELECT_LEX
*
sel
,
TABLE_LIST
*
nested_join_table
)
{
List_iterator
<
TABLE_LIST
>
li
(
nested_join_table
->
nested_join
->
join_list
);
List_iterator
<
TABLE_LIST
>
li2
(
nested_join_table
->
nested_join
->
join_list
);
bool
have_another
=
FALSE
;
TABLE_LIST
*
table
;
while
((
table
=
li
++
)
||
(
have_another
&&
(
li
=
li2
,
have_another
=
FALSE
,
(
table
=
li
++
))))
if
(
table
->
nested_join
)
{
if
(
!
table
->
on_expr
)
{
/* It's a semi-join nest. Walk into it as if it wasn't a nest */
have_another
=
TRUE
;
li2
=
li
;
li
=
List_iterator
<
TABLE_LIST
>
(
table
->
nested_join
->
join_list
);
}
else
count_cond_for_nj
(
sel
,
table
);
}
if
(
nested_join_table
->
on_expr
)
nested_join_table
->
on_expr
->
walk
(
&
Item
::
count_sargable_conds
,
0
,
(
uchar
*
)
sel
);
}
/**
/**
Update keyuse array with all possible keys we can use to fetch rows.
Update keyuse array with all possible keys we can use to fetch rows.
...
@@ -4751,12 +4778,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
...
@@ -4751,12 +4778,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab,
while
((
table
=
li
++
))
while
((
table
=
li
++
))
{
{
if
(
table
->
nested_join
)
if
(
table
->
nested_join
)
{
count_cond_for_nj
(
sel
,
table
);
if
(
table
->
on_expr
)
table
->
on_expr
->
walk
(
&
Item
::
count_sargable_conds
,
0
,
(
uchar
*
)
sel
);
if
(
table
->
sj_on_expr
)
table
->
sj_on_expr
->
walk
(
&
Item
::
count_sargable_conds
,
0
,
(
uchar
*
)
sel
);
}
}
}
}
}
...
...
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