Bug #11972: client uses wrong character set after reconnect.

The mysql client uses the default character set on reconnect.  The default character set is now controled by the client charset command while the client is running.  The charset command now also issues a SET NAMES command to the server to make sure that the client's charset settings are in sync with the server's.
parent 68e1e60f
...@@ -1974,6 +1974,9 @@ com_charset(String *buffer __attribute__((unused)), char *line) ...@@ -1974,6 +1974,9 @@ com_charset(String *buffer __attribute__((unused)), char *line)
if (new_cs) if (new_cs)
{ {
charset_info= new_cs; charset_info= new_cs;
mysql_set_character_set(&mysql, charset_info->csname);
default_charset= (char *)charset_info->csname;
default_charset_used= 1;
put_info("Charset changed", INFO_INFO); put_info("Charset changed", INFO_INFO);
} }
else put_info("Charset is not found", INFO_INFO); else put_info("Charset is not found", INFO_INFO);
......
...@@ -59,16 +59,16 @@ database() ...@@ -59,16 +59,16 @@ database()
test test
unlock tables; unlock tables;
drop table t1; drop table t1;
\
\
c_cp932 c_cp932
\
\
\
\
\
+----------------------+------------+--------+ +----------------------+------------+--------+
| concat('>',col1,'<') | col2 | col3 | | concat('>',col1,'<') | col2 | col3 |
+----------------------+------------+--------+ +----------------------+------------+--------+
......
...@@ -52,8 +52,8 @@ drop table t1; ...@@ -52,8 +52,8 @@ drop table t1;
--exec $MYSQL --default-character-set=cp932 test -e "charset utf8;" --exec $MYSQL --default-character-set=cp932 test -e "charset utf8;"
# its usage to switch internally in mysql to requested charset # its usage to switch internally in mysql to requested charset
--exec $MYSQL --default-character-set=utf8 test -e "charset cp932; set @@session.character_set_client= cp932; select '\'; create table t1 (c_cp932 TEXT CHARACTER SET cp932); insert into t1 values('\'); select * from t1; drop table t1;" --exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select '\'; create table t1 (c_cp932 TEXT CHARACTER SET cp932); insert into t1 values('\'); select * from t1; drop table t1;"
--exec $MYSQL --default-character-set=utf8 test -e "charset cp932; set character_set_client= cp932; select '\'" --exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select '\'"
--exec $MYSQL --default-character-set=utf8 test -e "/*charset cp932 */; set character_set_client= cp932; select '\'" --exec $MYSQL --default-character-set=utf8 test -e "/*charset cp932 */; set character_set_client= cp932; select '\'"
--exec $MYSQL --default-character-set=utf8 test -e "/*!\C cp932 */; set character_set_client= cp932; select '\'" --exec $MYSQL --default-character-set=utf8 test -e "/*!\C cp932 */; set character_set_client= cp932; select '\'"
......
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