Commit 4637832f authored by unknown's avatar unknown

Some SHOW VARIABLES have been renamed:

collation_client  -> character_set_client
collation_results -> character_set_results
character_set     -> character_set_server

SET NAMES now doesn't start client->server conversion
SET CHARACTER SET now starts both client->server and server->client conversion

parent 01add721
...@@ -4,7 +4,7 @@ CREATE TABLE t1 ( ...@@ -4,7 +4,7 @@ CREATE TABLE t1 (
latin1_f CHAR(32) CHARACTER SET latin1 NOT NULL latin1_f CHAR(32) CHARACTER SET latin1 NOT NULL
); );
CREATE TABLE t2 ( CREATE TABLE t2 (
latin1_f CHAR(32) CHARACTER SET latin1 COLLATE koi8r NOT NULL latin1_f CHAR(32) CHARACTER SET latin1 COLLATE koi8r_general_ci NOT NULL
); );
COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1' COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1'
INSERT INTO t1 (latin1_f) VALUES (_latin1'A'); INSERT INTO t1 (latin1_f) VALUES (_latin1'A');
...@@ -63,7 +63,7 @@ z ...@@ -63,7 +63,7 @@ z
SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1; SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_swedish_ci;
latin1_f latin1_f
A A
a a
...@@ -179,9 +179,9 @@ z ...@@ -179,9 +179,9 @@ z
SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE koi8r; SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE koi8r_general_ci;
COLLATION 'koi8r' is not valid for CHARACTER SET 'latin1' COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1'
SELECT latin1_f COLLATE latin1 AS latin1_f_as FROM t1 ORDER BY latin1_f_as; SELECT latin1_f COLLATE latin1_swedish_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
latin1_f_as latin1_f_as
A A
a a
...@@ -297,8 +297,8 @@ z ...@@ -297,8 +297,8 @@ z
SELECT latin1_f COLLATE koi8r AS latin1_f_as FROM t1 ORDER BY latin1_f_as; SELECT latin1_f COLLATE koi8r_general_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
COLLATION 'koi8r' is not valid for CHARACTER SET 'latin1' COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1'
SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f; SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f;
latin1_f count(*) latin1_f count(*)
A 2 A 2
...@@ -314,7 +314,7 @@ Z 2 ...@@ -314,7 +314,7 @@ Z 2
2 2
2 2
1 1
SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1; SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_swedish_ci;
latin1_f count(*) latin1_f count(*)
A 2 A 2
AD 2 AD 2
...@@ -389,8 +389,8 @@ z 1 ...@@ -389,8 +389,8 @@ z 1
1 1
1 1
1 1
SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE koi8r; SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE koi8r_general_ci;
COLLATION 'koi8r' is not valid for CHARACTER SET 'latin1' COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1'
SELECT DISTINCT latin1_f FROM t1; SELECT DISTINCT latin1_f FROM t1;
latin1_f latin1_f
A A
...@@ -406,8 +406,8 @@ UE ...@@ -406,8 +406,8 @@ UE
SS SS
Z Z
SELECT DISTINCT latin1_f COLLATE latin1 FROM t1; SELECT DISTINCT latin1_f COLLATE latin1_swedish_ci FROM t1;
latin1_f COLLATE latin1 latin1_f COLLATE latin1_swedish_ci
A A
AD AD
AE AE
...@@ -511,64 +511,18 @@ SHOW FIELDS FROM t1; ...@@ -511,64 +511,18 @@ 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 CHARACTER SET 'latin1'; SET CHARACTER SET 'latin1';
SHOW VARIABLES LIKE 'collation_client'; SHOW VARIABLES LIKE 'character_set_client';
Variable_name Value
collation_client latin1_swedish_ci
SET CHARACTER SET latin1;
SHOW VARIABLES LIKE 'collation_client';
Variable_name Value
collation_client latin1_swedish_ci
SHOW VARIABLES LIKE 'collation_client';
Variable_name Value
collation_client latin1_swedish_ci
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
charset('a') collation('a') coercibility('a') 'a'='A'
latin1 latin1_swedish_ci 3 1
SET CHARACTER SET latin1 COLLATE latin1_bin;
SHOW VARIABLES LIKE 'collation_client';
Variable_name Value
collation_client latin1_bin
SET CHARACTER SET LATIN1 COLLATE Latin1_Bin;
SHOW VARIABLES LIKE 'collation_client';
Variable_name Value Variable_name Value
collation_client latin1_bin character_set_client latin1
SET CHARACTER SET 'latin1' COLLATE 'latin1_bin';
SHOW VARIABLES LIKE 'collation_client';
Variable_name Value
collation_client 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_swedish_ci 3 1 latin1 latin1_swedish_ci 3 1
SET CHARACTER SET koi8r; SET CHARACTER SET koi8r;
SHOW VARIABLES LIKE 'collation_client'; SHOW VARIABLES LIKE 'collation_client';
Variable_name Value Variable_name Value
collation_client koi8r_general_ci
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
charset('a') collation('a') coercibility('a') 'a'='A'
latin1 latin1_swedish_ci 3 1
SET CHARACTER SET koi8r COLLATE koi8r_bin;
SHOW VARIABLES LIKE 'collation_client';
Variable_name Value
collation_client koi8r_bin
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
charset('a') collation('a') coercibility('a') 'a'='A'
latin1 latin1_swedish_ci 3 1
SET CHARACTER SET koi8r COLLATE DEFAULT;
SHOW VARIABLES LIKE 'collation_client';
Variable_name Value
collation_client 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 CHARACTER SET DEFAULT;
SHOW VARIABLES LIKE 'collation_client';
Variable_name Value
collation_client latin1_swedish_ci
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
charset('a') collation('a') coercibility('a') 'a'='A'
latin1 latin1_swedish_ci 3 1
SET CHARACTER SET latin1 COLLATE koi8r;
COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1'
SET CHARACTER SET 'DEFAULT'; SET CHARACTER SET 'DEFAULT';
Unknown character set: 'DEFAULT' Unknown character set: 'DEFAULT'
DROP TABLE t1; DROP TABLE t1;
...@@ -156,9 +156,9 @@ show variables like 'net_buffer_length'; ...@@ -156,9 +156,9 @@ show variables like 'net_buffer_length';
Variable_name Value Variable_name Value
net_buffer_length 1048576 net_buffer_length 1048576
set character set cp1251_koi8; set character set cp1251_koi8;
show variables like "collation_client"; show variables like "character_set_client";
Variable_name Value Variable_name Value
collation_client cp1251_bulgarian_ci character_set_client cp1251
select @@timestamp>0; select @@timestamp>0;
@@timestamp>0 @@timestamp>0
1 1
...@@ -185,7 +185,7 @@ set SESSION query_cache_size=10000; ...@@ -185,7 +185,7 @@ set SESSION query_cache_size=10000;
Variable 'query_cache_size' is a GLOBAL variable and should be set with SET GLOBAL Variable 'query_cache_size' is a GLOBAL variable and should be set with SET GLOBAL
set GLOBAL table_type=DEFAULT; set GLOBAL table_type=DEFAULT;
Variable 'table_type' doesn't have a default value Variable 'table_type' doesn't have a default value
set collation_client=UNKNOWN_CHARACTER_SET; set character_set_client=UNKNOWN_CHARACTER_SET;
Unknown character set: 'UNKNOWN_CHARACTER_SET' Unknown character set: 'UNKNOWN_CHARACTER_SET'
set global autocommit=1; set global autocommit=1;
Variable 'autocommit' is a LOCAL variable and can't be used with SET GLOBAL Variable 'autocommit' is a LOCAL variable and can't be used with SET GLOBAL
......
...@@ -9,7 +9,7 @@ CREATE TABLE t1 ( ...@@ -9,7 +9,7 @@ CREATE TABLE t1 (
--error 1251 --error 1251
CREATE TABLE t2 ( CREATE TABLE t2 (
latin1_f CHAR(32) CHARACTER SET latin1 COLLATE koi8r NOT NULL latin1_f CHAR(32) CHARACTER SET latin1 COLLATE koi8r_general_ci NOT NULL
); );
...@@ -57,39 +57,39 @@ INSERT INTO t1 (latin1_f) VALUES (_latin1'z'); ...@@ -57,39 +57,39 @@ INSERT INTO t1 (latin1_f) VALUES (_latin1'z');
-- ORDER BY -- ORDER BY
SELECT latin1_f FROM t1 ORDER BY latin1_f; SELECT latin1_f FROM t1 ORDER BY latin1_f;
SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1; SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_swedish_ci;
SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_german2_ci; SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_german2_ci;
SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_general_ci; SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_general_ci;
SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_bin; SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_bin;
--error 1251 --error 1251
SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE koi8r; SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE koi8r_general_ci;
--SELECT latin1_f COLLATE koi8r FROM t1 ; --SELECT latin1_f COLLATE koi8r FROM t1 ;
-- AS + ORDER BY -- AS + ORDER BY
SELECT latin1_f COLLATE latin1 AS latin1_f_as FROM t1 ORDER BY latin1_f_as; SELECT latin1_f COLLATE latin1_swedish_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
SELECT latin1_f COLLATE latin1_german2_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as; SELECT latin1_f COLLATE latin1_german2_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
SELECT latin1_f COLLATE latin1_general_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as; SELECT latin1_f COLLATE latin1_general_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
SELECT latin1_f COLLATE latin1_bin AS latin1_f_as FROM t1 ORDER BY latin1_f_as; SELECT latin1_f COLLATE latin1_bin AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
--error 1251 --error 1251
SELECT latin1_f COLLATE koi8r AS latin1_f_as FROM t1 ORDER BY latin1_f_as; SELECT latin1_f COLLATE koi8r_general_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
-- GROUP BY -- GROUP BY
SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f; SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f;
SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1; SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_swedish_ci;
SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_german2_ci; SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_german2_ci;
SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_general_ci; SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_general_ci;
SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_bin; SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_bin;
--error 1251 --error 1251
SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE koi8r; SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE koi8r_general_ci;
-- DISTINCT -- DISTINCT
SELECT DISTINCT latin1_f FROM t1; SELECT DISTINCT latin1_f FROM t1;
SELECT DISTINCT latin1_f COLLATE latin1 FROM t1; SELECT DISTINCT latin1_f COLLATE latin1_swedish_ci FROM t1;
SELECT DISTINCT latin1_f COLLATE latin1_german2_ci FROM t1; SELECT DISTINCT latin1_f COLLATE latin1_german2_ci FROM t1;
SELECT DISTINCT latin1_f COLLATE latin1_general_ci FROM t1; SELECT DISTINCT latin1_f COLLATE latin1_general_ci FROM t1;
SELECT DISTINCT latin1_f COLLATE latin1_bin FROM t1; SELECT DISTINCT latin1_f COLLATE latin1_bin FROM t1;
...@@ -127,35 +127,19 @@ ALTER TABLE t1 CHARACTER SET latin1 COLLATE latin1_bin; ...@@ -127,35 +127,19 @@ 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;
#
# Check SET CHARACTER SET
#
SET CHARACTER SET 'latin1'; SET CHARACTER SET 'latin1';
SHOW VARIABLES LIKE 'collation_client'; SHOW VARIABLES LIKE 'character_set_client';
SET CHARACTER SET latin1;
SHOW VARIABLES LIKE 'collation_client';
SHOW VARIABLES LIKE 'collation_client';
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
SET CHARACTER SET latin1 COLLATE latin1_bin;
SHOW VARIABLES LIKE 'collation_client';
SET CHARACTER SET LATIN1 COLLATE Latin1_Bin;
SHOW VARIABLES LIKE 'collation_client';
SET CHARACTER SET 'latin1' COLLATE 'latin1_bin';
SHOW VARIABLES LIKE 'collation_client';
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
SET CHARACTER SET koi8r; SET CHARACTER SET koi8r;
SHOW VARIABLES LIKE 'collation_client'; SHOW VARIABLES LIKE 'collation_client';
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
SET CHARACTER SET koi8r COLLATE koi8r_bin;
SHOW VARIABLES LIKE 'collation_client';
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
SET CHARACTER SET koi8r COLLATE DEFAULT;
SHOW VARIABLES LIKE 'collation_client';
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
SET CHARACTER SET DEFAULT;
SHOW VARIABLES LIKE 'collation_client';
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
--error 1251
SET CHARACTER SET latin1 COLLATE koi8r;
--error 1115 --error 1115
SET CHARACTER SET 'DEFAULT'; SET CHARACTER SET 'DEFAULT';
DROP TABLE t1; DROP TABLE t1;
...@@ -92,7 +92,7 @@ set net_buffer_length=2000000000; ...@@ -92,7 +92,7 @@ set net_buffer_length=2000000000;
show variables like 'net_buffer_length'; show variables like 'net_buffer_length';
set character set cp1251_koi8; set character set cp1251_koi8;
show variables like "collation_client"; show variables like "character_set_client";
select @@timestamp>0; select @@timestamp>0;
set @@rand_seed1=10000000,@@rand_seed2=1000000; set @@rand_seed1=10000000,@@rand_seed2=1000000;
...@@ -119,7 +119,7 @@ set SESSION query_cache_size=10000; ...@@ -119,7 +119,7 @@ set SESSION query_cache_size=10000;
--error 1230 --error 1230
set GLOBAL table_type=DEFAULT; set GLOBAL table_type=DEFAULT;
--error 1115 --error 1115
set collation_client=UNKNOWN_CHARACTER_SET; set character_set_client=UNKNOWN_CHARACTER_SET;
--error 1228 --error 1228
set global autocommit=1; set global autocommit=1;
--error 1228 --error 1228
......
...@@ -548,9 +548,7 @@ uint get_charset_number(const char *charset_name) ...@@ -548,9 +548,7 @@ uint get_charset_number(const char *charset_name)
for (cs= all_charsets; cs < all_charsets+255; ++cs) for (cs= all_charsets; cs < all_charsets+255; ++cs)
{ {
if ( cs[0] && cs[0]->name && if ( cs[0] && cs[0]->name &&
(!my_strcasecmp(&my_charset_latin1, cs[0]->name, charset_name) || !my_strcasecmp(&my_charset_latin1, cs[0]->name, charset_name))
(!my_strcasecmp(&my_charset_latin1, cs[0]->csname, charset_name) &&
(cs[0]->state & MY_CS_PRIMARY))))
return cs[0]->number; return cs[0]->number;
} }
return 0; /* this mimics find_type() */ return 0; /* this mimics find_type() */
......
...@@ -2106,8 +2106,8 @@ static int init_common_variables(const char *conf_file_name, int argc, ...@@ -2106,8 +2106,8 @@ static int init_common_variables(const char *conf_file_name, int argc,
} }
default_charset_info= default_collation; default_charset_info= default_collation;
} }
global_system_variables.collation_results= default_charset_info; global_system_variables.character_set_results= NULL;
global_system_variables.collation_client= default_charset_info; global_system_variables.character_set_client= default_charset_info;
global_system_variables.collation_connection= default_charset_info; global_system_variables.collation_connection= default_charset_info;
if (use_temp_pool && bitmap_init(&temp_pool,1024,1)) if (use_temp_pool && bitmap_init(&temp_pool,1024,1))
...@@ -4610,8 +4610,8 @@ static void set_options(void) ...@@ -4610,8 +4610,8 @@ 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.collation_results= default_charset_info; global_system_variables.character_set_results= NULL;
global_system_variables.collation_client= default_charset_info; global_system_variables.character_set_client= default_charset_info;
global_system_variables.collation_connection= default_charset_info; global_system_variables.collation_connection= default_charset_info;
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;
......
...@@ -709,7 +709,7 @@ bool Protocol_simple::store(const char *from, uint length, ...@@ -709,7 +709,7 @@ bool Protocol_simple::store(const char *from, uint length,
field_types[field_pos] <= MYSQL_TYPE_GEOMETRY)); field_types[field_pos] <= MYSQL_TYPE_GEOMETRY));
field_pos++; field_pos++;
#endif #endif
if (!my_charset_same(fromcs, tocs) && if (tocs && !my_charset_same(fromcs, tocs) &&
(fromcs != &my_charset_bin) && (fromcs != &my_charset_bin) &&
(tocs != &my_charset_bin)) (tocs != &my_charset_bin))
{ {
...@@ -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->variables.collation_results; CHARSET_INFO *tocs= this->thd->variables.character_set_results;
#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 ||
...@@ -732,7 +732,7 @@ bool Protocol_simple::store(const char *from, uint length, ...@@ -732,7 +732,7 @@ bool Protocol_simple::store(const char *from, uint length,
field_types[field_pos] <= MYSQL_TYPE_GEOMETRY)); field_types[field_pos] <= MYSQL_TYPE_GEOMETRY));
field_pos++; field_pos++;
#endif #endif
if (!my_charset_same(fromcs, tocs) && if (tocs && !my_charset_same(fromcs, tocs) &&
(fromcs != &my_charset_bin) && (fromcs != &my_charset_bin) &&
(tocs != &my_charset_bin)) (tocs != &my_charset_bin))
{ {
...@@ -831,12 +831,14 @@ bool Protocol_simple::store(Field *field) ...@@ -831,12 +831,14 @@ bool Protocol_simple::store(Field *field)
#endif #endif
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String str(buff,sizeof(buff), &my_charset_bin); String str(buff,sizeof(buff), &my_charset_bin);
CHARSET_INFO *tocs= this->thd->variables.character_set_results;
field->val_str(&str,&str); field->val_str(&str,&str);
if (!my_charset_same(field->charset(), this->thd->charset()) && if (tocs && !my_charset_same(field->charset(), tocs) &&
(field->charset() != &my_charset_bin) && (field->charset() != &my_charset_bin) &&
(this->thd->charset() != &my_charset_bin)) (tocs != &my_charset_bin))
{ {
convert.copy(str.ptr(), str.length(), str.charset(), this->thd->charset()); convert.copy(str.ptr(), str.length(), str.charset(), tocs);
return net_store_data(convert.ptr(), convert.length()); return net_store_data(convert.ptr(), convert.length());
} }
else else
......
...@@ -101,7 +101,7 @@ sys_var_long_ptr sys_binlog_cache_size("binlog_cache_size", ...@@ -101,7 +101,7 @@ sys_var_long_ptr sys_binlog_cache_size("binlog_cache_size",
&binlog_cache_size); &binlog_cache_size);
sys_var_thd_ulong sys_bulk_insert_buff_size("bulk_insert_buffer_size", sys_var_thd_ulong sys_bulk_insert_buff_size("bulk_insert_buffer_size",
&SV::bulk_insert_buff_size); &SV::bulk_insert_buff_size);
sys_var_str sys_charset("character_set", sys_var_str sys_charset("character_set_server",
sys_check_charset, sys_check_charset,
sys_update_charset, sys_update_charset,
sys_set_default_charset); sys_set_default_charset);
...@@ -109,9 +109,9 @@ sys_var_str sys_charset_system("character_set_system", ...@@ -109,9 +109,9 @@ sys_var_str sys_charset_system("character_set_system",
sys_check_charset, sys_check_charset,
sys_update_charset, sys_update_charset,
sys_set_default_charset); sys_set_default_charset);
sys_var_collation_client sys_collation_client("collation_client"); sys_var_character_set_client sys_character_set_client("character_set_client");
sys_var_character_set_results sys_character_set_results("character_set_results");
sys_var_collation_connection sys_collation_connection("collation_connection"); sys_var_collation_connection sys_collation_connection("collation_connection");
sys_var_collation_results sys_collation_results("collation_results");
sys_var_bool_ptr sys_concurrent_insert("concurrent_insert", 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",
...@@ -353,9 +353,9 @@ sys_var *sys_variables[]= ...@@ -353,9 +353,9 @@ 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_collation_client, &sys_character_set_client,
&sys_character_set_results,
&sys_collation_connection, &sys_collation_connection,
&sys_collation_results,
&sys_concurrent_insert, &sys_concurrent_insert,
&sys_connect_timeout, &sys_connect_timeout,
&sys_default_week_format, &sys_default_week_format,
...@@ -469,9 +469,9 @@ struct show_var_st init_vars[]= { ...@@ -469,9 +469,9 @@ 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},
{sys_charset_system.name, (char*) &sys_charset_system, SHOW_SYS}, {sys_charset_system.name, (char*) &sys_charset_system, SHOW_SYS},
{sys_collation_client.name, (char*) &sys_collation_client, SHOW_SYS}, {sys_character_set_client.name,(char*) &sys_character_set_client,SHOW_SYS},
{sys_character_set_results.name,(char*) &sys_character_set_results, SHOW_SYS},
{sys_collation_connection.name,(char*) &sys_collation_connection, SHOW_SYS}, {sys_collation_connection.name,(char*) &sys_collation_connection, SHOW_SYS},
{sys_collation_results.name, (char*) &sys_collation_results, 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},
{"datadir", mysql_real_data_home, SHOW_CHAR}, {"datadir", mysql_real_data_home, SHOW_CHAR},
...@@ -1207,7 +1207,7 @@ CHARSET_INFO *get_old_charset_by_name(const char *name) ...@@ -1207,7 +1207,7 @@ CHARSET_INFO *get_old_charset_by_name(const char *name)
for (c= old_conv; c->old_name; c++) for (c= old_conv; c->old_name; c++)
{ {
if (!my_strcasecmp(&my_charset_latin1,name,c->old_name)) if (!my_strcasecmp(&my_charset_latin1,name,c->old_name))
return get_charset_by_name(c->new_name,MYF(0)); return get_charset_by_csname(c->new_name,MY_CS_PRIMARY,MYF(0));
} }
return NULL; return NULL;
} }
...@@ -1221,7 +1221,25 @@ bool sys_var_collation::check(THD *thd, set_var *var) ...@@ -1221,7 +1221,25 @@ bool sys_var_collation::check(THD *thd, set_var *var)
if (!(res=var->value->val_str(&str))) if (!(res=var->value->val_str(&str)))
res= &empty_string; res= &empty_string;
if (!(tmp=get_charset_by_name(res->c_ptr(),MYF(0))) && if (!(tmp=get_charset_by_name(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_character_set::check(THD *thd, set_var *var)
{
CHARSET_INFO *tmp;
char buff[80];
String str(buff,sizeof(buff), system_charset_info), *res;
if (!(res=var->value->val_str(&str)))
res= &empty_string;
if (!(tmp=get_charset_by_csname(res->c_ptr(),MY_CS_PRIMARY,MYF(0))) &&
!(tmp=get_old_charset_by_name(res->c_ptr()))) !(tmp=get_old_charset_by_name(res->c_ptr())))
{ {
my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), res->c_ptr()); my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), res->c_ptr());
...@@ -1231,29 +1249,29 @@ bool sys_var_collation::check(THD *thd, set_var *var) ...@@ -1231,29 +1249,29 @@ bool sys_var_collation::check(THD *thd, set_var *var)
return 0; return 0;
} }
bool sys_var_collation_client::update(THD *thd, set_var *var) bool sys_var_character_set_client::update(THD *thd, set_var *var)
{ {
if (var->type == OPT_GLOBAL) if (var->type == OPT_GLOBAL)
global_system_variables.collation_client= var->save_result.charset; global_system_variables.character_set_client= var->save_result.charset;
else else
thd->variables.collation_client= var->save_result.charset; thd->variables.character_set_client= var->save_result.charset;
return 0; return 0;
} }
byte *sys_var_collation_client::value_ptr(THD *thd, enum_var_type type) byte *sys_var_character_set_client::value_ptr(THD *thd, enum_var_type type)
{ {
CHARSET_INFO *cs= ((type == OPT_GLOBAL) ? CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
global_system_variables.collation_client : global_system_variables.character_set_client :
thd->variables.collation_client); thd->variables.character_set_client);
return cs ? (byte*) cs->name : (byte*) ""; return cs ? (byte*) cs->csname : (byte*) "NULL";
} }
void sys_var_collation_client::set_default(THD *thd, enum_var_type type) void sys_var_character_set_client::set_default(THD *thd, enum_var_type type)
{ {
if (type == OPT_GLOBAL) if (type == OPT_GLOBAL)
global_system_variables.collation_client= default_charset_info; global_system_variables.character_set_client= default_charset_info;
else else
thd->variables.collation_client= global_system_variables.collation_client; thd->variables.character_set_client= global_system_variables.character_set_client;
} }
...@@ -1271,7 +1289,7 @@ byte *sys_var_collation_connection::value_ptr(THD *thd, enum_var_type type) ...@@ -1271,7 +1289,7 @@ byte *sys_var_collation_connection::value_ptr(THD *thd, enum_var_type type)
CHARSET_INFO *cs= ((type == OPT_GLOBAL) ? CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
global_system_variables.collation_connection : global_system_variables.collation_connection :
thd->variables.collation_connection); thd->variables.collation_connection);
return cs ? (byte*) cs->name : (byte*) ""; return cs ? (byte*) cs->name : (byte*) "NULL";
} }
void sys_var_collation_connection::set_default(THD *thd, enum_var_type type) void sys_var_collation_connection::set_default(THD *thd, enum_var_type type)
...@@ -1282,29 +1300,29 @@ void sys_var_collation_connection::set_default(THD *thd, enum_var_type type) ...@@ -1282,29 +1300,29 @@ void sys_var_collation_connection::set_default(THD *thd, enum_var_type type)
thd->variables.collation_connection= global_system_variables.collation_connection; thd->variables.collation_connection= global_system_variables.collation_connection;
} }
bool sys_var_collation_results::update(THD *thd, set_var *var) bool sys_var_character_set_results::update(THD *thd, set_var *var)
{ {
if (var->type == OPT_GLOBAL) if (var->type == OPT_GLOBAL)
global_system_variables.collation_results= var->save_result.charset; global_system_variables.character_set_results= var->save_result.charset;
else else
thd->variables.collation_results= var->save_result.charset; thd->variables.character_set_results= var->save_result.charset;
return 0; return 0;
} }
byte *sys_var_collation_results::value_ptr(THD *thd, enum_var_type type) byte *sys_var_character_set_results::value_ptr(THD *thd, enum_var_type type)
{ {
CHARSET_INFO *cs= ((type == OPT_GLOBAL) ? CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
global_system_variables.collation_results : global_system_variables.character_set_results :
thd->variables.collation_results); thd->variables.character_set_results);
return cs ? (byte*) cs->name : (byte*) ""; return cs ? (byte*) cs->csname : (byte*) "NULL";
} }
void sys_var_collation_results::set_default(THD *thd, enum_var_type type) void sys_var_character_set_results::set_default(THD *thd, enum_var_type type)
{ {
if (type == OPT_GLOBAL) if (type == OPT_GLOBAL)
global_system_variables.collation_results= default_charset_info; global_system_variables.character_set_results= NULL;
else else
thd->variables.collation_results= global_system_variables.collation_results; thd->variables.character_set_results= global_system_variables.character_set_results;
} }
...@@ -1319,9 +1337,9 @@ int set_var_collation_client::check(THD *thd) ...@@ -1319,9 +1337,9 @@ int set_var_collation_client::check(THD *thd)
int set_var_collation_client::update(THD *thd) int set_var_collation_client::update(THD *thd)
{ {
thd->variables.collation_client= collation_client; thd->variables.character_set_client= character_set_client;
thd->variables.character_set_results= character_set_results;
thd->variables.collation_connection= collation_connection; thd->variables.collation_connection= collation_connection;
thd->variables.collation_results= collation_results;
thd->protocol_simple.init(thd); thd->protocol_simple.init(thd);
thd->protocol_prep.init(thd); thd->protocol_prep.init(thd);
return 0; return 0;
......
...@@ -420,34 +420,49 @@ SHOW_TYPE type() { return SHOW_CHAR; } ...@@ -420,34 +420,49 @@ SHOW_TYPE type() { return SHOW_CHAR; }
virtual void set_default(THD *thd, enum_var_type type)= 0; virtual void set_default(THD *thd, enum_var_type type)= 0;
}; };
class sys_var_collation_client :public sys_var_collation class sys_var_character_set :public sys_var_thd
{ {
public: public:
sys_var_collation_client(const char *name_arg) :sys_var_collation(name_arg) {} sys_var_character_set(const char *name_arg) :sys_var_thd(name_arg) {}
bool check(THD *thd, set_var *var);
SHOW_TYPE type() { return SHOW_CHAR; }
bool check_update_type(Item_result type)
{
return type != STRING_RESULT; /* Only accept strings */
}
bool check_default(enum_var_type type) { return 0; }
virtual void set_default(THD *thd, enum_var_type type)= 0;
};
class sys_var_character_set_client :public sys_var_character_set
{
public:
sys_var_character_set_client(const char *name_arg) :
sys_var_character_set(name_arg) {}
bool update(THD *thd, set_var *var); bool update(THD *thd, set_var *var);
void set_default(THD *thd, enum_var_type type); void set_default(THD *thd, enum_var_type type);
byte *value_ptr(THD *thd, enum_var_type type); byte *value_ptr(THD *thd, enum_var_type type);
}; };
class sys_var_collation_connection :public sys_var_collation class sys_var_character_set_results :public sys_var_character_set
{ {
public: public:
sys_var_collation_connection(const char *name_arg) :sys_var_collation(name_arg) {} sys_var_character_set_results(const char *name_arg) :
sys_var_character_set(name_arg) {}
bool update(THD *thd, set_var *var); bool update(THD *thd, set_var *var);
void set_default(THD *thd, enum_var_type type); void set_default(THD *thd, enum_var_type type);
byte *value_ptr(THD *thd, enum_var_type type); byte *value_ptr(THD *thd, enum_var_type type);
}; };
class sys_var_collation_results :public sys_var_collation class sys_var_collation_connection :public sys_var_collation
{ {
public: public:
sys_var_collation_results(const char *name_arg) :sys_var_collation(name_arg) {} sys_var_collation_connection(const char *name_arg) :sys_var_collation(name_arg) {}
bool update(THD *thd, set_var *var); bool update(THD *thd, set_var *var);
void set_default(THD *thd, enum_var_type type); void set_default(THD *thd, enum_var_type type);
byte *value_ptr(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 */
class sys_var_readonly: public sys_var class sys_var_readonly: public sys_var
...@@ -555,16 +570,16 @@ class set_var_password: public set_var_base ...@@ -555,16 +570,16 @@ class set_var_password: public set_var_base
class set_var_collation_client: public set_var_base class set_var_collation_client: public set_var_base
{ {
CHARSET_INFO *collation_client; CHARSET_INFO *character_set_client;
CHARSET_INFO *character_set_results;
CHARSET_INFO *collation_connection; CHARSET_INFO *collation_connection;
CHARSET_INFO *collation_results;
public: public:
set_var_collation_client(CHARSET_INFO *client_coll_arg, set_var_collation_client(CHARSET_INFO *client_coll_arg,
CHARSET_INFO *connection_coll_arg, CHARSET_INFO *connection_coll_arg,
CHARSET_INFO *result_coll_arg) CHARSET_INFO *result_coll_arg)
:collation_client(client_coll_arg), :character_set_client(client_coll_arg),
collation_connection(connection_coll_arg), character_set_results(result_coll_arg),
collation_results(result_coll_arg) collation_connection(connection_coll_arg)
{} {}
int check(THD *thd); int check(THD *thd);
int update(THD *thd); int update(THD *thd);
......
...@@ -385,9 +385,9 @@ struct system_variables ...@@ -385,9 +385,9 @@ struct system_variables
my_bool low_priority_updates; my_bool low_priority_updates;
my_bool new_mode; my_bool new_mode;
CHARSET_INFO *collation_client; CHARSET_INFO *character_set_client;
CHARSET_INFO *character_set_results;
CHARSET_INFO *collation_connection; CHARSET_INFO *collation_connection;
CHARSET_INFO *collation_results;
}; };
void free_tmp_table(THD *thd, TABLE *entry); void free_tmp_table(THD *thd, TABLE *entry);
...@@ -670,7 +670,7 @@ class THD :public ilink ...@@ -670,7 +670,7 @@ class THD :public ilink
net.report_error= 1; net.report_error= 1;
DBUG_PRINT("error",("Fatal error set")); DBUG_PRINT("error",("Fatal error set"));
} }
inline CHARSET_INFO *charset() { return variables.collation_client; } inline CHARSET_INFO *charset() { return variables.character_set_client; }
}; };
/* /*
......
...@@ -1411,7 +1411,7 @@ opt_binary: ...@@ -1411,7 +1411,7 @@ opt_binary:
| BINARY { Lex->charset=&my_charset_bin; } | BINARY { Lex->charset=&my_charset_bin; }
| UNICODE_SYM | UNICODE_SYM
{ {
if (!(Lex->charset=get_charset_by_name("ucs2",MYF(0)))) if (!(Lex->charset=get_charset_by_csname("ucs2",MY_CS_PRIMARY,MYF(0))))
{ {
net_printf(YYTHD,ER_UNKNOWN_CHARACTER_SET,"ucs2"); net_printf(YYTHD,ER_UNKNOWN_CHARACTER_SET,"ucs2");
YYABORT; YYABORT;
...@@ -4420,31 +4420,25 @@ option_value: ...@@ -4420,31 +4420,25 @@ 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 opt_collate | charset old_or_new_charset_name_or_default
{ {
THD *thd= YYTHD; THD *thd= YYTHD;
LEX *lex= Lex; LEX *lex= Lex;
$2= $2 ? $2: global_system_variables.collation_client; $2= $2 ? $2: global_system_variables.character_set_client;
$3= $3 ? $3 : $2; lex->var_list.push_back(new set_var_collation_client($2,thd->db_charset,$2));
if (!my_charset_same($2,$3))
{
net_printf(thd,ER_COLLATION_CHARSET_MISMATCH,$3->name,$2->csname);
YYABORT;
}
lex->var_list.push_back(new set_var_collation_client($3,thd->db_charset,$3));
} }
| NAMES_SYM charset_name_or_default opt_collate | NAMES_SYM charset_name_or_default opt_collate
{ {
THD *thd= YYTHD; THD *thd= YYTHD;
LEX *lex= Lex; LEX *lex= Lex;
$2= $2 ? $2 : global_system_variables.collation_client; $2= $2 ? $2 : global_system_variables.character_set_client;
$3= $3 ? $3 : $2; $3= $3 ? $3 : $2;
if (!my_charset_same($2,$3)) if (!my_charset_same($2,$3))
{ {
net_printf(thd,ER_COLLATION_CHARSET_MISMATCH,$3->name,$2->csname); net_printf(thd,ER_COLLATION_CHARSET_MISMATCH,$3->name,$2->csname);
YYABORT; YYABORT;
} }
lex->var_list.push_back(new set_var_collation_client($3,$3,$3)); lex->var_list.push_back(new set_var_collation_client($3,$3,NULL));
} }
| 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