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
9d884fd3
Commit
9d884fd3
authored
Aug 12, 2015
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-8599 "WHERE varchar_field LIKE temporal_const" does not use range optimizer
parent
6e091dc7
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
243 additions
and
170 deletions
+243
-170
mysql-test/r/func_like.result
mysql-test/r/func_like.result
+25
-0
mysql-test/t/func_like.test
mysql-test/t/func_like.test
+19
-0
sql/item_cmpfunc.h
sql/item_cmpfunc.h
+14
-0
sql/opt_range.cc
sql/opt_range.cc
+183
-168
sql/opt_range.h
sql/opt_range.h
+2
-2
No files found.
mysql-test/r/func_like.result
View file @
9d884fd3
...
...
@@ -227,5 +227,30 @@ Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 10.0) and (`test`.`t1`.`a` like 10.00))
DROP TABLE t1;
#
# MDEV-8599 "WHERE varchar_field LIKE temporal_const" does not use range optimizer
#
CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET latin1, KEY(a)) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('00:00:00');
INSERT INTO t1 VALUES ('00:00:01');
INSERT INTO t1 VALUES ('00:00:02');
INSERT INTO t1 VALUES ('00:00:03');
INSERT INTO t1 VALUES ('00:00:04');
INSERT INTO t1 VALUES ('00:00:05');
INSERT INTO t1 VALUES ('00:00:06');
INSERT INTO t1 VALUES ('00:00:07');
EXPLAIN SELECT * FROM t1 WHERE a LIKE '00:00:00';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 13 NULL 1 Using where; Using index
EXPLAIN SELECT * FROM t1 WHERE a LIKE TIME'00:00:00';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 13 NULL 1 Using where; Using index
SELECT * FROM t1 WHERE a LIKE '00:00:00';
a
00:00:00
SELECT * FROM t1 WHERE a LIKE TIME'00:00:00';
a
00:00:00
DROP TABLE t1;
#
# End of 10.1 tests
#
mysql-test/t/func_like.test
View file @
9d884fd3
...
...
@@ -163,6 +163,25 @@ SELECT * FROM t1 WHERE a=10.0 AND a LIKE 10.00;
EXPLAIN
EXTENDED
SELECT
*
FROM
t1
WHERE
a
=
10.0
AND
a
LIKE
10.00
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# MDEV-8599 "WHERE varchar_field LIKE temporal_const" does not use range optimizer
--
echo
#
CREATE
TABLE
t1
(
a
VARCHAR
(
10
)
CHARACTER
SET
latin1
,
KEY
(
a
))
ENGINE
=
MyISAM
;
INSERT
INTO
t1
VALUES
(
'00:00:00'
);
INSERT
INTO
t1
VALUES
(
'00:00:01'
);
INSERT
INTO
t1
VALUES
(
'00:00:02'
);
INSERT
INTO
t1
VALUES
(
'00:00:03'
);
INSERT
INTO
t1
VALUES
(
'00:00:04'
);
INSERT
INTO
t1
VALUES
(
'00:00:05'
);
INSERT
INTO
t1
VALUES
(
'00:00:06'
);
INSERT
INTO
t1
VALUES
(
'00:00:07'
);
EXPLAIN
SELECT
*
FROM
t1
WHERE
a
LIKE
'00:00:00'
;
EXPLAIN
SELECT
*
FROM
t1
WHERE
a
LIKE
TIME
'00:00:00'
;
SELECT
*
FROM
t1
WHERE
a
LIKE
'00:00:00'
;
SELECT
*
FROM
t1
WHERE
a
LIKE
TIME
'00:00:00'
;
DROP
TABLE
t1
;
--
echo
#
--
echo
# End of 10.1 tests
--
echo
#
sql/item_cmpfunc.h
View file @
9d884fd3
...
...
@@ -120,6 +120,10 @@ public:
friend
class
Item_func
;
};
class
SEL_ARG
;
struct
KEY_PART
;
class
Item_bool_func
:
public
Item_int_func
{
protected:
...
...
@@ -147,6 +151,9 @@ protected:
SEL_TREE
*
get_ne_mm_tree
(
RANGE_OPT_PARAM
*
param
,
Field
*
field
,
Item
*
lt_value
,
Item
*
gt_value
,
Item_result
cmp_type
);
virtual
SEL_ARG
*
get_mm_leaf
(
RANGE_OPT_PARAM
*
param
,
Field
*
field
,
KEY_PART
*
key_part
,
Item_func
::
Functype
type
,
Item
*
value
);
public:
Item_bool_func
()
:
Item_int_func
()
{}
Item_bool_func
(
Item
*
a
)
:
Item_int_func
(
a
)
{}
...
...
@@ -1437,6 +1444,9 @@ protected:
DBUG_ENTER
(
"Item_func_null_predicate::get_func_mm_tree"
);
DBUG_RETURN
(
get_mm_parts
(
param
,
field
,
functype
(),
value
,
cmp_type
));
}
SEL_ARG
*
get_mm_leaf
(
RANGE_OPT_PARAM
*
param
,
Field
*
field
,
KEY_PART
*
key_part
,
Item_func
::
Functype
type
,
Item
*
value
);
public:
Item_func_null_predicate
(
Item
*
a
)
:
Item_bool_func
(
a
)
{
}
void
add_key_fields
(
JOIN
*
join
,
KEY_FIELD
**
key_fields
,
uint
*
and_level
,
...
...
@@ -1552,6 +1562,10 @@ class Item_func_like :public Item_bool_func2
DTCollation
cmp_collation
;
String
cmp_value1
,
cmp_value2
;
bool
with_sargable_pattern
()
const
;
protected:
SEL_ARG
*
get_mm_leaf
(
RANGE_OPT_PARAM
*
param
,
Field
*
field
,
KEY_PART
*
key_part
,
Item_func
::
Functype
type
,
Item
*
value
);
public:
int
escape
;
...
...
sql/opt_range.cc
View file @
9d884fd3
This diff is collapsed.
Click to expand it.
sql/opt_range.h
View file @
9d884fd3
...
...
@@ -38,7 +38,7 @@
class
JOIN
;
class
Item_sum
;
typedef
struct
st_key_part
{
struct
KEY_PART
{
uint16
key
,
part
;
/* See KEY_PART_INFO for meaning of the next two: */
uint16
store_length
,
length
;
...
...
@@ -50,7 +50,7 @@ typedef struct st_key_part {
uint8
flag
;
Field
*
field
;
Field
::
imagetype
image_type
;
}
KEY_PART
;
};
class
Explain_quick_select
;
/*
...
...
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