diff options
author | unknown <evgen@moonbone.local> | 2006-06-30 16:10:26 +0400 |
---|---|---|
committer | unknown <evgen@moonbone.local> | 2006-06-30 16:10:26 +0400 |
commit | 9bec41887e80099151d25875124ec3ba61c79d57 (patch) | |
tree | 87e65f04fe8ee0019857adc8e13b8d0dfa600375 /strings/ctype-mb.c | |
parent | c6f798a15ba04f7dd53aea4a5845cf615b0b77f4 (diff) | |
parent | bdf32845d697f394e848fb892b7bf99a6dfc24eb (diff) | |
download | mariadb-git-9bec41887e80099151d25875124ec3ba61c79d57.tar.gz |
Merge moonbone.local:/home/evgen/bk-trees/mysql-5.0-opt
into moonbone.local:/work/merge-5.1
mysql-test/r/ctype_ucs.result:
Auto merged
mysql-test/r/ctype_utf8.result:
Auto merged
mysql-test/t/ctype_ucs.test:
Auto merged
sql/item_cmpfunc.h:
Auto merged
sql/item_sum.cc:
Auto merged
sql/opt_range.cc:
Auto merged
sql/spatial.h:
Auto merged
sql/sql_select.cc:
Auto merged
sql/sql_select.h:
Auto merged
sql/sql_update.cc:
Auto merged
strings/ctype-mb.c:
Auto merged
Diffstat (limited to 'strings/ctype-mb.c')
-rw-r--r-- | strings/ctype-mb.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index a10dffea66f..898b7a4a57d 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -527,27 +527,20 @@ my_bool my_like_range_mb(CHARSET_INFO *cs, char *min_str,char *max_str, uint *min_length,uint *max_length) { + uint mblen; const char *end= ptr + ptr_length; char *min_org= min_str; char *min_end= min_str + res_length; char *max_end= max_str + res_length; - uint charlen= res_length / cs->mbmaxlen; + uint maxcharlen= res_length / cs->mbmaxlen; - for (; ptr != end && min_str != min_end && charlen > 0 ; ptr++, charlen--) + for (; ptr != end && min_str != min_end && maxcharlen ; maxcharlen--) { + /* We assume here that escape, w_any, w_namy are one-byte characters */ if (*ptr == escape && ptr+1 != end) - { - ptr++; /* Skip escape */ - *min_str++= *max_str++ = *ptr; - continue; - } - if (*ptr == w_one || *ptr == w_many) /* '_' and '%' in SQL */ - { - charlen= my_charpos(cs, min_org, min_str, res_length/cs->mbmaxlen); - - if (charlen < (uint) (min_str - min_org)) - min_str= min_org + charlen; - + ptr++; /* Skip escape */ + else if (*ptr == w_one || *ptr == w_many) /* '_' and '%' in SQL */ + { /* Calculate length of keys: 'a\0\0... is the smallest possible string when we have space expand @@ -571,7 +564,16 @@ my_bool my_like_range_mb(CHARSET_INFO *cs, pad_max_char(cs, max_str, max_end); return 0; } - *min_str++= *max_str++ = *ptr; + if ((mblen= my_ismbchar(cs, ptr, end)) > 1) + { + if (ptr+mblen > end || min_str+mblen > min_end) + break; + while (mblen--) + *min_str++= *max_str++= *ptr++; + } + else + *min_str++= *max_str++= *ptr++; + } *min_length= *max_length = (uint) (min_str - min_org); |