List:Commits« Previous MessageNext Message »
From:mikael Date:February 14 2006 1:22pm
Subject:bk commit into 5.1 tree (mikron:1.2128)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of mikron. When mikron does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2128 06/02/14 14:22:21 mikron@stripped +3 -0
  WL 2826: Error handling of ALTER TABLE for partitioning
  First step for handling errors in ALTER TABLE for partitioning

  sql/sql_table.cc
    1.318 06/02/14 14:22:06 mikron@stripped +28 -16
    First step for handling errors in ALTER TABLE for partitioning

  sql/sql_partition.cc
    1.49 06/02/14 14:22:06 mikron@stripped +44 -7
    First step for handling errors in ALTER TABLE for partitioning

  sql/ha_partition.cc
    1.33 06/02/14 14:22:06 mikron@stripped +26 -16
    First step for handling errors in ALTER TABLE for partitioning

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	mikron
# Host:	mikael-ronstr-ms-dator.local
# Root:	/Users/mikron/wl2826

--- 1.317/sql/sql_table.cc	2006-02-14 11:08:45 +01:00
+++ 1.318/sql/sql_table.cc	2006-02-14 14:22:06 +01:00
@@ -320,7 +320,8 @@
   uint io_size= global_table_log.io_size;
   DBUG_ENTER("read_table_log_file_entry");
 
-  if (my_pread(file_id, file_entry, io_size, io_size * entry_no, MYF(0)))
+  if (my_pread(file_id, file_entry, io_size, io_size * entry_no,
+               MYF(MY_WME)))
     error= TRUE;
   DBUG_RETURN(error);
 }
@@ -346,7 +347,7 @@
   DBUG_ENTER("write_table_log_file_entry");
 
   if (my_pwrite(file_id, file_entry,
-                IO_SIZE, IO_SIZE * entry_no, MYF(0)) != IO_SIZE)
+                IO_SIZE, IO_SIZE * entry_no, MYF(MY_WME)) != IO_SIZE)
     error= TRUE;
   DBUG_RETURN(error);
 }
@@ -383,7 +384,7 @@
   if (write_table_log_file_entry(0UL))
     error= TRUE;
   if (!error)
-    error= sync_table_log();
+    VOID(sync_table_log());
   DBUG_RETURN(error);
 }
 
@@ -430,7 +431,7 @@
 
   bzero(file_entry, sizeof(global_table_log.file_entry));
   create_table_log_file_name(file_name);
-  if (!(my_open(file_name, O_RDWR | O_TRUNC | O_BINARY, MYF(0))))
+  if (!(my_open(file_name, O_RDWR | O_TRUNC | O_BINARY, MYF(MY_WME))))
   {
     if (read_table_log_file_entry(0UL))
     {
@@ -517,7 +518,7 @@
   if ((global_table_log.file_id= my_create(file_name,
                                            CREATE_MODE,
                                            O_RDWR | O_TRUNC | O_BINARY,
-                                           MYF(0))) < 0)
+                                           MYF(MY_WME))) < 0)
   {
     /* Couldn't create table log file, this is serious error */
     abort();
@@ -564,6 +565,7 @@
   hton= ha_resolve_by_name(current_thd, handler_name);
   if (!hton)
   {
+    my_error(ER_ILLEGAL_HA, table_log_entry->handler_type);
     DBUG_RETURN(TRUE);
   }
   init_sql_alloc(&mem_root, TABLE_ALLOC_BLOCK_SIZE, 0); 
@@ -573,7 +575,10 @@
   {
     file= get_new_handler(table_share, &mem_root, hton);
     if (!file)
+    {
+      mem_alloc_error(sizeof(handler));
       goto error;
+    }
   }
   switch (table_log_entry->action_type)
     case TLOG_ACTION_DELETE_CODE:
@@ -585,20 +590,24 @@
         if (frm_action)
         {
           strxmov(path, table_log_entry->name, reg_ext, NullS);
-          VOID(my_delete(path, MYF(0)));
+          if (my_delete(path, MYF(MY_WME)))
+            break;
           strxmov(path, table_log_entry->name, par_ext, NullS);
-          VOID(my_delete(path, MYF(0)));
+          if (my_delete(path, MYF(MY_WME)))
+            break;
         }
         else
         {
           if (file->delete_table(table_name))
             break;
         }
-        if ((!inactivate_table_log_entry(table_log_entry->entry_pos)) &&
-            (!sync_table_log()))
+        if ((!inactivate_table_log_entry(table_log_entry->entry_pos)))
           ;
         else
+        {
+          VOID(sync_table_log());
           error= FALSE;
+        }
         break;
       }
       if (table_log_entry->action_type == TLOG_ACTION_DELETE_CODE)
