diff options
author | bar@gw.udmsearch.izhnet.ru <> | 2002-03-12 21:37:58 +0400 |
---|---|---|
committer | bar@gw.udmsearch.izhnet.ru <> | 2002-03-12 21:37:58 +0400 |
commit | b37ce8e76944610b92087fe0e04e05f1b60903c8 (patch) | |
tree | aa6dbf1781d8122e350474b0cac9e5ee443426bc /sql | |
parent | 4237e7ace74c21d007964940f26f5496027d6e3d (diff) | |
download | mariadb-git-b37ce8e76944610b92087fe0e04e05f1b60903c8.tar.gz |
New ctype functions/macros to support many charsets at a time
Diffstat (limited to 'sql')
-rw-r--r-- | sql/convert.cc | 12 | ||||
-rw-r--r-- | sql/des_key_file.cc | 5 | ||||
-rw-r--r-- | sql/field.cc | 114 | ||||
-rw-r--r-- | sql/field.h | 19 | ||||
-rw-r--r-- | sql/field_conv.cc | 2 | ||||
-rw-r--r-- | sql/filesort.cc | 11 | ||||
-rw-r--r-- | sql/ha_innodb.cc | 5 | ||||
-rw-r--r-- | sql/hostname.cc | 4 | ||||
-rw-r--r-- | sql/init.cc | 14 | ||||
-rw-r--r-- | sql/item.cc | 4 | ||||
-rw-r--r-- | sql/item_func.cc | 3 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 16 | ||||
-rw-r--r-- | sql/item_sum.cc | 3 | ||||
-rw-r--r-- | sql/item_timefunc.cc | 8 | ||||
-rw-r--r-- | sql/key.cc | 5 | ||||
-rw-r--r-- | sql/log.cc | 4 | ||||
-rw-r--r-- | sql/mysql_priv.h | 6 | ||||
-rw-r--r-- | sql/mysqld.cc | 11 | ||||
-rw-r--r-- | sql/opt_range.cc | 3 | ||||
-rw-r--r-- | sql/procedure.cc | 3 | ||||
-rw-r--r-- | sql/slave.cc | 9 | ||||
-rw-r--r-- | sql/sql_acl.cc | 46 | ||||
-rw-r--r-- | sql/sql_analyse.cc | 10 | ||||
-rw-r--r-- | sql/sql_base.cc | 21 | ||||
-rw-r--r-- | sql/sql_cache.cc | 5 | ||||
-rw-r--r-- | sql/sql_db.cc | 6 | ||||
-rw-r--r-- | sql/sql_handler.cc | 2 | ||||
-rw-r--r-- | sql/sql_lex.cc | 78 | ||||
-rw-r--r-- | sql/sql_parse.cc | 15 | ||||
-rw-r--r-- | sql/sql_show.cc | 10 | ||||
-rw-r--r-- | sql/sql_string.cc | 74 | ||||
-rw-r--r-- | sql/sql_string.h | 4 | ||||
-rw-r--r-- | sql/sql_table.cc | 33 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 3 | ||||
-rw-r--r-- | sql/table.cc | 14 | ||||
-rw-r--r-- | sql/time.cc | 53 |
36 files changed, 359 insertions, 276 deletions
diff --git a/sql/convert.cc b/sql/convert.cc index 7a06208759c..1b9a94462c7 100644 --- a/sql/convert.cc +++ b/sql/convert.cc @@ -433,7 +433,17 @@ CONVERT *get_convert_set(const char *name) { for (CONVERT **ptr=convert_tables ; *ptr ; ptr++) { - if (!my_strcasecmp((*ptr)->name,name)) + /* + BAR TODO: Monty's comments: + Why is this using system_charset_info ? + Isn't the character-set string given in the users default charset? + Please add a TODO note to the code that this has to be fixed when the user + will be able to cast strings to different character sets... + The current code will also not work if/when we introduce support for + 16 bit characters... + (I know that there is a LOT of changes to do if we ever want do this...) + */ + if (!my_strcasecmp(system_charset_info,(*ptr)->name,name)) return (*ptr); } return 0; diff --git a/sql/des_key_file.cc b/sql/des_key_file.cc index d9c924b5a3c..ca92e38279b 100644 --- a/sql/des_key_file.cc +++ b/sql/des_key_file.cc @@ -70,9 +70,10 @@ load_des_key_file(const char *file_name) { offset=(char) (offset - '0'); // Remove newline and possible other control characters - for (start=buf+1 ; isspace(*start) ; start++) ; + for (start=buf+1 ; my_isspace(system_charset_info, *start) ; start++) ; end=buf+length; - for (end=strend(buf) ; end > start && !isgraph(end[-1]) ; end--) ; + for (end=strend(buf) ; + end > start && !my_isgraph(system_charset_info, end[-1]) ; end--) ; if (start != end) { 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; } diff --git a/sql/field.h b/sql/field.h index 422e91768e6..cd1697fcf44 100644 --- a/sql/field.h +++ b/sql/field.h @@ -145,12 +145,7 @@ public: virtual void set_key_image(char *buff,uint length) { set_image(buff,length); } inline int cmp_image(char *buff,uint length) - { - if (binary()) - return memcmp(ptr,buff,length); - else - return my_casecmp(ptr,buff,length); - } + { return memcmp(ptr,buff,length); } inline longlong val_int_offset(uint row_offset) { ptr+=row_offset; @@ -241,6 +236,8 @@ public: class Field_str :public Field { +protected: + CHARSET_INFO *field_charset; public: Field_str(char *ptr_arg,uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, utype unireg_check_arg, @@ -248,12 +245,20 @@ public: struct st_table *table_arg) :Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg, field_name_arg, table_arg) - {} + { field_charset=default_charset_info; } Item_result result_type () const { return STRING_RESULT; } uint decimals() const { return NOT_FIXED_DEC; } friend class create_field; void make_field(Send_field *); uint size_of() const { return sizeof(*this); } + inline int cmp_image(char *buff,uint length) + { + if (binary()) + return memcmp(ptr,buff,length); + else + return my_strncasecmp(field_charset,ptr,buff,length); + } + }; diff --git a/sql/field_conv.cc b/sql/field_conv.cc index c7a6d778953..02be0365002 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -276,7 +276,7 @@ static void do_cut_string(Copy_field *copy) ptr != end ; ptr++) { - if (!isspace(*ptr)) + if (!my_isspace(system_charset_info, *ptr)) { current_thd->cuted_fields++; // Give a warning break; diff --git a/sql/filesort.cc b/sql/filesort.cc index a5f42d5731e..675cc294de4 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -513,9 +513,8 @@ static void make_sortkey(register SORTPARAM *param, from=param->tmp_buffer; } uint tmp_length=my_strnxfrm(default_charset_info, - to,(unsigned char *) from, - sort_field->length, - length); + to,sort_field->length, + (unsigned char *) from, length); if (tmp_length < sort_field->length) bzero((char*) to+tmp_length,sort_field->length-tmp_length); } @@ -527,7 +526,7 @@ static void make_sortkey(register SORTPARAM *param, memcpy(to,res->ptr(),length); bzero((char *)to+length,diff); if (!item->binary) - case_sort((char*) to,length); + case_sort(default_charset_info, (char*) to,length); #ifdef USE_STRCOLL } #endif @@ -925,7 +924,7 @@ sortlength(SORT_FIELD *sortorder, uint s_length) sortorder->length=sortorder->field->pack_length(); #ifdef USE_STRCOLL if (use_strcoll(default_charset_info) && !sortorder->field->binary()) - sortorder->length= sortorder->length*MY_STRXFRM_MULTIPLY; + sortorder->length= sortorder->length*default_charset_info->strxfrm_multiply; #endif } if (sortorder->field->maybe_null()) @@ -938,7 +937,7 @@ sortlength(SORT_FIELD *sortorder, uint s_length) sortorder->length=sortorder->item->max_length; #ifdef USE_STRCOLL if (use_strcoll(default_charset_info) && !sortorder->item->binary) - sortorder->length= sortorder->length*MY_STRXFRM_MULTIPLY; + sortorder->length= sortorder->length*default_charset_info->strxfrm_multiply; #endif break; case INT_RESULT: diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 4cf06dfb731..d53b027a415 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -1194,7 +1194,10 @@ innobase_mysql_cmp( case FIELD_TYPE_STRING: case FIELD_TYPE_VAR_STRING: - ret = my_sortncmp((const char*) a, a_length, + // BAR TODO: Discuss with heikki.tuuri@innodb.com + // so that he sends CHARSET_INFO for the field to this function. + ret = my_sortncmp(default_charset_info, + (const char*) a, a_length, (const char*) b, b_length); if (ret < 0) { return(-1); diff --git a/sql/hostname.cc b/sql/hostname.cc index 7d4e4a8ca75..0b35f970c42 100644 --- a/sql/hostname.cc +++ b/sql/hostname.cc @@ -213,10 +213,10 @@ my_string ip_to_hostname(struct in_addr *in, uint *errors) /* Don't accept hostnames that starts with digits because they may be false ip:s */ - if (isdigit(name[0])) + if (my_isdigit(system_charset_info,name[0])) { char *pos; - for (pos= name+1 ; isdigit(*pos); pos++) ; + for (pos= name+1 ; my_isdigit(system_charset_info,*pos); pos++) ; if (*pos == '.') { DBUG_PRINT("error",("mysqld doesn't accept hostnames that starts with a number followed by a '.'")); diff --git a/sql/init.cc b/sql/init.cc index df06ddd41ef..fe80c282563 100644 --- a/sql/init.cc +++ b/sql/init.cc @@ -24,6 +24,7 @@ void unireg_init(ulong options) { uint i; double nr; + CHARSET_INFO *cs; DBUG_ENTER("unireg_init"); MYSYS_PROGRAM_DONT_USE_CURSES(); @@ -54,13 +55,16 @@ void unireg_init(ulong options) // The following is needed because of like optimization in select.cc - uchar max_char=my_sort_order[(uchar) max_sort_char]; - for (i = 0; i < 256; i++) + for (cs=compiled_charsets; cs->number; cs++) { - if ((uchar) my_sort_order[i] > max_char) + uchar max_char=cs->sort_order[(uchar) cs->max_sort_char]; + for (i = 0; i < 256; i++) { - max_char=(uchar) my_sort_order[i]; - max_sort_char= (char) i; + if ((uchar) cs->sort_order[i] > max_char) + { + max_char=(uchar) cs->sort_order[i]; + cs->max_sort_char= (char) i; + } } } thread_stack_min=thread_stack - STACK_MIN_SIZE; diff --git a/sql/item.cc b/sql/item.cc index c081fd9dd5f..0c241684474 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -50,7 +50,7 @@ void Item::set_name(char *str,uint length) name=str; // Used by AS else { - while (length && !isgraph(*str)) + while (length && !my_isgraph(system_charset_info,*str)) { // Fix problem with yacc length--; str++; @@ -62,7 +62,7 @@ void Item::set_name(char *str,uint length) bool Item::eq(const Item *item) const // Only doing this on conds { return type() == item->type() && name && item->name && - !my_strcasecmp(name,item->name); + !my_strcasecmp(system_charset_info,name,item->name); } /* diff --git a/sql/item_func.cc b/sql/item_func.cc index 65d4413b484..09e3aab08c6 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -991,7 +991,8 @@ longlong Item_func_find_in_set::val_int() const char *pos= f_pos; while (pos != f_end) { - if (toupper(*str) != toupper(*pos)) + if (my_toupper(find->charset(),*str) != + my_toupper(find->charset(),*pos)) goto not_found; str++; pos++; diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index cdf909e8c4d..de07f5b1ee7 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -42,7 +42,7 @@ uint nr_of_decimals(const char *str) if ((str=strchr(str,'.'))) { const char *start= ++str; - for ( ; isdigit(*str) ; str++) ; + for ( ; my_isdigit(system_charset_info,*str) ; str++) ; return (uint) (str-start); } return 0; @@ -1268,9 +1268,9 @@ extern "C" { extern const char *soundex_map; // In mysys/static.c } -static char get_scode(char *ptr) +static char get_scode(CHARSET_INFO *cs,char *ptr) { - uchar ch=toupper(*ptr); + uchar ch=my_toupper(cs,*ptr); if (ch < 'A' || ch > 'Z') { // Thread extended alfa (country spec) @@ -1292,21 +1292,21 @@ String *Item_func_soundex::val_str(String *str) char *to= (char *) tmp_value.ptr(); char *from= (char *) res->ptr(), *end=from+res->length(); - while (from != end && isspace(*from)) // Skip pre-space + while (from != end && my_isspace(str->charset(),*from)) // Skip pre-space from++; /* purecov: inspected */ if (from == end) return &empty_string; // No alpha characters. - *to++ = toupper(*from); // Copy first letter - last_ch = get_scode(from); // code of the first letter + *to++ = my_toupper(str->charset(),*from);// Copy first letter + last_ch = get_scode(str->charset(),from);// code of the first letter // for the first 'double-letter check. // Loop on input letters until // end of input (null) or output // letter code count = 3 for (from++ ; from < end ; from++) { - if (!isalpha(*from)) + if (!my_isalpha(str->charset(),*from)) continue; - ch=get_scode(from); + ch=get_scode(str->charset(),from); if ((ch != '0') && (ch != last_ch)) // if not skipped or double { *to++ = ch; // letter, copy to output diff --git a/sql/item_sum.cc b/sql/item_sum.cc index e8f16e3ed56..7ebeda19993 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -864,7 +864,8 @@ static int simple_raw_key_cmp(void* arg, byte* key1, byte* key2) static int simple_str_key_cmp(void* arg, byte* key1, byte* key2) { - return my_sortcmp((char*) key1, (char*) key2, *(uint*) arg); + /* BAR TODO: remove default_charset_info */ + return my_sortcmp(default_charset_info,(char*) key1, (char*) key2, *(uint*) arg); } /* diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 8f55a02b020..b10054e11d2 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -49,16 +49,16 @@ bool get_interval_info(const char *str,uint length,uint count, { const char *end=str+length; uint i; - while (str != end && !isdigit(*str)) + while (str != end && !my_isdigit(system_charset_info,*str)) str++; for (i=0 ; i < count ; i++) { long value; - for (value=0; str != end && isdigit(*str) ; str++) + for (value=0; str != end && my_isdigit(system_charset_info,*str) ; str++) value=value*10L + (long) (*str - '0'); values[i]= value; - while (str != end && !isdigit(*str)) + while (str != end && !my_isdigit(system_charset_info,*str)) str++; if (str == end && i != count-1) { @@ -289,7 +289,7 @@ static bool get_interval_value(Item *args,interval_type int_type, /* record negative intervalls in t->neg */ str=res->ptr(); const char *end=str+res->length(); - while (str != end && isspace(*str)) + while (str != end && my_isspace(system_charset_info,*str)) str++; if (str != end && *str == '-') { diff --git a/sql/key.cc b/sql/key.cc index d2f483e3d73..a5d3d0a65b9 100644 --- a/sql/key.cc +++ b/sql/key.cc @@ -192,8 +192,9 @@ int key_cmp(TABLE *table,const byte *key,uint idx,uint key_length) if (!(key_part->key_type & (FIELDFLAG_NUMBER+FIELDFLAG_BINARY+ FIELDFLAG_PACK))) { - if (my_sortcmp((char*) key,(char*) table->record[0]+key_part->offset, - length)) + /* BAR TODO: I'm not sure this should be system_charset_info */ + if (my_sortcmp(system_charset_info,(char*) key, + (char*) table->record[0]+key_part->offset,length)) return 1; } else if (memcmp(key,table->record[0]+key_part->offset,length)) diff --git a/sql/log.cc b/sql/log.cc index 892780d3882..1a315ea9f9c 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1208,7 +1208,7 @@ static bool test_if_number(register const char *str, while (*str++ == ' ') ; if (*--str == '-' || *str == '+') str++; - while (isdigit(*str) || (allow_wildcards && + while (my_isdigit(system_charset_info,*str) || (allow_wildcards && (*str == wild_many || *str == wild_one))) { flag=1; @@ -1217,7 +1217,7 @@ static bool test_if_number(register const char *str, if (*str == '.') { for (str++ ; - isdigit(*str) || + my_isdigit(system_charset_info,*str) || (allow_wildcards && (*str == wild_many || *str == wild_one)) ; str++, flag=1) ; } diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 924f85b0a89..728d6d7a35f 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -549,7 +549,7 @@ void open_log(MYSQL_LOG *log, const char *hostname, extern uint32 server_id; extern char *mysql_data_home,server_version[SERVER_VERSION_LENGTH], - max_sort_char, mysql_real_data_home[]; + mysql_real_data_home[]; extern my_string mysql_tmpdir; extern const char *first_keyword, *localhost, *delayed_user; extern ulong refresh_version,flush_version, thread_id,query_id,opened_tables, @@ -708,10 +708,10 @@ bool check_db_name(const char *db); bool check_column_name(const char *name); bool check_table_name(const char *name, uint length); char *get_field(MEM_ROOT *mem,TABLE *table,uint fieldnr); -int wild_case_compare(const char *str,const char *wildstr); +int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *wildstr); int wild_compare(const char *str,const char *str_end, const char *wildstr,const char *wildend,char escape); -int wild_case_compare(const char *str,const char *str_end, +int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *str_end, const char *wildstr,const char *wildend,char escape); /* from hostname.cc */ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 5e4fc654320..40b9ab24831 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -863,7 +863,7 @@ static void set_user(const char *user) { // allow a numeric uid to be used const char *pos; - for (pos=user; isdigit(*pos); pos++) ; + for (pos=user; my_isdigit(system_charset_info,*pos); pos++) ; if (*pos) // Not numeric id { fprintf(stderr,"Fatal error: Can't change to run as user '%s' ; Please check that the user exists!\n",user); @@ -3769,7 +3769,7 @@ static void get_options(int argc,char **argv) exit(1); } val = p--; - while(isspace(*p) && p > optarg) *p-- = 0; + while(my_isspace(system_charset_info,*p) && p > optarg) *p-- = 0; if(p == optarg) { fprintf(stderr, @@ -3778,7 +3778,7 @@ static void get_options(int argc,char **argv) } *val = 0; val += 2; - while(*val && isspace(*val)) *val++; + while(*val && my_isspace(system_charset_info,*val)) *val++; if (!*val) { fprintf(stderr, @@ -3937,7 +3937,7 @@ static void get_options(int argc,char **argv) have_symlink=SHOW_OPTION_DISABLED; break; case (int) OPT_BIND_ADDRESS: - if (optarg && isdigit(optarg[0])) + if (optarg && my_isdigit(system_charset_info,optarg[0])) { my_bind_addr = (ulong) inet_addr(optarg); } @@ -4409,7 +4409,8 @@ static ulong find_bit_type(const char *x, TYPELIB *bit_lib) j=pos; while (j != end) { - if (toupper(*i++) != toupper(*j++)) + if (my_toupper(system_charset_info,*i++) != + my_toupper(system_charset_info,*j++)) goto skipp; } found_int=bit; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 34ee34ecc79..8bd47913b7b 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -985,7 +985,8 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part, like_error=like_range(res->ptr(),res->length(),wild_prefix, field_length, min_str+offset,max_str+offset, - max_sort_char,&min_length,&max_length); + default_charset_info->max_sort_char, + &min_length,&max_length); } if (like_error) // Can't optimize with LIKE DBUG_RETURN(0); diff --git a/sql/procedure.cc b/sql/procedure.cc index 437bd82d6e5..7779f5ce085 100644 --- a/sql/procedure.cc +++ b/sql/procedure.cc @@ -57,7 +57,8 @@ setup_procedure(THD *thd,ORDER *param,select_result *result, DBUG_RETURN(0); for (i=0 ; i < array_elements(sql_procs) ; i++) { - if (!my_strcasecmp((*param->item)->name,sql_procs[i].name)) + if (!my_strcasecmp(system_charset_info, + (*param->item)->name,sql_procs[i].name)) { Procedure *proc=(*sql_procs[i].init)(thd,param,result,field_list); *error= !proc; diff --git a/sql/slave.cc b/sql/slave.cc index 100e305530f..9630cf6aa0e 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -237,9 +237,9 @@ void init_slave_skip_errors(char* arg) exit(1); } use_slave_mask = 1; - for (;isspace(*arg);++arg) + for (;my_isspace(system_charset_info,*arg);++arg) /* empty */; - if (!my_casecmp(arg,"all",3)) + if (!my_strncasecmp(system_charset_info,arg,"all",3)) { bitmap_set_all(&slave_error_mask); return; @@ -251,7 +251,7 @@ void init_slave_skip_errors(char* arg) break; if (err_code < MAX_SLAVE_ERROR) bitmap_set_bit(&slave_error_mask,(uint)err_code); - while (!isdigit(*p) && *p) + while (!my_isdigit(system_charset_info,*p) && *p) p++; } } @@ -492,7 +492,8 @@ static TABLE_RULE_ENT* find_wild(DYNAMIC_ARRAY *a, const char* key, int len) { TABLE_RULE_ENT* e ; get_dynamic(a, (gptr)&e, i); - if (!wild_case_compare(key, key_end, (const char*)e->db, + if (!wild_case_compare(system_charset_info, key, key_end, + (const char*)e->db, (const char*)(e->db + e->key_len),'\\')) return e; } diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index c5782f65798..198569cec3c 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -381,7 +381,7 @@ static uint get_access(TABLE *form,uint fieldnr) for (pos=form->field+fieldnr,bit=1 ; *pos ; pos++ , bit<<=1) { (*pos)->val_str(&res,&res); - if (toupper(res[0]) == 'Y') + if (my_toupper(system_charset_info, res[0]) == 'Y') access_bits|=bit; } return access_bits; @@ -729,7 +729,7 @@ uint acl_get(const char *host, const char *ip, const char *bin_ip, end=strmov((tmp_db=strmov(key+sizeof(struct in_addr),user)+1),db); if (lower_case_table_names) { - casedn_str(tmp_db); + my_casedn_str(system_charset_info, tmp_db); db=tmp_db; } key_length=(uint) (end-key); @@ -793,7 +793,7 @@ exit: } -int wild_case_compare(const char *str,const char *wildstr) +int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *wildstr) { reg3 int flag; DBUG_ENTER("wild_case_compare"); @@ -804,7 +804,8 @@ int wild_case_compare(const char *str,const char *wildstr) { if (*wildstr == wild_prefix && wildstr[1]) wildstr++; - if (toupper(*wildstr++) != toupper(*str++)) DBUG_RETURN(1); + if (my_toupper(cs, *wildstr++) != + my_toupper(cs, *str++)) DBUG_RETURN(1); } if (! *wildstr ) DBUG_RETURN (*str != 0); if (*wildstr++ == wild_one) @@ -822,12 +823,12 @@ int wild_case_compare(const char *str,const char *wildstr) char cmp; if ((cmp= *wildstr) == wild_prefix && wildstr[1]) cmp=wildstr[1]; - cmp=toupper(cmp); - while (*str && toupper(*str) != cmp) + cmp=my_toupper(cs, cmp); + while (*str && my_toupper(cs, *str) != cmp) str++; if (!*str) DBUG_RETURN (1); } - if (wild_case_compare(str,wildstr) == 0) DBUG_RETURN (0); + if (wild_case_compare(cs, str,wildstr) == 0) DBUG_RETURN (0); } while (*str++); DBUG_RETURN(1); } @@ -862,7 +863,8 @@ static void init_check_host(void) { // Check if host already exists acl_host_and_ip *acl=dynamic_element(&acl_wild_hosts,j, acl_host_and_ip *); - if (!my_strcasecmp(acl_user->host.hostname,acl->hostname)) + if (!my_strcasecmp(system_charset_info, + acl_user->host.hostname, acl->hostname)) break; // already stored } if (j == acl_wild_hosts.elements) // If new @@ -940,7 +942,8 @@ bool change_password(THD *thd, const char *host, const char *user, new_password[length & 16]=0; if (!thd || (!thd->slave_thread && ( strcmp(thd->user,user) || - my_strcasecmp(host,thd->host ? thd->host : thd->ip)))) + my_strcasecmp(system_charset_info, + host, (thd->host ? thd->host : thd->ip))))) { if (check_access(thd, UPDATE_ACL, "mysql",0,1)) DBUG_RETURN(1); @@ -1061,7 +1064,8 @@ static bool compare_hostname(const acl_host_and_ip *host, const char *hostname, return (tmp & host->ip_mask) == host->ip; } return (!host->hostname || - (hostname && !wild_case_compare(hostname,host->hostname)) || + (hostname && !wild_case_compare(system_charset_info, + hostname,host->hostname)) || (ip && !wild_compare(ip,host->hostname))); } @@ -1414,8 +1418,8 @@ public: tname= strdup_root(&memex,t); if (lower_case_table_names) { - casedn_str(db); - casedn_str(tname); + my_casedn_str(system_charset_info, db); + my_casedn_str(system_charset_info, tname); } key_length =(uint) strlen(d)+(uint) strlen(u)+(uint) strlen(t)+3; hash_key = (char*) alloc_root(&memex,key_length); @@ -1440,8 +1444,8 @@ public: } if (lower_case_table_names) { - casedn_str(db); - casedn_str(tname); + my_casedn_str(system_charset_info, db); + my_casedn_str(system_charset_info, tname); } key_length = ((uint) strlen(db) + (uint) strlen(user) + (uint) strlen(tname) + 3); @@ -1534,8 +1538,10 @@ static GRANT_TABLE *table_hash_search(const char *host,const char* ip, } else { - if ((host && !wild_case_compare(host,grant_table->host)) || - (ip && !wild_case_compare(ip,grant_table->host))) + if ((host && !wild_case_compare(system_charset_info, + host,grant_table->host)) || + (ip && !wild_case_compare(system_charset_info, + ip,grant_table->host))) found=grant_table; // Host ok } } @@ -2051,7 +2057,7 @@ int mysql_grant (THD *thd, const char *db, List <LEX_USER> &list, uint rights, if (lower_case_table_names && db) { strmov(tmp_db,db); - casedn_str(tmp_db); + my_casedn_str(system_charset_info, tmp_db); db=tmp_db; } @@ -2476,8 +2482,10 @@ bool check_grant_db(THD *thd,const char *db) GRANT_TABLE *grant_table = (GRANT_TABLE*) hash_element(&hash_tables,idx); if (len < grant_table->key_length && !memcmp(grant_table->hash_key,helping,len) && - (thd->host && !wild_case_compare(thd->host,grant_table->host) || - (thd->ip && !wild_case_compare(thd->ip,grant_table->host)))) + (thd->host && !wild_case_compare(system_charset_info, + thd->host,grant_table->host) || + (thd->ip && !wild_case_compare(system_charset_info, + thd->ip,grant_table->host)))) { error=0; // Found match break; diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index df8a8f1fdde..fc764333916 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -163,7 +163,7 @@ bool test_if_number(NUM_INFO *info, const char *str, uint str_len) // MySQL removes any endspaces of a string, so we must take care only of // spaces in front of a string - for (; str != end && isspace(*str); str++) ; + for (; str != end && my_isspace(system_charset_info, *str); str++) ; if (str == end) return 0; @@ -176,10 +176,10 @@ bool test_if_number(NUM_INFO *info, const char *str, uint str_len) else info->negative = 0; begin = str; - for (; str != end && isdigit(*str); str++) + for (; str != end && my_isdigit(system_charset_info,*str); str++) { if (!info->integers && *str == '0' && (str + 1) != end && - isdigit(*(str + 1))) + my_isdigit(system_charset_info,*(str + 1))) info->zerofill = 1; // could be a postnumber for example info->integers++; } @@ -205,7 +205,7 @@ bool test_if_number(NUM_INFO *info, const char *str, uint str_len) str++; if (*str != '-' && *str != '+') return 0; - for (str++; str != end && isdigit(*str); str++) ; + for (str++; str != end && my_isdigit(system_charset_info,*str); str++) ; if (str == end) { info->is_float = 1; // we can't use variable decimals here @@ -220,7 +220,7 @@ bool test_if_number(NUM_INFO *info, const char *str, uint str_len) info->ullval = (ulonglong) strtoull(begin, NULL, 10); return 1; } - for (; str != end && isdigit(*str); str++) + for (; str != end && my_isdigit(system_charset_info,*str); str++) info->decimals++; if (str == end) { diff --git a/sql/sql_base.cc b/sql/sql_base.cc index f4a70db2e5d..e73a0c63fa6 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -50,7 +50,8 @@ static byte *cache_key(const byte *record,uint *length, void table_cache_init(void) { - VOID(hash_init(&open_cache,table_cache_size+16,0,0,cache_key, + VOID(hash_init(&open_cache, + table_cache_size+16,0,0,cache_key, (void (*)(void*)) free_cache_entry,0)); mysql_rm_tmp_tables(); } @@ -780,7 +781,7 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name, { if (table->key_length == key_length && !memcmp(table->table_cache_key,key,key_length) && - !my_strcasecmp(table->table_name,alias)) + !my_strcasecmp(system_charset_info,table->table_name,alias)) goto reset; } my_printf_error(ER_TABLE_NOT_LOCKED,ER(ER_TABLE_NOT_LOCKED),MYF(0),alias); @@ -1559,11 +1560,12 @@ Field *find_field_in_table(THD *thd,TABLE *table,const char *name,uint length, Field **ptr=table->field; while ((field = *ptr++)) { - if (!my_strcasecmp(field->field_name, name)) + if (!my_strcasecmp(system_charset_info, field->field_name, name)) goto found; } } - if (allow_rowid && !my_strcasecmp(name,"_rowid") && + if (allow_rowid && + !my_strcasecmp(system_charset_info, name, "_rowid") && (field=table->rowid_field)) goto found; return (Field*) 0; @@ -1686,7 +1688,8 @@ find_item_in_list(Item *find,List<Item> &items) { if (field_name && item->type() == Item::FIELD_ITEM) { - if (!my_strcasecmp(((Item_field*) item)->name,field_name)) + if (!my_strcasecmp(system_charset_info, + ((Item_field*) item)->name,field_name)) { if (!table_name) { @@ -1709,8 +1712,9 @@ find_item_in_list(Item *find,List<Item> &items) } } else if (!table_name && (item->eq(find) || - find->name && - !my_strcasecmp(item->name,find->name))) + find->name && + !my_strcasecmp(system_charset_info, + item->name,find->name))) { found=li.ref(); break; @@ -1938,7 +1942,8 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds) // TODO: This could be optimized to use hashed names if t2 had a hash for (j=0 ; j < t2->fields ; j++) { - if (!my_strcasecmp(t1->field[i]->field_name, + if (!my_strcasecmp(system_charset_info, + t1->field[i]->field_name, t2->field[j]->field_name)) { Item_func_eq *tmp=new Item_func_eq(new Item_field(t1->field[i]), diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index c5ebeead05a..72ac20d8818 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -896,8 +896,9 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length) Test if the query is a SELECT (pre-space is removed in dispatch_command) */ - if (toupper(sql[0]) != 'S' || toupper(sql[1]) != 'E' || - toupper(sql[2]) !='L') + if (my_toupper(system_charset_info, sql[0]) != 'S' || + my_toupper(system_charset_info, sql[1]) != 'E' || + my_toupper(system_charset_info,sql[2]) !='L') { DBUG_PRINT("qcache", ("The statement is not a SELECT; Not cached")); goto err; diff --git a/sql/sql_db.cc b/sql/sql_db.cc index dd8ed634011..30e7262cae0 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -218,7 +218,8 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, DBUG_PRINT("info",("Examining: %s", file->name)); /* Check if file is a raid directory */ - if (isdigit(file->name[0]) && isdigit(file->name[1]) && + if (my_isdigit(system_charset_info,file->name[0]) && + my_isdigit(system_charset_info,file->name[1]) && !file->name[2] && !level) { char newpath[FN_REFLEN]; @@ -243,7 +244,8 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, continue; } strxmov(filePath,org_path,"/",file->name,NullS); - if (db && !my_strcasecmp(fn_ext(file->name), reg_ext)) + if (db && !my_strcasecmp(system_charset_info, + fn_ext(file->name), reg_ext)) { /* Drop the table nicely */ *fn_ext(file->name)=0; // Remove extension diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 8f9d3474ce2..f4d6f3416a6 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -270,7 +270,7 @@ static TABLE **find_table_ptr_by_name(THD *thd, const char *db, for (TABLE *table=*ptr; table ; table=*ptr) { if (!memcmp(table->table_cache_key, db, dblen) && - !my_strcasecmp(table->table_name,table_name)) + !my_strcasecmp(system_charset_info,table->table_name,table_name)) break; ptr=&(table->next); } diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 7995e7701e5..9371eb00b79 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -92,15 +92,15 @@ void lex_init(void) /* Fill state_map with states to get a faster parser */ for (i=0; i < 256 ; i++) { - if (isalpha(i)) + if (my_isalpha(system_charset_info,i)) state_map[i]=(uchar) STATE_IDENT; - else if (isdigit(i)) + else if (my_isdigit(system_charset_info,i)) state_map[i]=(uchar) STATE_NUMBER_IDENT; #if defined(USE_MB) && defined(USE_MB_IDENT) - else if (use_mb(default_charset_info) && my_ismbhead(default_charset_info, i)) + else if (use_mb(system_charset_info) && my_ismbhead(system_charset_info, i)) state_map[i]=(uchar) STATE_IDENT; #endif - else if (!isgraph(i)) + else if (!my_isgraph(system_charset_info,i)) state_map[i]=(uchar) STATE_SKIP; else state_map[i]=(uchar) STATE_CHAR; @@ -220,8 +220,8 @@ static char *get_text(LEX *lex) c = yyGet(); #ifdef USE_MB int l; - if (use_mb(default_charset_info) && - (l = my_ismbchar(default_charset_info, + if (use_mb(system_charset_info) && + (l = my_ismbchar(system_charset_info, (const char *)lex->ptr-1, (const char *)lex->end_of_query))) { lex->ptr += l-1; @@ -265,8 +265,8 @@ static char *get_text(LEX *lex) { #ifdef USE_MB int l; - if (use_mb(default_charset_info) && - (l = my_ismbchar(default_charset_info, + if (use_mb(system_charset_info) && + (l = my_ismbchar(system_charset_info, (const char *)str, (const char *)end))) { while (l--) *to++ = *str++; @@ -471,11 +471,11 @@ int yylex(void *arg) break; } #if defined(USE_MB) && defined(USE_MB_IDENT) - if (use_mb(default_charset_info)) + if (use_mb(system_charset_info)) { - if (my_ismbhead(default_charset_info, yyGetLast())) + if (my_ismbhead(system_charset_info, yyGetLast())) { - int l = my_ismbchar(default_charset_info, + int l = my_ismbchar(system_charset_info, (const char *)lex->ptr-1, (const char *)lex->end_of_query); if (l == 0) { @@ -487,10 +487,10 @@ int yylex(void *arg) while (state_map[c=yyGet()] == STATE_IDENT || state_map[c] == STATE_NUMBER_IDENT) { - if (my_ismbhead(default_charset_info, c)) + if (my_ismbhead(system_charset_info, c)) { int l; - if ((l = my_ismbchar(default_charset_info, + if ((l = my_ismbchar(system_charset_info, (const char *)lex->ptr-1, (const char *)lex->end_of_query)) == 0) break; @@ -533,7 +533,7 @@ int yylex(void *arg) return((int) c); case STATE_NUMBER_IDENT: // number or ident which num-start - while (isdigit((c = yyGet()))) ; + while (my_isdigit(system_charset_info,(c = yyGet()))) ; if (state_map[c] != STATE_IDENT) { // Can't be identifier state=STATE_INT_OR_REAL; @@ -542,12 +542,13 @@ int yylex(void *arg) if (c == 'e' || c == 'E') { // The following test is written this way to allow numbers of type 1e1 - if (isdigit(yyPeek()) || (c=(yyGet())) == '+' || c == '-') + if (my_isdigit(system_charset_info,yyPeek()) || + (c=(yyGet())) == '+' || c == '-') { // Allow 1E+10 - if (isdigit(yyPeek())) // Number must have digit after sign + if (my_isdigit(system_charset_info,yyPeek())) // Number must have digit after sign { yySkip(); - while (isdigit(yyGet())) ; + while (my_isdigit(system_charset_info,yyGet())) ; yylval->lex_str=get_token(lex,yyLength()); return(FLOAT_NUM); } @@ -557,7 +558,7 @@ int yylex(void *arg) else if (c == 'x' && (lex->ptr - lex->tok_start) == 2 && lex->tok_start[0] == '0' ) { // Varbinary - while (isxdigit((c = yyGet()))) ; + while (my_isxdigit(system_charset_info,(c = yyGet()))) ; if ((lex->ptr - lex->tok_start) >= 4 && state_map[c] != STATE_IDENT) { yylval->lex_str=get_token(lex,yyLength()); @@ -571,11 +572,11 @@ int yylex(void *arg) // fall through case STATE_IDENT_START: // Incomplete ident #if defined(USE_MB) && defined(USE_MB_IDENT) - if (use_mb(default_charset_info)) + if (use_mb(system_charset_info)) { - if (my_ismbhead(default_charset_info, yyGetLast())) + if (my_ismbhead(system_charset_info, yyGetLast())) { - int l = my_ismbchar(default_charset_info, + int l = my_ismbchar(system_charset_info, (const char *)lex->ptr-1, (const char *)lex->end_of_query); if (l == 0) @@ -588,10 +589,10 @@ int yylex(void *arg) while (state_map[c=yyGet()] == STATE_IDENT || state_map[c] == STATE_NUMBER_IDENT) { - if (my_ismbhead(default_charset_info, c)) + if (my_ismbhead(system_charset_info, c)) { int l; - if ((l = my_ismbchar(default_charset_info, + if ((l = my_ismbchar(system_charset_info, (const char *)lex->ptr-1, (const char *)lex->end_of_query)) == 0) break; @@ -618,15 +619,15 @@ int yylex(void *arg) case STATE_USER_VARIABLE_DELIMITER: lex->tok_start=lex->ptr; // Skip first ` #ifdef USE_MB - if (use_mb(default_charset_info)) + if (use_mb(system_charset_info)) { while ((c=yyGet()) && state_map[c] != STATE_USER_VARIABLE_DELIMITER && c != (uchar) NAMES_SEP_CHAR) { - if (my_ismbhead(default_charset_info, c)) + if (my_ismbhead(system_charset_info, c)) { int l; - if ((l = my_ismbchar(default_charset_info, + if ((l = my_ismbchar(system_charset_info, (const char *)lex->ptr-1, (const char *)lex->end_of_query)) == 0) break; @@ -651,17 +652,18 @@ int yylex(void *arg) if (prev_state == STATE_OPERATOR_OR_IDENT) { if (c == '-' && yyPeek() == '-' && - (isspace(yyPeek2()) || iscntrl(yyPeek2()))) + (my_isspace(system_charset_info,yyPeek2()) || + my_iscntrl(system_charset_info,yyPeek2()))) state=STATE_COMMENT; else state= STATE_CHAR; // Must be operator break; } - if (!isdigit(c=yyGet()) || yyPeek() == 'x') + if (!my_isdigit(system_charset_info,c=yyGet()) || yyPeek() == 'x') { if (c != '.') { - if (c == '-' && isspace(yyPeek())) + if (c == '-' && my_isspace(system_charset_info,yyPeek())) state=STATE_COMMENT; else state = STATE_CHAR; // Return sign as single char @@ -669,9 +671,9 @@ int yylex(void *arg) } yyUnget(); // Fix for next loop } - while (isdigit(c=yyGet())) ; // Incomplete real or int number + while (my_isdigit(system_charset_info,c=yyGet())) ; // Incomplete real or int number if ((c == 'e' || c == 'E') && - (yyPeek() == '+' || yyPeek() == '-' || isdigit(yyPeek()))) + (yyPeek() == '+' || yyPeek() == '-' || my_isdigit(system_charset_info,yyPeek()))) { // Real number yyUnget(); c= '.'; // Fool next test @@ -685,19 +687,19 @@ int yylex(void *arg) } // fall through case STATE_REAL: // Incomplete real number - while (isdigit(c = yyGet())) ; + while (my_isdigit(system_charset_info,c = yyGet())) ; if (c == 'e' || c == 'E') { c = yyGet(); if (c == '-' || c == '+') c = yyGet(); // Skip sign - if (!isdigit(c)) + if (!my_isdigit(system_charset_info,c)) { // No digit after sign state= STATE_CHAR; break; } - while (isdigit(yyGet())) ; + while (my_isdigit(system_charset_info,yyGet())) ; yylval->lex_str=get_token(lex,yyLength()); return(FLOAT_NUM); } @@ -706,7 +708,7 @@ int yylex(void *arg) case STATE_HEX_NUMBER: // Found x'hexstring' yyGet(); // Skip ' - while (isxdigit((c = yyGet()))) ; + while (my_isxdigit(system_charset_info,(c = yyGet()))) ; length=(lex->ptr - lex->tok_start); // Length of hexnum+3 if (!(length & 1) || c != '\'') { @@ -786,7 +788,7 @@ int yylex(void *arg) ulong version=MYSQL_VERSION_ID; yySkip(); state=STATE_START; - if (isdigit(yyPeek())) + if (my_isdigit(system_charset_info,yyPeek())) { // Version number version=strtol((char*) lex->ptr,(char**) &lex->ptr,10); } @@ -841,7 +843,7 @@ int yylex(void *arg) // Actually real shouldn't start // with . but allow them anyhow case STATE_REAL_OR_POINT: - if (isdigit(yyPeek())) + if (my_isdigit(system_charset_info,yyPeek())) state = STATE_REAL; // Real else { @@ -868,7 +870,7 @@ int yylex(void *arg) return((int) '@'); case STATE_HOSTNAME: // end '@' of user@hostname for (c=yyGet() ; - isalnum(c) || c == '.' || c == '_' || c == '$'; + my_isalnum(system_charset_info,c) || c == '.' || c == '_' || c == '$'; c= yyGet()) ; yylval->lex_str=get_token(lex,yyLength()); return(LEX_HOSTNAME); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index e649f109a0d..ef6c0eb2a5d 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -692,7 +692,8 @@ pthread_handler_decl(handle_bootstrap,arg) while (fgets(buff, thd->net.max_packet, file)) { uint length=(uint) strlen(buff); - while (length && (isspace(buff[length-1]) || buff[length-1] == ';')) + while (length && (my_isspace(system_charset_info, buff[length-1]) || + buff[length-1] == ';')) length--; buff[length]=0; thd->current_tablenr=0; @@ -917,13 +918,14 @@ bool dispatch_command(enum enum_server_command command, THD *thd, { packet_length--; // Remove end null /* Remove garage at start and end of query */ - while (isspace(packet[0]) && packet_length > 0) + while (my_isspace(system_charset_info,packet[0]) && packet_length > 0) { packet++; packet_length--; } char *pos=packet+packet_length; // Point at end null - while (packet_length > 0 && (pos[-1] == ';' || isspace(pos[-1]))) + while (packet_length > 0 && + (pos[-1] == ';' || my_isspace(system_charset_info,pos[-1]))) { pos--; packet_length--; @@ -2261,7 +2263,8 @@ mysql_execute_command(void) if (user->password.str && (strcmp(thd->user,user->user.str) || user->host.str && - my_strcasecmp(user->host.str, thd->host_or_ip))) + my_strcasecmp(system_charset_info, + user->host.str, thd->host_or_ip))) { if (check_access(thd, UPDATE_ACL, "mysql",0,1)) goto error; @@ -3112,8 +3115,8 @@ TABLE_LIST *add_table_to_list(Table_ident *table, LEX_STRING *alias, ptr->name=alias_str; if (lower_case_table_names) { - casedn_str(ptr->db); - casedn_str(table->table.str); + my_casedn_str(system_charset_info,ptr->db); + my_casedn_str(system_charset_info,table->table.str); } ptr->real_name=table->table.str; ptr->lock_type=flags; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 52541ffe50f..3e7b8f13844 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -209,7 +209,7 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path, else { // Return only .frm files which aren't temp files. - if (my_strcasecmp(ext=fn_ext(file->name),reg_ext) || + if (my_strcasecmp(system_charset_info, ext=fn_ext(file->name),reg_ext) || is_prefix(file->name,tmp_file_prefix)) continue; *ext=0; @@ -217,7 +217,7 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path, { if (lower_case_table_names) { - if (wild_case_compare(file->name,wild)) + if (wild_case_compare(system_charset_info,file->name,wild)) continue; } else if (wild_compare(file->name,wild)) @@ -472,7 +472,8 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild, String *packet= &thd->packet; for (ptr=table->field; (field= *ptr) ; ptr++) { - if (!wild || !wild[0] || !wild_case_compare(field->field_name,wild)) + if (!wild || !wild[0] || + !wild_case_compare(system_charset_info, field->field_name,wild)) { #ifdef NOT_USED if (thd->col_access & TABLE_ACLS || @@ -744,7 +745,8 @@ mysqld_list_fields(THD *thd, TABLE_LIST *table_list, const char *wild) Field **ptr,*field; for (ptr=table->field ; (field= *ptr); ptr++) { - if (!wild || !wild[0] || !wild_case_compare(field->field_name,wild)) + if (!wild || !wild[0] || + !wild_case_compare(system_charset_info, field->field_name,wild)) field_list.push_back(new Item_field(field)); } restore_record(table,2); // Get empty record diff --git a/sql/sql_string.cc b/sql/sql_string.cc index f0cfd590072..62b1812afb3 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -234,7 +234,7 @@ bool String::fill(uint32 max_length,char fill_char) void String::strip_sp() { - while (str_length && isspace(Ptr[str_length-1])) + while (str_length && my_isspace(str_charset,Ptr[str_length-1])) str_length--; } @@ -296,10 +296,10 @@ uint32 String::numchars() register uint32 n=0,mblen; register const char *mbstr=Ptr; register const char *end=mbstr+str_length; - if (use_mb(default_charset_info)) + if (use_mb(str_charset)) { while (mbstr < end) { - if ((mblen=my_ismbchar(default_charset_info, mbstr,end))) mbstr+=mblen; + if ((mblen=my_ismbchar(str_charset, mbstr,end))) mbstr+=mblen; else ++mbstr; ++n; } @@ -316,11 +316,11 @@ int String::charpos(int i,uint32 offset) register uint32 mblen; register const char *mbstr=Ptr+offset; register const char *end=Ptr+str_length; - if (use_mb(default_charset_info)) + if (use_mb(str_charset)) { if (i<=0) return i; while (i && mbstr < end) { - if ((mblen=my_ismbchar(default_charset_info, mbstr,end))) mbstr+=mblen; + if ((mblen=my_ismbchar(str_charset, mbstr,end))) mbstr+=mblen; else ++mbstr; --i; } @@ -380,12 +380,14 @@ int String::strstr_case(const String &s,uint32 offset) skipp: while (str != end) { - if (my_sort_order[*str++] == my_sort_order[*search]) + if (str_charset->sort_order[*str++] == str_charset->sort_order[*search]) { register char *i,*j; i=(char*) str; j=(char*) search+1; while (j != search_end) - if (my_sort_order[*i++] != my_sort_order[*j++]) goto skipp; + if (str_charset->sort_order[*i++] != + str_charset->sort_order[*j++]) + goto skipp; return (int) (str-Ptr) -1; } } @@ -505,15 +507,15 @@ int sortcmp(const String *x,const String *y) uint32 x_len=x->length(),y_len=y->length(),len=min(x_len,y_len); #ifdef USE_STRCOLL - if (use_strcoll(default_charset_info)) + if (use_strcoll(x->str_charset)) { #ifndef CMP_ENDSPACE - while (x_len && isspace(s[x_len-1])) + while (x_len && my_isspace(x->str_charset,s[x_len-1])) x_len--; - while (y_len && isspace(t[y_len-1])) + while (y_len && my_isspace(x->str_charset,t[y_len-1])) y_len--; #endif - return my_strnncoll(default_charset_info, + return my_strnncoll(x->str_charset, (unsigned char *)s,x_len,(unsigned char *)t,y_len); } else @@ -523,9 +525,10 @@ int sortcmp(const String *x,const String *y) y_len-=len; while (len--) { - if (my_sort_order[(uchar) *s++] != my_sort_order[(uchar) *t++]) - return ((int) my_sort_order[(uchar) s[-1]] - - (int) my_sort_order[(uchar) t[-1]]); + if (x->str_charset->sort_order[(uchar) *s++] != + x->str_charset->sort_order[(uchar) *t++]) + return ((int) x->str_charset->sort_order[(uchar) s[-1]] - + (int) x->str_charset->sort_order[(uchar) t[-1]]); } #ifndef CMP_ENDSPACE /* Don't compare end space in strings */ @@ -534,14 +537,14 @@ int sortcmp(const String *x,const String *y) { const char *end=t+y_len; for (; t != end ; t++) - if (!isspace(*t)) + if (!my_isspace(x->str_charset,*t)) return -1; } else { const char *end=s+x_len; for (; s != end ; s++) - if (!isspace(*s)) + if (!my_isspace(x->str_charset,*s)) return 1; } return 0; @@ -589,11 +592,10 @@ String *copy_if_not_alloced(String *to,String *from,uint32 from_length) /* Make it easier to handle different charactersets */ #ifdef USE_MB -#define INC_PTR(A,B) A+=((use_mb_flag && \ - my_ismbchar(default_charset_info,A,B)) ? \ - my_ismbchar(default_charset_info,A,B) : 1) +#define INC_PTR(cs,A,B) A+=((use_mb_flag && \ + my_ismbchar(cs,A,B)) ? my_ismbchar(cs,A,B) : 1) #else -#define INC_PTR(A,B) A++ +#define INC_PTR(cs,A,B) A++ #endif /* @@ -604,12 +606,12 @@ String *copy_if_not_alloced(String *to,String *from,uint32 from_length) */ #ifdef LIKE_CMP_TOUPPER -#define likeconv(A) (uchar) toupper(A) +#define likeconv(s,A) (uchar) my_toupper(s,A) #else -#define likeconv(A) (uchar) my_sort_order[(uchar) (A)] +#define likeconv(s,A) (uchar) (s)->sort_order[(uchar) (A)] #endif -int wild_case_compare(const char *str,const char *str_end, +int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *str_end, const char *wildstr,const char *wildend, char escape) { @@ -626,7 +628,7 @@ int wild_case_compare(const char *str,const char *str_end, #ifdef USE_MB int l; if (use_mb_flag && - (l = my_ismbchar(default_charset_info, wildstr, wildend))) + (l = my_ismbchar(cs, wildstr, wildend))) { if (str+l > str_end || memcmp(str, wildstr, l) != 0) return 1; @@ -635,7 +637,7 @@ int wild_case_compare(const char *str,const char *str_end, } else #endif - if (str == str_end || likeconv(*wildstr++) != likeconv(*str++)) + if (str == str_end || likeconv(cs,*wildstr++) != likeconv(cs,*str++)) return(1); // No match if (wildstr == wildend) return (str != str_end); // Match if both are at end @@ -647,7 +649,7 @@ int wild_case_compare(const char *str,const char *str_end, { if (str == str_end) // Skip one char if possible return (result); - INC_PTR(str,str_end); + INC_PTR(cs,str,str_end); } while (++wildstr < wildend && *wildstr == wild_one); if (wildstr == wildend) break; @@ -664,7 +666,7 @@ int wild_case_compare(const char *str,const char *str_end, { if (str == str_end) return (-1); - INC_PTR(str,str_end); + INC_PTR(cs,str,str_end); continue; } break; // Not a wild character @@ -682,10 +684,10 @@ int wild_case_compare(const char *str,const char *str_end, int mblen; LINT_INIT(mblen); if (use_mb_flag) - mblen = my_ismbchar(default_charset_info, wildstr, wildend); + mblen = my_ismbchar(cs, wildstr, wildend); #endif - INC_PTR(wildstr,wildend); // This is compared trough cmp - cmp=likeconv(cmp); + INC_PTR(cs,wildstr,wildend); // This is compared trough cmp + cmp=likeconv(cs,cmp); do { #ifdef USE_MB @@ -703,26 +705,26 @@ int wild_case_compare(const char *str,const char *str_end, break; } } - else if (!my_ismbchar(default_charset_info, str, str_end) && - likeconv(*str) == cmp) + else if (!my_ismbchar(cs, str, str_end) && + likeconv(cs,*str) == cmp) { str++; break; } - INC_PTR(str, str_end); + INC_PTR(cs,str, str_end); } } else { #endif /* USE_MB */ - while (str != str_end && likeconv(*str) != cmp) + while (str != str_end && likeconv(cs,*str) != cmp) str++; if (str++ == str_end) return (-1); #ifdef USE_MB } #endif { - int tmp=wild_case_compare(str,str_end,wildstr,wildend,escape); + int tmp=wild_case_compare(cs,str,str_end,wildstr,wildend,escape); if (tmp <= 0) return (tmp); } @@ -739,7 +741,7 @@ int wild_case_compare(String &match,String &wild, char escape) DBUG_ENTER("wild_case_compare"); DBUG_PRINT("enter",("match='%s', wild='%s', escape='%c'" ,match.ptr(),wild.ptr(),escape)); - DBUG_RETURN(wild_case_compare(match.ptr(),match.ptr()+match.length(), + DBUG_RETURN(wild_case_compare(match.str_charset,match.ptr(),match.ptr()+match.length(), wild.ptr(), wild.ptr()+wild.length(),escape)); } diff --git a/sql/sql_string.h b/sql/sql_string.h index 6e8fefb079a..811e49a0d02 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -198,8 +198,8 @@ public: } bool fill(uint32 max_length,char fill); void strip_sp(); - inline void caseup() { ::caseup(Ptr,str_length); } - inline void casedn() { ::casedn(Ptr,str_length); } + inline void caseup() { my_caseup(str_charset,Ptr,str_length); } + inline void casedn() { my_casedn(str_charset,Ptr,str_length); } friend int sortcmp(const String *a,const String *b); friend int stringcmp(const String *a,const String *b); friend String *copy_if_not_alloced(String *a,String *b,uint32 arg_length); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 4b849fd850d..7e679f59fc0 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -302,7 +302,9 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, null_fields++; while ((dup_field=it2++) != sql_field) { - if (my_strcasecmp(sql_field->field_name, dup_field->field_name) == 0) + if (my_strcasecmp(system_charset_info, + sql_field->field_name, + dup_field->field_name) == 0) { my_error(ER_DUP_FIELDNAME,MYF(0),sql_field->field_name); DBUG_RETURN(-1); @@ -496,7 +498,9 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, it.rewind(); field=0; while ((sql_field=it++) && - my_strcasecmp(column->field_name,sql_field->field_name)) + my_strcasecmp(system_charset_info, + column->field_name, + sql_field->field_name)) field++; if (!sql_field) { @@ -727,7 +731,7 @@ static bool check_if_keyname_exists(const char *name, KEY *start, KEY *end) { for (KEY *key=start ; key != end ; key++) - if (!my_strcasecmp(name,key->name)) + if (!my_strcasecmp(system_charset_info,name,key->name)) return 1; return 0; } @@ -1235,9 +1239,9 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, strmov(new_name_buff,new_name); fn_same(new_name_buff,table_name,3); if (lower_case_table_names) - casedn_str(new_name); + my_casedn_str(system_charset_info,new_name); if ((lower_case_table_names && - !my_strcasecmp(new_name_buff,table_name)) || + !my_strcasecmp(system_charset_info, new_name_buff,table_name)) || (!lower_case_table_names && !strcmp(new_name_buff,table_name))) new_name=table_name; // No. Make later check easier @@ -1348,7 +1352,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, while ((drop=drop_it++)) { if (drop->type == Alter_drop::COLUMN && - !my_strcasecmp(field->field_name, drop->name)) + !my_strcasecmp(system_charset_info,field->field_name, drop->name)) { /* Reset auto_increment value if it was dropped */ if (MTYP_TYPENR(field->unireg_check) == Field::NEXT_NUMBER && @@ -1369,7 +1373,8 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, def_it.rewind(); while ((def=def_it++)) { - if (def->change && !my_strcasecmp(field->field_name, def->change)) + if (def->change && + !my_strcasecmp(system_charset_info,field->field_name, def->change)) break; } if (def) @@ -1393,7 +1398,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, Alter_column *alter; while ((alter=alter_it++)) { - if (!my_strcasecmp(field->field_name, alter->name)) + if (!my_strcasecmp(system_charset_info,field->field_name, alter->name)) break; } if (alter) @@ -1427,7 +1432,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, find_it.rewind(); while ((find=find_it++)) // Add new columns { - if (!my_strcasecmp(def->after, find->field_name)) + if (!my_strcasecmp(system_charset_info,def->after, find->field_name)) break; } if (!find) @@ -1473,7 +1478,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, while ((drop=drop_it++)) { if (drop->type == Alter_drop::KEY && - !my_strcasecmp(key_name, drop->name)) + !my_strcasecmp(system_charset_info,key_name, drop->name)) break; } if (drop) @@ -1495,10 +1500,11 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, { if (cfield->change) { - if (!my_strcasecmp(key_part_name, cfield->change)) + if (!my_strcasecmp(system_charset_info,key_part_name, cfield->change)) break; } - else if (!my_strcasecmp(key_part_name, cfield->field_name)) + else if (!my_strcasecmp(system_charset_info, + key_part_name, cfield->field_name)) break; } if (!cfield) @@ -1518,7 +1524,8 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, if (key_parts.elements) key_list.push_back(new Key(key_info->flags & HA_SPATIAL ? Key::SPATIAL : (key_info->flags & HA_NOSAME ? - (!my_strcasecmp(key_name, "PRIMARY") ? + (!my_strcasecmp(system_charset_info, + key_name, "PRIMARY") ? Key::PRIMARY : Key::UNIQUE) : (key_info->flags & HA_FULLTEXT ? Key::FULLTEXT : Key::MULTIPLE)), diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 41e56328613..d762c8784a3 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -3654,7 +3654,8 @@ column_list_id: LEX *lex=Lex; while ((point=iter++)) { - if (!my_strcasecmp(point->column.ptr(),new_str->ptr())) + if (!my_strcasecmp(system_charset_info, + point->column.ptr(), new_str->ptr())) break; } lex->grant_tot_col|= lex->which_columns; diff --git a/sql/table.cc b/sql/table.cc index 9e6283d6ad4..2fa5d41f1ba 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1067,9 +1067,10 @@ bool check_db_name(const char *name) while (*name) { #if defined(USE_MB) && defined(USE_MB_IDENT) - if (use_mb(default_charset_info)) + if (use_mb(system_charset_info)) { - int len=my_ismbchar(default_charset_info, name, name+MBMAXLEN); + int len=my_ismbchar(system_charset_info, name, + name+system_charset_info->mbmaxlen); if (len) { name += len; @@ -1099,9 +1100,9 @@ bool check_table_name(const char *name, uint length) while (name != end) { #if defined(USE_MB) && defined(USE_MB_IDENT) - if (use_mb(default_charset_info)) + if (use_mb(system_charset_info)) { - int len=my_ismbchar(default_charset_info, name, end); + int len=my_ismbchar(system_charset_info, name, end); if (len) { name += len; @@ -1121,9 +1122,10 @@ bool check_column_name(const char *name) while (*name) { #if defined(USE_MB) && defined(USE_MB_IDENT) - if (use_mb(default_charset_info)) + if (use_mb(system_charset_info)) { - int len=my_ismbchar(default_charset_info, name, name+MBMAXLEN); + int len=my_ismbchar(system_charset_info, name, + name+system_charset_info->mbmaxlen); if (len) { name += len; diff --git a/sql/time.cc b/sql/time.cc index aab886648e3..2a791ccc30e 100644 --- a/sql/time.cc +++ b/sql/time.cc @@ -268,13 +268,13 @@ void find_date(string pos,uint *vek,uint flag) DBUG_PRINT("enter",("pos: '%s' flag: %d",pos,flag)); bzero((char*) vek,sizeof(int)*4); - while (*pos && !isdigit(*pos)) + while (*pos && !my_isdigit(system_charset_info,*pos)) pos++; length=(uint) strlen(pos); for (uint i=0 ; i< 3; i++) { start=pos; value=0; - while (isdigit(pos[0]) && + while (my_isdigit(system_charset_info,pos[0]) && ((pos-start) < 2 || ((pos-start) < 4 && length >= 8 && !(flag & 3)))) { @@ -282,7 +282,8 @@ void find_date(string pos,uint *vek,uint flag) pos++; } vek[flag & 3]=value; flag>>=2; - while (*pos && (ispunct(*pos) || isspace(*pos))) + while (*pos && (my_ispunct(system_charset_info,*pos) || + my_isspace(system_charset_info,*pos))) pos++; } DBUG_PRINT("exit",("year: %d month: %d day: %d",vek[0],vek[1],vek[2])); @@ -434,7 +435,8 @@ str_to_TIME(const char *str, uint length, TIME *l_time,bool fuzzy_date) DBUG_ENTER("str_to_TIME"); DBUG_PRINT("enter",("str: %.*s",length,str)); - for (; str != end && !isdigit(*str) ; str++) ; // Skip garbage + // Skip garbage + for (; str != end && !my_isdigit(system_charset_info, *str) ; str++) ; if (str == end) DBUG_RETURN(TIMESTAMP_NONE); /* @@ -442,14 +444,14 @@ str_to_TIME(const char *str, uint length, TIME *l_time,bool fuzzy_date) ** If length= 8 or >= 14 then year is of format YYYY. (YYYY-MM-DD, YYYYMMDD, YYYYYMMDDHHMMSS) */ - for (pos=str; pos != end && isdigit(*pos) ; pos++) ; + for (pos=str; pos != end && my_isdigit(system_charset_info,*pos) ; pos++) ; digits= (uint) (pos-str); year_length= (digits == 4 || digits == 8 || digits >= 14) ? 4 : 2; field_length=year_length-1; - for (i=0 ; i < 6 && str != end && isdigit(*str) ; i++) + for (i=0 ; i < 6 && str != end && my_isdigit(system_charset_info,*str) ; i++) { uint tmp_value=(uint) (uchar) (*str++ - '0'); - while (str != end && isdigit(str[0]) && field_length--) + while (str != end && my_isdigit(system_charset_info,str[0]) && field_length--) { tmp_value=tmp_value*10 + (uint) (uchar) (*str - '0'); str++; @@ -459,10 +461,12 @@ str_to_TIME(const char *str, uint length, TIME *l_time,bool fuzzy_date) str++; // ISO8601: CCYYMMDDThhmmss else if ( i != 5 ) // Skip inter-field delimiters { - while (str != end && (ispunct(*str) || isspace(*str))) + while (str != end && + (my_ispunct(system_charset_info,*str) || + my_isspace(system_charset_info,*str))) { // Only allow space between days and hours - if (isspace(*str) && i != 2) + if (my_isspace(system_charset_info,*str) && i != 2) DBUG_RETURN(TIMESTAMP_NONE); str++; } @@ -470,12 +474,13 @@ str_to_TIME(const char *str, uint length, TIME *l_time,bool fuzzy_date) field_length=1; // Rest fields can only be 2 } /* Handle second fractions */ - if (i == 6 && (uint) (end-str) >= 2 && *str == '.' && isdigit(str[1])) + if (i == 6 && (uint) (end-str) >= 2 && *str == '.' && + my_isdigit(system_charset_info,str[1])) { str++; uint tmp_value=(uint) (uchar) (*str - '0'); field_length=3; - while (str++ != end && isdigit(str[0]) && field_length--) + while (str++ != end && my_isdigit(system_charset_info,str[0]) && field_length--) tmp_value=tmp_value*10 + (uint) (uchar) (*str - '0'); date[6]=tmp_value; } @@ -498,7 +503,7 @@ str_to_TIME(const char *str, uint length, TIME *l_time,bool fuzzy_date) { for ( ; str != end ; str++) { - if (!isspace(*str)) + if (!my_isspace(system_charset_info,*str)) { current_thd->cuted_fields++; break; @@ -559,7 +564,8 @@ bool str_to_time(const char *str,uint length,TIME *l_time) uint state; l_time->neg=0; - for (; str != end && !isdigit(*str) && *str != '-' ; str++) + for (; str != end && + !my_isdigit(system_charset_info,*str) && *str != '-' ; str++) length--; if (str != end && *str == '-') { @@ -578,7 +584,7 @@ bool str_to_time(const char *str,uint length,TIME *l_time) } /* Not a timestamp. Try to get this as a DAYS_TO_SECOND string */ - for (value=0; str != end && isdigit(*str) ; str++) + for (value=0; str != end && my_isdigit(system_charset_info,*str) ; str++) value=value*10L + (long) (*str - '0'); if (*str == ' ') @@ -589,14 +595,16 @@ bool str_to_time(const char *str,uint length,TIME *l_time) LINT_INIT(state); found_days=found_hours=0; - if ((uint) (end-str) > 1 && (*str == ' ' && isdigit(str[1]))) + if ((uint) (end-str) > 1 && (*str == ' ' && + my_isdigit(system_charset_info,str[1]))) { // days ! date[0]=value; state=1; // Assume next is hours found_days=1; str++; // Skip space; } - else if ((end-str) > 1 && *str == ':' && isdigit(str[1])) + else if ((end-str) > 1 && *str == ':' && + my_isdigit(system_charset_info,str[1])) { date[0]=0; // Assume we found hours date[1]=value; @@ -618,10 +626,11 @@ bool str_to_time(const char *str,uint length,TIME *l_time) /* Read hours, minutes and seconds */ for (;;) { - for (value=0; str != end && isdigit(*str) ; str++) + for (value=0; str != end && my_isdigit(system_charset_info,*str) ; str++) value=value*10L + (long) (*str - '0'); date[state++]=value; - if (state == 4 || (end-str) < 2 || *str != ':' || !isdigit(str[1])) + if (state == 4 || (end-str) < 2 || *str != ':' || + !my_isdigit(system_charset_info,str[1])) break; str++; // Skip ':' } @@ -641,11 +650,13 @@ bool str_to_time(const char *str,uint length,TIME *l_time) fractional: /* Get fractional second part */ - if ((end-str) >= 2 && *str == '.' && isdigit(str[1])) + if ((end-str) >= 2 && *str == '.' && my_isdigit(system_charset_info,str[1])) { uint field_length=3; str++; value=(uint) (uchar) (*str - '0'); - while (++str != end && isdigit(str[0]) && field_length--) + while (++str != end && + my_isdigit(system_charset_info,str[0]) && + field_length--) value=value*10 + (uint) (uchar) (*str - '0'); date[4]=value; } @@ -670,7 +681,7 @@ bool str_to_time(const char *str,uint length,TIME *l_time) { do { - if (!isspace(*str)) + if (!my_isspace(system_charset_info,*str)) { current_thd->cuted_fields++; break; |