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
7aca974f
Commit
7aca974f
authored
Sep 21, 2005
by
sergefp@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for BUG#13317: Make range optimizer able to produce ranges for "view.field IN (c1,c2)"
and "view.field BETWEEN c1 AND c2"
parent
46861063
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
4 deletions
+45
-4
mysql-test/r/range.result
mysql-test/r/range.result
+19
-0
mysql-test/t/range.test
mysql-test/t/range.test
+22
-0
sql/opt_range.cc
sql/opt_range.cc
+4
-4
No files found.
mysql-test/r/range.result
View file @
7aca974f
...
...
@@ -768,3 +768,22 @@ SELECT * FROM t1;
a
2
DROP TABLE t1;
create table t1 (a int, b int, primary key(a,b));
create view v1 as select a, b from t1;
INSERT INTO `t1` VALUES
(0,0),(1,0),(2,0),(3,0),(4,0),(5,1),(6,1),(7,1),(8,1),(9,1),(10,2),(11,2),(12,2)
,(13,2),(14,2),(15,3),(16,3),(17,3),(18,3),(19,3);
explain select * from t1 where a in (3,4) and b in (1,2,3);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index
explain select * from v1 where a in (3,4) and b in (1,2,3);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index
explain select * from t1 where a between 3 and 4 and b between 1 and 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index
explain select * from v1 where a between 3 and 4 and b between 1 and 2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index
drop view v1;
drop table t1;
mysql-test/t/range.test
View file @
7aca974f
...
...
@@ -578,3 +578,25 @@ DELETE FROM t1 WHERE NOT(a <=> 2);
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
#
# BUG#13317: range optimization doesn't work for IN over VIEW.
#
create
table
t1
(
a
int
,
b
int
,
primary
key
(
a
,
b
));
create
view
v1
as
select
a
,
b
from
t1
;
INSERT
INTO
`t1`
VALUES
(
0
,
0
),(
1
,
0
),(
2
,
0
),(
3
,
0
),(
4
,
0
),(
5
,
1
),(
6
,
1
),(
7
,
1
),(
8
,
1
),(
9
,
1
),(
10
,
2
),(
11
,
2
),(
12
,
2
)
,(
13
,
2
),(
14
,
2
),(
15
,
3
),(
16
,
3
),(
17
,
3
),(
18
,
3
),(
19
,
3
);
--
replace_column
9
#
explain
select
*
from
t1
where
a
in
(
3
,
4
)
and
b
in
(
1
,
2
,
3
);
--
replace_column
9
#
explain
select
*
from
v1
where
a
in
(
3
,
4
)
and
b
in
(
1
,
2
,
3
);
--
replace_column
9
#
explain
select
*
from
t1
where
a
between
3
and
4
and
b
between
1
and
2
;
--
replace_column
9
#
explain
select
*
from
v1
where
a
between
3
and
4
and
b
between
1
and
2
;
drop
view
v1
;
drop
table
t1
;
sql/opt_range.cc
View file @
7aca974f
...
...
@@ -3533,17 +3533,17 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond)
switch
(
cond_func
->
functype
())
{
case
Item_func
:
:
BETWEEN
:
if
(
cond_func
->
arguments
()[
0
]
->
type
()
!=
Item
::
FIELD_ITEM
)
if
(
cond_func
->
arguments
()[
0
]
->
real_item
()
->
type
()
!=
Item
::
FIELD_ITEM
)
DBUG_RETURN
(
0
);
field_item
=
(
Item_field
*
)
(
cond_func
->
arguments
()[
0
]);
field_item
=
(
Item_field
*
)
(
cond_func
->
arguments
()[
0
]
->
real_item
()
);
value
=
NULL
;
break
;
case
Item_func
:
:
IN_FUNC
:
{
Item_func_in
*
func
=
(
Item_func_in
*
)
cond_func
;
if
(
func
->
key_item
()
->
type
()
!=
Item
::
FIELD_ITEM
)
if
(
func
->
key_item
()
->
real_item
()
->
type
()
!=
Item
::
FIELD_ITEM
)
DBUG_RETURN
(
0
);
field_item
=
(
Item_field
*
)
(
func
->
key_item
());
field_item
=
(
Item_field
*
)
(
func
->
key_item
()
->
real_item
()
);
value
=
NULL
;
break
;
}
...
...
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