@@ -609,11 +618,11 @@
       {
         strxmov(path, table_log_entry->name, reg_ext, NullS);
         strxmov(from_path, table_log_entry->from_name, reg_ext, NullS);
-        if (my_rename(path, from_path, MYF(0)))
+        if (my_rename(path, from_path, MYF(MY_WME)))
           break;
         strxmov(path, table_log_entry->name, par_ext, NullS);
         strxmov(from_path, table_log_entry->from_name, par_ext, NullS);
-        if (my_rename(path, from_path, MYF(0)))
+        if (my_rename(path, from_path, MYF(MY_WME)))
           break;
       }
       else
@@ -621,11 +630,13 @@
         if (file->rename_table(table_log_entry->name,
                                table_log_entry->from_name))
           break;
-        if ((!inactivate_table_log_entry(table_log_entry->entry_pos)) &&
-            (!sync_table_log()))
+        if ((!inactivate_table_log_entry(table_log_entry->entry_pos)))
           ;
         else
+        {
+          VOID(sync_table_log());
           error= FALSE;
+        }
       }
       break;
     default:
@@ -662,7 +673,7 @@
   if (global_table_log.first_free == NULL)
   {
     if (!(used_entry= (TABLE_LOG_MEMORY_ENTRY*)my_malloc(
-                              sizeof(TABLE_LOG_MEMORY_ENTRY), MYF(0))))
+                              sizeof(TABLE_LOG_MEMORY_ENTRY), MYF(MY_WME))))
     {
       DBUG_RETURN(TRUE);
     }
@@ -748,7 +759,8 @@
     error= TRUE;
   if (write_header && !error)
   {
-    if (sync_table_log() || write_table_log_header())
+    VOID(sync_table_log());
+    if (write_table_log_header())
       error= TRUE;
   }
   if (error)
@@ -1232,7 +1244,7 @@
     VOID(pthread_mutex_lock(&LOCK_open));
     if (my_delete(frm_name, MYF(MY_WME)) ||
         inactivate_table_log_entry(part_info->frm_log_entry->entry_pos) ||
-        sync_table_log() ||
+        (sync_table_log(), FALSE) ||
         my_rename(shadow_frm_name, frm_name, MYF(MY_WME)) ||
         lpt->table->file->create_handler_files(path, shadow_path, TRUE))
     {

--- 1.32/sql/ha_partition.cc	2006-02-11 06:41:31 +01:00
+++ 1.33/sql/ha_partition.cc	2006-02-14 14:22:06 +01:00
@@ -584,6 +584,7 @@
   uint no_subparts= m_part_info->no_subparts;
   uint i= 0;
   uint name_variant;
+  int  ret_error;
   int  error= 0;
   DBUG_ENTER("ha_partition::drop_partitions");
 
@@ -610,7 +611,8 @@
                                    sub_elem->partition_name, name_variant);
           file= m_file[part];
           DBUG_PRINT("info", ("Drop subpartition %s", part_name_buff));
