diff options
Diffstat (limited to 'strings/strcoll.ic')
-rw-r--r-- | strings/strcoll.ic | 75 |
1 files changed, 69 insertions, 6 deletions
diff --git a/strings/strcoll.ic b/strings/strcoll.ic index b0556cfac43..eb5b3d5fe9b 100644 --- a/strings/strcoll.ic +++ b/strings/strcoll.ic @@ -202,25 +202,40 @@ MY_FUNCTION_NAME(strnncoll)(CHARSET_INFO *cs __attribute__((unused)), } +#ifdef DEFINE_STRNNCOLLSP_NOPAD + /** - Compare two strings according to the collation, with PAD SPACE handling. + Compare two strings according to the collation, with NO PAD handling. @param cs - the character set and collation @param a - the left string @param a_length - the length of the left string @param b - the right string @param b_length - the length of the right string - @param diff_if_only_endspace_difference - not used in the code. - TODO: this should be eventually removed (in 10.2?) @return - the comparison result */ +static int +MY_FUNCTION_NAME(strnncollsp)(CHARSET_INFO *cs __attribute__((unused)), + const uchar *a, size_t a_length, + const uchar *b, size_t b_length) +{ + return MY_FUNCTION_NAME(strnncoll)(cs, a, a_length, b, b_length, FALSE); +} +#else +/** + Compare two strings according to the collation, with PAD SPACE handling. + @param cs - the character set and collation + @param a - the left string + @param a_length - the length of the left string + @param b - the right string + @param b_length - the length of the right string + @return - the comparison result +*/ static int MY_FUNCTION_NAME(strnncollsp)(CHARSET_INFO *cs __attribute__((unused)), const uchar *a, size_t a_length, - const uchar *b, size_t b_length, - my_bool diff_if_only_endspace_difference - __attribute__((unused))) + const uchar *b, size_t b_length) { const uchar *a_end= a + a_length; const uchar *b_end= b + b_length; @@ -261,6 +276,51 @@ MY_FUNCTION_NAME(strnncollsp)(CHARSET_INFO *cs __attribute__((unused)), DBUG_ASSERT(0); return 0; } +#endif + + +#ifdef DEFINE_STRNXFRM +#ifndef WEIGHT_MB2_FRM +#define WEIGHT_MB2_FRM(x,y) WEIGHT_MB2(x,y) +#endif + +static size_t +MY_FUNCTION_NAME(strnxfrm)(CHARSET_INFO *cs, + uchar *dst, size_t dstlen, uint nweights, + const uchar *src, size_t srclen, uint flags) +{ + uchar *d0= dst; + uchar *de= dst + dstlen; + const uchar *se= src + srclen; + const uchar *sort_order= cs->sort_order; + + for (; dst < de && src < se && nweights; nweights--) + { + if (my_charlen(cs, (const char *) src, (const char *) se) > 1) + { + /* + Note, it is safe not to check (src < se) + in the code below, because my_charlen() would + not return 2 if src was too short + */ + uint16 e= WEIGHT_MB2_FRM(src[0], src[1]); + *dst++= (uchar) (e >> 8); + if (dst < de) + *dst++= (uchar) (e & 0xFF); + src+= 2; + } + else + *dst++= sort_order ? sort_order[*src++] : *src++; + } +#ifdef DEFINE_STRNNCOLLSP_NOPAD + return my_strxfrm_pad_desc_and_reverse_nopad(cs, d0, dst, de, + nweights, flags, 0); +#else + return my_strxfrm_pad_desc_and_reverse(cs, d0, dst, de, nweights, flags, 0); +#endif +} +#endif /* DEFINE_STRNXFRM */ + /* We usually include this file at least two times from the same source file, @@ -273,3 +333,6 @@ MY_FUNCTION_NAME(strnncollsp)(CHARSET_INFO *cs __attribute__((unused)), #undef WEIGHT_MB3 #undef WEIGHT_MB4 #undef WEIGHT_PAD_SPACE +#undef WEIGHT_MB2_FRM +#undef DEFINE_STRNXFRM +#undef DEFINE_STRNNCOLLSP_NOPAD |