Bug #84861 db_name is ignored when creating table with data directory
Submitted: 7 Feb 2017 14:40 Modified: 3 Mar 2017 19:25
Reporter: Stefan Gluszek Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: DDL Severity:S2 (Serious)
Version:5.5/5.6/5.7/8.0 OS:Linux
Assigned to: CPU Architecture:Any

[7 Feb 2017 14:40] Stefan Gluszek
Description:
Since version 5.5.54 or after this: https://github.com/mysql/mysql-server/commit/42732cc195fd237c9b17490e96f1bb29db433b0b commit the db_name is ignored when creating tables with data directory.

How to repeat:
CREATE DATABASE testing123;
CREATE TABLE IF NOT EXISTS testing123.test(id int(11)) data directory "/tmp/"
ERROR 1046 (3D000): No database selected

USE testing123;
CREATE TABLE IF NOT EXISTS testing123.test(id int(11)) data directory "/tmp/"
Query OK, 0 rows affected (0.53 sec)

And actually it doesn't matter which database is selected as long as you have a current database. So I could do.
USE anydb;
CREATE TABLE IF NOT EXISTS testing123.test(id int(11)) data directory "/tmp/"
Query OK, 0 rows affected (0.53 sec)
[7 Feb 2017 22:54] MySQL Verification Team
Thank you for the bug report. Verified as described.
[8 Feb 2017 11:32] Dyre Tjeldvoll
Posted by developer:
 
Note that the synopsis is somewhat misleading. The database name is not ignored when creating the table and the symbolic links to the external data directory. It is ignored in the permission check but this does not affect the result as long as there is a current database, since the privilege does not depend on the database used.
[3 Mar 2017 19:25] Paul DuBois
Posted by developer:
 
Noted in 5.5.55, 5.6.36, 5.7.18, 8.0.1 changelogs.

For CREATE TABLE statements that specified the table name with a
database qualifier and included a DATA DIRECTORY or INDEX DIRECTORY
option, an error occurred if there was no default database.