mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 20:12:31 +01:00
User variables didn't store charset, so this didn't work
as expected and returned default charset instead: SET @x = _koi8_ru'test'; SELECT CHARSET(@x);
This commit is contained in:
parent
9564cd43d2
commit
0d2b6552b1
3 changed files with 11 additions and 6 deletions
|
@ -1801,7 +1801,8 @@ Item_func_set_user_var::fix_length_and_dec()
|
|||
}
|
||||
|
||||
void Item_func_set_user_var::update_hash(void *ptr, uint length,
|
||||
Item_result type)
|
||||
Item_result type,
|
||||
CHARSET_INFO *cs)
|
||||
{
|
||||
if ((null_value=args[0]->null_value))
|
||||
{
|
||||
|
@ -1810,6 +1811,7 @@ void Item_func_set_user_var::update_hash(void *ptr, uint length,
|
|||
my_free(entry->value,MYF(0));
|
||||
entry->value=0;
|
||||
entry->length=0;
|
||||
entry->var_charset=cs;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1840,6 +1842,7 @@ void Item_func_set_user_var::update_hash(void *ptr, uint length,
|
|||
memcpy(entry->value,ptr,length);
|
||||
entry->length= length;
|
||||
entry->type=type;
|
||||
entry->var_charset=cs;
|
||||
}
|
||||
return;
|
||||
|
||||
|
@ -1874,7 +1877,7 @@ double
|
|||
Item_func_set_user_var::val()
|
||||
{
|
||||
double value=args[0]->val();
|
||||
update_hash((void*) &value,sizeof(value), REAL_RESULT);
|
||||
update_hash((void*) &value,sizeof(value), REAL_RESULT, default_charset_info);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -1882,7 +1885,7 @@ longlong
|
|||
Item_func_set_user_var::val_int()
|
||||
{
|
||||
longlong value=args[0]->val_int();
|
||||
update_hash((void*) &value,sizeof(longlong),INT_RESULT);
|
||||
update_hash((void*) &value,sizeof(longlong),INT_RESULT, default_charset_info);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -1891,9 +1894,9 @@ Item_func_set_user_var::val_str(String *str)
|
|||
{
|
||||
String *res=args[0]->val_str(str);
|
||||
if (!res) // Null value
|
||||
update_hash((void*) 0,0,STRING_RESULT);
|
||||
update_hash((void*) 0,0,STRING_RESULT, default_charset_info);
|
||||
else
|
||||
update_hash(res->c_ptr(),res->length()+1,STRING_RESULT);
|
||||
update_hash(res->c_ptr(),res->length()+1,STRING_RESULT,res->charset());
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -1939,6 +1942,7 @@ Item_func_get_user_var::val_str(String *str)
|
|||
null_value=1;
|
||||
return NULL;
|
||||
}
|
||||
str->set_charset(entry->var_charset);
|
||||
break;
|
||||
}
|
||||
return str;
|
||||
|
|
|
@ -875,7 +875,7 @@ public:
|
|||
double val();
|
||||
longlong val_int();
|
||||
String *val_str(String *str);
|
||||
void update_hash(void *ptr, uint length, enum Item_result type);
|
||||
void update_hash(void *ptr, uint length, enum Item_result type, CHARSET_INFO *cs);
|
||||
bool update();
|
||||
enum Item_result result_type () const { return cached_result_type; }
|
||||
bool fix_fields(THD *thd, struct st_table_list *tables, Item **ref);
|
||||
|
|
|
@ -830,6 +830,7 @@ class user_var_entry
|
|||
char *value;
|
||||
ulong length, update_query_id;
|
||||
Item_result type;
|
||||
CHARSET_INFO *var_charset;
|
||||
};
|
||||
|
||||
/* Class for unique (removing of duplicates) */
|
||||
|
|
Loading…
Reference in a new issue