Commit 60102e0f authored by unknown's avatar unknown

set_var.cc, set_var.h:

  New thread variable client_character_set


sql/set_var.h:
  New thread variable client_character_set
sql/set_var.cc:
  New thread variable client_character_set
parent 98e5fb01
...@@ -104,6 +104,7 @@ sys_var_str sys_charset("character_set", ...@@ -104,6 +104,7 @@ sys_var_str sys_charset("character_set",
sys_check_charset, sys_check_charset,
sys_update_charset, sys_update_charset,
sys_set_default_charset); sys_set_default_charset);
sys_var_thd_client_charset sys_client_charset("client_character_set");
sys_var_thd_conv_charset sys_convert_charset("convert_character_set"); sys_var_thd_conv_charset sys_convert_charset("convert_character_set");
sys_var_bool_ptr sys_concurrent_insert("concurrent_insert", sys_var_bool_ptr sys_concurrent_insert("concurrent_insert",
&myisam_concurrent_insert); &myisam_concurrent_insert);
...@@ -331,6 +332,7 @@ sys_var *sys_variables[]= ...@@ -331,6 +332,7 @@ sys_var *sys_variables[]=
&sys_binlog_cache_size, &sys_binlog_cache_size,
&sys_buffer_results, &sys_buffer_results,
&sys_bulk_insert_buff_size, &sys_bulk_insert_buff_size,
&sys_client_charset,
&sys_concurrent_insert, &sys_concurrent_insert,
&sys_connect_timeout, &sys_connect_timeout,
&sys_convert_charset, &sys_convert_charset,
...@@ -437,6 +439,7 @@ struct show_var_st init_vars[]= { ...@@ -437,6 +439,7 @@ struct show_var_st init_vars[]= {
{sys_bulk_insert_buff_size.name,(char*) &sys_bulk_insert_buff_size,SHOW_SYS}, {sys_bulk_insert_buff_size.name,(char*) &sys_bulk_insert_buff_size,SHOW_SYS},
{sys_charset.name, (char*) &sys_charset, SHOW_SYS}, {sys_charset.name, (char*) &sys_charset, SHOW_SYS},
{"character_sets", (char*) &charsets_list, SHOW_CHAR_PTR}, {"character_sets", (char*) &charsets_list, SHOW_CHAR_PTR},
{sys_client_charset.name, (char*) &sys_client_charset, SHOW_SYS},
{sys_concurrent_insert.name,(char*) &sys_concurrent_insert, SHOW_SYS}, {sys_concurrent_insert.name,(char*) &sys_concurrent_insert, SHOW_SYS},
{sys_connect_timeout.name, (char*) &sys_connect_timeout, SHOW_SYS}, {sys_connect_timeout.name, (char*) &sys_connect_timeout, SHOW_SYS},
{sys_convert_charset.name, (char*) &sys_convert_charset, SHOW_SYS}, {sys_convert_charset.name, (char*) &sys_convert_charset, SHOW_SYS},
...@@ -1174,6 +1177,55 @@ byte *sys_var_thd_conv_charset::value_ptr(THD *thd, enum_var_type type) ...@@ -1174,6 +1177,55 @@ byte *sys_var_thd_conv_charset::value_ptr(THD *thd, enum_var_type type)
} }
bool sys_var_thd_client_charset::check(THD *thd, set_var *var)
{
CHARSET_INFO *tmp;
char buff[80];
String str(buff,sizeof(buff), system_charset_info), *res;
if (!var->value) // Default value
{
var->save_result.charset= (var->type != OPT_GLOBAL ?
global_system_variables.thd_charset
: default_charset_info);
return 0;
}
if (!(res=var->value->val_str(&str)))
res= &empty_string;
if (!(tmp=get_charset_by_csname(res->c_ptr(),MYF(0))))
{
my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), res->c_ptr());
return 1;
}
var->save_result.charset= tmp; // Save for update
return 0;
}
bool sys_var_thd_client_charset::update(THD *thd, set_var *var)
{
if (var->type == OPT_GLOBAL)
global_system_variables.thd_charset= var->save_result.charset;
else
{
thd->variables.thd_charset= var->save_result.charset;
thd->protocol_simple.init(thd);
thd->protocol_prep.init(thd);
}
return 0;
}
byte *sys_var_thd_client_charset::value_ptr(THD *thd, enum_var_type type)
{
CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
global_system_variables.thd_charset :
thd->variables.thd_charset);
return cs ? (byte*) cs->csname : (byte*) "";
}
bool sys_var_timestamp::update(THD *thd, set_var *var) bool sys_var_timestamp::update(THD *thd, set_var *var)
{ {
......
...@@ -423,6 +423,22 @@ class sys_var_thd_conv_charset :public sys_var_thd ...@@ -423,6 +423,22 @@ class sys_var_thd_conv_charset :public sys_var_thd
bool check_default(enum_var_type type) { return 0; } bool check_default(enum_var_type type) { return 0; }
}; };
class sys_var_thd_client_charset :public sys_var_thd
{
public:
sys_var_thd_client_charset(const char *name_arg) :sys_var_thd(name_arg)
{}
bool check(THD *thd, set_var *var);
bool update(THD *thd, set_var *var);
SHOW_TYPE type() { return SHOW_CHAR; }
byte *value_ptr(THD *thd, enum_var_type type);
bool check_update_type(Item_result type)
{
return type != STRING_RESULT; /* Only accept strings */
}
bool check_default(enum_var_type type) { return 0; }
};
/* Variable that you can only read from */ /* Variable that you can only read from */
...@@ -473,6 +489,7 @@ class set_var :public set_var_base ...@@ -473,6 +489,7 @@ class set_var :public set_var_base
enum_var_type type; enum_var_type type;
union union
{ {
CHARSET_INFO *charset;
CONVERT *convert; CONVERT *convert;
ulong ulong_value; ulong ulong_value;
} save_result; } save_result;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment