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
e41e56ae
Commit
e41e56ae
authored
Feb 14, 2012
by
Sergey Petrunya
Browse files
Options
Browse Files
Download
Plain Diff
Merge fix for BUG#928048
parents
c8bbe06a
c9355dc2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
3 deletions
+56
-3
mysql-test/r/subselect_mat.result
mysql-test/r/subselect_mat.result
+17
-0
mysql-test/r/subselect_sj_mat.result
mysql-test/r/subselect_sj_mat.result
+18
-0
mysql-test/t/subselect_sj_mat.test
mysql-test/t/subselect_sj_mat.test
+17
-0
sql/sql_select.cc
sql/sql_select.cc
+4
-3
No files found.
mysql-test/r/subselect_mat.result
View file @
e41e56ae
...
@@ -1831,6 +1831,23 @@ id select_type table type possible_keys key key_len ref rows Extra
...
@@ -1831,6 +1831,23 @@ id select_type table type possible_keys key key_len ref rows Extra
3 MATERIALIZED alias3 ALL NULL NULL NULL NULL 2
3 MATERIALIZED alias3 ALL NULL NULL NULL NULL 2
3 MATERIALIZED alias4 index c c 11 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
3 MATERIALIZED alias4 index c c 11 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
DROP TABLE t1,t2;
DROP TABLE t1,t2;
#
# BUG#928048: Query containing IN subquery with OR in the where clause returns a wrong result
#
create table t1 (a int, b int);
insert into t1 values (7,5), (3,3), (5,4), (9,3);
create table t2 (a int, b int, index i_a(a));
insert into t2 values
(4,2), (7,9), (7,4), (3,1), (5,3), (3,1), (9,4), (8,1);
explain select * from t1 where t1.a in (select a from t2 where t2.a=7 or t2.b<=1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
2 MATERIALIZED t2 ALL i_a NULL NULL NULL 8 Using where
select * from t1 where t1.a in (select a from t2 where t2.a=7 or t2.b<=1);
a b
7 5
3 3
drop table t1,t2;
# This must be at the end:
# This must be at the end:
set optimizer_switch=@subselect_sj_mat_tmp;
set optimizer_switch=@subselect_sj_mat_tmp;
set join_cache_level=@save_join_cache_level;
set join_cache_level=@save_join_cache_level;
...
...
mysql-test/r/subselect_sj_mat.result
View file @
e41e56ae
...
@@ -1867,6 +1867,24 @@ WHERE alias4.c = alias3.b
...
@@ -1867,6 +1867,24 @@ WHERE alias4.c = alias3.b
id select_type table type possible_keys key key_len ref rows Extra
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
DROP TABLE t1,t2;
DROP TABLE t1,t2;
#
# BUG#928048: Query containing IN subquery with OR in the where clause returns a wrong result
#
create table t1 (a int, b int);
insert into t1 values (7,5), (3,3), (5,4), (9,3);
create table t2 (a int, b int, index i_a(a));
insert into t2 values
(4,2), (7,9), (7,4), (3,1), (5,3), (3,1), (9,4), (8,1);
explain select * from t1 where t1.a in (select a from t2 where t2.a=7 or t2.b<=1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 5 func 1
2 MATERIALIZED t2 ALL i_a NULL NULL NULL 8 Using where
select * from t1 where t1.a in (select a from t2 where t2.a=7 or t2.b<=1);
a b
7 5
3 3
drop table t1,t2;
# This must be at the end:
# This must be at the end:
set optimizer_switch=@subselect_sj_mat_tmp;
set optimizer_switch=@subselect_sj_mat_tmp;
set join_cache_level=@save_join_cache_level;
set join_cache_level=@save_join_cache_level;
mysql-test/t/subselect_sj_mat.test
View file @
e41e56ae
...
@@ -1529,6 +1529,23 @@ WHERE b = a AND a IN (
...
@@ -1529,6 +1529,23 @@ WHERE b = a AND a IN (
DROP
TABLE
t1
,
t2
;
DROP
TABLE
t1
,
t2
;
--
echo
#
--
echo
# BUG#928048: Query containing IN subquery with OR in the where clause returns a wrong result
--
echo
#
create
table
t1
(
a
int
,
b
int
);
insert
into
t1
values
(
7
,
5
),
(
3
,
3
),
(
5
,
4
),
(
9
,
3
);
create
table
t2
(
a
int
,
b
int
,
index
i_a
(
a
));
insert
into
t2
values
(
4
,
2
),
(
7
,
9
),
(
7
,
4
),
(
3
,
1
),
(
5
,
3
),
(
3
,
1
),
(
9
,
4
),
(
8
,
1
);
explain
select
*
from
t1
where
t1
.
a
in
(
select
a
from
t2
where
t2
.
a
=
7
or
t2
.
b
<=
1
);
select
*
from
t1
where
t1
.
a
in
(
select
a
from
t2
where
t2
.
a
=
7
or
t2
.
b
<=
1
);
drop
table
t1
,
t2
;
--
echo
# This must be at the end:
--
echo
# This must be at the end:
set
optimizer_switch
=@
subselect_sj_mat_tmp
;
set
optimizer_switch
=@
subselect_sj_mat_tmp
;
set
join_cache_level
=@
save_join_cache_level
;
set
join_cache_level
=@
save_join_cache_level
;
...
...
sql/sql_select.cc
View file @
e41e56ae
...
@@ -11490,7 +11490,7 @@ Item *eliminate_item_equal(COND *cond, COND_EQUAL *upper_levels,
...
@@ -11490,7 +11490,7 @@ Item *eliminate_item_equal(COND *cond, COND_EQUAL *upper_levels,
}
}
/*
/*
Check if "
item_field
=head" equality is already guaranteed to be true
Check if "
field_item
=head" equality is already guaranteed to be true
on upper AND-levels.
on upper AND-levels.
*/
*/
if
(
upper
)
if
(
upper
)
...
@@ -11502,7 +11502,8 @@ Item *eliminate_item_equal(COND *cond, COND_EQUAL *upper_levels,
...
@@ -11502,7 +11502,8 @@ Item *eliminate_item_equal(COND *cond, COND_EQUAL *upper_levels,
Item_equal_fields_iterator
li
(
*
item_equal
);
Item_equal_fields_iterator
li
(
*
item_equal
);
while
((
item
=
li
++
)
!=
field_item
)
while
((
item
=
li
++
)
!=
field_item
)
{
{
if
(
item
->
find_item_equal
(
upper_levels
)
==
upper
)
if
(
embedding_sjm
(
item
)
==
field_sjm
&&
item
->
find_item_equal
(
upper_levels
)
==
upper
)
break
;
break
;
}
}
}
}
...
@@ -11646,7 +11647,7 @@ static COND* substitute_for_best_equal_field(JOIN_TAB *context_tab,
...
@@ -11646,7 +11647,7 @@ static COND* substitute_for_best_equal_field(JOIN_TAB *context_tab,
if
(
and_level
)
if
(
and_level
)
{
{
cond_equal
=
&
((
Item_cond_and
*
)
cond
)
->
cond_equal
;
cond_equal
=
&
((
Item_cond_and
*
)
cond
)
->
cond_equal
;
cond_list
->
disjoin
((
List
<
Item
>
*
)
&
cond_equal
->
current_level
);
cond_list
->
disjoin
((
List
<
Item
>
*
)
&
cond_equal
->
current_level
);
/* remove Item_equal objects from the AND. */
List_iterator_fast
<
Item_equal
>
it
(
cond_equal
->
current_level
);
List_iterator_fast
<
Item_equal
>
it
(
cond_equal
->
current_level
);
while
((
item_equal
=
it
++
))
while
((
item_equal
=
it
++
))
...
...
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