Commit 0f79f614 authored by bar@mysql.com's avatar bar@mysql.com

Bug#6787 LIKE not working properly with _ and utf8 data

parent de031d0e
...@@ -19,6 +19,9 @@ select 'a ' = 'a\t', 'a ' < 'a\t', 'a ' > 'a\t'; ...@@ -19,6 +19,9 @@ select 'a ' = 'a\t', 'a ' < 'a\t', 'a ' > 'a\t';
select 'a a' > 'a', 'a \t' < 'a'; select 'a a' > 'a', 'a \t' < 'a';
'a a' > 'a' 'a \t' < 'a' 'a a' > 'a' 'a \t' < 'a'
1 1 1 1
select 'c' like '\_' as want0;
want0
0
CREATE TABLE t ( CREATE TABLE t (
c char(20) NOT NULL c char(20) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
......
...@@ -814,3 +814,6 @@ t2 CREATE TABLE `t2` ( ...@@ -814,3 +814,6 @@ t2 CREATE TABLE `t2` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t2; drop table t2;
drop table t1; drop table t1;
select 'c' like '\_' as want0;
want0
0
...@@ -24,6 +24,11 @@ select 'a ' = 'a\t', 'a ' < 'a\t', 'a ' > 'a\t'; ...@@ -24,6 +24,11 @@ select 'a ' = 'a\t', 'a ' < 'a\t', 'a ' > 'a\t';
select 'a a' > 'a', 'a \t' < 'a'; select 'a a' > 'a', 'a \t' < 'a';
#
# Bug #6787 LIKE not working properly with _ and utf8 data
#
select 'c' like '\_' as want0;
# #
# Bug #5679 utf8_unicode_ci LIKE--trailing % doesn't equal zero characters # Bug #5679 utf8_unicode_ci LIKE--trailing % doesn't equal zero characters
# #
......
...@@ -660,3 +660,9 @@ create table t2 select concat(a,_utf8'') as a, concat(b,_utf8'')as b from t1; ...@@ -660,3 +660,9 @@ create table t2 select concat(a,_utf8'') as a, concat(b,_utf8'')as b from t1;
show create table t2; show create table t2;
drop table t2; drop table t2;
drop table t1; drop table t1;
#
# Bug #6787 LIKE not working properly with _ and utf8 data
#
select 'c' like '\_' as want0;
...@@ -7288,6 +7288,7 @@ int my_wildcmp_uca(CHARSET_INFO *cs, ...@@ -7288,6 +7288,7 @@ int my_wildcmp_uca(CHARSET_INFO *cs,
{ {
while (1) while (1)
{ {
my_bool escaped= 0;
if ((scan= mb_wc(cs, &w_wc, (const uchar*)wildstr, if ((scan= mb_wc(cs, &w_wc, (const uchar*)wildstr,
(const uchar*)wildend)) <= 0) (const uchar*)wildend)) <= 0)
return 1; return 1;
...@@ -7305,6 +7306,7 @@ int my_wildcmp_uca(CHARSET_INFO *cs, ...@@ -7305,6 +7306,7 @@ int my_wildcmp_uca(CHARSET_INFO *cs,
(const uchar*)wildend)) <= 0) (const uchar*)wildend)) <= 0)
return 1; return 1;
wildstr+= scan; wildstr+= scan;
escaped= 1;
} }
if ((scan= mb_wc(cs, &s_wc, (const uchar*)str, if ((scan= mb_wc(cs, &s_wc, (const uchar*)str,
...@@ -7312,7 +7314,7 @@ int my_wildcmp_uca(CHARSET_INFO *cs, ...@@ -7312,7 +7314,7 @@ int my_wildcmp_uca(CHARSET_INFO *cs,
return 1; return 1;
str+= scan; str+= scan;
if (w_wc == (my_wc_t)w_one) if (!escaped && w_wc == (my_wc_t)w_one)
{ {
result= 1; /* Found an anchor char */ result= 1; /* Found an anchor char */
} }
......
...@@ -1545,31 +1545,33 @@ int my_wildcmp_unicode(CHARSET_INFO *cs, ...@@ -1545,31 +1545,33 @@ int my_wildcmp_unicode(CHARSET_INFO *cs,
{ {
while (1) while (1)
{ {
my_bool escaped= 0;
if ((scan= mb_wc(cs, &w_wc, (const uchar*)wildstr, if ((scan= mb_wc(cs, &w_wc, (const uchar*)wildstr,
(const uchar*)wildend)) <= 0) (const uchar*)wildend)) <= 0)
return 1; return 1;
if (w_wc == (my_wc_t)escape)
{
wildstr+= scan;
if ((scan= mb_wc(cs,&w_wc, (const uchar*)wildstr,
(const uchar*)wildend)) <= 0)
return 1;
}
if (w_wc == (my_wc_t)w_many) if (w_wc == (my_wc_t)w_many)
{ {
result= 1; /* Found an anchor char */ result= 1; /* Found an anchor char */
break; break;
} }
wildstr+= scan; wildstr+= scan;
if (w_wc == (my_wc_t)escape)
{
if ((scan= mb_wc(cs, &w_wc, (const uchar*)wildstr,
(const uchar*)wildend)) <= 0)
return 1;
wildstr+= scan;
escaped= 1;
}
if ((scan= mb_wc(cs, &s_wc, (const uchar*)str, if ((scan= mb_wc(cs, &s_wc, (const uchar*)str,
(const uchar*)str_end)) <=0) (const uchar*)str_end)) <= 0)
return 1; return 1;
str+= scan; str+= scan;
if (w_wc == (my_wc_t)w_one) if (!escaped && w_wc == (my_wc_t)w_one)
{ {
result= 1; /* Found an anchor char */ result= 1; /* Found an anchor char */
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment