Bug #84000 Alter rename table with non-existing database gives errno: -1 - Unknown error -1
Submitted: 29 Nov 2016 8:20 Modified: 15 Dec 2016 17:49
Reporter: Shahriyar Rzayev Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Errors Severity:S2 (Serious)
Version:5.6.32, 5.6.34 OS:Any
Assigned to: CPU Architecture:Any

[29 Nov 2016 8:20] Shahriyar Rzayev
Description:
If you try to alter table and rename it for non-existing database:

mysql [localhost] {root} (dbtest) > alter table dbtest.sbtest1 rename fff.sbtest1;
ERROR 1025 (HY000): Error on rename of './dbtest/sbtest1' to './fff/sbtest1' (errno: -1 - Unknown error -1)

mysql [localhost] {root} (dbtest) > show tables;
+------------------+
| Tables_in_dbtest |
+------------------+
| sbtest1          |
+------------------+
1 row in set (0.00 sec)

mysql [localhost] {root} (dbtest) > select count(*) from sbtest1;
+----------+
| count(*) |
+----------+
|    10000 |
+----------+
1 row in set (0.04 sec)

How to repeat:
See description.

Suggested fix:
Make proper error message.
[29 Nov 2016 8:53] MySQL Verification Team
Hello Shahriyar,

Thank you for the report.

Thanks,
Umesh
[29 Nov 2016 9:24] Jon Olav Hauglid
Posted by developer:
 
Can be considered fixed in 8.0:

query 'alter table db1.tb1 rename fff.tb1' failed: 1049: Unknown database 'fff'
[29 Nov 2016 9:35] Ståle Deraas
Posted by developer:
 
We will close this bug as fixed in 8.0 based on comment above.
[29 Nov 2016 9:57] Shahriyar Rzayev
@Jon Olav Hauglid
Interesting to know, how about MyISAM in 8.0?

For 5.6:
mysql> alter table t2 rename test1.t2;
ERROR 7 (HY000): Error on rename of './fff/t2.MYI' to './test1/t2.MYI' (Errcode: 2 - No such file or directory)
[29 Nov 2016 14:45] Jon Olav Hauglid
Posted by developer:
 
"Unknown database" with MyISAM as well. It doesn't matter which storage engine is used, this error is now reported before engines are contacted.
[15 Dec 2016 17:49] Paul DuBois
Posted by developer:
 
Noted in 8.0.0 changelog.

Renaming a table to be part of a nonexistent database failed
(correctly), but with an "Unknown error" message. A proper error
message is now produced; this was corrected as part of the data
dictionary implementation.