preserve stored FRM in ARZ across OPTIMIZE TABLE. filed as http://bugs.mysql.com/bug.php?id=45377 --- storage/archive/ha_archive.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) Index: mysql-5.1/storage/archive/ha_archive.cc =================================================================== --- mysql-5.1.orig/storage/archive/ha_archive.cc 2009-06-23 14:47:17.296582502 +1000 +++ mysql-5.1/storage/archive/ha_archive.cc 2009-07-21 00:12:51.438625713 +1000 @@ -1285,12 +1285,25 @@ int ha_archive::optimize(THD* thd, HA_CH share->archive_write_open= FALSE; } + char* frm_string; + frm_string= (char*)malloc(sizeof(char) * archive.frm_length); + if (!frm_string) + { + return ENOMEM; + } + azread_frm(&archive, frm_string); + /* Lets create a file to contain the new data */ fn_format(writer_filename, share->table_name, "", ARN, MY_REPLACE_EXT | MY_UNPACK_FILENAME); if (!(azopen(&writer, writer_filename, O_CREAT|O_RDWR|O_BINARY))) - DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); + { + free(frm_string); + DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); + } + + azwrite_frm(&writer, frm_string, archive.frm_length); /* An extended rebuild is a lot more effort. We open up each row and re-record it. @@ -1361,9 +1374,10 @@ int ha_archive::optimize(THD* thd, HA_CH // make the file we just wrote be our data file rc = my_rename(writer_filename,share->data_file_name,MYF(0)); - + free(frm_string); DBUG_RETURN(rc); error: + free(frm_string); DBUG_PRINT("ha_archive", ("Failed to recover, error was %d", rc)); azclose(&writer);