Commit 45329852 authored by bar@bar.mysql.r18.ru's avatar bar@bar.mysql.r18.ru

New variable to turn off automatic charset conversion of query results

Some speed improvements
parent 9617ba2b
...@@ -4551,6 +4551,7 @@ static void set_options(void) ...@@ -4551,6 +4551,7 @@ static void set_options(void)
sizeof(mysql_real_data_home)-1); sizeof(mysql_real_data_home)-1);
/* Set default values for some variables */ /* Set default values for some variables */
global_system_variables.convert_result_charset= TRUE;
global_system_variables.table_type= DB_TYPE_MYISAM; global_system_variables.table_type= DB_TYPE_MYISAM;
global_system_variables.tx_isolation= ISO_REPEATABLE_READ; global_system_variables.tx_isolation= ISO_REPEATABLE_READ;
global_system_variables.select_limit= (ulonglong) HA_POS_ERROR; global_system_variables.select_limit= (ulonglong) HA_POS_ERROR;
......
...@@ -703,11 +703,13 @@ bool Protocol_simple::store(const char *from, uint length, CHARSET_INFO *cs) ...@@ -703,11 +703,13 @@ bool Protocol_simple::store(const char *from, uint length, CHARSET_INFO *cs)
field_types[field_pos] <= MYSQL_TYPE_GEOMETRY)); field_types[field_pos] <= MYSQL_TYPE_GEOMETRY));
field_pos++; field_pos++;
#endif #endif
if (cs != this->thd->charset()) if (!my_charset_same(cs, this->thd->charset()) &&
(cs != &my_charset_bin) &&
(this->thd->charset() != &my_charset_bin) &&
(this->thd->variables.convert_result_charset))
{ {
String tmp; convert.copy(from, length, cs, this->thd->charset());
tmp.copy(from, length, cs, this->thd->charset()); return net_store_data(convert.ptr(), convert.length());
return net_store_data(tmp.ptr(), tmp.length());
} }
else else
return net_store_data(from, length); return net_store_data(from, length);
...@@ -800,16 +802,18 @@ bool Protocol_simple::store(Field *field) ...@@ -800,16 +802,18 @@ bool Protocol_simple::store(Field *field)
field_pos++; field_pos++;
#endif #endif
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String tmp1(buff,sizeof(buff), &my_charset_bin); String str(buff,sizeof(buff), &my_charset_bin);
field->val_str(&tmp1,&tmp1); field->val_str(&str,&str);
if (field->charset() != this->thd->charset()) if (!my_charset_same(field->charset(), this->thd->charset()) &&
(field->charset() != &my_charset_bin) &&
(this->thd->charset() != &my_charset_bin) &&
(this->thd->variables.convert_result_charset))
{ {
String tmp; convert.copy(str.ptr(), str.length(), str.charset(), this->thd->charset());
tmp.copy(tmp1.ptr(), tmp1.length(), tmp1.charset(), this->thd->charset()); return net_store_data(convert.ptr(), convert.length());
return net_store_data(tmp.ptr(), tmp.length());
} }
else else
return net_store_data(tmp1.ptr(), tmp1.length()); return net_store_data(str.ptr(), str.length());
} }
......
...@@ -30,6 +30,7 @@ class Protocol ...@@ -30,6 +30,7 @@ class Protocol
protected: protected:
THD *thd; THD *thd;
String *packet; String *packet;
String convert;
uint field_pos; uint field_pos;
#ifndef DEBUG_OFF #ifndef DEBUG_OFF
enum enum_field_types *field_types; enum enum_field_types *field_types;
...@@ -44,6 +45,7 @@ protected: ...@@ -44,6 +45,7 @@ protected:
public: public:
Protocol() {} Protocol() {}
Protocol(THD *thd) { init(thd); } Protocol(THD *thd) { init(thd); }
virtual ~Protocol() {}
void init(THD* thd); void init(THD* thd);
bool send_fields(List<Item> *list, uint flag); bool send_fields(List<Item> *list, uint flag);
bool send_records_num(List<Item> *list, ulonglong records); bool send_records_num(List<Item> *list, ulonglong records);
......
...@@ -109,6 +109,8 @@ sys_var_bool_ptr sys_concurrent_insert("concurrent_insert", ...@@ -109,6 +109,8 @@ sys_var_bool_ptr sys_concurrent_insert("concurrent_insert",
&myisam_concurrent_insert); &myisam_concurrent_insert);
sys_var_long_ptr sys_connect_timeout("connect_timeout", sys_var_long_ptr sys_connect_timeout("connect_timeout",
&connect_timeout); &connect_timeout);
sys_var_thd_bool sys_convert_result_charset("convert_result_charset",
&SV::convert_result_charset);
sys_var_enum sys_delay_key_write("delay_key_write", sys_var_enum sys_delay_key_write("delay_key_write",
&delay_key_write_options, &delay_key_write_options,
&delay_key_write_typelib, &delay_key_write_typelib,
...@@ -337,6 +339,7 @@ sys_var *sys_variables[]= ...@@ -337,6 +339,7 @@ sys_var *sys_variables[]=
&sys_client_collation, &sys_client_collation,
&sys_concurrent_insert, &sys_concurrent_insert,
&sys_connect_timeout, &sys_connect_timeout,
&sys_convert_result_charset,
&sys_default_week_format, &sys_default_week_format,
&sys_delay_key_write, &sys_delay_key_write,
&sys_delayed_insert_limit, &sys_delayed_insert_limit,
...@@ -445,6 +448,7 @@ struct show_var_st init_vars[]= { ...@@ -445,6 +448,7 @@ struct show_var_st init_vars[]= {
{sys_client_collation.name, (char*) &sys_client_collation, SHOW_SYS}, {sys_client_collation.name, (char*) &sys_client_collation, 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_result_charset.name, (char*) &sys_convert_result_charset, SHOW_SYS},
{"datadir", mysql_real_data_home, SHOW_CHAR}, {"datadir", mysql_real_data_home, SHOW_CHAR},
{"default_week_format", (char*) &sys_default_week_format, SHOW_SYS}, {"default_week_format", (char*) &sys_default_week_format, SHOW_SYS},
{sys_delay_key_write.name, (char*) &sys_delay_key_write, SHOW_SYS}, {sys_delay_key_write.name, (char*) &sys_delay_key_write, SHOW_SYS},
...@@ -1455,7 +1459,6 @@ void set_var_init() ...@@ -1455,7 +1459,6 @@ void set_var_init()
(*var)->option_limits= find_option(my_long_options, (*var)->name); (*var)->option_limits= find_option(my_long_options, (*var)->name);
hash_insert(&system_variable_hash, (byte*) *var); hash_insert(&system_variable_hash, (byte*) *var);
} }
/* /*
Special cases Special cases
Needed because MySQL can't find the limits for a variable it it has Needed because MySQL can't find the limits for a variable it it has
......
...@@ -374,6 +374,7 @@ struct system_variables ...@@ -374,6 +374,7 @@ struct system_variables
my_bool log_warnings; my_bool log_warnings;
my_bool low_priority_updates; my_bool low_priority_updates;
my_bool new_mode; my_bool new_mode;
my_bool convert_result_charset;
CHARSET_INFO *thd_charset; CHARSET_INFO *thd_charset;
}; };
......
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