From e28a241907aa7a511b65b196703efaeea71e1dc4 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Wed, 18 Mar 2015 17:10:48 +0400 Subject: MDEV-7661 Unexpected result for: CAST(0xHHHH AS CHAR CHARACTER SET xxx) for incorrect byte sequences --- sql/item_strfunc.cc | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'sql/item_strfunc.cc') diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 54fc8d555c8..32b6d6348ac 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -3378,15 +3378,12 @@ String *Item_func_conv_charset::val_str(String *str) if (use_cached_value) return null_value ? 0 : &str_value; String *arg= args[0]->val_str(str); - uint dummy_errors; - if (args[0]->null_value) - { - null_value=1; - return 0; - } - null_value= tmp_value.copy(arg->ptr(), arg->length(), arg->charset(), - conv_charset, &dummy_errors); - return null_value ? 0 : check_well_formed_result(&tmp_value); + String_copier_for_item copier(current_thd); + return ((null_value= args[0]->null_value || + copier.copy_with_warn(conv_charset, &tmp_value, + arg->charset(), arg->ptr(), + arg->length(), arg->length()))) ? + 0 : &tmp_value; } void Item_func_conv_charset::fix_length_and_dec() -- cgit v1.2.1