mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03: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:
@ -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,
|
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))
|
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));
|
my_free(entry->value,MYF(0));
|
||||||
entry->value=0;
|
entry->value=0;
|
||||||
entry->length=0;
|
entry->length=0;
|
||||||
|
entry->var_charset=cs;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1840,6 +1842,7 @@ void Item_func_set_user_var::update_hash(void *ptr, uint length,
|
|||||||
memcpy(entry->value,ptr,length);
|
memcpy(entry->value,ptr,length);
|
||||||
entry->length= length;
|
entry->length= length;
|
||||||
entry->type=type;
|
entry->type=type;
|
||||||
|
entry->var_charset=cs;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1874,7 +1877,7 @@ double
|
|||||||
Item_func_set_user_var::val()
|
Item_func_set_user_var::val()
|
||||||
{
|
{
|
||||||
double value=args[0]->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;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1882,7 +1885,7 @@ longlong
|
|||||||
Item_func_set_user_var::val_int()
|
Item_func_set_user_var::val_int()
|
||||||
{
|
{
|
||||||
longlong value=args[0]->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;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1891,9 +1894,9 @@ Item_func_set_user_var::val_str(String *str)
|
|||||||
{
|
{
|
||||||
String *res=args[0]->val_str(str);
|
String *res=args[0]->val_str(str);
|
||||||
if (!res) // Null value
|
if (!res) // Null value
|
||||||
update_hash((void*) 0,0,STRING_RESULT);
|
update_hash((void*) 0,0,STRING_RESULT, default_charset_info);
|
||||||
else
|
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;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1939,6 +1942,7 @@ Item_func_get_user_var::val_str(String *str)
|
|||||||
null_value=1;
|
null_value=1;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
str->set_charset(entry->var_charset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
|
@ -875,7 +875,7 @@ public:
|
|||||||
double val();
|
double val();
|
||||||
longlong val_int();
|
longlong val_int();
|
||||||
String *val_str(String *str);
|
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();
|
bool update();
|
||||||
enum Item_result result_type () const { return cached_result_type; }
|
enum Item_result result_type () const { return cached_result_type; }
|
||||||
bool fix_fields(THD *thd, struct st_table_list *tables, Item **ref);
|
bool fix_fields(THD *thd, struct st_table_list *tables, Item **ref);
|
||||||
|
@ -830,6 +830,7 @@ class user_var_entry
|
|||||||
char *value;
|
char *value;
|
||||||
ulong length, update_query_id;
|
ulong length, update_query_id;
|
||||||
Item_result type;
|
Item_result type;
|
||||||
|
CHARSET_INFO *var_charset;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Class for unique (removing of duplicates) */
|
/* Class for unique (removing of duplicates) */
|
||||||
|
Reference in New Issue
Block a user