[Commits] bzr commit into Mariadb 5.2, with Maria 2.0:maria/5.2 branch (monty:2829)

Michael Widenius michael.widenius at gmail.com
Wed Jul 21 02:07:53 EEST 2010


#At lp:maria/5.2 based on revid:monty at mysql.com-20100719185328-5dzjcy1fksdok0qo

 2829 Michael Widenius	2010-07-21
      Fix for LP#588599, mysqlbug#45377: ARCHIVE tables aren't discoverable after OPTIMIZE
      Fix based on code from Stewart Smith
      modified:
        storage/archive/ha_archive.cc

per-file messages:
  storage/archive/ha_archive.cc
    Ensure that the frm definition is stored in optimized tables.
=== modified file 'storage/archive/ha_archive.cc'
--- a/storage/archive/ha_archive.cc	2010-06-01 19:52:20 +0000
+++ b/storage/archive/ha_archive.cc	2010-07-20 23:07:45 +0000
@@ -1290,10 +1290,11 @@ int ha_archive::repair(THD* thd, HA_CHEC
 */
 int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
 {
-  DBUG_ENTER("ha_archive::optimize");
   int rc= 0;
   azio_stream writer;
   char writer_filename[FN_REFLEN];
+  char* frm_string;
+  DBUG_ENTER("ha_archive::optimize");
 
   init_archive_reader();
 
@@ -1304,12 +1305,28 @@ int ha_archive::optimize(THD* thd, HA_CH
     share->archive_write_open= FALSE;
   }
 
+  if (!(frm_string= (char*) malloc(archive.frm_length)))
+    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);
+  }
+
+  rc= azwrite_frm(&writer, frm_string, archive.frm_length);
+  free(frm_string);
+  if (rc)
+  {
+    rc= HA_ERR_CRASHED_ON_USAGE;
+    goto error;
+  }
 
   /* 
     An extended rebuild is a lot more effort. We open up each row and re-record it. 
@@ -1387,7 +1404,6 @@ 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));
 
-
   DBUG_RETURN(rc);
 error:
   DBUG_PRINT("ha_archive", ("Failed to recover, error was %d", rc));



More information about the commits mailing list