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
bd0b3681
Commit
bd0b3681
authored
Jul 27, 2018
by
Varun Gupta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix added along with a test for a case missed in the patch for MDEV-16751
parent
37dee22d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
4 deletions
+47
-4
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
+17
-0
mysql-test/t/subselect_sj_mat.test
mysql-test/t/subselect_sj_mat.test
+9
-0
sql/sql_select.cc
sql/sql_select.cc
+4
-4
No files found.
mysql-test/r/subselect_mat.result
View file @
bd0b3681
...
...
@@ -2436,6 +2436,23 @@ a
drop procedure prepare_data;
set @@optimizer_switch= @save_optimizer_switch;
drop table t1,t2,t3;
CREATE TABLE t1 ( id int NOT NULL, key(id));
INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19);
CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL);
INSERT INTO t2 VALUES (11,11),(12,12),(13,13);
CREATE VIEW v1 AS SELECT t2.i1 FROM t2 where t2.i1 = t2.i2;
explain SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
1 PRIMARY t1 ref id id 4 test.t2.i1 2 Using index
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1);
1
1
1
1
drop table t1,t2;
drop view v1;
# End of 5.5 tests
set @subselect_mat_test_optimizer_switch_value=null;
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
...
...
mysql-test/r/subselect_sj_mat.result
View file @
bd0b3681
...
...
@@ -2476,4 +2476,21 @@ a
drop procedure prepare_data;
set @@optimizer_switch= @save_optimizer_switch;
drop table t1,t2,t3;
CREATE TABLE t1 ( id int NOT NULL, key(id));
INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19);
CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL);
INSERT INTO t2 VALUES (11,11),(12,12),(13,13);
CREATE VIEW v1 AS SELECT t2.i1 FROM t2 where t2.i1 = t2.i2;
explain SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
1 PRIMARY t1 ref id id 4 test.t2.i1 2 Using index
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1);
1
1
1
1
drop table t1,t2;
drop view v1;
# End of 5.5 tests
mysql-test/t/subselect_sj_mat.test
View file @
bd0b3681
...
...
@@ -2221,4 +2221,13 @@ drop procedure prepare_data;
set
@@
optimizer_switch
=
@
save_optimizer_switch
;
drop
table
t1
,
t2
,
t3
;
CREATE
TABLE
t1
(
id
int
NOT
NULL
,
key
(
id
));
INSERT
INTO
t1
VALUES
(
11
),(
12
),(
13
),(
14
),(
15
),(
16
),(
17
),(
18
),(
19
);
CREATE
TABLE
t2
(
i1
int
NOT
NULL
,
i2
int
NOT
NULL
);
INSERT
INTO
t2
VALUES
(
11
,
11
),(
12
,
12
),(
13
,
13
);
CREATE
VIEW
v1
AS
SELECT
t2
.
i1
FROM
t2
where
t2
.
i1
=
t2
.
i2
;
explain
SELECT
1
FROM
t1
where
t1
.
id
IN
(
SELECT
v1
.
i1
from
v1
);
SELECT
1
FROM
t1
where
t1
.
id
IN
(
SELECT
v1
.
i1
from
v1
);
drop
table
t1
,
t2
;
drop
view
v1
;
--
echo
# End of 5.5 tests
sql/sql_select.cc
View file @
bd0b3681
...
...
@@ -7445,11 +7445,11 @@ bool JOIN_TAB::keyuse_is_valid_for_access_in_chosen_plan(JOIN *join,
st_select_lex
*
sjm_sel
=
emb_sj_nest
->
sj_subq_pred
->
unit
->
first_select
();
for
(
uint
i
=
0
;
i
<
sjm_sel
->
item_list
.
elements
;
i
++
)
{
DBUG_ASSERT
(
sjm_sel
->
ref_pointer_array
[
i
]
->
type
()
==
Item
::
FIELD_ITEM
);
if
(
keyuse
->
val
->
type
()
==
Item
::
FIELD_ITEM
)
DBUG_ASSERT
(
sjm_sel
->
ref_pointer_array
[
i
]
->
real_item
()
->
type
()
==
Item
::
FIELD_ITEM
);
if
(
keyuse
->
val
->
real_item
()
->
type
()
==
Item
::
FIELD_ITEM
)
{
Field
*
field
=
((
Item_field
*
)
sjm_sel
->
ref_pointer_array
[
i
])
->
field
;
if
(
field
->
eq
(((
Item_field
*
)
keyuse
->
val
)
->
field
))
Field
*
field
=
((
Item_field
*
)
sjm_sel
->
ref_pointer_array
[
i
]
->
real_item
()
)
->
field
;
if
(
field
->
eq
(((
Item_field
*
)
keyuse
->
val
->
real_item
()
)
->
field
))
return
true
;
}
}
...
...
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