From 83bc8c4e389305290cae4b9ed7fc89f9a348eb44 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 20 Mar 2006 16:28:25 +0400 Subject: [PATCH] Bug#17374: select ... like 'A%' operator fails to find value on columuns with key Fixed that LIKE worked case insensitively for latin2_czech_cs, which was wrong for a case sensitive collation. include/m_ctype.h: Making my_wildcmp_bin public instead of static strings/ctype-bin.c: Making my_wildcmp_bin public instead of static strings/ctype-czech.c: Use my_wildcmp_bin instead of case insensitive my_wildcmp_8bit mysql-test/include/have_latin2_ch.inc: New BitKeeper file ``mysql-test/include/have_latin2_ch.inc'' mysql-test/r/ctype_latin2_ch.result: New BitKeeper file ``mysql-test/r/ctype_latin2_ch.result'' mysql-test/r/have_latin2_ch.require: New BitKeeper file ``mysql-test/r/have_latin2_ch.require'' mysql-test/t/ctype_latin2_ch.test: New BitKeeper file ``mysql-test/t/ctype_latin2_ch.test'' --- include/m_ctype.h | 5 +++++ mysql-test/include/have_latin2_ch.inc | 4 ++++ mysql-test/r/ctype_latin2_ch.result | 30 +++++++++++++++++++++++++++ mysql-test/r/have_latin2_ch.require | 2 ++ mysql-test/t/ctype_latin2_ch.test | 30 +++++++++++++++++++++++++++ strings/ctype-bin.c | 8 +++---- strings/ctype-czech.c | 2 +- 7 files changed, 76 insertions(+), 5 deletions(-) create mode 100644 mysql-test/include/have_latin2_ch.inc create mode 100644 mysql-test/r/ctype_latin2_ch.result create mode 100644 mysql-test/r/have_latin2_ch.require create mode 100644 mysql-test/t/ctype_latin2_ch.test diff --git a/include/m_ctype.h b/include/m_ctype.h index a5dc7cc00c6..d6d2c4fe25b 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -342,6 +342,11 @@ int my_wildcmp_8bit(CHARSET_INFO *, const char *wildstr,const char *wildend, int escape, int w_one, int w_many); +int my_wildcmp_bin(CHARSET_INFO *, + const char *str,const char *str_end, + const char *wildstr,const char *wildend, + int escape, int w_one, int w_many); + uint my_numchars_8bit(CHARSET_INFO *, const char *b, const char *e); uint my_numcells_8bit(CHARSET_INFO *, const char *b, const char *e); uint my_charpos_8bit(CHARSET_INFO *, const char *b, const char *e, uint pos); diff --git a/mysql-test/include/have_latin2_ch.inc b/mysql-test/include/have_latin2_ch.inc new file mode 100644 index 00000000000..9d3ee6b341c --- /dev/null +++ b/mysql-test/include/have_latin2_ch.inc @@ -0,0 +1,4 @@ +-- require r/have_latin2_ch.require +disable_query_log; +show collation like "latin2_czech_cs"; +enable_query_log; diff --git a/mysql-test/r/ctype_latin2_ch.result b/mysql-test/r/ctype_latin2_ch.result new file mode 100644 index 00000000000..2b3765c07c4 --- /dev/null +++ b/mysql-test/r/ctype_latin2_ch.result @@ -0,0 +1,30 @@ +drop table if exists t1; +set names latin2; +select 'A' = 'a' collate latin2_czech_cs; +'A' = 'a' collate latin2_czech_cs +0 +create table t1 ( +id int(5) not null, +tt char(255) not null +) character set latin2 collate latin2_czech_cs; +insert into t1 values (1,'Aa'); +insert into t1 values (2,'Aas'); +alter table t1 add primary key aaa(tt); +select * from t1 where tt like 'Aa%'; +id tt +1 Aa +2 Aas +select * from t1 ignore index (primary) where tt like 'Aa%'; +id tt +1 Aa +2 Aas +select * from t1 where tt like '%Aa%'; +id tt +1 Aa +2 Aas +select * from t1 where tt like 'AA%'; +id tt +select * from t1 ignore index (primary) where tt like 'AA%'; +id tt +select * from t1 where tt like '%AA%'; +id tt diff --git a/mysql-test/r/have_latin2_ch.require b/mysql-test/r/have_latin2_ch.require new file mode 100644 index 00000000000..352401bbfe8 --- /dev/null +++ b/mysql-test/r/have_latin2_ch.require @@ -0,0 +1,2 @@ +Collation Charset Id Default Compiled Sortlen +latin2_czech_cs latin2 2 Yes 4 diff --git a/mysql-test/t/ctype_latin2_ch.test b/mysql-test/t/ctype_latin2_ch.test new file mode 100644 index 00000000000..626d83fa17d --- /dev/null +++ b/mysql-test/t/ctype_latin2_ch.test @@ -0,0 +1,30 @@ +-- source include/have_latin2_ch.inc + +# +# Tests with latin2_czech_cs +# +--disable_warnings +drop table if exists t1; +--enable_warnings + +# +# Bug#17374: select ... like 'A%' operator fails +# to find value on columuns with key +# +set names latin2; +select 'A' = 'a' collate latin2_czech_cs; +create table t1 ( + id int(5) not null, + tt char(255) not null +) character set latin2 collate latin2_czech_cs; +insert into t1 values (1,'Aa'); +insert into t1 values (2,'Aas'); +alter table t1 add primary key aaa(tt); +select * from t1 where tt like 'Aa%'; +select * from t1 ignore index (primary) where tt like 'Aa%'; +select * from t1 where tt like '%Aa%'; +select * from t1 where tt like 'AA%'; +select * from t1 ignore index (primary) where tt like 'AA%'; +select * from t1 where tt like '%AA%'; + +# End of 4.1 tests diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c index 1ac79ac9ca0..dc078763341 100644 --- a/strings/ctype-bin.c +++ b/strings/ctype-bin.c @@ -269,10 +269,10 @@ void my_hash_sort_bin(CHARSET_INFO *cs __attribute__((unused)), #define INC_PTR(cs,A,B) (A)++ -static int my_wildcmp_bin(CHARSET_INFO *cs, - const char *str,const char *str_end, - const char *wildstr,const char *wildend, - int escape, int w_one, int w_many) +int my_wildcmp_bin(CHARSET_INFO *cs, + const char *str,const char *str_end, + const char *wildstr,const char *wildend, + int escape, int w_one, int w_many) { int result= -1; /* Not found, using wildcards */ diff --git a/strings/ctype-czech.c b/strings/ctype-czech.c index 4bd2fbddbc4..2ff5500090a 100644 --- a/strings/ctype-czech.c +++ b/strings/ctype-czech.c @@ -583,7 +583,7 @@ static MY_COLLATION_HANDLER my_collation_latin2_czech_ci_handler = my_strnncollsp_czech, my_strnxfrm_czech, my_like_range_czech, - my_wildcmp_8bit, + my_wildcmp_bin, my_strcasecmp_8bit, my_instr_simple, my_hash_sort_simple,