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

Use of CHARSWT_INFO *result_collation

instead of bool convert_result_charset
SET CHARACTER SET inststead of SET NAMES in tests
parent 2cdc21d2
...@@ -510,11 +510,11 @@ t1 CREATE TABLE `t1` ( ...@@ -510,11 +510,11 @@ t1 CREATE TABLE `t1` (
SHOW FIELDS FROM t1; SHOW FIELDS FROM t1;
Field Type Collation Null Key Default Extra Field Type Collation Null Key Default Extra
latin1_f char(32) latin1_bin YES NULL latin1_f char(32) latin1_bin YES NULL
SET NAMES 'latin1'; SET CHARACTER SET 'latin1';
SHOW VARIABLES LIKE 'client_collation'; SHOW VARIABLES LIKE 'client_collation';
Variable_name Value Variable_name Value
client_collation latin1_swedish_ci client_collation latin1_swedish_ci
SET NAMES latin1; SET CHARACTER SET latin1;
SHOW VARIABLES LIKE 'client_collation'; SHOW VARIABLES LIKE 'client_collation';
Variable_name Value Variable_name Value
client_collation latin1_swedish_ci client_collation latin1_swedish_ci
...@@ -524,51 +524,51 @@ client_collation latin1_swedish_ci ...@@ -524,51 +524,51 @@ client_collation latin1_swedish_ci
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
charset('a') collation('a') coercibility('a') 'a'='A' charset('a') collation('a') coercibility('a') 'a'='A'
latin1 latin1_swedish_ci 3 1 latin1 latin1_swedish_ci 3 1
SET NAMES latin1 COLLATE latin1_bin; SET CHARACTER SET latin1 COLLATE latin1_bin;
SHOW VARIABLES LIKE 'client_collation'; SHOW VARIABLES LIKE 'client_collation';
Variable_name Value Variable_name Value
client_collation latin1_bin client_collation latin1_bin
SET NAMES LATIN1 COLLATE Latin1_Bin; SET CHARACTER SET LATIN1 COLLATE Latin1_Bin;
SHOW VARIABLES LIKE 'client_collation'; SHOW VARIABLES LIKE 'client_collation';
Variable_name Value Variable_name Value
client_collation latin1_bin client_collation latin1_bin
SET NAMES 'latin1' COLLATE 'latin1_bin'; SET CHARACTER SET 'latin1' COLLATE 'latin1_bin';
SHOW VARIABLES LIKE 'client_collation'; SHOW VARIABLES LIKE 'client_collation';
Variable_name Value Variable_name Value
client_collation latin1_bin client_collation latin1_bin
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
charset('a') collation('a') coercibility('a') 'a'='A' charset('a') collation('a') coercibility('a') 'a'='A'
latin1 latin1_bin 3 0 latin1 latin1_swedish_ci 3 1
SET NAMES koi8r; SET CHARACTER SET koi8r;
SHOW VARIABLES LIKE 'client_collation'; SHOW VARIABLES LIKE 'client_collation';
Variable_name Value Variable_name Value
client_collation koi8r_general_ci client_collation koi8r_general_ci
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
charset('a') collation('a') coercibility('a') 'a'='A' charset('a') collation('a') coercibility('a') 'a'='A'
latin1 latin1_swedish_ci 3 1 latin1 latin1_swedish_ci 3 1
SET NAMES koi8r COLLATE koi8r_bin; SET CHARACTER SET koi8r COLLATE koi8r_bin;
SHOW VARIABLES LIKE 'client_collation'; SHOW VARIABLES LIKE 'client_collation';
Variable_name Value Variable_name Value
client_collation koi8r_bin client_collation koi8r_bin
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
charset('a') collation('a') coercibility('a') 'a'='A' charset('a') collation('a') coercibility('a') 'a'='A'
latin1 latin1_swedish_ci 3 1 latin1 latin1_swedish_ci 3 1
SET NAMES koi8r COLLATE DEFAULT; SET CHARACTER SET koi8r COLLATE DEFAULT;
SHOW VARIABLES LIKE 'client_collation'; SHOW VARIABLES LIKE 'client_collation';
Variable_name Value Variable_name Value
client_collation koi8r_general_ci client_collation koi8r_general_ci
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
charset('a') collation('a') coercibility('a') 'a'='A' charset('a') collation('a') coercibility('a') 'a'='A'
latin1 latin1_swedish_ci 3 1 latin1 latin1_swedish_ci 3 1
SET NAMES DEFAULT; SET CHARACTER SET DEFAULT;
SHOW VARIABLES LIKE 'client_collation'; SHOW VARIABLES LIKE 'client_collation';
Variable_name Value Variable_name Value
client_collation latin1_swedish_ci client_collation latin1_swedish_ci
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
charset('a') collation('a') coercibility('a') 'a'='A' charset('a') collation('a') coercibility('a') 'a'='A'
latin1 latin1_swedish_ci 3 1 latin1 latin1_swedish_ci 3 1
SET NAMES latin1 COLLATE koi8r; SET CHARACTER SET latin1 COLLATE koi8r;
COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1' COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1'
SET NAMES 'DEFAULT'; SET CHARACTER SET 'DEFAULT';
Unknown character set: 'DEFAULT' Unknown character set: 'DEFAULT'
DROP TABLE t1; DROP TABLE t1;
SET NAMES koi8r; SET CHARACTER SET koi8r;
DROP TABLE IF EXISTS ; DROP TABLE IF EXISTS ;
CREATE TABLE CREATE TABLE
( (
...@@ -6,15 +6,15 @@ CREATE TABLE ...@@ -6,15 +6,15 @@ CREATE TABLE
); );
SHOW TABLES; SHOW TABLES;
Tables_in_test Tables_in_test
таблица
SHOW CREATE TABLE ; SHOW CREATE TABLE ;
Table Create Table Table Create Table
таблица CREATE TABLE `таблица` ( CREATE TABLE `` (
`поле` char(32) character set koi8r NOT NULL default '' `` char(32) character set koi8r NOT NULL default ''
) TYPE=MyISAM CHARSET=latin1 ) TYPE=MyISAM CHARSET=latin1
SHOW FIELDS FROM ; SHOW FIELDS FROM ;
Field Type Collation Null Key Default Extra Field Type Collation Null Key Default Extra
поле char(32) character set koi8r koi8r_general_ci char(32) character set koi8r koi8r_general_ci
SET CHARACTER SET cp1251; SET CHARACTER SET cp1251;
SHOW TABLES; SHOW TABLES;
Tables_in_test Tables_in_test
......
...@@ -127,35 +127,35 @@ ALTER TABLE t1 CHARACTER SET latin1 COLLATE latin1_bin; ...@@ -127,35 +127,35 @@ ALTER TABLE t1 CHARACTER SET latin1 COLLATE latin1_bin;
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
SHOW FIELDS FROM t1; SHOW FIELDS FROM t1;
SET NAMES 'latin1'; SET CHARACTER SET 'latin1';
SHOW VARIABLES LIKE 'client_collation'; SHOW VARIABLES LIKE 'client_collation';
SET NAMES latin1; SET CHARACTER SET latin1;
SHOW VARIABLES LIKE 'client_collation'; SHOW VARIABLES LIKE 'client_collation';
SHOW VARIABLES LIKE 'client_collation'; SHOW VARIABLES LIKE 'client_collation';
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
SET NAMES latin1 COLLATE latin1_bin; SET CHARACTER SET latin1 COLLATE latin1_bin;
SHOW VARIABLES LIKE 'client_collation'; SHOW VARIABLES LIKE 'client_collation';
SET NAMES LATIN1 COLLATE Latin1_Bin; SET CHARACTER SET LATIN1 COLLATE Latin1_Bin;
SHOW VARIABLES LIKE 'client_collation'; SHOW VARIABLES LIKE 'client_collation';
SET NAMES 'latin1' COLLATE 'latin1_bin'; SET CHARACTER SET 'latin1' COLLATE 'latin1_bin';
SHOW VARIABLES LIKE 'client_collation'; SHOW VARIABLES LIKE 'client_collation';
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
SET NAMES koi8r; SET CHARACTER SET koi8r;
SHOW VARIABLES LIKE 'client_collation'; SHOW VARIABLES LIKE 'client_collation';
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
SET NAMES koi8r COLLATE koi8r_bin; SET CHARACTER SET koi8r COLLATE koi8r_bin;
SHOW VARIABLES LIKE 'client_collation'; SHOW VARIABLES LIKE 'client_collation';
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
SET NAMES koi8r COLLATE DEFAULT; SET CHARACTER SET koi8r COLLATE DEFAULT;
SHOW VARIABLES LIKE 'client_collation'; SHOW VARIABLES LIKE 'client_collation';
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
SET NAMES DEFAULT; SET CHARACTER SET DEFAULT;
SHOW VARIABLES LIKE 'client_collation'; SHOW VARIABLES LIKE 'client_collation';
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
--error 1251 --error 1251
SET NAMES latin1 COLLATE koi8r; SET CHARACTER SET latin1 COLLATE koi8r;
--error 1115 --error 1115
SET NAMES 'DEFAULT'; SET CHARACTER SET 'DEFAULT';
DROP TABLE t1; DROP TABLE t1;
SET NAMES koi8r; SET CHARACTER SET koi8r;
--disable_warnings --disable_warnings
DROP TABLE IF EXISTS ; DROP TABLE IF EXISTS ;
......
...@@ -2087,6 +2087,10 @@ static int init_common_variables(const char *conf_file_name, int argc, ...@@ -2087,6 +2087,10 @@ static int init_common_variables(const char *conf_file_name, int argc,
#endif #endif
if (!(default_charset_info= get_charset_by_name(sys_charset.value, MYF(MY_WME)))) if (!(default_charset_info= get_charset_by_name(sys_charset.value, MYF(MY_WME))))
return 1; return 1;
global_system_variables.result_collation= default_charset_info;
global_system_variables.client_collation= default_charset_info;
global_system_variables.literal_collation= default_charset_info;
charsets_list= list_charsets(MYF(MY_CS_COMPILED | MY_CS_CONFIG)); charsets_list= list_charsets(MYF(MY_CS_COMPILED | MY_CS_CONFIG));
if (use_temp_pool && bitmap_init(&temp_pool,1024,1)) if (use_temp_pool && bitmap_init(&temp_pool,1024,1))
...@@ -4566,7 +4570,7 @@ static void set_options(void) ...@@ -4566,7 +4570,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.result_collation= default_charset_info;
global_system_variables.client_collation= default_charset_info; global_system_variables.client_collation= default_charset_info;
global_system_variables.literal_collation= default_charset_info; global_system_variables.literal_collation= default_charset_info;
global_system_variables.table_type= DB_TYPE_MYISAM; global_system_variables.table_type= DB_TYPE_MYISAM;
......
...@@ -724,7 +724,7 @@ bool Protocol_simple::store(const char *from, uint length, ...@@ -724,7 +724,7 @@ bool Protocol_simple::store(const char *from, uint length,
bool Protocol_simple::store(const char *from, uint length, bool Protocol_simple::store(const char *from, uint length,
CHARSET_INFO *fromcs) CHARSET_INFO *fromcs)
{ {
CHARSET_INFO *tocs= this->thd->result_charset(fromcs); CHARSET_INFO *tocs= this->thd->variables.result_collation;
#ifndef DEBUG_OFF #ifndef DEBUG_OFF
DBUG_ASSERT(field_types == 0 || DBUG_ASSERT(field_types == 0 ||
field_types[field_pos] == MYSQL_TYPE_DECIMAL || field_types[field_pos] == MYSQL_TYPE_DECIMAL ||
...@@ -834,8 +834,7 @@ bool Protocol_simple::store(Field *field) ...@@ -834,8 +834,7 @@ bool Protocol_simple::store(Field *field)
field->val_str(&str,&str); field->val_str(&str,&str);
if (!my_charset_same(field->charset(), this->thd->charset()) && if (!my_charset_same(field->charset(), this->thd->charset()) &&
(field->charset() != &my_charset_bin) && (field->charset() != &my_charset_bin) &&
(this->thd->charset() != &my_charset_bin) && (this->thd->charset() != &my_charset_bin))
(this->thd->variables.convert_result_charset))
{ {
convert.copy(str.ptr(), str.length(), str.charset(), this->thd->charset()); convert.copy(str.ptr(), str.length(), str.charset(), this->thd->charset());
return net_store_data(convert.ptr(), convert.length()); return net_store_data(convert.ptr(), convert.length());
......
...@@ -110,8 +110,6 @@ sys_var_bool_ptr sys_concurrent_insert("concurrent_insert", ...@@ -110,8 +110,6 @@ 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,
...@@ -202,6 +200,7 @@ sys_var_thd_ulong sys_read_buff_size("read_buffer_size", ...@@ -202,6 +200,7 @@ sys_var_thd_ulong sys_read_buff_size("read_buffer_size",
&SV::read_buff_size); &SV::read_buff_size);
sys_var_thd_ulong sys_read_rnd_buff_size("read_rnd_buffer_size", sys_var_thd_ulong sys_read_rnd_buff_size("read_rnd_buffer_size",
&SV::read_rnd_buff_size); &SV::read_rnd_buff_size);
sys_var_result_collation sys_result_collation("result_collation");
sys_var_long_ptr sys_rpl_recovery_rank("rpl_recovery_rank", sys_var_long_ptr sys_rpl_recovery_rank("rpl_recovery_rank",
&rpl_recovery_rank); &rpl_recovery_rank);
sys_var_long_ptr sys_query_cache_size("query_cache_size", sys_var_long_ptr sys_query_cache_size("query_cache_size",
...@@ -347,7 +346,6 @@ sys_var *sys_variables[]= ...@@ -347,7 +346,6 @@ 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,
...@@ -408,6 +406,7 @@ sys_var *sys_variables[]= ...@@ -408,6 +406,7 @@ sys_var *sys_variables[]=
&sys_rand_seed2, &sys_rand_seed2,
&sys_read_buff_size, &sys_read_buff_size,
&sys_read_rnd_buff_size, &sys_read_rnd_buff_size,
&sys_result_collation,
&sys_rpl_recovery_rank, &sys_rpl_recovery_rank,
&sys_safe_updates, &sys_safe_updates,
&sys_select_limit, &sys_select_limit,
...@@ -459,7 +458,6 @@ struct show_var_st init_vars[]= { ...@@ -459,7 +458,6 @@ 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},
...@@ -563,6 +561,7 @@ struct show_var_st init_vars[]= { ...@@ -563,6 +561,7 @@ struct show_var_st init_vars[]= {
{sys_pseudo_thread_id.name, (char*) &sys_pseudo_thread_id, SHOW_SYS}, {sys_pseudo_thread_id.name, (char*) &sys_pseudo_thread_id, SHOW_SYS},
{sys_read_buff_size.name, (char*) &sys_read_buff_size, SHOW_SYS}, {sys_read_buff_size.name, (char*) &sys_read_buff_size, SHOW_SYS},
{sys_read_rnd_buff_size.name,(char*) &sys_read_rnd_buff_size, SHOW_SYS}, {sys_read_rnd_buff_size.name,(char*) &sys_read_rnd_buff_size, SHOW_SYS},
{sys_result_collation.name, (char*) &sys_result_collation, SHOW_SYS},
{sys_rpl_recovery_rank.name,(char*) &sys_rpl_recovery_rank, SHOW_SYS}, {sys_rpl_recovery_rank.name,(char*) &sys_rpl_recovery_rank, SHOW_SYS},
#ifdef HAVE_QUERY_CACHE #ifdef HAVE_QUERY_CACHE
{sys_query_cache_limit.name,(char*) &sys_query_cache_limit, SHOW_SYS}, {sys_query_cache_limit.name,(char*) &sys_query_cache_limit, SHOW_SYS},
...@@ -1267,6 +1266,31 @@ void sys_var_literal_collation::set_default(THD *thd, enum_var_type type) ...@@ -1267,6 +1266,31 @@ void sys_var_literal_collation::set_default(THD *thd, enum_var_type type)
thd->variables.literal_collation= global_system_variables.literal_collation; thd->variables.literal_collation= global_system_variables.literal_collation;
} }
bool sys_var_result_collation::update(THD *thd, set_var *var)
{
if (var->type == OPT_GLOBAL)
global_system_variables.result_collation= var->save_result.charset;
else
thd->variables.result_collation= var->save_result.charset;
return 0;
}
byte *sys_var_result_collation::value_ptr(THD *thd, enum_var_type type)
{
CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
global_system_variables.result_collation :
thd->variables.result_collation);
return cs ? (byte*) cs->name : (byte*) "";
}
void sys_var_result_collation::set_default(THD *thd, enum_var_type type)
{
if (type == OPT_GLOBAL)
global_system_variables.result_collation= default_charset_info;
else
thd->variables.result_collation= global_system_variables.result_collation;
}
/***************************************************************************** /*****************************************************************************
Functions to handle SET NAMES and SET CHARACTER SET Functions to handle SET NAMES and SET CHARACTER SET
...@@ -1274,24 +1298,14 @@ void sys_var_literal_collation::set_default(THD *thd, enum_var_type type) ...@@ -1274,24 +1298,14 @@ void sys_var_literal_collation::set_default(THD *thd, enum_var_type type)
int set_var_client_collation::check(THD *thd) int set_var_client_collation::check(THD *thd)
{ {
client_charset= client_charset ?
client_charset : global_system_variables.client_collation;
client_collation= client_collation ? client_collation : client_charset;
if (!my_charset_same(client_charset, client_collation))
{
my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0),
client_collation->name, client_charset->csname);
return -1;
}
return 0; return 0;
} }
int set_var_client_collation::update(THD *thd) int set_var_client_collation::update(THD *thd)
{ {
thd->variables.client_collation= client_collation; thd->variables.client_collation= client_collation;
thd->variables.literal_collation= convert_result_charset ? thd->variables.literal_collation= literal_collation;
thd->db_charset: client_collation; thd->variables.result_collation= result_collation;
thd->variables.convert_result_charset= convert_result_charset;
thd->protocol_simple.init(thd); thd->protocol_simple.init(thd);
thd->protocol_prep.init(thd); thd->protocol_prep.init(thd);
return 0; return 0;
......
...@@ -438,6 +438,15 @@ class sys_var_literal_collation :public sys_var_collation ...@@ -438,6 +438,15 @@ class sys_var_literal_collation :public sys_var_collation
byte *value_ptr(THD *thd, enum_var_type type); byte *value_ptr(THD *thd, enum_var_type type);
}; };
class sys_var_result_collation :public sys_var_collation
{
public:
sys_var_result_collation(const char *name_arg) :sys_var_collation(name_arg) {}
bool update(THD *thd, set_var *var);
void set_default(THD *thd, enum_var_type type);
byte *value_ptr(THD *thd, enum_var_type type);
};
/* Variable that you can only read from */ /* Variable that you can only read from */
...@@ -546,14 +555,16 @@ class set_var_password: public set_var_base ...@@ -546,14 +555,16 @@ class set_var_password: public set_var_base
class set_var_client_collation: public set_var_base class set_var_client_collation: public set_var_base
{ {
CHARSET_INFO *client_charset;
CHARSET_INFO *client_collation; CHARSET_INFO *client_collation;
my_bool convert_result_charset; CHARSET_INFO *literal_collation;
CHARSET_INFO *result_collation;
public: public:
set_var_client_collation(CHARSET_INFO *cset_arg, set_var_client_collation(CHARSET_INFO *client_coll_arg,
CHARSET_INFO *coll_arg ,my_bool conv_arg) CHARSET_INFO *literal_coll_arg,
:client_charset(cset_arg), client_collation(coll_arg), CHARSET_INFO *result_coll_arg)
convert_result_charset(conv_arg) :client_collation(client_coll_arg),
literal_collation(literal_coll_arg),
result_collation(result_coll_arg)
{} {}
int check(THD *thd); int check(THD *thd);
int update(THD *thd); int update(THD *thd);
......
...@@ -378,10 +378,10 @@ struct system_variables ...@@ -378,10 +378,10 @@ 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 *client_collation; CHARSET_INFO *client_collation;
CHARSET_INFO *literal_collation; CHARSET_INFO *literal_collation;
CHARSET_INFO *result_collation;
}; };
void free_tmp_table(THD *thd, TABLE *entry); void free_tmp_table(THD *thd, TABLE *entry);
...@@ -663,8 +663,6 @@ class THD :public ilink ...@@ -663,8 +663,6 @@ class THD :public ilink
DBUG_PRINT("error",("Fatal error set")); DBUG_PRINT("error",("Fatal error set"));
} }
inline CHARSET_INFO *charset() { return variables.client_collation; } inline CHARSET_INFO *charset() { return variables.client_collation; }
inline CHARSET_INFO *result_charset(CHARSET_INFO *cs)
{ return variables.convert_result_charset ? charset() : cs; }
}; };
/* /*
......
...@@ -563,7 +563,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); ...@@ -563,7 +563,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%type <lex_str> %type <lex_str>
IDENT TEXT_STRING REAL_NUM FLOAT_NUM NUM LONG_NUM HEX_NUM LEX_HOSTNAME IDENT TEXT_STRING REAL_NUM FLOAT_NUM NUM LONG_NUM HEX_NUM LEX_HOSTNAME
ULONGLONG_NUM field_ident select_alias ident ident_or_text ULONGLONG_NUM field_ident select_alias ident ident_or_text
UNDERSCORE_CHARSET IDENT_sys TEXT_STRING_sys TEXT_STRING_db UNDERSCORE_CHARSET IDENT_sys TEXT_STRING_sys TEXT_STRING_literal
NCHAR_STRING NCHAR_STRING
%type <lex_str_ptr> %type <lex_str_ptr>
...@@ -2279,9 +2279,9 @@ simple_expr: ...@@ -2279,9 +2279,9 @@ simple_expr:
Lex->uncacheable();; Lex->uncacheable();;
} }
| ENCRYPT '(' expr ',' expr ')' { $$= new Item_func_encrypt($3,$5); } | ENCRYPT '(' expr ',' expr ')' { $$= new Item_func_encrypt($3,$5); }
| DECODE_SYM '(' expr ',' TEXT_STRING_db ')' | DECODE_SYM '(' expr ',' TEXT_STRING_literal ')'
{ $$= new Item_func_decode($3,$5.str); } { $$= new Item_func_decode($3,$5.str); }
| ENCODE_SYM '(' expr ',' TEXT_STRING_db ')' | ENCODE_SYM '(' expr ',' TEXT_STRING_literal ')'
{ $$= new Item_func_encode($3,$5.str); } { $$= new Item_func_encode($3,$5.str); }
| DES_DECRYPT_SYM '(' expr ')' | DES_DECRYPT_SYM '(' expr ')'
{ $$= new Item_func_des_decrypt($3); } { $$= new Item_func_des_decrypt($3); }
...@@ -2910,7 +2910,7 @@ having_clause: ...@@ -2910,7 +2910,7 @@ having_clause:
; ;
opt_escape: opt_escape:
ESCAPE_SYM TEXT_STRING_db { $$= $2.str; } ESCAPE_SYM TEXT_STRING_literal { $$= $2.str; }
| /* empty */ { $$= (char*) "\\"; }; | /* empty */ { $$= (char*) "\\"; };
...@@ -3921,24 +3921,22 @@ opt_ignore_lines: ...@@ -3921,24 +3921,22 @@ opt_ignore_lines:
/* Common definitions */ /* Common definitions */
text_literal: text_literal:
TEXT_STRING_db TEXT_STRING_literal
{ {
THD *thd= YYTHD; THD *thd= YYTHD;
CHARSET_INFO *cs= my_charset_same(thd->charset(),thd->db_charset) ? $$ = new Item_string($1.str,$1.length,thd->variables.literal_collation);
thd->charset() : thd->db_charset;
$$ = new Item_string($1.str,$1.length,cs);
} }
| NCHAR_STRING | NCHAR_STRING
{ $$= new Item_string($1.str,$1.length,national_charset_info); } { $$= new Item_string($1.str,$1.length,national_charset_info); }
| UNDERSCORE_CHARSET TEXT_STRING | UNDERSCORE_CHARSET TEXT_STRING
{ $$ = new Item_string($2.str,$2.length,Lex->charset); } { $$ = new Item_string($2.str,$2.length,Lex->charset); }
| text_literal TEXT_STRING_db | text_literal TEXT_STRING_literal
{ ((Item_string*) $1)->append($2.str,$2.length); } { ((Item_string*) $1)->append($2.str,$2.length); }
; ;
text_string: text_string:
TEXT_STRING_db TEXT_STRING_literal
{ $$= new String($1.str,$1.length,YYTHD->db_charset); } { $$= new String($1.str,$1.length,YYTHD->variables.literal_collation); }
| HEX_NUM | HEX_NUM
{ {
Item *tmp = new Item_varbinary($1.str,$1.length); Item *tmp = new Item_varbinary($1.str,$1.length);
...@@ -4104,18 +4102,18 @@ TEXT_STRING_sys: ...@@ -4104,18 +4102,18 @@ TEXT_STRING_sys:
} }
; ;
TEXT_STRING_db: TEXT_STRING_literal:
TEXT_STRING TEXT_STRING
{ {
THD *thd= YYTHD; THD *thd= YYTHD;
if (my_charset_same(thd->charset(),thd->db_charset)) if (my_charset_same(thd->charset(),thd->variables.literal_collation))
{ {
$$=$1; $$=$1;
} }
else else
{ {
String ident; String ident;
ident.copy($1.str,$1.length,thd->charset(),thd->db_charset); ident.copy($1.str,$1.length,thd->charset(),thd->variables.literal_collation);
$$.str= thd->strmake(ident.ptr(),ident.length()); $$.str= thd->strmake(ident.ptr(),ident.length());
$$.length= ident.length(); $$.length= ident.length();
} }
...@@ -4403,15 +4401,32 @@ option_value: ...@@ -4403,15 +4401,32 @@ option_value:
find_sys_var("tx_isolation"), find_sys_var("tx_isolation"),
new Item_int((int32) $4))); new Item_int((int32) $4)));
} }
| charset old_or_new_charset_name_or_default | charset old_or_new_charset_name_or_default opt_collate
{ {
THD *thd= YYTHD;
LEX *lex= Lex; LEX *lex= Lex;
lex->var_list.push_back(new set_var_client_collation($2,NULL,1)); $2= $2 ? $2: global_system_variables.client_collation;
$3= $3 ? $3 : $2;
if (!my_charset_same($2,$3))
{
net_printf(YYTHD,ER_COLLATION_CHARSET_MISMATCH,
$3->name,$2->csname);
YYABORT;
}
lex->var_list.push_back(new set_var_client_collation($3,thd->db_charset,$3));
} }
| NAMES_SYM charset_name_or_default opt_collate | NAMES_SYM charset_name_or_default opt_collate
{ {
LEX *lex= Lex; LEX *lex= Lex;
lex->var_list.push_back(new set_var_client_collation($2,$3,0)); $2= $2 ? $2 : global_system_variables.client_collation;
$3= $3 ? $3 : $2;
if (!my_charset_same($2,$3))
{
net_printf(YYTHD,ER_COLLATION_CHARSET_MISMATCH,
$3->name,$2->csname);
YYABORT;
}
lex->var_list.push_back(new set_var_client_collation($3,$3,$3));
} }
| PASSWORD equal text_or_password | PASSWORD equal text_or_password
{ {
......
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