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
1d1d8651
Commit
1d1d8651
authored
Aug 05, 2011
by
Sergey Petrunya
Browse files
Options
Browse Files
Download
Plain Diff
Merge
parents
b5571557
0e19f3e3
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
605 additions
and
169 deletions
+605
-169
mysql-test/r/group_min_max.result
mysql-test/r/group_min_max.result
+3
-3
mysql-test/r/range.result
mysql-test/r/range.result
+47
-1
mysql-test/r/range_mrr_icp.result
mysql-test/r/range_mrr_icp.result
+47
-1
mysql-test/r/range_vs_index_merge_innodb.result
mysql-test/r/range_vs_index_merge_innodb.result
+2
-2
mysql-test/t/range.test
mysql-test/t/range.test
+47
-1
sql/opt_range.cc
sql/opt_range.cc
+459
-161
No files found.
mysql-test/r/group_min_max.result
View file @
1d1d8651
...
...
@@ -876,10 +876,10 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
explain select a1,a2,b, max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 1
63
NULL 17 Using where; Using index for group-by
1 SIMPLE t1 range NULL idx_t1_1 1
47
NULL 17 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t1 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 1
63
NULL 17 Using where; Using index for group-by
1 SIMPLE t1 range NULL idx_t1_1 1
47
NULL 17 Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t1 where (c > 'b111') and (c <= 'g112') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL idx_t1_1 163 NULL 17 Using where; Using index for group-by
...
...
@@ -924,7 +924,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
explain select a1,a2,b, max(c) from t2 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 1
63
NULL # Using where; Using index for group-by
1 SIMPLE t2 range NULL idx_t2_1 1
46
NULL # Using where; Using index for group-by
explain select a1,a2,b,min(c),max(c) from t2 where (c > 'b1') or (c <= 'g1') group by a1,a2,b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range NULL idx_t2_1 163 NULL # Using where; Using index for group-by
...
...
mysql-test/r/range.result
View file @
1d1d8651
drop table if exists t1, t2, t3;
drop table if exists t1, t2, t3
, t10, t100
;
CREATE TABLE t1 (
event_date date DEFAULT '0000-00-00' NOT NULL,
type int(11) DEFAULT '0' NOT NULL,
...
...
@@ -1763,3 +1763,49 @@ select min(f1) from t1 where f1 >= '2006-05-25 07:00:20' and f1 between '2003-
min(f1)
NULL
drop table t1;
#
# BUG#11765831: 'RANGE ACCESS' MAY INCORRECTLY FILTER
# AWAY QUALIFYING ROWS
#
CREATE TABLE t10(
K INT NOT NULL AUTO_INCREMENT,
I INT, J INT,
PRIMARY KEY(K),
KEY(I,J)
);
INSERT INTO t10(I,J) VALUES (6,1),(6,2),(6,3),(6,4),(6,5),
(6,6),(6,7),(6,8),(6,9),(6,0);
CREATE TABLE t100 LIKE t10;
INSERT INTO t100(I,J) SELECT X.I, X.K+(10*Y.K) FROM t10 AS X,t10 AS Y;
INSERT INTO t100(I,J) VALUES(8,26);
EXPLAIN SELECT * FROM t100 WHERE I <> 6 OR (I <> 8 AND J = 5);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t100 range I I 10 NULL 4 Using where
SELECT * FROM t100 WHERE I <> 6 OR (I <> 8 AND J = 5);
K I J
101 8 26
DROP TABLE t10,t100;
#
# lp:817363: Wrong result with sort_union and multipart key in maria-5.3
#
CREATE TABLE t1 (a int NOT NULL , b int, c int, d varchar(32), KEY (d,b), PRIMARY KEY (a)) ;
INSERT INTO t1 VALUES (7,7,NULL,'e'),(8,1,0,'p'),(9,7,1,'s'),(10,1,1,'j'),(12,2,0,'c'),(13,0,0,'a'),(14,1,1,'q');
SELECT c FROM t1 WHERE d='q' OR d>='q' OR a > 97 OR (d IN ('j','s','i') AND b = 102);
c
1
1
SELECT c FROM t1 ignore index (d) WHERE d='q' OR d>='q' OR a > 97 OR (d IN ('j','s','i') AND b = 102);
c
1
1
SELECT * FROM t1 ignore index(d) WHERE d = 'q' OR d >= 'q' OR (d IN ( 'j' , 's' , 'i' ) AND ( b = 102 ));
a b c d
9 7 1 s
14 1 1 q
SELECT * FROM t1 force index(d) WHERE d = 'q' OR d >= 'q' OR (d IN ( 'j' , 's' , 'i' ) AND ( b = 102 ));
a b c d
14 1 1 q
9 7 1 s
DROP TABLE t1;
mysql-test/r/range_mrr_icp.result
View file @
1d1d8651
set @mrr_icp_extra_tmp=@@optimizer_switch;
set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';
drop table if exists t1, t2, t3;
drop table if exists t1, t2, t3
, t10, t100
;
CREATE TABLE t1 (
event_date date DEFAULT '0000-00-00' NOT NULL,
type int(11) DEFAULT '0' NOT NULL,
...
...
@@ -1765,4 +1765,50 @@ select min(f1) from t1 where f1 >= '2006-05-25 07:00:20' and f1 between '2003-
min(f1)
NULL
drop table t1;
#
# BUG#11765831: 'RANGE ACCESS' MAY INCORRECTLY FILTER
# AWAY QUALIFYING ROWS
#
CREATE TABLE t10(
K INT NOT NULL AUTO_INCREMENT,
I INT, J INT,
PRIMARY KEY(K),
KEY(I,J)
);
INSERT INTO t10(I,J) VALUES (6,1),(6,2),(6,3),(6,4),(6,5),
(6,6),(6,7),(6,8),(6,9),(6,0);
CREATE TABLE t100 LIKE t10;
INSERT INTO t100(I,J) SELECT X.I, X.K+(10*Y.K) FROM t10 AS X,t10 AS Y;
INSERT INTO t100(I,J) VALUES(8,26);
EXPLAIN SELECT * FROM t100 WHERE I <> 6 OR (I <> 8 AND J = 5);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t100 range I I 10 NULL 4 Using index condition; Rowid-ordered scan
SELECT * FROM t100 WHERE I <> 6 OR (I <> 8 AND J = 5);
K I J
101 8 26
DROP TABLE t10,t100;
#
# lp:817363: Wrong result with sort_union and multipart key in maria-5.3
#
CREATE TABLE t1 (a int NOT NULL , b int, c int, d varchar(32), KEY (d,b), PRIMARY KEY (a)) ;
INSERT INTO t1 VALUES (7,7,NULL,'e'),(8,1,0,'p'),(9,7,1,'s'),(10,1,1,'j'),(12,2,0,'c'),(13,0,0,'a'),(14,1,1,'q');
SELECT c FROM t1 WHERE d='q' OR d>='q' OR a > 97 OR (d IN ('j','s','i') AND b = 102);
c
1
1
SELECT c FROM t1 ignore index (d) WHERE d='q' OR d>='q' OR a > 97 OR (d IN ('j','s','i') AND b = 102);
c
1
1
SELECT * FROM t1 ignore index(d) WHERE d = 'q' OR d >= 'q' OR (d IN ( 'j' , 's' , 'i' ) AND ( b = 102 ));
a b c d
9 7 1 s
14 1 1 q
SELECT * FROM t1 force index(d) WHERE d = 'q' OR d >= 'q' OR (d IN ( 'j' , 's' , 'i' ) AND ( b = 102 ));
a b c d
9 7 1 s
14 1 1 q
DROP TABLE t1;
set optimizer_switch=@mrr_icp_extra_tmp;
mysql-test/r/range_vs_index_merge_innodb.result
View file @
1d1d8651
...
...
@@ -332,7 +332,7 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN
SELECT * FROM City WHERE (ID < 200) OR (ID BETWEEN 100 AND 200);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City range PRIMARY PRIMARY 4 NULL
199
Using where
1 SIMPLE City range PRIMARY PRIMARY 4 NULL
200
Using where
EXPLAIN
SELECT * FROM City WHERE (ID < 600) OR (ID BETWEEN 900 AND 1500);
id select_type table type possible_keys key key_len ref rows Extra
...
...
@@ -369,7 +369,7 @@ WHERE ((ID < 200) AND (Name LIKE 'Ha%' OR (Country > 'A' AND Country < 'ARG')))
OR ((ID BETWEEN 100 AND 200) AND
(Name LIKE 'Pa%' OR (Population > 103000 AND Population < 104000)));
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE City range PRIMARY,Population,Country,Name PRIMARY 4 NULL
199
Using where
1 SIMPLE City range PRIMARY,Population,Country,Name PRIMARY 4 NULL
200
Using where
SELECT * FROM City USE INDEX ()
WHERE ((ID < 10) AND (Name LIKE 'H%' OR (Country > 'A' AND Country < 'ARG')))
OR ((ID BETWEEN 100 AND 110) AND
...
...
mysql-test/t/range.test
View file @
1d1d8651
...
...
@@ -3,7 +3,7 @@
#
--
disable_warnings
drop
table
if
exists
t1
,
t2
,
t3
;
drop
table
if
exists
t1
,
t2
,
t3
,
t10
,
t100
;
--
enable_warnings
CREATE
TABLE
t1
(
...
...
@@ -1402,3 +1402,49 @@ insert into t1 values ('2000-03-09 15:56:59'),('2000-05-05 23:24:28'),('2000-06-
select
min
(
f1
)
from
t1
where
f1
>=
'2006-05-25 07:00:20'
and
f1
between
'2003-11-23 10:00:09'
and
'2010-01-01 01:01:01'
and
f1
>
'2001-01-01 01:01:01'
;
drop
table
t1
;
--
echo
#
--
echo
# BUG#11765831: 'RANGE ACCESS' MAY INCORRECTLY FILTER
--
echo
# AWAY QUALIFYING ROWS
--
echo
#
CREATE
TABLE
t10
(
K
INT
NOT
NULL
AUTO_INCREMENT
,
I
INT
,
J
INT
,
PRIMARY
KEY
(
K
),
KEY
(
I
,
J
)
);
INSERT
INTO
t10
(
I
,
J
)
VALUES
(
6
,
1
),(
6
,
2
),(
6
,
3
),(
6
,
4
),(
6
,
5
),
(
6
,
6
),(
6
,
7
),(
6
,
8
),(
6
,
9
),(
6
,
0
);
CREATE
TABLE
t100
LIKE
t10
;
INSERT
INTO
t100
(
I
,
J
)
SELECT
X
.
I
,
X
.
K
+
(
10
*
Y
.
K
)
FROM
t10
AS
X
,
t10
AS
Y
;
# Insert offending value:
INSERT
INTO
t100
(
I
,
J
)
VALUES
(
8
,
26
);
let
$query
=
SELECT
*
FROM
t100
WHERE
I
<>
6
OR
(
I
<>
8
AND
J
=
5
);
#Verify that 'range' access will be used
--
echo
--
eval
EXPLAIN
$query
# Only row 101,8,26 should be returned
--
echo
--
eval
$query
DROP
TABLE
t10
,
t100
;
--
echo
#
--
echo
# lp:817363: Wrong result with sort_union and multipart key in maria-5.3
--
echo
#
CREATE
TABLE
t1
(
a
int
NOT
NULL
,
b
int
,
c
int
,
d
varchar
(
32
),
KEY
(
d
,
b
),
PRIMARY
KEY
(
a
))
;
INSERT
INTO
t1
VALUES
(
7
,
7
,
NULL
,
'e'
),(
8
,
1
,
0
,
'p'
),(
9
,
7
,
1
,
's'
),(
10
,
1
,
1
,
'j'
),(
12
,
2
,
0
,
'c'
),(
13
,
0
,
0
,
'a'
),(
14
,
1
,
1
,
'q'
);
SELECT
c
FROM
t1
WHERE
d
=
'q'
OR
d
>=
'q'
OR
a
>
97
OR
(
d
IN
(
'j'
,
's'
,
'i'
)
AND
b
=
102
);
SELECT
c
FROM
t1
ignore
index
(
d
)
WHERE
d
=
'q'
OR
d
>=
'q'
OR
a
>
97
OR
(
d
IN
(
'j'
,
's'
,
'i'
)
AND
b
=
102
);
SELECT
*
FROM
t1
ignore
index
(
d
)
WHERE
d
=
'q'
OR
d
>=
'q'
OR
(
d
IN
(
'j'
,
's'
,
'i'
)
AND
(
b
=
102
));
SELECT
*
FROM
t1
force
index
(
d
)
WHERE
d
=
'q'
OR
d
>=
'q'
OR
(
d
IN
(
'j'
,
's'
,
'i'
)
AND
(
b
=
102
));
DROP
TABLE
t1
;
sql/opt_range.cc
View file @
1d1d8651
This diff is collapsed.
Click to expand 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