Bug #83140 "use db_name" and "select schema()" work for non-existing databases
Submitted: 25 Sep 2016 15:56 Modified: 3 Oct 2016 18:15
Reporter: Giuseppe Maxia (OCA) Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: Information schema Severity:S2 (Serious)
Version:8.0.0 OS:Any
Assigned to: CPU Architecture:Any

[25 Sep 2016 15:56] Giuseppe Maxia
This is related to Bug#82953.
When a database directory is created manually, it should not be recognized by the server
("Manually created database directories are not recognized by the MySQL Server."  https://dev.mysql.com/doc/refman/8.0/en/data-dictionary-limitations.html)

However, after creating a database withe the unsupported method, some commands succeed:

mysql [localhost] {msandbox} (test) > use db1
Database changed
mysql [localhost] {msandbox} (db1) > select schema();
| schema() |
| db1      |
1 row in set (0.00 sec)

mysql [localhost] {msandbox} (db1) > show tables;
ERROR 1049 (42000): Unknown database 'db1'

How to repeat:
-- Create a directory 'db1' inside the data directory.
-- Start MySQL server

-- Run commands:

use db1
select schema();
show tables;

Suggested fix:
Make the server behave consistently. If the database is not recognized, "use db1" should fail.
On the other hand, if the db1 directory is accompanied by a .SDI file, the server should recognized it and add the name to the data dictionary.
[26 Sep 2016 5:00] MySQL Verification Team
Hello Giuseppe,

Thank you for the report.

[3 Oct 2016 18:15] Paul DuBois
Posted by developer:
Noted in 8.0.1 changelog.

Manual creation of a directory in the data directory resulted in USE
dir_name succeeding even though the directory was not registered as a
database in the data dictionary.