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
c44c1bd1
Commit
c44c1bd1
authored
Jun 02, 2011
by
Sergey Petrunya
Browse files
Options
Browse Files
Download
Plain Diff
Merge fix for BUG#787299.
parents
97db0315
ebb130b1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
4 deletions
+62
-4
mysql-test/r/subselect_sj.result
mysql-test/r/subselect_sj.result
+21
-0
mysql-test/r/subselect_sj_jcl6.result
mysql-test/r/subselect_sj_jcl6.result
+21
-0
mysql-test/t/subselect_sj.test
mysql-test/t/subselect_sj.test
+13
-0
sql/opt_subselect.cc
sql/opt_subselect.cc
+5
-4
sql/sql_select.h
sql/sql_select.h
+2
-0
No files found.
mysql-test/r/subselect_sj.result
View file @
c44c1bd1
...
@@ -1245,4 +1245,25 @@ t1field
...
@@ -1245,4 +1245,25 @@ t1field
2
2
3
3
drop table t1,t2;
drop table t1,t2;
#
# BUG#787299: Valgrind complains on a join query with two IN subqueries
#
create table t1 (a int);
insert into t1 values (1), (2), (3);
create table t2 as select * from t1;
select * from t1 A, t1 B
where A.a = B.a and A.a in (select a from t2 C) and B.a in (select a from t2 D);
a a
1 1
2 2
3 3
explain
select * from t1 A, t1 B
where A.a = B.a and A.a in (select a from t2 C) and B.a in (select a from t2 D);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY A ALL NULL NULL NULL NULL 3 Start temporary
1 PRIMARY B ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
1 PRIMARY C ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
1 PRIMARY D ALL NULL NULL NULL NULL 3 Using where; End temporary; Using join buffer (flat, BNL join)
drop table t1, t2;
set @@optimizer_switch=@save_optimizer_switch;
set @@optimizer_switch=@save_optimizer_switch;
mysql-test/r/subselect_sj_jcl6.result
View file @
c44c1bd1
...
@@ -1253,6 +1253,27 @@ t1field
...
@@ -1253,6 +1253,27 @@ t1field
2
2
3
3
drop table t1,t2;
drop table t1,t2;
#
# BUG#787299: Valgrind complains on a join query with two IN subqueries
#
create table t1 (a int);
insert into t1 values (1), (2), (3);
create table t2 as select * from t1;
select * from t1 A, t1 B
where A.a = B.a and A.a in (select a from t2 C) and B.a in (select a from t2 D);
a a
1 1
2 2
3 3
explain
select * from t1 A, t1 B
where A.a = B.a and A.a in (select a from t2 C) and B.a in (select a from t2 D);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY A ALL NULL NULL NULL NULL 3 Start temporary
1 PRIMARY B ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
1 PRIMARY C ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
1 PRIMARY D ALL NULL NULL NULL NULL 3 Using where; End temporary; Using join buffer (incremental, BNL join)
drop table t1, t2;
set @@optimizer_switch=@save_optimizer_switch;
set @@optimizer_switch=@save_optimizer_switch;
#
#
# BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off
# BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off
...
...
mysql-test/t/subselect_sj.test
View file @
c44c1bd1
...
@@ -1137,5 +1137,18 @@ WHERE
...
@@ -1137,5 +1137,18 @@ WHERE
WHERE
C
.
t2field
IN
(
SELECT
D
.
t2field
FROM
t2
D
));
WHERE
C
.
t2field
IN
(
SELECT
D
.
t2field
FROM
t2
D
));
drop
table
t1
,
t2
;
drop
table
t1
,
t2
;
--
echo
#
--
echo
# BUG#787299: Valgrind complains on a join query with two IN subqueries
--
echo
#
create
table
t1
(
a
int
);
insert
into
t1
values
(
1
),
(
2
),
(
3
);
create
table
t2
as
select
*
from
t1
;
select
*
from
t1
A
,
t1
B
where
A
.
a
=
B
.
a
and
A
.
a
in
(
select
a
from
t2
C
)
and
B
.
a
in
(
select
a
from
t2
D
);
explain
select
*
from
t1
A
,
t1
B
where
A
.
a
=
B
.
a
and
A
.
a
in
(
select
a
from
t2
C
)
and
B
.
a
in
(
select
a
from
t2
D
);
drop
table
t1
,
t2
;
# The following command must be the last one the file
# The following command must be the last one the file
set
@@
optimizer_switch
=@
save_optimizer_switch
;
set
@@
optimizer_switch
=@
save_optimizer_switch
;
sql/opt_subselect.cc
View file @
c44c1bd1
...
@@ -2042,7 +2042,7 @@ void advance_sj_state(JOIN *join, table_map remaining_tables,
...
@@ -2042,7 +2042,7 @@ void advance_sj_state(JOIN *join, table_map remaining_tables,
/* Initialize the state or copy it from prev. tables */
/* Initialize the state or copy it from prev. tables */
if
(
idx
==
join
->
const_tables
)
if
(
idx
==
join
->
const_tables
)
{
{
pos
->
first_firstmatch_table
=
MAX_TABLES
;
pos
->
invalidate_firstmatch_prefix
()
;
pos
->
first_loosescan_table
=
MAX_TABLES
;
pos
->
first_loosescan_table
=
MAX_TABLES
;
pos
->
dupsweedout_tables
=
0
;
pos
->
dupsweedout_tables
=
0
;
pos
->
sjm_scan_need_tables
=
0
;
pos
->
sjm_scan_need_tables
=
0
;
...
@@ -2107,7 +2107,7 @@ void advance_sj_state(JOIN *join, table_map remaining_tables,
...
@@ -2107,7 +2107,7 @@ void advance_sj_state(JOIN *join, table_map remaining_tables,
pos
->
first_firstmatch_rtbl
=
remaining_tables
;
pos
->
first_firstmatch_rtbl
=
remaining_tables
;
}
}
if
(
pos
->
first_firstmatch_table
!=
MAX_TABLES
)
if
(
pos
->
in_firstmatch_prefix
()
)
{
{
if
(
outer_corr_tables
&
pos
->
first_firstmatch_rtbl
)
if
(
outer_corr_tables
&
pos
->
first_firstmatch_rtbl
)
{
{
...
@@ -2115,7 +2115,7 @@ void advance_sj_state(JOIN *join, table_map remaining_tables,
...
@@ -2115,7 +2115,7 @@ void advance_sj_state(JOIN *join, table_map remaining_tables,
Trying to add an sj-inner table whose sj-nest has an outer correlated
Trying to add an sj-inner table whose sj-nest has an outer correlated
table that was not in the prefix. This means FirstMatch can't be used.
table that was not in the prefix. This means FirstMatch can't be used.
*/
*/
pos
->
first_firstmatch_table
=
MAX_TABLES
;
pos
->
invalidate_firstmatch_prefix
()
;
}
}
else
else
{
{
...
@@ -2123,7 +2123,8 @@ void advance_sj_state(JOIN *join, table_map remaining_tables,
...
@@ -2123,7 +2123,8 @@ void advance_sj_state(JOIN *join, table_map remaining_tables,
pos
->
firstmatch_need_tables
|=
sj_inner_tables
;
pos
->
firstmatch_need_tables
|=
sj_inner_tables
;
}
}
if
(
!
(
pos
->
firstmatch_need_tables
&
remaining_tables
))
if
(
pos
->
in_firstmatch_prefix
()
&&
!
(
pos
->
firstmatch_need_tables
&
remaining_tables
))
{
{
/*
/*
Got a complete FirstMatch range.
Got a complete FirstMatch range.
...
...
sql/sql_select.h
View file @
c44c1bd1
...
@@ -584,6 +584,8 @@ typedef struct st_position
...
@@ -584,6 +584,8 @@ typedef struct st_position
*/
*/
table_map
firstmatch_need_tables
;
table_map
firstmatch_need_tables
;
bool
in_firstmatch_prefix
()
{
return
(
first_firstmatch_table
!=
MAX_TABLES
);
}
void
invalidate_firstmatch_prefix
()
{
first_firstmatch_table
=
MAX_TABLES
;
}
/* Duplicate Weedout strategy */
/* Duplicate Weedout strategy */
/* The first table that the strategy will need to handle */
/* The first table that the strategy will need to handle */
...
...
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