diff options
author | unknown <aelkin@mysql.com> | 2006-02-09 16:23:09 +0200 |
---|---|---|
committer | unknown <aelkin@mysql.com> | 2006-02-09 16:23:09 +0200 |
commit | e025e47a76cb43cad54ff5bdc81a6717a8f3497f (patch) | |
tree | 62a885bef438849f6bce8103b589c4944703fe7e /client | |
parent | 543f067dceee2c3b2ad668f19bcc6e9a87f6708c (diff) | |
download | mariadb-git-e025e47a76cb43cad54ff5bdc81a6717a8f3497f.tar.gz |
BUG#16217 forced to introduce a separate mysql client command to adopt its
internal charset to one associated with currently being handled query.
To note such a query can come from interactive client either.
There was a discussion within replication team and Monty who's suggestion won.
It avoids straightforward parsing of all `set' queries that could affect client side
character set.
According to the idea, mysql client does not parse `set' queries but rather cares of
`charset new_cs_name' command.
This command is generated by mysqlbinlog in form of exclaiming comment (Lars' suggestion)
so that enlightened clients like `mysql' knows what to do with it.
Interactive human can switch between many multi-byte charsets during the session
providing the command explicitly.
To note that setting new internal mysql's charset does not
trigger sending any `SET' sql statement to the server.
client/mysql.cc:
BUG#16217 revealed the problem of switching between charsets in mysql client.
Such switching is necessary in a case when being scanned query consists of
multi-byte chars and internal charset was initialized differently. mysql finds
`/' escape and misiterprete it
while in fact one could be a part of a multi-byte symbol like the bug page reported.
This patch extends mysql `charset' command, '\C' shortcut.
mysql-test/r/ctype_ucs_binlog.result:
comment line generated by mysqlbinlog for processing of logs with multi-byte chars.
mysql-test/r/mysql.result:
results are altered due to #16217
mysql-test/r/mysqlbinlog.result:
Results are altered due to #16217
mysql-test/r/mysqlbinlog2.result:
commeted command for mysql client due to multi-byte binlog
mysql-test/r/rpl_charset.result:
commented command for mysql due to multi-byte binlogs
mysql-test/r/rpl_timezone.result:
commented command for mysql client due to multi-byte binlogs
mysql-test/r/user_var-binlog.result:
commented command for mysql client due to multi-byte binlogs
mysql-test/t/mysql.test:
Main test for mysql client is extended to check `charset' command.
mysql-test/t/mysqlbinlog.test:
Checking how /*! \C cs_name */ are added to the output of mysqlbinlog.
The exclaiming comment is for further processing by mysql client.
The added part mimics the failure to recover tables from binlog - see BUG#16217.
sql/log_event.cc:
Sending into output instructions for mysql client to switch internally
to appropriate charset.
mysql client is supposed to be invoked with --default-character-set=
"to default character set of the server created the binlog".
Diffstat (limited to 'client')
-rw-r--r-- | client/mysql.cc | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index 98af6561966..8d578aac58b 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -194,7 +194,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*), com_warnings(String *str, char*), com_nowarnings(String *str, char*); @@ -268,6 +268,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", 'C', com_charset, 1, + "Switch to another charset. Might be needed for processing binlog with multi-byte charsets." }, { "warnings", 'W', com_warnings, 0, "Show warnings after every statement." }, { "nowarning", 'w', com_nowarnings, 0, @@ -1909,6 +1911,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 |