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

SET NAMES doesn't start recoding

SET CHARACTER SET does
parent 06febc8d
...@@ -6,16 +6,16 @@ CREATE TABLE ...@@ -6,16 +6,16 @@ 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 NAMES cp1251; SET CHARACTER SET cp1251;
SHOW TABLES; SHOW TABLES;
Tables_in_test Tables_in_test
...@@ -27,7 +27,7 @@ Table Create Table ...@@ -27,7 +27,7 @@ Table Create Table
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 NAMES utf8; SET CHARACTER SET utf8;
SHOW TABLES; SHOW TABLES;
Tables_in_test Tables_in_test
таблица таблица
...@@ -39,5 +39,5 @@ Table Create Table ...@@ -39,5 +39,5 @@ Table Create Table
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 NAMES koi8r; SET CHARACTER SET koi8r;
DROP TABLE ; DROP TABLE ;
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1;
--enable_warnings --enable_warnings
SET NAMES latin1; SET CHARACTER SET latin1;
CREATE TABLE t1 ( CREATE TABLE t1 (
comment CHAR(32) ASCII NOT NULL, comment CHAR(32) ASCII NOT NULL,
...@@ -137,12 +137,12 @@ INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r' ...@@ -137,12 +137,12 @@ INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'
INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'','CYR CAPIT YU'); INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'','CYR CAPIT YU');
INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'','CYR CAPIT YA'); INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'','CYR CAPIT YA');
SET NAMES utf8; SET CHARACTER SET utf8;
SELECT koi8_ru_f,MIN(comment),COUNT(*) FROM t1 GROUP BY 1; SELECT koi8_ru_f,MIN(comment),COUNT(*) FROM t1 GROUP BY 1;
ALTER TABLE t1 ADD utf8_f CHAR(32) CHARACTER SET utf8 NOT NULL; ALTER TABLE t1 ADD utf8_f CHAR(32) CHARACTER SET utf8 NOT NULL;
UPDATE t1 SET utf8_f=CONVERT(koi8_ru_f USING utf8); UPDATE t1 SET utf8_f=CONVERT(koi8_ru_f USING utf8);
SET NAMES koi8r; SET CHARACTER SET koi8r;
SELECT * FROM t1; SELECT * FROM t1;
ALTER TABLE t1 ADD bin_f CHAR(32) BYTE NOT NULL; ALTER TABLE t1 ADD bin_f CHAR(32) BYTE NOT NULL;
...@@ -165,7 +165,7 @@ FROM t1 t11,t1 t12 ...@@ -165,7 +165,7 @@ FROM t1 t11,t1 t12
WHERE t11.koi8_ru_f=CONVERT(t12.utf8_f USING koi8r) WHERE t11.koi8_ru_f=CONVERT(t12.utf8_f USING koi8r)
ORDER BY t12.utf8_f,t11.comment,t12.comment; ORDER BY t12.utf8_f,t11.comment,t12.comment;
SET NAMES utf8; SET CHARACTER SET utf8;
ALTER TABLE t1 ADD ucs2_f CHAR(32) CHARACTER SET ucs2; ALTER TABLE t1 ADD ucs2_f CHAR(32) CHARACTER SET ucs2;
ALTER TABLE t1 CHANGE ucs2_f ucs2_f CHAR(32) UNICODE NOT NULL; ALTER TABLE t1 CHANGE ucs2_f ucs2_f CHAR(32) UNICODE NOT NULL;
...@@ -199,7 +199,7 @@ UPDATE t1 SET armscii8_f=CONVERT(ucs2_f USING armscii8) WHERE comment LIKE _lati ...@@ -199,7 +199,7 @@ UPDATE t1 SET armscii8_f=CONVERT(ucs2_f USING armscii8) WHERE comment LIKE _lati
UPDATE t1 SET utf8_f=CONVERT(ucs2_f USING utf8) WHERE utf8_f=_utf8''; UPDATE t1 SET utf8_f=CONVERT(ucs2_f USING utf8) WHERE utf8_f=_utf8'';
UPDATE t1 SET ucs2_f=CONVERT(utf8_f USING ucs2) WHERE ucs2_f=_ucs2''; UPDATE t1 SET ucs2_f=CONVERT(utf8_f USING ucs2) WHERE ucs2_f=_ucs2'';
SELECT * FROM t1; SELECT * FROM t1;
SET NAMES 'binary'; SET CHARACTER SET 'binary';
SELECT * FROM t1; SELECT * FROM t1;
SELECT min(comment),count(*) FROM t1 GROUP BY ucs2_f; SELECT min(comment),count(*) FROM t1 GROUP BY ucs2_f;
DROP TABLE t1; DROP TABLE t1;
...@@ -13,16 +13,16 @@ SHOW TABLES; ...@@ -13,16 +13,16 @@ SHOW TABLES;
SHOW CREATE TABLE ; SHOW CREATE TABLE ;
SHOW FIELDS FROM ; SHOW FIELDS FROM ;
SET NAMES cp1251; SET CHARACTER SET cp1251;
SHOW TABLES; SHOW TABLES;
SHOW CREATE TABLE ; SHOW CREATE TABLE ;
SHOW FIELDS FROM ; SHOW FIELDS FROM ;
SET NAMES utf8; SET CHARACTER SET utf8;
SHOW TABLES; SHOW TABLES;
SHOW CREATE TABLE таблица; SHOW CREATE TABLE таблица;
SHOW FIELDS FROM таблица; SHOW FIELDS FROM таблица;
SET NAMES koi8r; SET CHARACTER SET koi8r;
DROP TABLE ; DROP TABLE ;
...@@ -1237,7 +1237,7 @@ void sys_var_client_collation::set_default(THD *thd, enum_var_type type) ...@@ -1237,7 +1237,7 @@ void sys_var_client_collation::set_default(THD *thd, enum_var_type type)
global_system_variables.client_collation= default_charset_info; global_system_variables.client_collation= default_charset_info;
else else
{ {
thd->variables.client_collation= thd->db_charset; thd->variables.client_collation= global_system_variables.client_collation;
} }
} }
...@@ -1264,7 +1264,7 @@ void sys_var_literal_collation::set_default(THD *thd, enum_var_type type) ...@@ -1264,7 +1264,7 @@ void sys_var_literal_collation::set_default(THD *thd, enum_var_type type)
if (type == OPT_GLOBAL) if (type == OPT_GLOBAL)
global_system_variables.literal_collation= default_charset_info; global_system_variables.literal_collation= default_charset_info;
else else
thd->variables.literal_collation= thd->db_charset; thd->variables.literal_collation= global_system_variables.literal_collation;
} }
...@@ -1274,7 +1274,8 @@ void sys_var_literal_collation::set_default(THD *thd, enum_var_type type) ...@@ -1274,7 +1274,8 @@ 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 : thd->db_charset; client_charset= client_charset ?
client_charset : global_system_variables.client_collation;
client_collation= client_collation ? client_collation : client_charset; client_collation= client_collation ? client_collation : client_charset;
if (!my_charset_same(client_charset, client_collation)) if (!my_charset_same(client_charset, client_collation))
{ {
...@@ -1288,7 +1289,8 @@ int set_var_client_collation::check(THD *thd) ...@@ -1288,7 +1289,8 @@ int set_var_client_collation::check(THD *thd)
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= client_collation; thd->variables.literal_collation= convert_result_charset ?
thd->db_charset: client_collation;
thd->variables.convert_result_charset= convert_result_charset; 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);
......
...@@ -602,7 +602,6 @@ bool mysql_change_db(THD *thd, const char *name) ...@@ -602,7 +602,6 @@ bool mysql_change_db(THD *thd, const char *name)
strmov(path+unpack_dirname(path,path), MY_DB_OPT_FILE); strmov(path+unpack_dirname(path,path), MY_DB_OPT_FILE);
load_db_opt(path, &create); load_db_opt(path, &create);
thd->db_charset= create.table_charset ? create.table_charset : default_charset_info; thd->db_charset= create.table_charset ? create.table_charset : default_charset_info;
thd->variables.client_collation=thd->db_charset ? thd->db_charset : default_charset_info;
DBUG_RETURN(0); DBUG_RETURN(0);
} }
......
...@@ -4411,7 +4411,7 @@ option_value: ...@@ -4411,7 +4411,7 @@ option_value:
| 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,1)); lex->var_list.push_back(new set_var_client_collation($2,$3,0));
} }
| 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