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
31d87cd5
Commit
31d87cd5
authored
Mar 02, 2003
by
serg@serg.mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimizer should check for "field LIKE const" not "field like STRING"
parent
d77cd383
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
8 deletions
+27
-8
.bzrignore
.bzrignore
+2
-0
mysql-test/r/func_like.result
mysql-test/r/func_like.result
+10
-0
mysql-test/t/func_like.test
mysql-test/t/func_like.test
+7
-4
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+8
-4
No files found.
.bzrignore
View file @
31d87cd5
...
...
@@ -528,3 +528,5 @@ support-files/MacOSX/Info.plist
support-files/MacOSX/StartupParameters.plist
support-files/MacOSX/postinstall
support-files/MacOSX/preinstall
configure.lineno
innobase/configure.lineno
mysql-test/r/func_like.result
View file @
31d87cd5
drop table if exists t1;
create table t1 (a varchar(10), key(a));
insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
explain select * from t1 where a like 'abc%';
table type possible_keys key key_len ref rows Extra
t1 range a a 11 NULL 1 Using where; Using index
explain select * from t1 where a like concat('abc','%');
table type possible_keys key key_len ref rows Extra
t1 range a a 11 NULL 1 Using where; Using index
select * from t1 where a like "abc%";
a
abc
abcd
select * from t1 where a like concat("abc","%");
a
abc
abcd
select * from t1 where a like "ABC%";
a
abc
...
...
mysql-test/t/func_like.test
View file @
31d87cd5
...
...
@@ -5,10 +5,13 @@
drop
table
if
exists
t1
;
create
table
t1
(
a
varchar
(
10
),
key
(
a
));
insert
into
t1
values
(
"a"
),(
"abc"
),(
"abcd"
),(
"hello"
),(
"test"
);
select
*
from
t1
where
a
like
"abc%"
;
select
*
from
t1
where
a
like
"ABC%"
;
select
*
from
t1
where
a
like
"test%"
;
select
*
from
t1
where
a
like
"te_t"
;
explain
select
*
from
t1
where
a
like
'abc%'
;
explain
select
*
from
t1
where
a
like
concat
(
'abc'
,
'%'
);
select
*
from
t1
where
a
like
"abc%"
;
select
*
from
t1
where
a
like
concat
(
"abc"
,
"%"
);
select
*
from
t1
where
a
like
"ABC%"
;
select
*
from
t1
where
a
like
"test%"
;
select
*
from
t1
where
a
like
"te_t"
;
#
# The following will test the Turbo Boyer-Moore code
...
...
sql/item_cmpfunc.cc
View file @
31d87cd5
...
...
@@ -1409,12 +1409,16 @@ longlong Item_func_like::val_int()
Item_func
::
optimize_type
Item_func_like
::
select_optimize
()
const
{
if
(
args
[
1
]
->
type
()
==
STRING_ITEM
)
if
(
args
[
1
]
->
const_item
()
)
{
if
(((
Item_string
*
)
args
[
1
])
->
str_value
[
0
]
!=
wild_many
)
String
*
res2
=
args
[
1
]
->
val_str
((
String
*
)
&
tmp_value2
);
if
(
!
res2
)
return
OPTIMIZE_NONE
;
if
(
*
res2
->
ptr
()
!=
wild_many
)
{
if
((
args
[
0
]
->
result_type
()
!=
STRING_RESULT
)
||
((
Item_string
*
)
args
[
1
])
->
str_value
[
0
]
!=
wild_one
)
if
(
args
[
0
]
->
result_type
()
!=
STRING_RESULT
||
*
res2
->
ptr
()
!=
wild_one
)
return
OPTIMIZE_OP
;
}
}
...
...
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