Skip to content

Commit 77c75a4

Browse files
author
Alexander Barkov
committed
A clean-up patch for Item_func_conv_charset (needed for MDEV-9181)
Removing the "conv_charset" member and using collation.collation instead, as they duplicated each other.
1 parent 71b3906 commit 77c75a4

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

sql/item_strfunc.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3404,15 +3404,15 @@ String *Item_func_conv_charset::val_str(String *str)
34043404
String *arg= args[0]->val_str(str);
34053405
String_copier_for_item copier(current_thd);
34063406
return ((null_value= args[0]->null_value ||
3407-
copier.copy_with_warn(conv_charset, &tmp_value,
3407+
copier.copy_with_warn(collation.collation, &tmp_value,
34083408
arg->charset(), arg->ptr(),
34093409
arg->length(), arg->length()))) ?
34103410
0 : &tmp_value;
34113411
}
34123412

34133413
void Item_func_conv_charset::fix_length_and_dec()
34143414
{
3415-
collation.set(conv_charset, DERIVATION_IMPLICIT);
3415+
DBUG_ASSERT(collation.derivation == DERIVATION_IMPLICIT);
34163416
fix_char_length(args[0]->max_char_length());
34173417
}
34183418

@@ -3421,7 +3421,7 @@ void Item_func_conv_charset::print(String *str, enum_query_type query_type)
34213421
str->append(STRING_WITH_LEN("convert("));
34223422
args[0]->print(str, query_type);
34233423
str->append(STRING_WITH_LEN(" using "));
3424-
str->append(conv_charset->csname);
3424+
str->append(collation.collation->csname);
34253425
str->append(')');
34263426
}
34273427

sql/item_strfunc.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -959,20 +959,22 @@ class Item_func_conv_charset :public Item_str_func
959959
String tmp_value;
960960
public:
961961
bool safe;
962-
CHARSET_INFO *conv_charset; // keep it public
963962
Item_func_conv_charset(THD *thd, Item *a, CHARSET_INFO *cs):
964963
Item_str_func(thd, a)
965-
{ conv_charset= cs; use_cached_value= 0; safe= 0; }
964+
{
965+
collation.set(cs, DERIVATION_IMPLICIT);
966+
use_cached_value= 0; safe= 0;
967+
}
966968
Item_func_conv_charset(THD *thd, Item *a, CHARSET_INFO *cs, bool cache_if_const):
967969
Item_str_func(thd, a)
968970
{
969-
conv_charset= cs;
971+
collation.set(cs, DERIVATION_IMPLICIT);
970972
if (cache_if_const && args[0]->const_item() && !args[0]->is_expensive())
971973
{
972974
uint errors= 0;
973975
String tmp, *str= args[0]->val_str(&tmp);
974976
if (!str || str_value.copy(str->ptr(), str->length(),
975-
str->charset(), conv_charset, &errors))
977+
str->charset(), cs, &errors))
976978
null_value= 1;
977979
use_cached_value= 1;
978980
str_value.mark_as_const();

storage/spider/spd_db_mysql.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4041,7 +4041,7 @@ int spider_db_mysql_util::open_item_func(
40414041
{
40424042
Item_func_conv_charset *item_func_conv_charset =
40434043
(Item_func_conv_charset *)item_func;
4044-
CHARSET_INFO *conv_charset = item_func_conv_charset->conv_charset;
4044+
CHARSET_INFO *conv_charset = item_func_conv_charset->collation.collation;
40454045
uint cset_length = strlen(conv_charset->csname);
40464046
if (str->reserve(SPIDER_SQL_USING_LEN + cset_length))
40474047
DBUG_RETURN(HA_ERR_OUT_OF_MEM);

0 commit comments

Comments
 (0)