From: Date: February 10 2006 2:12pm Subject: bk commit into 4.1 tree (aelkin:1.2476) BUG#16217 List-Archive: http://lists.mysql.com/commits/2443 X-Bug: 16217 Message-Id: <200602101312.k1ADCa6m030059@dsl-hkigw8-feb0de00-199.dhcp.inet.fi> Below is the list of changes that have just been committed into a local 4.1 repository of elkin. When elkin does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet 1.2476 06/02/10 15:12:27 aelkin@stripped +4 -0 BUG#16217 fix partly backported from 5.0. It is different in mysqlbinlog part. This changeset is assumed to stay in 4.1. sql/log_event.cc 1.188 06/02/10 15:12:22 aelkin@stripped +12 -0 Inserting exclaiming comment command for mysql client made differently than in 5.0. Parsing still is cheap enough not to think to modify server code instead. mysql-test/t/mysqlbinlog.test 1.16 06/02/10 15:12:22 aelkin@stripped +18 -1 backported from 5.0. The last part of the test to mimic bug#16217 mysql-test/r/mysqlbinlog.result 1.10 06/02/10 15:12:21 aelkin@stripped +18 -1 changed in 5.0 client/mysql.cc 1.218 06/02/10 15:12:20 aelkin@stripped +25 -1 BUG#16217 forced to introduce a separate mysql client command. Feature is backported from 5.0, precisely ChangeSet 1.2034 06/02/09 16:23:09 aelkin@stripped (under second review at the moment) # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: aelkin # Host: dsl-hkigw8-feb0de00-199.dhcp.inet.fi # Root: /usr_rh9/home/elkin.rh9/MySQL/FIXES/mysql-4.1-bug16217 --- 1.217/client/mysql.cc 2005-12-20 20:47:23 +02:00 +++ 1.218/client/mysql.cc 2006-02-10 15:12:20 +02:00 @@ -190,7 +190,7 @@ com_connect(String *str,char*), com_status(String *str,char*), com_use(String *str,char*), com_source(String *str, char*), com_rehash(String *str, char*), com_tee(String *str, char*), - com_notee(String *str, char*), + com_notee(String *str, char*), com_charset(String *str,char*), com_prompt(String *str, char*), com_delimiter(String *str, char*); #ifdef USE_POPEN @@ -263,6 +263,8 @@ "Set outfile [to_outfile]. Append everything into given outfile." }, { "use", 'u', com_use, 1, "Use another database. Takes database name as argument." }, + { "charset_name", 'C', com_charset, 1, + "Switch to another charset. Might be needed for processing binlog." }, /* Get bash-like expansion for some commands */ { "create table", 0, 0, 0, ""}, { "create database", 0, 0, 0, ""}, @@ -1850,6 +1852,28 @@ return 0; } + /* ARGSUSED */ +static int +com_charset(String *buffer __attribute__((unused)), char *line) +{ + char buff[256], *param; + CHARSET_INFO * new_cs; + strmake(buff, line, sizeof(buff) - 1); + param= get_arg(buff, 0); + if (!param || !*param) + { + return put_info("Usage: \\C char_setname | charset charset_name", + INFO_ERROR, 0); + } + new_cs= get_charset_by_csname(param, MY_CS_PRIMARY, MYF(MY_WME)); + if (new_cs) + { + charset_info= new_cs; + put_info("Charset changed", INFO_INFO); + } + else put_info("Charset is not found", INFO_INFO); + return 0; +} /* Execute command --- 1.187/sql/log_event.cc 2005-11-28 15:55:35 +02:00 +++ 1.188/sql/log_event.cc 2006-02-10 15:12:22 +02:00 @@ -949,6 +949,7 @@ void Query_log_event::print(FILE* file, bool short_form, char* last_db) { char buff[40],*end; // Enough for SET TIMESTAMP + const uint set_len= sizeof("SET ONE_SHOT CHARACTER_SET_CLIENT=") - 1; if (!short_form) { print_header(file); @@ -978,6 +979,17 @@ my_fwrite(file, (byte*) buff, (uint) (end-buff),MYF(MY_NABP | MY_WME)); if (flags & LOG_EVENT_THREAD_SPECIFIC_F) fprintf(file,"SET @@session.pseudo_thread_id=%lu;\n",(ulong)thread_id); + /* charset_name command for mysql client */ + if (!strncmp(query, "SET ONE_SHOT CHARACTER_SET_CLIENT=", set_len)) + { + char * endptr; + int cs_number= strtoul(query + set_len, &endptr, 10); + DBUG_ASSERT(*endptr == ','); + CHARSET_INFO *cs_info= get_charset(cs_number, MYF(MY_WME)); + if (cs_info) { + fprintf(file, "/*!\\C %s */;\n", cs_info->csname); + } + } my_fwrite(file, (byte*) query, q_len, MYF(MY_NABP | MY_WME)); fprintf(file, ";\n"); } --- 1.9/mysql-test/r/mysqlbinlog.result 2004-06-09 17:06:55 +03:00 +++ 1.10/mysql-test/r/mysqlbinlog.result 2006-02-10 15:12:21 +02:00 @@ -84,4 +84,21 @@ use test; SET TIMESTAMP=1000000000; insert into t1 values ("Alas"); -drop table t1, t2; +flush logs; +create table t3 (f text character set utf8); +create table t4 (f text character set cp932); +flush logs; +rename table t3 to t03, t4 to t04; +select HEX(f) from t03; +HEX(f) +E382BD +select HEX(f) from t3; +HEX(f) +E382BD +select HEX(f) from t04; +HEX(f) +835C +select HEX(f) from t4; +HEX(f) +835C +drop table t1, t2, t03, t04, t3, t4; --- 1.15/mysql-test/t/mysqlbinlog.test 2005-09-15 17:17:15 +03:00 +++ 1.16/mysql-test/t/mysqlbinlog.test 2006-02-10 15:12:22 +02:00 @@ -98,7 +98,24 @@ --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR --exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --position=27 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002 + +# Bug#16217 (mysql client did not know how not switch its internal charset) +flush logs; +create table t3 (f text character set utf8); +create table t4 (f text character set cp932); +--exec $MYSQL --default-character-set=utf8 test -e "insert into t3 values(_utf8'ソ')" +--exec $MYSQL --default-character-set=cp932 test -e "insert into t4 values(_cp932'ƒ\');" +flush logs; +rename table t3 to t03, t4 to t04; +--exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000004 | $MYSQL --default-character-set=utf8 +# original and recovered data must be equal +select HEX(f) from t03; +select HEX(f) from t3; +select HEX(f) from t04; +select HEX(f) from t4; + + # clean up -drop table t1, t2; +drop table t1, t2, t03, t04, t3, t4; # End of 4.1 tests