diff options
Diffstat (limited to 'sql/field.cc')
-rw-r--r-- | sql/field.cc | 114 |
1 files changed, 61 insertions, 53 deletions
diff --git a/sql/field.cc b/sql/field.cc index 5d398d0ae5f..f2d9f51283a 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -68,7 +68,8 @@ const char field_separator=','; */ static bool -number_dec(struct st_decstr *sdec, const char *str, const char *end) +number_dec(CHARSET_INFO *cs, struct st_decstr *sdec, + const char *str, const char *end) { sdec->sign=sdec->extra=0; if (str == end) @@ -86,7 +87,7 @@ number_dec(struct st_decstr *sdec, const char *str, const char *end) str++; } const char *start=str; - while (str != end && isdigit(*str)) + while (str != end && my_isdigit(cs,*str)) str++; if (!(sdec->nr_length=(uint) (str-start))) sdec->extra=1; // We must put one 0 before . @@ -95,13 +96,13 @@ number_dec(struct st_decstr *sdec, const char *str, const char *end) { str++; start=str; - while (str != end && isdigit(*str)) + while (str != end && my_isdigit(cs,*str)) str++; } sdec->nr_dec=(uint) (str-start); if (current_thd->count_cuted_fields) { - while (str != end && isspace(*str)) + while (str != end && my_isspace(cs,*str)) str++; /* purecov: inspected */ if (str != end) { @@ -135,7 +136,8 @@ bool test_if_int(const char *str,int length) { const char *end=str+length; - while (str != end && isspace(*str)) // Allow start space + // Allow start space + while (str != end && my_isspace(system_charset_info,*str)) str++; /* purecov: inspected */ if (str != end && (*str == '-' || *str == '+')) str++; @@ -143,7 +145,7 @@ bool test_if_int(const char *str,int length) return 0; // Error: Empty string for ( ; str != end ; str++) { - if (!isdigit(*str)) + if (!my_isdigit(system_charset_info,*str)) { if (*str == '.') { // Allow '.0000' @@ -151,10 +153,10 @@ bool test_if_int(const char *str,int length) if (str == end) return 1; } - if (!isspace(*str)) + if (!my_isspace(system_charset_info,*str)) return 0; for (str++ ; str != end ; str++) - if (!isspace(*str)) + if (!my_isspace(system_charset_info,*str)) return 0; return 1; } @@ -165,7 +167,7 @@ bool test_if_int(const char *str,int length) static bool test_if_real(const char *str,int length) { - while (length && isspace(*str)) + while (length && my_isspace(system_charset_info,*str)) { // Allow start space length--; str++; } @@ -174,10 +176,10 @@ static bool test_if_real(const char *str,int length) if (*str == '+' || *str == '-') { length--; str++; - if (!length || !(isdigit(*str) || *str == '.')) + if (!length || !(my_isdigit(system_charset_info,*str) || *str == '.')) return 0; } - while (length && isdigit(*str)) + while (length && my_isdigit(system_charset_info,*str)) { length--; str++; } @@ -186,7 +188,7 @@ static bool test_if_real(const char *str,int length) if (*str == '.') { length--; str++; - while (length && isdigit(*str)) + while (length && my_isdigit(system_charset_info,*str)) { length--; str++; } @@ -195,18 +197,19 @@ static bool test_if_real(const char *str,int length) return 1; if (*str == 'E' || *str == 'e') { - if (length < 3 || (str[1] != '+' && str[1] != '-') || !isdigit(str[2])) + if (length < 3 || (str[1] != '+' && str[1] != '-') || + !my_isdigit(system_charset_info,str[2])) return 0; length-=3; str+=3; - while (length && isdigit(*str)) + while (length && my_isdigit(system_charset_info,*str)) { length--; str++; } } for ( ; length ; length--, str++) { // Allow end space - if (!isspace(*str)) + if (!my_isspace(system_charset_info,*str)) return 0; } return 1; @@ -405,7 +408,7 @@ void Field_decimal::store(const char *from,uint len) if ((tmp_dec= dec)) tmp_dec++; // Calculate pos of '.' - while (from != end && isspace(*from)) + while (from != end && my_isspace(system_charset_info,*from)) from++; if (zerofill) { @@ -416,7 +419,7 @@ void Field_decimal::store(const char *from,uint len) } else fyllchar=' '; - error=number_dec(&decstr,from,end); + error=number_dec(system_charset_info,&decstr,from,end); if (decstr.sign) { from++; @@ -479,7 +482,7 @@ void Field_decimal::store(const char *from,uint len) { if (*from != '0') { - if (!isspace(*from)) // Space is ok + if (!my_isspace(system_charset_info,*from)) // Space is ok current_thd->cuted_fields++; break; } @@ -603,8 +606,10 @@ int Field_decimal::cmp(const char *a_ptr,const char *b_ptr) for (end=a_ptr+field_length; a_ptr != end && (*a_ptr == *b_ptr || - ((isspace(*a_ptr) || *a_ptr == '+' || *a_ptr == '0') && - (isspace(*b_ptr) || *b_ptr == '+' || *b_ptr == '0'))); + ((my_isspace(system_charset_info,*a_ptr) || *a_ptr == '+' || + *a_ptr == '0') && + (my_isspace(system_charset_info,*b_ptr) || *b_ptr == '+' || + *b_ptr == '0'))); a_ptr++,b_ptr++) { if (*a_ptr == '-') // If both numbers are negative @@ -631,7 +636,7 @@ void Field_decimal::sort_string(char *to,uint length) char *str,*end; for (str=ptr,end=ptr+length; str != end && - ((isspace(*str) || *str == '+' || *str == '0')) ; + ((my_isspace(system_charset_info,*str) || *str == '+' || *str == '0')) ; str++) *to++=' '; @@ -643,7 +648,7 @@ void Field_decimal::sort_string(char *to,uint length) *to++=1; // Smaller than any number str++; while (str != end) - if (isdigit(*str)) + if (my_isdigit(system_charset_info,*str)) *to++= (char) ('9' - *str++); else *to++= *str++; @@ -1265,7 +1270,7 @@ void Field_medium::sql_type(String &res) const void Field_long::store(const char *from,uint len) { - while (len && isspace(*from)) + while (len && my_isspace(system_charset_info,*from)) { len--; from++; } @@ -1493,7 +1498,7 @@ void Field_long::sql_type(String &res) const void Field_longlong::store(const char *from,uint len) { - while (len && isspace(*from)) + while (len && my_isspace(system_charset_info,*from)) { // For easy error check len--; from++; } @@ -3306,7 +3311,7 @@ void Field_string::store(const char *from,uint length) const char *end=from+length; for (from+=field_length ; from != end ; from++) { - if (!isspace(*from)) + if (!my_isspace(field_charset,*from)) { current_thd->cuted_fields++; break; @@ -3377,7 +3382,7 @@ int Field_string::cmp(const char *a_ptr, const char *b_ptr) if (binary_flag) return memcmp(a_ptr,b_ptr,field_length); else - return my_sortcmp(a_ptr,b_ptr,field_length); + return my_sortcmp(field_charset,a_ptr,b_ptr,field_length); } void Field_string::sort_string(char *to,uint length) @@ -3387,17 +3392,17 @@ void Field_string::sort_string(char *to,uint length) else { #ifdef USE_STRCOLL - if (use_strcoll(default_charset_info)) { - uint tmp=my_strnxfrm(default_charset_info, - (unsigned char *)to, (unsigned char *) ptr, - length, field_length); + if (use_strcoll(field_charset)) { + uint tmp=my_strnxfrm(field_charset, + (unsigned char *)to, length, + (unsigned char *) ptr, field_length); if (tmp < length) bzero(to + tmp, length - tmp); } else #endif for (char *from=ptr,*end=ptr+length ; from != end ;) - *to++=(char) my_sort_order[(uint) (uchar) *from++]; + *to++=(char) field_charset->sort_order[(uint) (uchar) *from++]; } } @@ -3446,7 +3451,7 @@ int Field_string::pack_cmp(const char *a, const char *b, uint length) int cmp= memcmp(a,b,min(a_length,b_length)); return cmp ? cmp : (int) (a_length - b_length); } - return my_sortncmp(a,a_length, b,b_length); + return my_sortncmp(field_charset, a,a_length, b,b_length); } @@ -3463,7 +3468,7 @@ int Field_string::pack_cmp(const char *b, uint length) int cmp= memcmp(ptr,b,min(a_length,b_length)); return cmp ? cmp : (int) (a_length - b_length); } - return my_sortncmp(ptr,a_length, b, b_length); + return my_sortncmp(field_charset, ptr,a_length, b, b_length); } @@ -3568,7 +3573,7 @@ int Field_varstring::cmp(const char *a_ptr, const char *b_ptr) if (binary_flag) diff=memcmp(a_ptr+2,b_ptr+2,min(a_length,b_length)); else - diff=my_sortcmp(a_ptr+2,b_ptr+2,min(a_length,b_length)); + diff=my_sortcmp(field_charset, a_ptr+2,b_ptr+2,min(a_length,b_length)); return diff ? diff : (int) (a_length - b_length); } @@ -3580,10 +3585,10 @@ void Field_varstring::sort_string(char *to,uint length) else { #ifdef USE_STRCOLL - if (use_strcoll(default_charset_info)) - tot_length=my_strnxfrm(default_charset_info, - (unsigned char *) to, (unsigned char *)ptr+2, - length, tot_length); + if (use_strcoll(field_charset)) + tot_length=my_strnxfrm(field_charset, + (unsigned char *) to, length, + (unsigned char *)ptr+2, tot_length); else { #endif @@ -3591,7 +3596,7 @@ void Field_varstring::sort_string(char *to,uint length) if (tot_length > length) tot_length=length; for (char *from=ptr+2,*end=from+tot_length ; from != end ;) - *tmp++=(char) my_sort_order[(uint) (uchar) *from++]; + *tmp++=(char) field_charset->sort_order[(uint) (uchar) *from++]; #ifdef USE_STRCOLL } #endif @@ -3662,7 +3667,7 @@ int Field_varstring::pack_cmp(const char *a, const char *b, uint key_length) int cmp= memcmp(a,b,min(a_length,b_length)); return cmp ? cmp : (int) (a_length - b_length); } - return my_sortncmp(a,a_length, b,b_length); + return my_sortncmp(field_charset, a,a_length, b,b_length); } int Field_varstring::pack_cmp(const char *b, uint key_length) @@ -3683,7 +3688,7 @@ int Field_varstring::pack_cmp(const char *b, uint key_length) int cmp= memcmp(a,b,min(a_length,b_length)); return cmp ? cmp : (int) (a_length - b_length); } - return my_sortncmp(a,a_length, b,b_length); + return my_sortncmp(field_charset, a,a_length, b,b_length); } uint Field_varstring::packed_col_length(const char *ptr, uint length) @@ -3906,7 +3911,7 @@ int Field_blob::cmp(const char *a,uint32 a_length, const char *b, if (binary_flag) diff=memcmp(a,b,min(a_length,b_length)); else - diff=my_sortcmp(a,b,min(a_length,b_length)); + diff=my_sortcmp(field_charset, a,b,min(a_length,b_length)); return diff ? diff : (int) (a_length - b_length); } @@ -4063,11 +4068,11 @@ void Field_blob::sort_string(char *to,uint length) else { #ifdef USE_STRCOLL - if (use_strcoll(default_charset_info)) + if (use_strcoll(field_charset)) { - blob_length=my_strnxfrm(default_charset_info, - (unsigned char *)to,(unsigned char *)blob, - length,blob_org_length); + blob_length=my_strnxfrm(field_charset, + (unsigned char *)to, length, + (unsigned char *)blob, blob_org_length); if (blob_length >= length) return; to+=blob_length; @@ -4075,7 +4080,7 @@ void Field_blob::sort_string(char *to,uint length) else #endif for (char *end=blob+blob_length ; blob != end ;) - *to++=(char) my_sort_order[(uint) (uchar) *blob++]; + *to++=(char) field_charset->sort_order[(uint) (uchar) *blob++]; } bzero(to,length-blob_length); } @@ -4153,7 +4158,7 @@ int Field_blob::pack_cmp(const char *a, const char *b, uint key_length) int cmp= memcmp(a,b,min(a_length,b_length)); return cmp ? cmp : (int) (a_length - b_length); } - return my_sortncmp(a,a_length, b,b_length); + return my_sortncmp(field_charset, a,a_length, b,b_length); } @@ -4179,7 +4184,7 @@ int Field_blob::pack_cmp(const char *b, uint key_length) int cmp= memcmp(a,b,min(a_length,b_length)); return cmp ? cmp : (int) (a_length - b_length); } - return my_sortncmp(a,a_length, b,b_length); + return my_sortncmp(field_charset, a,a_length, b,b_length); } /* Create a packed key that will be used for storage from a MySQL row */ @@ -4290,14 +4295,16 @@ void Field_enum::store_type(ulonglong value) uint find_enum(TYPELIB *lib,const char *x, uint length) { const char *end=x+length; - while (end > x && isspace(end[-1])) + while (end > x && my_isspace(system_charset_info,end[-1])) end--; const char *i; const char *j; for (uint pos=0 ; (j=lib->type_names[pos]) ; pos++) { - for (i=x ; i != end && toupper(*i) == toupper(*j) ; i++, j++) ; + for (i=x ; i != end && + my_toupper(system_charset_info,*i) == + my_toupper(system_charset_info,*j) ; i++, j++) ; if (i == end && ! *j) return(pos+1); } @@ -4474,7 +4481,7 @@ void Field_enum::sql_type(String &res) const ulonglong find_set(TYPELIB *lib,const char *x,uint length) { const char *end=x+length; - while (end > x && isspace(end[-1])) + while (end > x && my_isspace(system_charset_info, end[-1])) end--; ulonglong found=0; @@ -4600,7 +4607,8 @@ bool Field_enum::eq_def(Field *field) if (typelib->count < from_lib->count) return 0; for (uint i=0 ; i < from_lib->count ; i++) - if (my_strcasecmp(typelib->type_names[i],from_lib->type_names[i])) + if (my_strcasecmp(field_charset, + typelib->type_names[i],from_lib->type_names[i])) return 0; return 1; } |