diff options
-rw-r--r-- | client/mysql.cc | 17 | ||||
-rw-r--r-- | mysql-test/r/bug20328.result | 44 | ||||
-rw-r--r-- | mysql-test/t/bug20328.test | 9 |
3 files changed, 67 insertions, 3 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index 09818ae27b3..123aa3ae639 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1725,7 +1725,14 @@ static int com_server_help(String *buffer __attribute__((unused)), if (help_arg[0] != '\'') { - (void) strxnmov(cmd_buf, sizeof(cmd_buf), "help '", help_arg, "'", NullS); + char *end_arg= strend(help_arg); + if(--end_arg) + { + while (my_isspace(charset_info,*end_arg)) + end_arg--; + *++end_arg= '\0'; + } + (void) strxnmov(cmd_buf, sizeof(cmd_buf), "help '", help_arg, "'", NullS); server_cmd= cmd_buf; } @@ -1811,9 +1818,13 @@ com_help(String *buffer __attribute__((unused)), { reg1 int i, j; char * help_arg= strchr(line,' '), buff[32], *end; - if (help_arg) - return com_server_help(buffer,line,help_arg+1); + { + while (my_isspace(charset_info,*help_arg)) + help_arg++; + if (*help_arg) + return com_server_help(buffer,line,help_arg); + } put_info("\nFor information about MySQL products and services, visit:\n" " http://www.mysql.com/\n" diff --git a/mysql-test/r/bug20328.result b/mysql-test/r/bug20328.result new file mode 100644 index 00000000000..62955775ec4 --- /dev/null +++ b/mysql-test/r/bug20328.result @@ -0,0 +1,44 @@ +? (\?) Synonym for `help'. +clear (\c) Clear command. +connect (\r) Reconnect to the server. Optional arguments are db and host. +delimiter (\d) Set query delimiter. +edit (\e) Edit command with $EDITOR. +ego (\G) Send command to mysql server, display result vertically. +exit (\q) Exit mysql. Same as quit. +go (\g) Send command to mysql server. +help (\h) Display this help. +nopager (\n) Disable pager, print to stdout. +notee (\t) Don't write into outfile. +pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. +print (\p) Print current command. +prompt (\R) Change your mysql prompt. +quit (\q) Quit mysql. +rehash (\#) Rebuild completion hash. +source (\.) Execute an SQL script file. Takes a file name as an argument. +status (\s) Get status information from the server. +system (\!) Execute a system shell command. +tee (\T) Set outfile [to_outfile]. Append everything into given outfile. +use (\u) Use another database. Takes database name as argument. +charset_name(\C) Switch to another charset. Might be needed for processing binlog. +? (\?) Synonym for `help'. +clear (\c) Clear command. +connect (\r) Reconnect to the server. Optional arguments are db and host. +delimiter (\d) Set query delimiter. +edit (\e) Edit command with $EDITOR. +ego (\G) Send command to mysql server, display result vertically. +exit (\q) Exit mysql. Same as quit. +go (\g) Send command to mysql server. +help (\h) Display this help. +nopager (\n) Disable pager, print to stdout. +notee (\t) Don't write into outfile. +pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. +print (\p) Print current command. +prompt (\R) Change your mysql prompt. +quit (\q) Quit mysql. +rehash (\#) Rebuild completion hash. +source (\.) Execute an SQL script file. Takes a file name as an argument. +status (\s) Get status information from the server. +system (\!) Execute a system shell command. +tee (\T) Set outfile [to_outfile]. Append everything into given outfile. +use (\u) Use another database. Takes database name as argument. +charset_name(\C) Switch to another charset. Might be needed for processing binlog. diff --git a/mysql-test/t/bug20328.test b/mysql-test/t/bug20328.test new file mode 100644 index 00000000000..6ae4717de9c --- /dev/null +++ b/mysql-test/t/bug20328.test @@ -0,0 +1,9 @@ +# This test should work in embedded server after we fix mysqltest +-- source include/not_embedded.inc + +# +# Bug #20328: mysql client interprets commands in comments +# +--exec echo 'help' | $MYSQL +--exec echo 'help ' | $MYSQL + |