diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/filesort.cc | 4 | ||||
-rw-r--r-- | sql/item.cc | 23 | ||||
-rw-r--r-- | sql/item.h | 21 | ||||
-rw-r--r-- | sql/item_buff.cc | 2 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 42 | ||||
-rw-r--r-- | sql/item_func.cc | 16 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 43 | ||||
-rw-r--r-- | sql/item_strfunc.h | 26 | ||||
-rw-r--r-- | sql/item_sum.cc | 2 | ||||
-rw-r--r-- | sql/item_timefunc.cc | 8 | ||||
-rw-r--r-- | sql/item_timefunc.h | 20 | ||||
-rw-r--r-- | sql/opt_range.cc | 2 | ||||
-rw-r--r-- | sql/set_var.h | 2 | ||||
-rw-r--r-- | sql/sql_analyse.cc | 12 | ||||
-rw-r--r-- | sql/sql_select.cc | 8 |
15 files changed, 109 insertions, 122 deletions
diff --git a/sql/filesort.cc b/sql/filesort.cc index 2130bdaeb93..13989bdae8f 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -519,7 +519,7 @@ static void make_sortkey(register SORTPARAM *param, switch (sort_field->result_type) { case STRING_RESULT: { - CHARSET_INFO *cs=item->charset(); + CHARSET_INFO *cs=item->collation.collation; if ((maybe_null=item->maybe_null)) *to++=1; /* All item->str() to use some extra byte for end null.. */ @@ -1040,7 +1040,7 @@ sortlength(SORT_FIELD *sortorder, uint s_length, bool *multi_byte_charset) switch ((sortorder->result_type=sortorder->item->result_type())) { case STRING_RESULT: sortorder->length=sortorder->item->max_length; - if (use_strnxfrm((cs=sortorder->item->charset()))) + if (use_strnxfrm((cs=sortorder->item->collation.collation))) { sortorder->length= sortorder->length*cs->strxfrm_multiply; sortorder->need_strxnfrm= 1; diff --git a/sql/item.cc b/sql/item.cc index 48f9dfea4e1..17b0519b61c 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -43,7 +43,7 @@ Item::Item(): { marker= 0; maybe_null=null_value=with_sum_func=unsigned_flag=0; - set_charset(default_charset(), DERIVATION_COERCIBLE); + collation.set(default_charset(), DERIVATION_COERCIBLE); name= 0; decimals= 0; max_length= 0; THD *thd= current_thd; @@ -149,7 +149,7 @@ bool Item_string::eq(const Item *item, bool binary_cmp) const { if (binary_cmp) return !sortcmp(&str_value, &item->str_value, &my_charset_bin); - return !sortcmp(&str_value, &item->str_value, charset()); + return !sortcmp(&str_value, &item->str_value, collation.collation); } return 0; } @@ -258,7 +258,7 @@ bool DTCollation::aggregate(DTCollation &dt) Item_field::Item_field(Field *f) :Item_ident(NullS,f->table_name,f->field_name) { set_field(f); - set_charset(DERIVATION_IMPLICIT); + collation.set(DERIVATION_IMPLICIT); fixed= 1; // This item is not needed in fix_fields } @@ -267,7 +267,7 @@ Item_field::Item_field(THD *thd, Item_field &item): Item_ident(thd, item), field(item.field), result_field(item.result_field) -{ set_charset(DERIVATION_IMPLICIT); } +{ collation.set(DERIVATION_IMPLICIT); } void Item_field::set_field(Field *field_par) { @@ -279,7 +279,7 @@ void Item_field::set_field(Field *field_par) field_name=field_par->field_name; db_name=field_par->table->table_cache_key; unsigned_flag=test(field_par->flags & UNSIGNED_FLAG); - set_charset(field_par->charset(), DERIVATION_IMPLICIT); + collation.set(field_par->charset(), DERIVATION_IMPLICIT); } const char *Item_ident::full_name() const @@ -962,7 +962,7 @@ void Item::init_make_field(Send_field *tmp_field, tmp_field->org_col_name= empty_name; tmp_field->table_name= empty_name; tmp_field->col_name= name; - tmp_field->charsetnr= charset()->number; + tmp_field->charsetnr= collation.collation->number; tmp_field->flags=maybe_null ? 0 : NOT_NULL_FLAG; tmp_field->type=field_type; tmp_field->length=max_length; @@ -1076,7 +1076,7 @@ int Item::save_in_field(Field *field, bool no_conversions) field->result_type() == STRING_RESULT) { String *result; - CHARSET_INFO *cs=charset(); + CHARSET_INFO *cs= collation.collation; char buff[MAX_FIELD_WIDTH]; // Alloc buffer for small columns str_value.set_quick(buff,sizeof(buff),cs); result=val_str(&str_value); @@ -1113,7 +1113,8 @@ int Item_string::save_in_field(Field *field, bool no_conversions) if (null_value) return set_field_to_null(field); field->set_notnull(); - return (field->store(result->ptr(),result->length(),charset())) ? -1 : 0; + return (field->store(result->ptr(),result->length(),collation.collation)) ? + -1 : 0; } @@ -1167,7 +1168,7 @@ Item_varbinary::Item_varbinary(const char *str, uint str_length) str+=2; } *ptr=0; // Keep purify happy - set_charset(&my_charset_bin, DERIVATION_COERCIBLE); + collation.set(&my_charset_bin, DERIVATION_COERCIBLE); } longlong Item_varbinary::val_int() @@ -1188,7 +1189,7 @@ int Item_varbinary::save_in_field(Field *field, bool no_conversions) field->set_notnull(); if (field->result_type() == STRING_RESULT) { - error=field->store(str_value.ptr(),str_value.length(),charset()); + error=field->store(str_value.ptr(),str_value.length(),collation.collation); } else { @@ -1686,7 +1687,7 @@ Item_cache* Item_cache::get_cache(Item_result type) void Item_cache_str::store(Item *item) { - str_value.set(buffer, sizeof(buffer), item->charset()); + str_value.set(buffer, sizeof(buffer), item->collation.collation); value= item->str_result(&str_value); if ((null_value= item->null_value)) value= 0; diff --git a/sql/item.h b/sql/item.h index 9df6532a637..621dc017d25 100644 --- a/sql/item.h +++ b/sql/item.h @@ -169,21 +169,6 @@ public: virtual Item *get_tmp_table_item(THD *thd) { return copy_or_same(thd); } CHARSET_INFO *default_charset() const; - Derivation derivation() const { return collation.derivation; } - CHARSET_INFO *charset() const { return collation.collation; } - void set_charset(CHARSET_INFO *cs) - { collation.collation= cs; } - void set_charset(Derivation dv) - { collation.derivation= dv; } - void set_charset(CHARSET_INFO *cs, Derivation dv) - { collation.collation= cs; collation.derivation= dv; } - void set_charset(Item &item) - { collation= item.collation; } - void set_charset(DTCollation *collation_arg) - { - collation.collation= collation_arg->collation; - collation.derivation= collation_arg->derivation; - } virtual void set_outer_resolving() {} // Row emulation @@ -229,7 +214,7 @@ public: Item_field(const char *db_par,const char *table_name_par, const char *field_name_par) :Item_ident(db_par,table_name_par,field_name_par),field(0),result_field(0) - { set_charset(DERIVATION_IMPLICIT); } + { collation.set(DERIVATION_IMPLICIT); } // Constructor need to process subselect with temporary tables (see Item) Item_field(THD *thd, Item_field &item); Item_field(Field *field); @@ -432,7 +417,7 @@ public: Item_string(const char *str,uint length, CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE) { - set_charset(cs, dv); + collation.set(cs, dv); str_value.set(str,length,cs); max_length=length; set_name(str, length, cs); @@ -441,7 +426,7 @@ public: Item_string(const char *name_par, const char *str, uint length, CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE) { - set_charset(cs, dv); + collation.set(cs, dv); str_value.set(str,length,cs); max_length=length; set_name(name_par,0,cs); diff --git a/sql/item_buff.cc b/sql/item_buff.cc index c4431294dff..1559cfe958e 100644 --- a/sql/item_buff.cc +++ b/sql/item_buff.cc @@ -57,7 +57,7 @@ bool Item_str_buff::cmp(void) else if (null_value) return 0; // new and old value was null else - tmp= sortcmp(&value,res,item->charset()) != 0; + tmp= sortcmp(&value,res,item->collation.collation) != 0; if (tmp) value.copy(*res); // Remember for next cmp return tmp; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index d992b4d69d0..7d8da16338b 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -151,15 +151,17 @@ void Item_bool_func2::fix_length_and_dec() uint strong= 0; uint weak= 0; - if ((args[0]->derivation() < args[1]->derivation()) && - !my_charset_same(args[0]->charset(), args[1]->charset()) && - (args[0]->charset()->state & MY_CS_UNICODE)) + if ((args[0]->collation.derivation < args[1]->collation.derivation) && + !my_charset_same(args[0]->collation.collation, + args[1]->collation.collation) && + (args[0]->collation.collation->state & MY_CS_UNICODE)) { weak= 1; } - else if ((args[1]->derivation() < args[0]->derivation()) && - !my_charset_same(args[0]->charset(), args[1]->charset()) && - (args[1]->charset()->state & MY_CS_UNICODE)) + else if ((args[1]->collation.derivation < args[0]->collation.derivation) && + !my_charset_same(args[0]->collation.collation, + args[1]->collation.collation) && + (args[1]->collation.collation->state & MY_CS_UNICODE)) { strong= 1; } @@ -172,15 +174,15 @@ void Item_bool_func2::fix_length_and_dec() String tmp, cstr; String *ostr= args[weak]->val_str(&tmp); cstr.copy(ostr->ptr(), ostr->length(), ostr->charset(), - args[strong]->charset()); + args[strong]->collation.collation); conv= new Item_string(cstr.ptr(),cstr.length(),cstr.charset(), - args[weak]->derivation()); + args[weak]->collation.derivation); ((Item_string*)conv)->str_value.copy(); } else { - conv= new Item_func_conv_charset(args[weak],args[strong]->charset()); - conv->collation.set(args[weak]->derivation()); + conv= new Item_func_conv_charset(args[weak],args[strong]->collation.collation); + conv->collation.set(args[weak]->collation.derivation); } args[weak]= conv ? conv : args[weak]; } @@ -725,13 +727,13 @@ Item_func_ifnull::val_str(String *str) if (!args[0]->null_value) { null_value=0; - res->set_charset(charset()); + res->set_charset(collation.collation); return res; } res=args[1]->val_str(str); if ((null_value=args[1]->null_value)) return 0; - res->set_charset(charset()); + res->set_charset(collation.collation); return res; } @@ -750,12 +752,12 @@ Item_func_if::fix_length_and_dec() if (null1) { cached_result_type= arg2_type; - set_charset(args[2]->charset()); + collation.set(args[2]->collation.collation); } else if (null2) { cached_result_type= arg1_type; - set_charset(args[1]->charset()); + collation.set(args[1]->collation.collation); } else { @@ -767,7 +769,7 @@ Item_func_if::fix_length_and_dec() } else { - set_charset(&my_charset_bin); // Number + collation.set(&my_charset_bin); // Number } } } @@ -797,7 +799,7 @@ Item_func_if::val_str(String *str) Item *arg= args[0]->val_int() ? args[1] : args[2]; String *res=arg->val_str(str); if (res) - res->set_charset(charset()); + res->set_charset(collation.collation); null_value=arg->null_value; return res; } @@ -1182,7 +1184,7 @@ void in_string::set(uint pos,Item *item) if (!str->charset()) { CHARSET_INFO *cs; - if (!(cs= item->charset())) + if (!(cs= item->collation.collation)) cs= &my_charset_bin; // Should never happen for STR items str->set_charset(cs); } @@ -1260,7 +1262,7 @@ cmp_item* cmp_item::get_comparator(Item *item) { switch (item->result_type()) { case STRING_RESULT: - return new cmp_item_sort_string(item->charset()); + return new cmp_item_sort_string(item->collation.collation); break; case INT_RESULT: return new cmp_item_int; @@ -1839,7 +1841,7 @@ bool Item_func_like::fix_fields(THD *thd, TABLE_LIST *tlist, Item ** ref) We could also do boyer-more for non-const items, but as we would have to recompute the tables for each row it's not worth it. */ - if (args[1]->const_item() && !use_strnxfrm(charset()) && + if (args[1]->const_item() && !use_strnxfrm(collation.collation) && !(specialflag & SPECIAL_NO_NEW_FUNC)) { String* res2 = args[1]->val_str(&tmp_value2); @@ -1860,7 +1862,7 @@ bool Item_func_like::fix_fields(THD *thd, TABLE_LIST *tlist, Item ** ref) { const char* tmp = first + 1; for (; *tmp != wild_many && *tmp != wild_one && *tmp != escape; tmp++) ; - canDoTurboBM = (tmp == last) && !use_mb(args[0]->charset()); + canDoTurboBM = (tmp == last) && !use_mb(args[0]->collation.collation); } if (canDoTurboBM) diff --git a/sql/item_func.cc b/sql/item_func.cc index 843fe6cd350..a7c5b35b8db 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -309,9 +309,9 @@ Field *Item_func::tmp_table_field(TABLE *t_arg) break; case STRING_RESULT: if (max_length > 255) - res= new Field_blob(max_length, maybe_null, name, t_arg, charset()); + res= new Field_blob(max_length, maybe_null, name, t_arg, collation.collation); else - res= new Field_string(max_length, maybe_null, name, t_arg, charset()); + res= new Field_string(max_length, maybe_null, name, t_arg, collation.collation); break; case ROW_RESULT: default: @@ -976,13 +976,13 @@ String *Item_func_min_max::val_str(String *str) res2= args[i]->val_str(res == str ? &tmp_value : str); if (res2) { - int cmp= sortcmp(res,res2,charset()); + int cmp= sortcmp(res,res2,collation.collation); if ((cmp_sign < 0 ? cmp : -cmp) < 0) res=res2; } } } - res->set_charset(charset()); + res->set_charset(collation.collation); return res; } case ROW_RESULT: @@ -1100,7 +1100,7 @@ longlong Item_func_coercibility::val_int() return 0; } null_value= 0; - return (longlong) args[0]->derivation(); + return (longlong) args[0]->collation.derivation; } void Item_func_locate::fix_length_and_dec() @@ -1434,8 +1434,8 @@ udf_handler::fix_fields(THD *thd, TABLE_LIST *tables, Item_result_field *func, There is no a general rule for UDF. Everything depends on the particular user definted function. */ - if (item->charset()->state & MY_CS_BINSORT) - func->set_charset(&my_charset_bin); + if (item->collation.collation->state & MY_CS_BINSORT) + func->collation.set(&my_charset_bin); if (item->maybe_null) func->maybe_null=1; func->with_sum_func= func->with_sum_func || item->with_sum_func; @@ -2199,7 +2199,7 @@ Item_func_set_user_var::val_str(String *str) update_hash((void*) 0, 0, STRING_RESULT, &my_charset_bin, DERIVATION_NONE); else update_hash((void*) res->ptr(), res->length(), STRING_RESULT, - res->charset(), args[0]->derivation()); + res->charset(), args[0]->collation.derivation); return res; } diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index b4f4df6968d..b92839e6c1e 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -310,7 +310,7 @@ String *Item_func_concat::val_str(String *str) } } } - res->set_charset(charset()); + res->set_charset(collation.collation); return res; null: @@ -596,7 +596,7 @@ String *Item_func_concat_ws::val_str(String *str) use_as_buff=str; } } - res->set_charset(charset()); + res->set_charset(collation.collation); return res; null: @@ -697,7 +697,7 @@ String *Item_func_reverse::val_str(String *str) void Item_func_reverse::fix_length_and_dec() { - set_charset(*args[0]); + collation.set(args[0]->collation); max_length = args[0]->max_length; } @@ -933,7 +933,7 @@ void Item_str_func::left_right_max_length() max_length=args[0]->max_length; if (args[1]->const_item()) { - int length=(int) args[1]->val_int()*charset()->mbmaxlen; + int length=(int) args[1]->val_int()*collation.collation->mbmaxlen; if (length <= 0) max_length=0; else @@ -944,7 +944,7 @@ void Item_str_func::left_right_max_length() void Item_func_left::fix_length_and_dec() { - set_charset(*args[0]); + collation.set(args[0]->collation); left_right_max_length(); } @@ -971,7 +971,7 @@ String *Item_func_right::val_str(String *str) void Item_func_right::fix_length_and_dec() { - set_charset(*args[0]); + collation.set(args[0]->collation); left_right_max_length(); } @@ -1006,7 +1006,7 @@ void Item_func_substr::fix_length_and_dec() { max_length=args[0]->max_length; - set_charset(*args[0]); + collation.set(args[0]->collation); if (args[1]->const_item()) { int32 start=(int32) args[1]->val_int()-1; @@ -1314,7 +1314,7 @@ void Item_func_trim::fix_length_and_dec() if (arg_count == 1) { collation.set(args[0]->collation); - remove.set_charset(charset()); + remove.set_charset(collation.collation); remove.set_ascii(" ",1); } else @@ -1535,7 +1535,7 @@ String *Item_func_user::val_str(String *str) void Item_func_soundex::fix_length_and_dec() { - set_charset(*args[0]); + collation.set(args[0]->collation); max_length=args[0]->max_length; set_if_bigger(max_length,4); } @@ -1567,7 +1567,7 @@ String *Item_func_soundex::val_str(String *str) { String *res =args[0]->val_str(str); char last_ch,ch; - CHARSET_INFO *cs= charset(); + CHARSET_INFO *cs= collation.collation; if ((null_value=args[0]->null_value)) return 0; /* purecov: inspected */ @@ -1707,7 +1707,7 @@ String *Item_func_elt::val_str(String *str) } null_value=0; res= args[tmp]->val_str(str); - res->set_charset(charset()); + res->set_charset(collation.collation); return res; } @@ -1813,7 +1813,7 @@ String *Item_func_char::val_str(String *str) int32 num=(int32) args[i]->val_int(); if (!args[i]->null_value) #ifdef USE_MB - if (use_mb(charset())) + if (use_mb(collation.collation)) { if (num&0xFF000000L) { str->append((char)(num>>24)); @@ -1860,7 +1860,7 @@ inline String* alloc_buffer(String *res,String *str,String *tmp_value, void Item_func_repeat::fix_length_and_dec() { - set_charset(*args[0]); + collation.set(args[0]->collation); if (args[1]->const_item()) { max_length=(long) (args[0]->max_length * args[1]->val_int()); @@ -2109,7 +2109,7 @@ String *Item_func_conv_charset::val_str(String *str) void Item_func_conv_charset::fix_length_and_dec() { - set_charset(conv_charset, DERIVATION_IMPLICIT); + collation.set(conv_charset, DERIVATION_IMPLICIT); max_length = args[0]->max_length*conv_charset->mbmaxlen; } @@ -2192,7 +2192,7 @@ String *Item_func_set_collation::val_str(String *str) str=args[0]->val_str(str); if ((null_value=args[0]->null_value)) return 0; - str->set_charset(charset()); + str->set_charset(collation.collation); return str; } @@ -2203,7 +2203,7 @@ void Item_func_set_collation::fix_length_and_dec() String tmp, *str= args[1]->val_str(&tmp); colname= str->c_ptr(); if (colname == binary_keyword) - set_collation= get_charset_by_csname(args[0]->charset()->csname, + set_collation= get_charset_by_csname(args[0]->collation.collation->csname, MY_CS_BINSORT,MYF(0)); else { @@ -2214,13 +2214,14 @@ void Item_func_set_collation::fix_length_and_dec() } } - if (!set_collation || !my_charset_same(args[0]->charset(),set_collation)) + if (!set_collation || + !my_charset_same(args[0]->collation.collation,set_collation)) { my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0), - colname,args[0]->charset()->csname); + colname,args[0]->collation.collation->csname); return; } - set_charset(set_collation, DERIVATION_EXPLICIT); + collation.set(set_collation, DERIVATION_EXPLICIT); max_length= args[0]->max_length; } @@ -2237,7 +2238,7 @@ bool Item_func_set_collation::eq(const Item *item, bool binary_cmp) const func_name() != item_func->func_name()) return 0; Item_func_set_collation *item_func_sc=(Item_func_set_collation*) item; - if (charset() != item_func_sc->charset()) + if (collation.collation != item_func_sc->collation.collation) return 0; for (uint i=0; i < arg_count ; i++) if (!args[i]->eq(item_func_sc->args[i], binary_cmp)) @@ -2539,7 +2540,7 @@ String *Item_func_quote::val_str(String *str) } *to= '\''; str->length(new_length); - str->set_charset(charset()); + str->set_charset(collation.collation); return str; null: diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 7f8d7ade67b..dfcc22b3443 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -153,7 +153,7 @@ public: Item_str_conv(Item *item) :Item_str_func(item) {} void fix_length_and_dec() { - set_charset(*args[0]); + collation.set(args[0]->collation); max_length = args[0]->max_length; } }; @@ -335,12 +335,11 @@ public: class Item_func_database :public Item_str_func { public: - Item_func_database() { set_charset(DERIVATION_IMPLICIT); } + Item_func_database() { collation.set(system_charset_info,DERIVATION_IMPLICIT); } String *val_str(String *); void fix_length_and_dec() { max_length= MAX_FIELD_NAME * system_charset_info->mbmaxlen; - set_charset(system_charset_info); } const char *func_name() const { return "database"; } }; @@ -348,12 +347,11 @@ public: class Item_func_user :public Item_str_func { public: - Item_func_user() { set_charset(DERIVATION_IMPLICIT); } + Item_func_user() { collation.set(system_charset_info, DERIVATION_IMPLICIT); } String *val_str(String *); void fix_length_and_dec() { max_length= (USERNAME_LENGTH+HOSTNAME_LENGTH+1)*system_charset_info->mbmaxlen; - set_charset(system_charset_info); } const char *func_name() const { return "user"; } }; @@ -417,7 +415,7 @@ public: String *val_str(String *); void fix_length_and_dec() { - set_charset(default_charset()); + collation.set(default_charset()); max_length=args[0]->max_length+(args[0]->max_length-args[0]->decimals)/3; } const char *func_name() const { return "format"; } @@ -431,7 +429,7 @@ public: String *val_str(String *); void fix_length_and_dec() { - set_charset(default_charset()); + collation.set(default_charset()); maybe_null=0; max_length=arg_count; } const char *func_name() const { return "char"; } @@ -481,7 +479,7 @@ public: String *val_str(String *); void fix_length_and_dec() { - set_charset(default_charset()); + collation.set(default_charset()); decimals=0; max_length=64; } }; @@ -496,7 +494,7 @@ public: String *val_str(String *); void fix_length_and_dec() { - set_charset(default_charset()); + collation.set(default_charset()); decimals=0; max_length=args[0]->max_length*2; } }; @@ -517,7 +515,7 @@ public: } void fix_length_and_dec() { - set_charset(&my_charset_bin); + collation.set(&my_charset_bin); max_length=args[0]->max_length; } void print(String *str) { print_op(str); } @@ -533,7 +531,7 @@ public: const char *func_name() const { return "load_file"; } void fix_length_and_dec() { - set_charset(&my_charset_bin, DERIVATION_COERCIBLE); + collation.set(&my_charset_bin, DERIVATION_COERCIBLE); maybe_null=1; max_length=MAX_BLOB_WIDTH; } @@ -570,7 +568,7 @@ public: String *val_str(String *); void fix_length_and_dec() { - set_charset(*args[0]); + collation.set(args[0]->collation); max_length= args[0]->max_length * 2 + 2; } }; @@ -615,7 +613,7 @@ public: void fix_length_and_dec() { max_length=40; // should be enough - set_charset(default_charset()); + collation.set(system_charset_info); }; }; @@ -628,6 +626,6 @@ public: void fix_length_and_dec() { max_length=40; // should be enough - set_charset(default_charset()); + collation.set(system_charset_info); }; }; diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 3bd131c0e60..0da2725f3ab 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -193,7 +193,7 @@ Item_sum_hybrid::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) max_length=float_length(decimals); }else { - cmp_charset= item->charset(); + cmp_charset= item->collation.collation; max_length=item->max_length; } decimals=item->decimals; diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index c2d1504e94a..62d8afd7ec0 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -574,7 +574,7 @@ void Item_func_curdate::fix_length_and_dec() struct tm tm_tmp,*start; time_t query_start=current_thd->query_start(); - set_charset(default_charset()); + collation.set(default_charset()); decimals=0; max_length=10*default_charset()->mbmaxlen; localtime_r(&query_start,&tm_tmp); @@ -617,7 +617,7 @@ void Item_func_curtime::fix_length_and_dec() max_length=8*cs->mbmaxlen; localtime_r(&query_start,&tm_tmp); start=&tm_tmp; - set_charset(cs); + collation.set(cs); value=(longlong) ((ulong) ((uint) start->tm_hour)*10000L+ (ulong) (((uint) start->tm_min)*100L+ (uint) start->tm_sec)); @@ -644,7 +644,7 @@ void Item_func_now::fix_length_and_dec() decimals=0; max_length=19*cs->mbmaxlen; - set_charset(cs); + collation.set(cs); localtime_r(&query_start,&tm_tmp); start=&tm_tmp; value=((longlong) ((ulong) ((uint) start->tm_year+1900)*10000L+ @@ -1130,7 +1130,7 @@ bool Item_func_from_unixtime::get_date(TIME *ltime, void Item_date_add_interval::fix_length_and_dec() { enum_field_types arg0_field_type; - set_charset(default_charset()); + collation.set(default_charset()); maybe_null=1; max_length=26*MY_CHARSET_BIN_MB_MAXLEN; value.alloc(32); diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 20b95f8e22d..a6fb9b11de4 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -93,7 +93,7 @@ public: enum Item_result result_type () const { return INT_RESULT; } void fix_length_and_dec() { - set_charset(default_charset()); + collation.set(default_charset()); decimals=0; max_length=2*default_charset()->mbmaxlen; maybe_null=1; @@ -110,7 +110,7 @@ public: enum Item_result result_type () const { return STRING_RESULT; } void fix_length_and_dec() { - set_charset(default_charset()); + collation.set(default_charset()); decimals=0; max_length=10*default_charset()->mbmaxlen; maybe_null=1; @@ -254,7 +254,7 @@ public: enum Item_result result_type () const { return INT_RESULT; } void fix_length_and_dec() { - set_charset(default_charset()); + collation.set(default_charset()); decimals=0; max_length=1*default_charset()->mbmaxlen; maybe_null=1; @@ -270,7 +270,7 @@ class Item_func_dayname :public Item_func_weekday enum Item_result result_type () const { return STRING_RESULT; } void fix_length_and_dec() { - set_charset(default_charset()); + collation.set(default_charset()); decimals=0; max_length=9*default_charset()->mbmaxlen; maybe_null=1; @@ -322,7 +322,7 @@ public: const char *func_name() const { return "date"; } void fix_length_and_dec() { - set_charset(default_charset()); + collation.set(default_charset()); decimals=0; max_length=10*default_charset()->mbmaxlen; } @@ -440,7 +440,7 @@ class Item_func_from_unixtime :public Item_date_func const char *func_name() const { return "from_unixtime"; } void fix_length_and_dec() { - set_charset(default_charset()); + collation.set(default_charset()); decimals=0; max_length=19*default_charset()->mbmaxlen; } @@ -457,7 +457,7 @@ public: String *val_str(String *); void fix_length_and_dec() { - set_charset(default_charset()); + collation.set(default_charset()); maybe_null=1; max_length=13*default_charset()->mbmaxlen; } @@ -529,12 +529,12 @@ public: String *tmp=args[0]->val_str(a); null_value=args[0]->null_value; if (tmp) - tmp->set_charset(charset()); + tmp->set_charset(collation.collation); return tmp; } void fix_length_and_dec() { - set_charset(default_charset()); + collation.set(default_charset()); max_length=args[0]->max_length; } void print(String *str); @@ -547,7 +547,7 @@ public: Item_char_typecast(Item *a) :Item_typecast(a) {} void fix_length_and_dec() { - set_charset(default_charset()); + collation.set(default_charset()); max_length=args[0]->max_length; } }; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 18c465ffde3..935abac5146 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -930,7 +930,7 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part, { bool like_error; char buff1[MAX_FIELD_WIDTH],*min_str,*max_str; - String tmp(buff1,sizeof(buff1),value->charset()),*res; + String tmp(buff1,sizeof(buff1),value->collation.collation),*res; uint length,offset,min_length,max_length; if (!field->optimize_range(param->real_keynr[key_part->key])) diff --git a/sql/set_var.h b/sql/set_var.h index 978aba3384a..968687ad382 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -607,7 +607,7 @@ public: { Item_field *item= (Item_field*) value_arg; if (!(value=new Item_string(item->field_name, strlen(item->field_name), - item->charset()))) + item->collation.collation))) value=value_arg; /* Give error message later */ } else diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index ced5993e293..a6c24a25d6e 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -326,9 +326,9 @@ void field_str::add() if (length > max_length) max_length = length; - if (sortcmp(res, &min_arg,item->charset()) < 0) + if (sortcmp(res, &min_arg,item->collation.collation) < 0) min_arg.copy(*res); - if (sortcmp(res, &max_arg,item->charset()) > 0) + if (sortcmp(res, &max_arg,item->collation.collation) > 0) max_arg.copy(*res); } @@ -736,7 +736,7 @@ void field_str::get_opt_type(String *answer, ha_rows total_rows) { if (must_be_blob) { - if (item->charset() == &my_charset_bin) + if (item->collation.collation == &my_charset_bin) answer->append("TINYBLOB", 8); else answer->append("TINYTEXT", 8); @@ -754,21 +754,21 @@ void field_str::get_opt_type(String *answer, ha_rows total_rows) } else if (max_length < (1L << 16)) { - if (item->charset() == &my_charset_bin) + if (item->collation.collation == &my_charset_bin) answer->append("BLOB", 4); else answer->append("TEXT", 4); } else if (max_length < (1L << 24)) { - if (item->charset() == &my_charset_bin) + if (item->collation.collation == &my_charset_bin) answer->append("MEDIUMBLOB", 10); else answer->append("MEDIUMTEXT", 10); } else { - if (item->charset() == &my_charset_bin) + if (item->collation.collation == &my_charset_bin) answer->append("LONGBLOB", 8); else answer->append("LONGTEXT", 8); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 7803e87572d..71c0d0bdddc 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -4229,9 +4229,9 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, case STRING_RESULT: if (item_sum->max_length > 255) return new Field_blob(item_sum->max_length,maybe_null, - item->name,table,item->charset()); + item->name,table,item->collation.collation); return new Field_string(item_sum->max_length,maybe_null, - item->name,table,item->charset()); + item->name,table,item->collation.collation); case ROW_RESULT: default: // This case should never be choosen @@ -4288,10 +4288,10 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, case STRING_RESULT: if (item->max_length > 255) new_field= new Field_blob(item->max_length,maybe_null, - item->name,table,item->charset()); + item->name,table,item->collation.collation); else new_field= new Field_string(item->max_length,maybe_null, - item->name,table,item->charset()); + item->name,table,item->collation.collation); break; case ROW_RESULT: default: |