20 #include <my_global.h>
24 static uchar ctype_bin[]=
27 32, 32, 32, 32, 32, 32, 32, 32, 32, 40, 40, 40, 40, 40, 32, 32,
28 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
29 72, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
30 132,132,132,132,132,132,132,132,132,132, 16, 16, 16, 16, 16, 16,
31 16,129,129,129,129,129,129, 1, 1, 1, 1, 1, 1, 1, 1, 1,
32 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 16, 16, 16, 16, 16,
33 16,130,130,130,130,130,130, 2, 2, 2, 2, 2, 2, 2, 2, 2,
34 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 16, 16, 16, 16, 32,
35 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
36 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
37 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
38 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
39 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
40 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
41 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
42 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
48 static uchar bin_char_array[] =
50 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
51 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
52 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
53 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
54 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
55 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
56 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111,
57 112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
58 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
59 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
60 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
61 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
62 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
63 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
64 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
65 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
73 cs->max_sort_char=255;
77 static int my_strnncoll_binary(
const CHARSET_INFO *cs __attribute__((unused)),
78 const uchar *s,
size_t slen,
79 const uchar *t,
size_t tlen,
82 size_t len= MY_MIN(slen,tlen);
83 int cmp= memcmp(s,t,len);
84 return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
88 size_t my_lengthsp_binary(
const CHARSET_INFO *cs __attribute__((unused)),
89 const char *ptr __attribute__((unused)),
119 __attribute__((unused)),
120 const uchar *s,
size_t slen,
121 const uchar *t,
size_t tlen,
122 my_bool diff_if_only_endspace_difference
123 __attribute__((unused)))
125 return my_strnncoll_binary(cs,s,slen,t,tlen,0);
130 __attribute__((unused)),
131 const uchar *s,
size_t slen,
132 const uchar *t,
size_t tlen,
135 size_t len=MY_MIN(slen,tlen);
136 int cmp= memcmp(s,t,len);
137 return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen);
166 static int my_strnncollsp_8bit_bin(
const CHARSET_INFO *cs
167 __attribute__((unused)),
168 const uchar *a,
size_t a_length,
169 const uchar *b,
size_t b_length,
170 my_bool diff_if_only_endspace_difference)
176 #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
177 diff_if_only_endspace_difference= 0;
180 end= a + (length= MY_MIN(a_length, b_length));
184 return ((
int) a[-1] - (int) b[-1]);
187 if (a_length != b_length)
194 if (diff_if_only_endspace_difference)
196 if (a_length < b_length)
204 for (end= a + a_length-length; a < end ; a++)
207 return (*a <
' ') ? -swap : swap;
216 static size_t my_case_str_bin(
const CHARSET_INFO *cs __attribute__((unused)),
217 char *str __attribute__((unused)))
223 static size_t my_case_bin(
const CHARSET_INFO *cs __attribute__((unused)),
224 char *src __attribute__((unused)),
226 char *dst __attribute__((unused)),
227 size_t dstlen __attribute__((unused)))
233 static int my_strcasecmp_bin(
const CHARSET_INFO *cs __attribute__((unused)),
234 const char *s,
const char *t)
240 uint my_mbcharlen_8bit(
const CHARSET_INFO *cs __attribute__((unused)),
241 uint c __attribute__((unused)))
247 static int my_mb_wc_bin(
const CHARSET_INFO *cs __attribute__((unused)),
250 const uchar *end __attribute__((unused)))
253 return MY_CS_TOOSMALL;
260 static int my_wc_mb_bin(
const CHARSET_INFO *cs __attribute__((unused)),
263 uchar *e __attribute__((unused)))
266 return MY_CS_TOOSMALL;
277 void my_hash_sort_8bit_bin(
const CHARSET_INFO *cs __attribute__((unused)),
278 const uchar *key,
size_t len,
279 ulong *nr1, ulong *nr2)
281 const uchar *pos = key;
287 key= skip_trailing_space(key, len);
289 for (; pos < (uchar*) key ; pos++)
291 nr1[0]^=(ulong) ((((uint) nr1[0] & 63)+nr2[0]) *
292 ((uint)*pos)) + (nr1[0] << 8);
298 void my_hash_sort_bin(
const CHARSET_INFO *cs __attribute__((unused)),
299 const uchar *key,
size_t len,ulong *nr1, ulong *nr2)
301 const uchar *pos = key;
305 for (; pos < (uchar*) key ; pos++)
307 nr1[0]^=(ulong) ((((uint) nr1[0] & 63)+nr2[0]) *
308 ((uint)*pos)) + (nr1[0] << 8);
319 #define likeconv(s,A) (A)
320 #define INC_PTR(cs,A,B) (A)++
325 const char *str,
const char *str_end,
326 const char *wildstr,
const char *wildend,
327 int escape,
int w_one,
int w_many,
int recurse_level)
331 if (my_string_stack_guard && my_string_stack_guard(recurse_level))
333 while (wildstr != wildend)
335 while (*wildstr != w_many && *wildstr != w_one)
337 if (*wildstr == escape && wildstr+1 != wildend)
339 if (str == str_end || likeconv(cs,*wildstr++) != likeconv(cs,*str++))
341 if (wildstr == wildend)
342 return(str != str_end);
345 if (*wildstr == w_one)
351 INC_PTR(cs,str,str_end);
352 }
while (++wildstr < wildend && *wildstr == w_one);
353 if (wildstr == wildend)
356 if (*wildstr == w_many)
361 for (; wildstr != wildend ; wildstr++)
363 if (*wildstr == w_many)
365 if (*wildstr == w_one)
369 INC_PTR(cs,str,str_end);
374 if (wildstr == wildend)
379 if ((cmp= *wildstr) == escape && wildstr+1 != wildend)
382 INC_PTR(cs,wildstr,wildend);
383 cmp=likeconv(cs,cmp);
386 while (str != str_end && (uchar) likeconv(cs,*str) != cmp)
388 if (str++ == str_end)
391 int tmp=my_wildcmp_bin_impl(cs,str,str_end,
392 wildstr,wildend,escape,
393 w_one, w_many, recurse_level + 1);
397 }
while (str != str_end && wildstr[0] != w_many);
401 return(str != str_end ? 1 : 0);
405 const char *str,
const char *str_end,
406 const char *wildstr,
const char *wildend,
407 int escape,
int w_one,
int w_many)
409 return my_wildcmp_bin_impl(cs, str, str_end,
411 escape, w_one, w_many, 1);
417 uchar * dst,
size_t dstlen, uint nweights,
418 const uchar *src,
size_t srclen, uint
flags)
420 set_if_smaller(srclen, dstlen);
421 set_if_smaller(srclen, nweights);
423 memcpy(dst, src, srclen);
424 return my_strxfrm_pad_desc_and_reverse(cs, dst, dst + srclen, dst + dstlen,
425 nweights - srclen, flags, 0);
430 uint my_instr_bin(
const CHARSET_INFO *cs __attribute__((unused)),
431 const char *b,
size_t b_length,
432 const char *s,
size_t s_length,
435 register const uchar *str, *search, *end, *search_end;
437 if (s_length <= b_length)
450 str= (
const uchar*) b;
451 search= (
const uchar*) s;
452 end= (
const uchar*) b+b_length-s_length+1;
453 search_end= (
const uchar*) s + s_length;
458 if ( (*str++) == (*search))
460 register const uchar *
i,*j;
465 while (j != search_end)
466 if ((*i++) != (*j++))
472 match[0].end= (size_t) (str- (
const uchar*)b-1);
473 match[0].mb_len= match[0].end;
477 match[1].beg= match[0].end;
478 match[1].end= match[0].end+s_length;
479 match[1].mb_len= match[1].end-match[1].beg;
492 my_coll_init_8bit_bin,
493 my_strnncoll_8bit_bin,
494 my_strnncollsp_8bit_bin,
495 my_strnxfrm_8bit_bin,
496 my_strnxfrmlen_simple,
497 my_like_range_simple,
501 my_hash_sort_8bit_bin,
510 my_strnncollsp_binary,
511 my_strnxfrm_8bit_bin,
512 my_strnxfrmlen_simple,
513 my_like_range_simple,
529 my_well_formed_len_8bit,
540 my_long10_to_str_8bit,
541 my_longlong10_to_str_8bit,
549 my_strntoull10rnd_8bit,
557 MY_CS_COMPILED|MY_CS_BINSORT|MY_CS_PRIMARY,
584 &my_collation_binary_handler