Bug #27381 InnoDB exits when attempting to rename table to non-existant database
Submitted: 22 Mar 2007 18:52 Modified: 7 Apr 2007 20:26
Reporter: Harrison Fisk
Status: Closed
Category:Server: InnoDB Severity:S2 (Serious)
Version:MySQL 5.0.36, 5.1 OS:Any (All)
Assigned to: Vasil Dimov Target Version:
Tags: crash, innodb, rename

[22 Mar 2007 18:52] Harrison Fisk
Description:
When you start the system with innodb_file_per_table and attempt to rename an InnoDB table
to a different database that doesn't exist, then InnoDB will exit with the following
message:

InnoDB: Operating system error number 2 in a file operation.
InnoDB: The error means the system cannot find the path specified.
InnoDB: File name ./test/ibtest.ibd
InnoDB: File operation call: 'rename'.
InnoDB: Cannot continue operation.

How to repeat:
Start MySQL with innodb_file_per_table = 1 then issue the following statements:

CREATE TABLE ibtest (id int) ENGINE=InnoDB;
RENAME TABLE ibtest TO non_existing_database.ibtest;

Suggested fix:
RENAME TABLE calls os_file_rename in the file innobase/os/os0file.c  

When this function gets a failed rename, then it calls os_file_handle_error which exits. 
Instead it could call os_file_handle_error_no_exit either all of the time, or
conditionally when required since renaming failing isn't bad for RENAME TABLE.
[22 Mar 2007 20:10] Vasil Dimov
I will take it
[23 Mar 2007 12:35] Vasil Dimov
I confirm the issue (tested on 5.1.18-beta BK)
[23 Mar 2007 18:35] Heikki Tuuri
Vasil,

thank you. Excellent work!

This should be fixed both in 5.0 and 5.1.

Regards,

Heikki
[26 Mar 2007 21:49] Vasil Dimov
The fix has been committed to 5.0 and 5.1 InnoDB repositories.
[6 Apr 2007 19:21] Bugs System
Pushed into 5.0.40
[6 Apr 2007 19:25] Bugs System
Pushed into 5.1.18-beta
[7 Apr 2007 20:26] Paul DuBois
Noted in 5.0.40, 5.1.18  changelogs.

With innodb_file_per_table enabled, attempting to rename an InnoDB
table to a non-existent database caused the server to exit.