-          error+= file->delete_table((const char *) part_name_buff);
+          if ((ret_error= file->delete_table((const char *) part_name_buff)))
+            error= ret_error;
         } while (++j < no_subparts);
       }
       else
@@ -620,7 +622,8 @@
                               TRUE);
         file= m_file[i];
         DBUG_PRINT("info", ("Drop partition %s", part_name_buff));
-        error+= file->delete_table((const char *) part_name_buff);
+        if ((ret_error= file->delete_table((const char *) part_name_buff)))
+          error= ret_error;
       }
       if (part_elem->part_state == PART_IS_CHANGED)
         part_elem->part_state= PART_NORMAL;
@@ -663,6 +666,7 @@
   uint i= 0;
   uint j= 0;
   int error= 0;
+  int ret_error;
   uint temp_partitions= m_part_info->temp_partitions.elements;
   handler *file;
   partition_element *part_elem, *sub_elem;
@@ -693,8 +697,9 @@
                                    sub_elem->partition_name,
                                    NORMAL_PART_NAME);
           DBUG_PRINT("info", ("Delete subpartition %s", norm_name_buff));
-          if (file->delete_table((const char *) norm_name_buff) ||
-              inactivate_table_log_entry(sub_elem->log_entry->entry_pos))
+          if ((ret_error= file->delete_table((const char *) norm_name_buff)))
+            error= ret_error;
+          else if (inactivate_table_log_entry(sub_elem->log_entry->entry_pos))
             error= 1;
           else
             sub_elem->log_entry= NULL; /* Indicate success */
@@ -707,8 +712,9 @@
                               part_elem->partition_name, NORMAL_PART_NAME,
                               TRUE);
         DBUG_PRINT("info", ("Delete partition %s", norm_name_buff));
-        if (file->delete_table((const char *) norm_name_buff) ||
-            inactivate_table_log_entry(sub_elem->log_entry->entry_pos))
+        if ((ret_error= file->delete_table((const char *) norm_name_buff)))
+          error= ret_error;
+        else if (inactivate_table_log_entry(sub_elem->log_entry->entry_pos))
           error= 1;
         else
           sub_elem->log_entry= NULL; /* Indicate success */
@@ -761,8 +767,9 @@
           {
             file= m_reorged_file[part_count++];
             DBUG_PRINT("info", ("Delete subpartition %s", norm_name_buff));
-            if (file->delete_table((const char *) norm_name_buff) ||
-              inactivate_table_log_entry(sub_elem->log_entry->entry_pos))
+            if ((ret_error= file->delete_table((const char *) norm_name_buff)))
+              error= ret_error;
+            else if (inactivate_table_log_entry(sub_elem->log_entry->entry_pos))
               error= 1;
             VOID(sync_table_log());
           }
@@ -773,9 +780,10 @@
                                    TEMP_PART_NAME);
           DBUG_PRINT("info", ("Rename subpartition from %s to %s",
                      part_name_buff, norm_name_buff));
-          if (file->rename_table((const char *) norm_name_buff,
-                                 (const char *) part_name_buff) ||
-              inactivate_table_log_entry(sub_elem->log_entry->entry_pos))
+          if ((ret_error= file->rename_table((const char *) norm_name_buff,
+                                             (const char *) part_name_buff)))
+            error= ret_error;
+          else if (inactivate_table_log_entry(sub_elem->log_entry->entry_pos))
             error= 1;
           else
             sub_elem->log_entry= NULL;
@@ -790,8 +798,9 @@
         {
           file= m_reorged_file[part_count++];
           DBUG_PRINT("info", ("Delete subpartition %s", norm_name_buff));
-          if (file->delete_table((const char *) norm_name_buff) ||
-            inactivate_table_log_entry(part_elem->log_entry->entry_pos))
+          if ((ret_error= file->delete_table((const char *) norm_name_buff)))
+            error= ret_error;
+          else if (inactivate_table_log_entry(part_elem->log_entry->entry_pos))
             error= 1;
           VOID(sync_table_log());
         }
