Bug #85942 use database name include backslash will be escaped
Submitted: 14 Apr 2017 3:44 Modified: 14 Apr 2017 4:38
Reporter: edge yang Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DDL Severity:S3 (Non-critical)
Version:5.5 5.6 OS:Any
Assigned to: CPU Architecture:Any
Tags: backslash database

[14 Apr 2017 3:44] edge yang
Description:
When i create/drop a database like `test\.test`,it could be create/drop by this name.
But use database,you must use `test\\.test`!
What it affected:
If database name include backslash '\',mysqldump will be create and then use db.
But use db will thow error:ERROR 1049 (42000): Unknown database.

How to repeat:
mysql> create database `test\.test`;
mysql> use `test\.test`
ERROR 1049 (42000): Unknown database 'test.test'
mysql> use `test\\.test`
Database changed
mysql> select database();
+------------+
| database() |
+------------+
| test\.test |
+------------+
1 row in set (0.00 sec)

Suggested fix:
Use database statement not escaped backslash like create/drop database
or
mysqldump output sql statement escaped backslash like use `test\\.test`
[14 Apr 2017 4:38] MySQL Verification Team
Thank you for the bug report. 5.7 version not affected:

c:\dbs>c:\dbs\5.7\bin\mysql -uroot --port=3570 -p --local-infile  --prompt="mysql 5.7 > "
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.19 Source distribution - pull: 2017-apr-05

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql 5.7 > create database `test\.test`;
Query OK, 1 row affected (0.07 sec)

mysql 5.7 > use `test\.test`
Database changed
mysql 5.7 > exit
Bye

c:\dbs>56c

c:\dbs>c:\dbs\5.6\bin\mysql -uroot --local-infile --port=3560 -p --prompt="mysql 5.6 > "
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.37 Source distribution - pull: 2017-apr-05

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql 5.6 > create database `test\.test`;
Query OK, 1 row affected (0.04 sec)

mysql 5.6 > use `test\.test`
ERROR 1049 (42000): Unknown database 'test.test'
mysql 5.6 > exit
Bye

c:\dbs>55c

c:\dbs>c:\dbs\5.5\bin\mysql -uroot --port=3550 -p --local_infile=1 --prompt="mysql 5.5 > "
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.56 Source distribution -  pull: 2017-apr-05

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql 5.5 > create database `test\.test`;
Query OK, 1 row affected (0.00 sec)

mysql 5.5 > use `test\.test`
ERROR 1049 (42000): Unknown database 'test.test'