Commit 32d32b6e authored by unknown's avatar unknown

Merge mysql.com:/usr_rh9/home/elkin.rh9/MySQL/BARE/mysql-4.1

into  mysql.com:/usr_rh9/home/elkin.rh9/MySQL/FIXES/mysql-4.1-bug16217

parents 1c1e1576 a68f1715
......@@ -190,7 +190,7 @@ static int com_quit(String *str,char*),
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 @@ static COMMANDS commands[] = {
"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 @@ com_clear(String *buffer,char *line __attribute__((unused)))
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
......
......@@ -84,4 +84,21 @@ SET INSERT_ID=1;
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;
......@@ -98,7 +98,24 @@ select "--- --position --" as "";
--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
......@@ -949,6 +949,7 @@ Query_log_event::Query_log_event(const char* buf, int event_len,
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 @@ void Query_log_event::print(FILE* file, bool short_form, char* last_db)
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");
}
......
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