diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index dc9d57b1d9d..243f11db106 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1943,7 +1943,8 @@ void Item_func_conv_charset3::fix_length_and_dec() String *Item_func_set_collation::val_str(String *str) { str=args[0]->val_str(str); - null_value=args[0]->null_value; + if ((null_value=args[0]->null_value)) + return 0; str->set_charset(set_collation); return str; } @@ -1961,8 +1962,10 @@ bool Item_func_set_collation::fix_fields(THD *thd,struct st_table_list *tables, return 1; maybe_null=args[0]->maybe_null; binary=args[0]->binary; - const_item_cache=args[0]->const_item(); str_value.set_charset(set_collation); + with_sum_func= with_sum_func || args[0]->with_sum_func; + used_tables_cache=args[0]->used_tables(); + const_item_cache=args[0]->const_item(); fix_length_and_dec(); return 0; } @@ -1987,7 +1990,6 @@ bool Item_func_set_collation::eq(const Item *item, bool binary_cmp) const return 1; } - String *Item_func_charset::val_str(String *str) { String *res = args[0]->val_str(str); diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 997d9c8d834..af94e387717 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -504,10 +504,7 @@ public: bool fix_fields(THD *thd,struct st_table_list *tables, Item **ref); String *val_str(String *); void fix_length_and_dec() - { - max_length = args[0]->max_length; - str_value.set_charset(set_collation); - } + { max_length = args[0]->max_length; } bool eq(const Item *item, bool binary_cmp) const; const char *func_name() const { return "set_collation"; } };