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
1c418df7
Commit
1c418df7
authored
May 08, 2017
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '5.5' into 10.0
parents
fc25437a
15f9931f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
89 additions
and
6 deletions
+89
-6
extra/mysqld_safe_helper.c
extra/mysqld_safe_helper.c
+1
-1
mysql-test/r/subselect_mat_cost_bugs.result
mysql-test/r/subselect_mat_cost_bugs.result
+42
-0
mysql-test/t/subselect_mat_cost_bugs.test
mysql-test/t/subselect_mat_cost_bugs.test
+39
-0
sql/sql_select.cc
sql/sql_select.cc
+7
-5
No files found.
extra/mysqld_safe_helper.c
View file @
1c418df7
...
...
@@ -59,7 +59,7 @@ int main(int argc, char *argv[])
MY_INIT
(
argv
[
0
]);
if
(
argc
<
3
)
do_usage
(
argv
[
0
]
);
do_usage
();
user_info
=
my_check_user
(
argv
[
1
],
MYF
(
0
));
if
(
user_info
?
my_set_user
(
argv
[
1
],
user_info
,
MYF
(
MY_WME
))
...
...
mysql-test/r/subselect_mat_cost_bugs.result
View file @
1c418df7
...
...
@@ -400,3 +400,45 @@ id select_type table type possible_keys key key_len ref rows Extra
select * from t1 where c1 = 'a2' and (c1, c2) not in (select * from t2);
c1 c2
drop table t1, t2;
#
# MDEV-12673: cost-based choice between materialization and in-to-exists
#
CREATE TABLE t1 (
pk1 int, a1 varchar(3), b1 varchar(3), PRIMARY KEY (pk1), KEY(a1), KEY(b1)
) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1,'foo','bar'),(2,'bar','foo');
CREATE TABLE t2 (pk2 INT PRIMARY KEY, a2 VARCHAR(3), KEY(a2)) ENGINE=MyISAM;
INSERT INTO t2 VALUES (1,'abc'),(2,'xyz'),(3,'foo');
SELECT 'qux' IN ( SELECT a1 FROM t1 INNER JOIN t2 WHERE a2 = b1 AND pk2 = 3 );
'qux' IN ( SELECT a1 FROM t1 INNER JOIN t2 WHERE a2 = b1 AND pk2 = 3 )
0
SELECT 'bar' IN ( SELECT a1 FROM t1 INNER JOIN t2 WHERE a2 = b1 AND pk2 = 3 );
'bar' IN ( SELECT a1 FROM t1 INNER JOIN t2 WHERE a2 = b1 AND pk2 = 3 )
1
EXPLAIN
SELECT 'bar' IN ( SELECT a1 FROM t1 INNER JOIN t2 WHERE a2 = b1 AND pk2 = 3 );
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
2 SUBQUERY t2 const PRIMARY,a2 PRIMARY 4 const 1
2 SUBQUERY t1 ref a1,b1 b1 6 const 1 Using where
DROP TABLE t1,t2;
CREATE TABLE t1 (i1 INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1);
CREATE TABLE t2 (i2 int, c2 varchar(3), KEY(i2,c2)) ENGINE=MyISAM;
INSERT INTO t2 VALUES (1,'abc'),(2,'foo');
CREATE TABLE t3 (pk3 int PRIMARY KEY, c3 varchar(3)) ENGINE=MyISAM;
INSERT INTO t3 VALUES (1,'foo'),(2,'bar');
SELECT * FROM t1 WHERE i1 NOT IN (
SELECT i2 FROM t2 RIGHT JOIN t3 ON (c3 = c2) WHERE pk3 = i1
);
i1
1
EXPLAIN
SELECT * FROM t1 WHERE i1 NOT IN (
SELECT i2 FROM t2 RIGHT JOIN t3 ON (c3 = c2) WHERE pk3 = i1
);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1
2 DEPENDENT SUBQUERY t3 const PRIMARY PRIMARY 4 const 1
2 DEPENDENT SUBQUERY t2 index NULL i2 11 NULL 2 Using where; Using index
DROP TABLE t1,t2,t3;
mysql-test/t/subselect_mat_cost_bugs.test
View file @
1c418df7
...
...
@@ -424,3 +424,42 @@ explain select * from t1 where c1 = 'a2' and (c1, c2) not in (select * from t2);
select
*
from
t1
where
c1
=
'a2'
and
(
c1
,
c2
)
not
in
(
select
*
from
t2
);
drop
table
t1
,
t2
;
--
echo
#
--
echo
# MDEV-12673: cost-based choice between materialization and in-to-exists
--
echo
#
CREATE
TABLE
t1
(
pk1
int
,
a1
varchar
(
3
),
b1
varchar
(
3
),
PRIMARY
KEY
(
pk1
),
KEY
(
a1
),
KEY
(
b1
)
)
ENGINE
=
MyISAM
;
INSERT
INTO
t1
VALUES
(
1
,
'foo'
,
'bar'
),(
2
,
'bar'
,
'foo'
);
CREATE
TABLE
t2
(
pk2
INT
PRIMARY
KEY
,
a2
VARCHAR
(
3
),
KEY
(
a2
))
ENGINE
=
MyISAM
;
INSERT
INTO
t2
VALUES
(
1
,
'abc'
),(
2
,
'xyz'
),(
3
,
'foo'
);
SELECT
'qux'
IN
(
SELECT
a1
FROM
t1
INNER
JOIN
t2
WHERE
a2
=
b1
AND
pk2
=
3
);
SELECT
'bar'
IN
(
SELECT
a1
FROM
t1
INNER
JOIN
t2
WHERE
a2
=
b1
AND
pk2
=
3
);
EXPLAIN
SELECT
'bar'
IN
(
SELECT
a1
FROM
t1
INNER
JOIN
t2
WHERE
a2
=
b1
AND
pk2
=
3
);
DROP
TABLE
t1
,
t2
;
CREATE
TABLE
t1
(
i1
INT
)
ENGINE
=
MyISAM
;
INSERT
INTO
t1
VALUES
(
1
);
CREATE
TABLE
t2
(
i2
int
,
c2
varchar
(
3
),
KEY
(
i2
,
c2
))
ENGINE
=
MyISAM
;
INSERT
INTO
t2
VALUES
(
1
,
'abc'
),(
2
,
'foo'
);
CREATE
TABLE
t3
(
pk3
int
PRIMARY
KEY
,
c3
varchar
(
3
))
ENGINE
=
MyISAM
;
INSERT
INTO
t3
VALUES
(
1
,
'foo'
),(
2
,
'bar'
);
SELECT
*
FROM
t1
WHERE
i1
NOT
IN
(
SELECT
i2
FROM
t2
RIGHT
JOIN
t3
ON
(
c3
=
c2
)
WHERE
pk3
=
i1
);
EXPLAIN
SELECT
*
FROM
t1
WHERE
i1
NOT
IN
(
SELECT
i2
FROM
t2
RIGHT
JOIN
t3
ON
(
c3
=
c2
)
WHERE
pk3
=
i1
);
DROP
TABLE
t1
,
t2
,
t3
;
sql/sql_select.cc
View file @
1c418df7
...
...
@@ -8564,10 +8564,12 @@ get_best_combination(JOIN *join)
j
=
j
->
bush_children
->
start
;
used_tables
|=
j
->
table
->
map
;
if
(
j
->
type
!=
JT_CONST
&&
j
->
type
!=
JT_SYSTEM
)
{
if
((
keyuse
=
join
->
best_positions
[
tablenr
].
key
)
&&
create_ref_for_key
(
join
,
j
,
keyuse
,
TRUE
,
used_tables
))
DBUG_RETURN
(
TRUE
);
// Something went wrong
}
if
(
j
->
last_leaf_in_bush
)
j
=
j
->
bush_root_tab
;
}
...
...
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