@@ -801,9 +810,10 @@
                               TRUE);
         DBUG_PRINT("info", ("Rename partition from %s to %s",
                    part_name_buff, norm_name_buff));
-        if (file->rename_table((const char *) norm_name_buff,
-                               (const char *) part_name_buff) ||
-            inactivate_table_log_entry(part_elem->log_entry->entry_pos))
+        if ((ret_error= file->rename_table((const char *) norm_name_buff,
+                                           (const char *) part_name_buff)))
+          error= ret_error;
+        else if (inactivate_table_log_entry(part_elem->log_entry->entry_pos))
           error= 1;
         else
           part_elem->log_entry= NULL;

--- 1.48/sql/sql_partition.cc	2006-02-14 11:08:45 +01:00
+++ 1.49/sql/sql_partition.cc	2006-02-14 14:22:06 +01:00
@@ -4975,14 +4975,17 @@
 static bool mysql_change_partitions(ALTER_PARTITION_PARAM_TYPE *lpt)
 {
   char path[FN_REFLEN+1];
+  int error;
+  handler *file= lpt->table->file;
   DBUG_ENTER("mysql_change_partitions");
 
   build_table_filename(path, sizeof(path), lpt->db, lpt->table_name, "");
-  DBUG_RETURN(lpt->table->file->change_partitions(lpt->create_info, path,
-                                                  &lpt->copied,
-                                                  &lpt->deleted,
-                                                  lpt->pack_frm_data,
-                                                  lpt->pack_frm_len));
+  DBUG_RETURN(file->change_partitions(lpt->create_info,
+                                      path,
+                                      &lpt->copied,
+                                      &lpt->deleted,
+                                      lpt->pack_frm_data,
+                                      lpt->pack_frm_len));
 }
 
 
@@ -5008,10 +5011,17 @@
 static bool mysql_rename_partitions(ALTER_PARTITION_PARAM_TYPE *lpt)
 {
   char path[FN_REFLEN+1];
+  int error;
   DBUG_ENTER("mysql_rename_partitions");
 
   build_table_filename(path, sizeof(path), lpt->db, lpt->table_name, "");
-  DBUG_RETURN(lpt->table->file->rename_partitions(path));
+  if ((error= lpt->table->file->rename_partitions(path)))
+  {
+    if (error != 1)
+      lpt->table->file->print_error(error, MYF(0));
+    DBUG_RETURN(TRUE);
+  }
+  DBUG_RETURN(FALSE);
 }
 
 
@@ -5042,11 +5052,13 @@
   List_iterator<partition_element> part_it(part_info->partitions);
   uint i= 0;
   uint remove_count= 0;
+  int error;
   DBUG_ENTER("mysql_drop_partitions");
 
   build_table_filename(path, sizeof(path), lpt->db, lpt->table_name, "");
-  if (lpt->table->file->drop_partitions(path))
+  if ((error= lpt->table->file->drop_partitions(path)))
   {
+    lpt->table->file->print_error(error, MYF(0));
     DBUG_RETURN(TRUE);
   }
   do
@@ -5920,6 +5932,31 @@
       abort();
       if (!not_completed)
         abort();
+      if (!part_info->first_log_entry &&
+          execute_table_log_entry(part_info->first_log_entry))
+      {
+        /*
+          We couldn't recover from error
+        */
+      }
+      else
+      {
+        if (not_completed)
+        {
+          /*
+            We hit an error before things were completed but managed
+            to recover from the error.
+          */
+        }
+        else
+        {
+          /*
+            We hit an error after we had completed most of the operation
+            and were successful in a second attempt so the operation
+            actually is successful now.
+          */
+        }
+      }
       fast_alter_partition_error_handler(lpt);
       DBUG_RETURN(TRUE);
     }
Thread
bk commit into 5.1 tree (mikron:1.2128)mikael14 Feb