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
4d442610
Commit
4d442610
authored
Nov 19, 2012
by
Igor Babaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug mdev-622 (LP bug #1002508).
Back-ported the fix and the test case for bug 13528826 from mysql-5.6.
parent
e08f4f16
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
64 additions
and
12 deletions
+64
-12
mysql-test/r/order_by.result
mysql-test/r/order_by.result
+27
-0
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+2
-2
mysql-test/r/subselect_no_mat.result
mysql-test/r/subselect_no_mat.result
+2
-2
mysql-test/r/subselect_no_opts.result
mysql-test/r/subselect_no_opts.result
+2
-2
mysql-test/r/subselect_no_scache.result
mysql-test/r/subselect_no_scache.result
+2
-2
mysql-test/r/subselect_no_semijoin.result
mysql-test/r/subselect_no_semijoin.result
+2
-2
mysql-test/t/order_by.test
mysql-test/t/order_by.test
+24
-0
sql/sql_select.cc
sql/sql_select.cc
+3
-2
No files found.
mysql-test/r/order_by.result
View file @
4d442610
...
...
@@ -1993,4 +1993,31 @@ Handler_read_rnd 1
Handler_read_rnd_deleted 0
Handler_read_rnd_next 250
drop table t0, t1;
#
# LP bug #1002508 : the number of expected rows to be examined is off
# (bug #13528826)
#
CREATE TABLE t1(a int PRIMARY KEY, b int) ENGINE=myisam;
INSERT INTO t1 VALUES
(5, 10), (2, 70), (7, 80), (6, 20), (1, 50), (9, 40), (8, 30), (3, 60);
CREATE TABLE t2 (p int, a int, INDEX i_a(a)) ENGINE=myisam;
INSERT INTO t2 VALUES
(103, 7), (109, 3), (102, 3), (108, 1), (106, 3),
(107, 7), (105, 1), (101, 3), (100, 7), (110, 1);
EXPLAIN
SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 8 Using index
1 SIMPLE t2 ref i_a i_a 5 test.t1.a 2 Using index
EXPLAIN
SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a LIMIT 8;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 Using index
1 SIMPLE t2 ref i_a i_a 5 test.t1.a 2 Using index
EXPLAIN
SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a LIMIT 100;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 8 Using index
1 SIMPLE t2 ref i_a i_a 5 test.t1.a 2 Using index
DROP TABLE t1,t2;
End of 5.5 tests
mysql-test/r/subselect.result
View file @
4d442610
...
...
@@ -6860,7 +6860,7 @@ INSERT INTO t2 VALUES (45),(17),(20);
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY t1 index a a 5 NULL
1
Using where; Using index
2 SUBQUERY t1 index a a 5 NULL
2
Using where; Using index
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
DROP TABLE t1,t2;
#
...
...
@@ -6894,6 +6894,6 @@ INSERT INTO t2 VALUES (45),(17),(20);
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY t1 index a a 5 NULL
1
Using where; Using index
2 SUBQUERY t1 index a a 5 NULL
2
Using where; Using index
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
DROP TABLE t1,t2;
mysql-test/r/subselect_no_mat.result
View file @
4d442610
...
...
@@ -6858,7 +6858,7 @@ INSERT INTO t2 VALUES (45),(17),(20);
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY t1 index a a 5 NULL
1
Using where; Using index
2 SUBQUERY t1 index a a 5 NULL
2
Using where; Using index
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
DROP TABLE t1,t2;
#
...
...
@@ -6891,7 +6891,7 @@ INSERT INTO t2 VALUES (45),(17),(20);
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY t1 index a a 5 NULL
1
Using where; Using index
2 SUBQUERY t1 index a a 5 NULL
2
Using where; Using index
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
DROP TABLE t1,t2;
set optimizer_switch=default;
...
...
mysql-test/r/subselect_no_opts.result
View file @
4d442610
...
...
@@ -6855,7 +6855,7 @@ INSERT INTO t2 VALUES (45),(17),(20);
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY t1 index a a 5 NULL
1
Using where; Using index
2 SUBQUERY t1 index a a 5 NULL
2
Using where; Using index
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
DROP TABLE t1,t2;
#
...
...
@@ -6889,7 +6889,7 @@ INSERT INTO t2 VALUES (45),(17),(20);
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY t1 index a a 5 NULL
1
Using where; Using index
2 SUBQUERY t1 index a a 5 NULL
2
Using where; Using index
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
DROP TABLE t1,t2;
set @optimizer_switch_for_subselect_test=null;
mysql-test/r/subselect_no_scache.result
View file @
4d442610
...
...
@@ -6866,7 +6866,7 @@ INSERT INTO t2 VALUES (45),(17),(20);
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY t1 index a a 5 NULL
1
Using where; Using index
2 SUBQUERY t1 index a a 5 NULL
2
Using where; Using index
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
DROP TABLE t1,t2;
#
...
...
@@ -6900,7 +6900,7 @@ INSERT INTO t2 VALUES (45),(17),(20);
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY t1 index a a 5 NULL
1
Using where; Using index
2 SUBQUERY t1 index a a 5 NULL
2
Using where; Using index
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
DROP TABLE t1,t2;
set optimizer_switch=default;
...
...
mysql-test/r/subselect_no_semijoin.result
View file @
4d442610
...
...
@@ -6855,7 +6855,7 @@ INSERT INTO t2 VALUES (45),(17),(20);
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY t1 index a a 5 NULL
1
Using where; Using index
2 SUBQUERY t1 index a a 5 NULL
2
Using where; Using index
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
DROP TABLE t1,t2;
#
...
...
@@ -6889,7 +6889,7 @@ INSERT INTO t2 VALUES (45),(17),(20);
EXPLAIN SELECT * FROM t1 WHERE EXISTS ( SELECT a FROM t1, t2 WHERE b = a GROUP BY a HAVING a <> 1 ) ;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY t1 index a a 5 NULL
1
Using where; Using index
2 SUBQUERY t1 index a a 5 NULL
2
Using where; Using index
2 SUBQUERY t2 ref b b 5 test.t1.a 2 Using index
DROP TABLE t1,t2;
set @optimizer_switch_for_subselect_test=null;
...
...
mysql-test/t/order_by.test
View file @
4d442610
...
...
@@ -1690,6 +1690,30 @@ show status like '%Handler_read%';
drop
table
t0
,
t1
;
--
echo
#
--
echo
# LP bug #1002508 : the number of expected rows to be examined is off
--
echo
# (bug #13528826)
--
echo
#
CREATE
TABLE
t1
(
a
int
PRIMARY
KEY
,
b
int
)
ENGINE
=
myisam
;
INSERT
INTO
t1
VALUES
(
5
,
10
),
(
2
,
70
),
(
7
,
80
),
(
6
,
20
),
(
1
,
50
),
(
9
,
40
),
(
8
,
30
),
(
3
,
60
);
CREATE
TABLE
t2
(
p
int
,
a
int
,
INDEX
i_a
(
a
))
ENGINE
=
myisam
;
INSERT
INTO
t2
VALUES
(
103
,
7
),
(
109
,
3
),
(
102
,
3
),
(
108
,
1
),
(
106
,
3
),
(
107
,
7
),
(
105
,
1
),
(
101
,
3
),
(
100
,
7
),
(
110
,
1
);
EXPLAIN
SELECT
t1
.
a
FROM
t1
LEFT
JOIN
t2
ON
t1
.
a
=
t2
.
a
ORDER
BY
t1
.
a
;
EXPLAIN
SELECT
t1
.
a
FROM
t1
LEFT
JOIN
t2
ON
t1
.
a
=
t2
.
a
ORDER
BY
t1
.
a
LIMIT
8
;
EXPLAIN
SELECT
t1
.
a
FROM
t1
LEFT
JOIN
t2
ON
t1
.
a
=
t2
.
a
ORDER
BY
t1
.
a
LIMIT
100
;
DROP
TABLE
t1
,
t2
;
--
echo
End
of
5.5
tests
sql/sql_select.cc
View file @
4d442610
...
...
@@ -22831,6 +22831,7 @@ test_if_cheaper_ordering(const JOIN_TAB *tab, ORDER *order, TABLE *table,
ha_rows
table_records
=
table
->
file
->
stats
.
records
;
bool
group
=
join
&&
join
->
group
&&
order
==
join
->
group_list
;
ha_rows
ref_key_quick_rows
=
HA_POS_ERROR
;
const
bool
has_limit
=
(
select_limit_arg
!=
HA_POS_ERROR
);
/*
If not used with LIMIT, only use keys if the whole query can be
...
...
@@ -22962,7 +22963,7 @@ test_if_cheaper_ordering(const JOIN_TAB *tab, ORDER *order, TABLE *table,
be included into the result set.
*/
if
(
select_limit
>
table_records
/
rec_per_key
)
select_limit
=
table_records
;
select_limit
=
table_records
;
else
select_limit
=
(
ha_rows
)
(
select_limit
*
rec_per_key
);
}
/* group */
...
...
@@ -23044,7 +23045,7 @@ test_if_cheaper_ordering(const JOIN_TAB *tab, ORDER *order, TABLE *table,
*
new_key
=
best_key
;
*
new_key_direction
=
best_key_direction
;
*
new_select_limit
=
best_select_limit
;
*
new_select_limit
=
has_limit
?
best_select_limit
:
table_records
;
if
(
new_used_key_parts
!=
NULL
)
*
new_used_key_parts
=
best_key_parts
;
...
...
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