mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
optimizer should check for "field LIKE const" not "field like STRING"
BitKeeper/etc/ignore: Added configure.lineno innobase/configure.lineno to the ignore list
This commit is contained in:
@@ -528,3 +528,5 @@ support-files/MacOSX/Info.plist
|
|||||||
support-files/MacOSX/StartupParameters.plist
|
support-files/MacOSX/StartupParameters.plist
|
||||||
support-files/MacOSX/postinstall
|
support-files/MacOSX/postinstall
|
||||||
support-files/MacOSX/preinstall
|
support-files/MacOSX/preinstall
|
||||||
|
configure.lineno
|
||||||
|
innobase/configure.lineno
|
||||||
|
@@ -1,10 +1,20 @@
|
|||||||
drop table if exists t1;
|
drop table if exists t1;
|
||||||
create table t1 (a varchar(10), key(a));
|
create table t1 (a varchar(10), key(a));
|
||||||
insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
|
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%";
|
select * from t1 where a like "abc%";
|
||||||
a
|
a
|
||||||
abc
|
abc
|
||||||
abcd
|
abcd
|
||||||
|
select * from t1 where a like concat("abc","%");
|
||||||
|
a
|
||||||
|
abc
|
||||||
|
abcd
|
||||||
select * from t1 where a like "ABC%";
|
select * from t1 where a like "ABC%";
|
||||||
a
|
a
|
||||||
abc
|
abc
|
||||||
|
@@ -5,7 +5,10 @@
|
|||||||
drop table if exists t1;
|
drop table if exists t1;
|
||||||
create table t1 (a varchar(10), key(a));
|
create table t1 (a varchar(10), key(a));
|
||||||
insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
|
insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
|
||||||
|
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 "abc%";
|
||||||
|
select * from t1 where a like concat("abc","%");
|
||||||
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 "test%";
|
||||||
select * from t1 where a like "te_t";
|
select * from t1 where a like "te_t";
|
||||||
|
@@ -1409,12 +1409,16 @@ longlong Item_func_like::val_int()
|
|||||||
|
|
||||||
Item_func::optimize_type Item_func_like::select_optimize() const
|
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) ||
|
if (args[0]->result_type() != STRING_RESULT || *res2->ptr() != wild_one)
|
||||||
((Item_string *) args[1])->str_value[0] != wild_one)
|
|
||||||
return OPTIMIZE_OP;
|
return OPTIMIZE_OP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user