Bug #56754 ALTER TABLE ... RENAME does not rollback filename changes properly on OS X.
Submitted: 13 Sep 2010 16:58
Reporter: Jon Olav Hauglid Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DDL Severity:S3 (Non-critical)
Version:5.1, 5.5 OS:MacOS (10.6.4, 64 bit)
Assigned to: CPU Architecture:Any

[13 Sep 2010 16:58] Jon Olav Hauglid
Description:
With --lower-case-table-names=2 (default on Mac OS X), ALTER TABLE ... RENAME
does not preserve file names properly if it has to abort and rollback.

If a table is created using an upper case name, .frm/.MYI./.MYD will have
matching upper case names. However, if ALTER TABLE ... RENAME encounters
a problem after files have been renamed (such as when processing triggers),
the .frm/.MYI./MYD files will end up with lower case filenames.

RENAME TABLE works correctly.

How to repeat:
--source include/have_lowercase2.inc
CREATE TABLE T1(a INT);

# At this point we will have T1.frm, T1.MYI, T1.MYD

CREATE TRIGGER T1_BI BEFORE INSERT ON T1 FOR EACH ROW SET new.a= 1;
# Prevent renaming of trigger files from working so ALTER TABLE will abort.
let $MYSQLD_DATADIR= `select @@datadir`;
write_file $MYSQLD_DATADIR/test/T1_BI.TRN~;
dummy
EOF
chmod 0000 $MYSQLD_DATADIR/test/T1_BI.TRN~;
--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
--error 1
ALTER TABLE T1 RENAME T2;

# Here the file names will be t1.frm, t1.MYI, t1.MYD
# i.e. all converted to lowercase and not restored properly.

# Cleanup
chmod 0600 $MYSQLD_DATADIR/test/T1_BI.TRN~;
remove_file $MYSQLD_DATADIR/test/T1_BI.TRN~;
DROP TABLE T1;