diff options
author | Sergei Golubchik <serg@mariadb.org> | 2018-01-23 23:19:09 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2018-01-24 09:35:07 +0100 |
commit | e2da680c5119d78eb152394d521b898337ea5836 (patch) | |
tree | be3d6f0c8576e670cef19a2a81532fc9eae4e1cd | |
parent | 8637931f118b53ff6fdadf6006ccdb8dedd6f732 (diff) | |
download | mariadb-git-e2da680c5119d78eb152394d521b898337ea5836.tar.gz |
MDEV-13187 incorrect backslash parsing in clients
also cover USE and other built-in commands
-rw-r--r-- | client/mysql.cc | 7 | ||||
-rw-r--r-- | mysql-test/r/mysqldump-nl.result | 43 | ||||
-rw-r--r-- | mysql-test/t/mysqldump-nl.test | 20 |
3 files changed, 68 insertions, 2 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index 3521896c3b1..bc306c55880 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -4559,8 +4559,11 @@ static char *get_arg(char *line, get_arg_mode mode) } for (start=ptr ; *ptr; ptr++) { - if ((*ptr == '\\' && ptr[1]) || // escaped character - (!short_cmd && qtype && *ptr == qtype && ptr[1] == qtype)) // quote + /* if short_cmd use historical rules (only backslash) otherwise SQL rules */ + if (short_cmd + ? (*ptr == '\\' && ptr[1]) // escaped character + : (*ptr == '\\' && ptr[1] && qtype != '`') || // escaped character + (qtype && *ptr == qtype && ptr[1] == qtype)) // quote { // Remove (or skip) the backslash (or a second quote) if (mode != CHECK) diff --git a/mysql-test/r/mysqldump-nl.result b/mysql-test/r/mysqldump-nl.result index 6de439bdf3c..bca199dc46a 100644 --- a/mysql-test/r/mysqldump-nl.result +++ b/mysql-test/r/mysqldump-nl.result @@ -124,3 +124,46 @@ v1 1v drop database `mysqltest1 1tsetlqsym`; +create database `test```; +create database `test\`` +\! ls +#`; +show databases like 'test%'; +Database (test%) +test +test\` +\! ls +# +test` + +-- +-- Current Database: `test``` +-- + +/*!40000 DROP DATABASE IF EXISTS `test```*/; + +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test``` /*!40100 DEFAULT CHARACTER SET latin1 */; + +USE `test```; + +-- +-- Current Database: `test\`` +-- \! ls +-- #` +-- + +/*!40000 DROP DATABASE IF EXISTS `test\`` +\! ls +#`*/; + +CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test\`` +\! ls +#` /*!40100 DEFAULT CHARACTER SET latin1 */; + +USE `test\`` +\! ls +#`; +drop database `test```; +drop database `test\`` +\! ls +#`; diff --git a/mysql-test/t/mysqldump-nl.test b/mysql-test/t/mysqldump-nl.test index 311996e77c3..4513fb2c637 100644 --- a/mysql-test/t/mysqldump-nl.test +++ b/mysql-test/t/mysqldump-nl.test @@ -36,3 +36,23 @@ show tables from `mysqltest1 drop database `mysqltest1 1tsetlqsym`; + +create database `test```; +create database `test\`` +\! ls +#`; + +show databases like 'test%'; + +exec $MYSQL_DUMP --compact --comment --add-drop-database --databases 'test`' 'test\` +\! ls +#'; + +exec $MYSQL_DUMP --compact --comment --add-drop-database --databases 'test`' 'test\` +\! ls +#' | $MYSQL; + +drop database `test```; +drop database `test\`` +\! ls +#`; |