diff options
author | unknown <bar@bar.mysql.r18.ru> | 2003-09-19 15:18:19 +0500 |
---|---|---|
committer | unknown <bar@bar.mysql.r18.ru> | 2003-09-19 15:18:19 +0500 |
commit | 25cb265e518c48bc1fe577746d8b8e6d93e1d620 (patch) | |
tree | a720cfa7596cc981bc05e41c0c8c4a6103870eaa /strings/ctype-bin.c | |
parent | cb253b2ab0de502f48bd13e7d1328be480d33ba0 (diff) | |
download | mariadb-git-25cb265e518c48bc1fe577746d8b8e6d93e1d620.tar.gz |
Fixed that multibyte charsets didn't honor multibyte
sequence boundaries in functions LIKE and LOCATE in
the case of "binary" collation. Comparison was done
like if the strings were just a binary strings without
character set assumption.
Diffstat (limited to 'strings/ctype-bin.c')
-rw-r--r-- | strings/ctype-bin.c | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c index 9441268739a..3f74f514c48 100644 --- a/strings/ctype-bin.c +++ b/strings/ctype-bin.c @@ -262,8 +262,46 @@ static int my_strnxfrm_bin(CHARSET_INFO *cs __attribute__((unused)), return len; } +static +int my_instr_bin(CHARSET_INFO *cs __attribute__((unused)), + const char *big, uint b_length, + const char *small, uint s_length) +{ + register const uchar *str, *search, *end, *search_end; + + if (s_length <= b_length) + { + if (!s_length) + return 0; // Empty string is always found + + str= (const uchar*) big; + search= (const uchar*) small; + end= (const uchar*) big+b_length-s_length+1; + search_end= (const uchar*) small + s_length; + +skipp: + while (str != end) + { + if ( (*str++) == (*search)) + { + register const uchar *i,*j; + + i= str; + j= search+1; + + while (j != search_end) + if ((*i++) != (*j++)) + goto skipp; + + return (int) (str- (const uchar*)big) -1; + } + } + } + return -1; +} + -MY_COLLATION_HANDLER my_collation_bin_handler = +MY_COLLATION_HANDLER my_collation_8bit_bin_handler = { my_strnncoll_binary, my_strnncollsp_binary, @@ -271,6 +309,7 @@ MY_COLLATION_HANDLER my_collation_bin_handler = my_like_range_simple, my_wildcmp_bin, my_strcasecmp_bin, + my_instr_bin, my_hash_sort_bin }; @@ -317,5 +356,5 @@ CHARSET_INFO my_charset_bin = 1, /* mbmaxlen */ (char) 255, /* max_sort_char */ &my_charset_handler, - &my_collation_bin_handler + &my_collation_8bit_bin_handler }; |