Bug #56621 have DROP TABLE better handle the case of stray .frm files
Submitted: 7 Sep 2010 16:40
Reporter: Axel Schwenke Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server Severity:S4 (Feature request)
Version:5.1 OS:Any
Assigned to: CPU Architecture:Any

[7 Sep 2010 16:40] Axel Schwenke
Description:
Sometimes it happens that the datadir contains a stray .frm file, but the table itself does not exist. This happens often enough that InnoDB added extra diagnostics for this case (http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting-datadict.html)

Currently there is no way to get rid of such .frm files from SQL level. One has to manually delete a file on the MySQL server.

How to repeat:
Copy a .frm file for i.e. an InnoDB table to a second database. The table will be listed by SHOW TABLES, but acces to the table will fail. Also DROP TABLE will fail.

Suggested fix:
If DROP TABLE gets a "no such table" error from the engine handling the table, it should proceed and delete the .frm file. Optionally a warning should be emitted.

Alternatively a modifier could be added: DELETE FORCE TABLE ... to activate this new behavior. Still I think the first solution is better because it makes no sense to keep the .frm file when we *know* that the table itself does not exist.