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