@@ -4647,7 +4647,7 @@ user_var_entry *get_variable(HASH *hash, LEX_STRING &name,
46474647 entry->value =0 ;
46484648 entry->length =0 ;
46494649 entry->update_query_id =0 ;
4650- entry->collation . set (NULL , DERIVATION_IMPLICIT, 0 );
4650+ entry->set_charset (NULL );
46514651 entry->unsigned_flag = 0 ;
46524652 /*
46534653 If we are here, we were called from a SET or a query which sets a
@@ -4727,11 +4727,10 @@ bool Item_func_set_user_var::fix_fields(THD *thd, Item **ref)
47274727 and the variable has previously been initialized.
47284728 */
47294729 null_item= (args[0 ]->type () == NULL_ITEM);
4730- if (!entry->collation .collation || !null_item)
4731- entry->collation .set (args[0 ]->collation .derivation == DERIVATION_NUMERIC ?
4732- default_charset () : args[0 ]->collation .collation ,
4733- DERIVATION_IMPLICIT);
4734- collation.set (entry->collation .collation , DERIVATION_IMPLICIT);
4730+ if (!entry->charset () || !null_item)
4731+ entry->set_charset (args[0 ]->collation .derivation == DERIVATION_NUMERIC ?
4732+ default_charset () : args[0 ]->collation .collation );
4733+ collation.set (entry->charset (), DERIVATION_IMPLICIT);
47354734 cached_result_type= args[0 ]->result_type ();
47364735 if (thd->lex ->current_select )
47374736 {
@@ -4831,7 +4830,7 @@ bool Item_func_set_user_var::register_field_in_bitmap(uchar *arg)
48314830
48324831static bool
48334832update_hash (user_var_entry *entry, bool set_null, void *ptr, uint length,
4834- Item_result type, CHARSET_INFO *cs, Derivation dv,
4833+ Item_result type, CHARSET_INFO *cs,
48354834 bool unsigned_arg)
48364835{
48374836 if (set_null)
@@ -4882,7 +4881,7 @@ update_hash(user_var_entry *entry, bool set_null, void *ptr, uint length,
48824881 if (type == DECIMAL_RESULT)
48834882 ((my_decimal*)entry->value )->fix_buffer_pointer ();
48844883 entry->length = length;
4885- entry->collation . set (cs, dv );
4884+ entry->set_charset (cs);
48864885 entry->unsigned_flag = unsigned_arg;
48874886 }
48884887 entry->type =type;
@@ -4893,7 +4892,7 @@ update_hash(user_var_entry *entry, bool set_null, void *ptr, uint length,
48934892bool
48944893Item_func_set_user_var::update_hash (void *ptr, uint length,
48954894 Item_result res_type,
4896- CHARSET_INFO *cs, Derivation dv,
4895+ CHARSET_INFO *cs,
48974896 bool unsigned_arg)
48984897{
48994898 /*
@@ -4903,7 +4902,7 @@ Item_func_set_user_var::update_hash(void *ptr, uint length,
49034902 if ((null_value= args[0 ]->null_value ) && null_item)
49044903 res_type= entry->type ; // Don't change type of item
49054904 if (::update_hash (entry, (null_value= args[0 ]->null_value ),
4906- ptr, length, res_type, cs, dv, unsigned_arg))
4905+ ptr, length, res_type, cs, unsigned_arg))
49074906 {
49084907 null_value= 1 ;
49094908 return 1 ;
@@ -4983,19 +4982,19 @@ String *user_var_entry::val_str(bool *null_value, String *str,
49834982
49844983 switch (type) {
49854984 case REAL_RESULT:
4986- str->set_real (*(double *) value, decimals, collation. collation );
4985+ str->set_real (*(double *) value, decimals, charset () );
49874986 break ;
49884987 case INT_RESULT:
49894988 if (!unsigned_flag)
4990- str->set (*(longlong*) value, collation. collation );
4989+ str->set (*(longlong*) value, charset () );
49914990 else
4992- str->set (*(ulonglong*) value, collation. collation );
4991+ str->set (*(ulonglong*) value, charset () );
49934992 break ;
49944993 case DECIMAL_RESULT:
4995- str_set_decimal ((my_decimal *) value, str, collation. collation );
4994+ str_set_decimal ((my_decimal *) value, str, charset () );
49964995 break ;
49974996 case STRING_RESULT:
4998- if (str->copy (value, length, collation. collation ))
4997+ if (str->copy (value, length, charset () ))
49994998 str= 0 ;// EOM error
50004999 break ;
50015000 case ROW_RESULT:
@@ -5024,7 +5023,7 @@ my_decimal *user_var_entry::val_decimal(bool *null_value, my_decimal *val)
50245023 my_decimal2decimal ((my_decimal *) value, val);
50255024 break ;
50265025 case STRING_RESULT:
5027- str2my_decimal (E_DEC_FATAL_ERROR, value, length, collation. collation , val);
5026+ str2my_decimal (E_DEC_FATAL_ERROR, value, length, charset () , val);
50285027 break ;
50295028 case ROW_RESULT:
50305029 case TIME_RESULT:
@@ -5152,37 +5151,33 @@ Item_func_set_user_var::update()
51525151 case REAL_RESULT:
51535152 {
51545153 res= update_hash ((void *) &save_result.vreal ,sizeof (save_result.vreal ),
5155- REAL_RESULT, default_charset (), DERIVATION_IMPLICIT, 0 );
5154+ REAL_RESULT, default_charset (), 0 );
51565155 break ;
51575156 }
51585157 case INT_RESULT:
51595158 {
51605159 res= update_hash ((void *) &save_result.vint , sizeof (save_result.vint ),
5161- INT_RESULT, default_charset (), DERIVATION_IMPLICIT,
5162- unsigned_flag);
5160+ INT_RESULT, default_charset (), unsigned_flag);
51635161 break ;
51645162 }
51655163 case STRING_RESULT:
51665164 {
51675165 if (!save_result.vstr )// Null value
5168- res= update_hash ((void *) 0 , 0 , STRING_RESULT, &my_charset_bin,
5169- DERIVATION_IMPLICIT, 0 );
5166+ res= update_hash ((void *) 0 , 0 , STRING_RESULT, &my_charset_bin, 0 );
51705167 else
51715168 res= update_hash ((void *) save_result.vstr ->ptr (),
51725169 save_result.vstr ->length (), STRING_RESULT,
5173- save_result.vstr ->charset (),
5174- DERIVATION_IMPLICIT, 0 );
5170+ save_result.vstr ->charset (), 0 );
51755171 break ;
51765172 }
51775173 case DECIMAL_RESULT:
51785174 {
51795175 if (!save_result.vdec )// Null value
5180- res= update_hash ((void *) 0 , 0 , DECIMAL_RESULT, &my_charset_bin,
5181- DERIVATION_IMPLICIT, 0 );
5176+ res= update_hash ((void *) 0 , 0 , DECIMAL_RESULT, &my_charset_bin, 0 );
51825177 else
51835178 res= update_hash ((void *) save_result.vdec ,
51845179 sizeof (my_decimal), DECIMAL_RESULT,
5185- default_charset (), DERIVATION_IMPLICIT, 0 );
5180+ default_charset (), 0 );
51865181 break ;
51875182 }
51885183 case ROW_RESULT:
@@ -5576,7 +5571,7 @@ get_var_with_binlog(THD *thd, enum_sql_command sql_command,
55765571 ALIGN_SIZE (sizeof (BINLOG_USER_VAR_EVENT));
55775572 user_var_event->user_var_event = var_entry;
55785573 user_var_event->type = var_entry->type ;
5579- user_var_event->charset_number = var_entry->collation . collation ->number ;
5574+ user_var_event->charset_number = var_entry->charset () ->number ;
55805575 user_var_event->unsigned_flag = var_entry->unsigned_flag ;
55815576 if (!var_entry->value )
55825577 {
@@ -5624,7 +5619,7 @@ void Item_func_get_user_var::fix_length_and_dec()
56245619 unsigned_flag= var_entry->unsigned_flag ;
56255620 max_length= var_entry->length ;
56265621
5627- collation.set (var_entry->collation );
5622+ collation.set (var_entry->charset (), DERIVATION_IMPLICIT );
56285623 switch (m_cached_result_type) {
56295624 case REAL_RESULT:
56305625 fix_char_length (DBL_DIG + 8 );
@@ -5716,26 +5711,25 @@ bool Item_user_var_as_out_param::fix_fields(THD *thd, Item **ref)
57165711 of fields in LOAD DATA INFILE.
57175712 (Since Item_user_var_as_out_param is used only there).
57185713 */
5719- entry->collation . set (thd->lex ->exchange ->cs ?
5720- thd->lex ->exchange ->cs :
5721- thd->variables .collation_database );
5714+ entry->set_charset (thd->lex ->exchange ->cs ?
5715+ thd->lex ->exchange ->cs :
5716+ thd->variables .collation_database );
57225717 entry->update_query_id = thd->query_id ;
57235718 return FALSE ;
57245719}
57255720
57265721
57275722void Item_user_var_as_out_param::set_null_value (CHARSET_INFO* cs)
57285723{
5729- ::update_hash (entry, TRUE , 0 , 0 , STRING_RESULT, cs,
5730- DERIVATION_IMPLICIT, 0 /* unsigned_arg */ );
5724+ ::update_hash (entry, TRUE , 0 , 0 , STRING_RESULT, cs, 0 /* unsigned_arg */ );
57315725}
57325726
57335727
57345728void Item_user_var_as_out_param::set_value (const char *str, uint length,
57355729 CHARSET_INFO* cs)
57365730{
57375731 ::update_hash (entry, FALSE , (void *)str, length, STRING_RESULT, cs,
5738- DERIVATION_IMPLICIT, 0 /* unsigned_arg */ );
5732+ 0 /* unsigned_arg */ );
57395733}
57405734
57415735
0 commit comments