diff options
author | Alexander Barkov <bar@mnogosearch.org> | 2013-10-25 15:01:03 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mnogosearch.org> | 2013-10-25 15:01:03 +0400 |
commit | 71f8ca654eceea835d6330eb511ce41643dfaeb5 (patch) | |
tree | 2e87ceb27347664cd9317b7ba24a6cbc0f47749a /strings/ctype-utf8.c | |
parent | a6e28ce5e6a1cb2c5e4eaf9e900e7d6339094a75 (diff) | |
download | mariadb-git-71f8ca654eceea835d6330eb511ce41643dfaeb5.tar.gz |
MDEV-5180 Data type for WEIGHT_STRING is too short in some cases
(a bug in upstream)
Diffstat (limited to 'strings/ctype-utf8.c')
-rw-r--r-- | strings/ctype-utf8.c | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 207eaffb1a3..4cd05fcb591 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -2219,6 +2219,16 @@ my_strnxfrm_unicode(CHARSET_INFO *cs, /* + For BMP-only collations that use 2 bytes per weight. +*/ +size_t +my_strnxfrmlen_unicode(CHARSET_INFO *cs, size_t len) +{ + + return ((len + cs->mbmaxlen - 1) / cs->mbmaxlen) * 2; +} + +/* Store sorting weights using 3 bytes per character. This function is shared between utf8mb4_bin, utf16_bin, utf32_bin. */ @@ -2989,13 +2999,6 @@ int my_wildcmp_utf8(CHARSET_INFO *cs, } -static -size_t my_strnxfrmlen_utf8(CHARSET_INFO *cs __attribute__((unused)), - size_t len) -{ - return (len * 2 + 2) / 3; -} - static uint my_ismbchar_utf8(CHARSET_INFO *cs,const char *b, const char *e) { my_wc_t wc; @@ -3032,7 +3035,7 @@ static MY_COLLATION_HANDLER my_collation_utf8_general_ci_handler = my_strnncoll_utf8, my_strnncollsp_utf8, my_strnxfrm_unicode, - my_strnxfrmlen_utf8, + my_strnxfrmlen_unicode, my_like_range_mb, my_wildcmp_utf8, my_strcasecmp_utf8, @@ -3048,7 +3051,7 @@ static MY_COLLATION_HANDLER my_collation_utf8_bin_handler = my_strnncoll_mb_bin, my_strnncollsp_mb_bin, my_strnxfrm_unicode, - my_strnxfrmlen_utf8, + my_strnxfrmlen_unicode, my_like_range_mb, my_wildcmp_mb_bin, my_strcasecmp_mb_bin, @@ -3328,7 +3331,7 @@ static MY_COLLATION_HANDLER my_collation_cs_handler = my_strnncoll_utf8_cs, my_strnncollsp_utf8_cs, my_strnxfrm_unicode, - my_strnxfrmlen_utf8, + my_strnxfrmlen_unicode, my_like_range_simple, my_wildcmp_mb, my_strcasecmp_utf8, @@ -4601,7 +4604,7 @@ static MY_COLLATION_HANDLER my_collation_filename_handler = my_strnncoll_utf8, my_strnncollsp_utf8, my_strnxfrm_unicode, - my_strnxfrmlen_utf8, + my_strnxfrmlen_unicode, my_like_range_mb, my_wildcmp_utf8, my_strcasecmp_utf8, @@ -5428,14 +5431,6 @@ my_wildcmp_utf8mb4(CHARSET_INFO *cs, } -static size_t -my_strnxfrmlen_utf8mb4(CHARSET_INFO *cs __attribute__((unused)), size_t len) -{ - /* TODO: fix when working on WL "Unicode new version" */ - return (len * 2 + 2) / 4; -} - - static uint my_ismbchar_utf8mb4(CHARSET_INFO *cs, const char *b, const char *e) { @@ -5468,7 +5463,7 @@ static MY_COLLATION_HANDLER my_collation_utf8mb4_general_ci_handler= my_strnncoll_utf8mb4, my_strnncollsp_utf8mb4, my_strnxfrm_unicode, - my_strnxfrmlen_utf8mb4, + my_strnxfrmlen_unicode, my_like_range_mb, my_wildcmp_utf8mb4, my_strcasecmp_utf8mb4, |