List:Commits« Previous MessageNext Message »
From:Jon Olav Hauglid Date:September 26 2011 1:00pm
Subject:bzr push into mysql-trunk-wl5534 branch (jon.hauglid:3396 to 3397) WL#5534
View as plain text  
 3397 Jon Olav Hauglid	2011-09-26
      WL#5534 Online ALTER, Phase 1.
        
      Patch #26:
      - Change prepare_inplace_alter_table, inplace_alter_table,
        and commit_inplace_alter_table to return bool instead
        of int, to indicate that they are responsible for
        reporting their own errors.

    modified:
      sql/handler.cc
      sql/handler.h
      sql/sql_table.cc
 3396 Jon Olav Hauglid	2011-09-21
      WL#5534 Online ALTER, Phase 1.
        
      Patch #25:
      - Moved key parts initialization to compare_tables().
      - Removed unneeded TABLE_LIST parameter from
        handler::inplace_alter_table().

    modified:
      sql/handler.cc
      sql/handler.h
      sql/sql_table.cc
=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2011-09-21 08:17:09 +0000
+++ b/sql/handler.cc	2011-09-26 12:59:57 +0000
@@ -3881,9 +3881,9 @@ handler::check_if_supported_inplace_alte
 /*
   Default implementation to support old online add/drop index
  */
-int handler::inplace_alter_table(HA_CREATE_INFO *create_info,
-                                 Alter_inplace_information *ha_alter_info,
-                                 HA_ALTER_FLAGS *alter_flags)
+bool handler::inplace_alter_table(HA_CREATE_INFO *create_info,
+                                  Alter_inplace_information *ha_alter_info,
+                                  HA_ALTER_FLAGS *alter_flags)
 {
   DBUG_ENTER("inplace_alter_table");
   int error= 0;
@@ -3924,7 +3924,7 @@ int handler::inplace_alter_table(HA_CREA
       table->key_info= key_info;
       table->file->print_error(error, MYF(0));
       table->key_info= save_key_info;
-      DBUG_RETURN(error);
+      DBUG_RETURN(true);
     }
     ha_alter_info->pending_add_index= true;
   }
@@ -3942,7 +3942,7 @@ int handler::inplace_alter_table(HA_CREA
       if ((error= final_add_index(ha_alter_info->handler_ctx, true)))
       {
         print_error(error, MYF(0));
-        DBUG_RETURN(error);
+        DBUG_RETURN(true);
       }
       ha_alter_info->pending_add_index= false;
     }
@@ -3953,17 +3953,17 @@ int handler::inplace_alter_table(HA_CREA
                                    ha_alter_info->index_drop_count)))
     {
       table->file->print_error(error, MYF(0));
-      DBUG_RETURN(error);
+      DBUG_RETURN(true);
     }
   }
 
-  DBUG_RETURN(0);
+  DBUG_RETURN(false);
 }
 
-int handler::commit_inplace_alter_table(HA_CREATE_INFO *create_info,
-                                        Alter_inplace_information *ha_alter_info,
-                                        HA_ALTER_FLAGS *alter_flags,
-                                        bool commit)
+bool handler::commit_inplace_alter_table(HA_CREATE_INFO *create_info,
+                                         Alter_inplace_information *ha_alter_info,
+                                         HA_ALTER_FLAGS *alter_flags,
+                                         bool commit)
 {
   DBUG_ENTER("commit_inplace_alter_table");
   int error= 0;
@@ -3977,7 +3977,7 @@ int handler::commit_inplace_alter_table(
     if ((error= final_drop_index()))
     {
       print_error(error, MYF(0));
-      DBUG_RETURN(error);
+      DBUG_RETURN(true);
     }
   }
 
@@ -3987,16 +3987,16 @@ int handler::commit_inplace_alter_table(
     DBUG_EXECUTE_IF("alter_table_rollback_new_index", {
       final_add_index(ha_alter_info->handler_ctx, false);
       my_error(ER_UNKNOWN_ERROR, MYF(0));
-      DBUG_RETURN(ER_UNKNOWN_ERROR);
+      DBUG_RETURN(true);
     });
     if ((error= final_add_index(ha_alter_info->handler_ctx, commit)))
     {
       print_error(error, MYF(0));
-      DBUG_RETURN(error);
+      DBUG_RETURN(true);
     }
   }
 
-  DBUG_RETURN(0);
+  DBUG_RETURN(false);
 }
 
 /**

=== modified file 'sql/handler.h'
--- a/sql/handler.h	2011-09-21 08:17:09 +0000
+++ b/sql/handler.h	2011-09-26 12:59:57 +0000
@@ -2301,18 +2301,20 @@ public:
     writes blocked, otherwise the same level of locking as for
     inplace_alter_table() will be used.
 
+    @note Storage engines are responsible for reporting any errors.
+
     @param    create_info       Information from the parsing phase about new
                                 table properties.
     @param    ha_alter_info     Structure holding data used during in-place alter.
     @param    alter_flags       Bitmask that shows what will be changed.
 
-    @retval   != 0              Error
-    @retval   0                 Success
+    @retval   true              Error
+    @retval   false             Success
  */
- virtual int prepare_inplace_alter_table(HA_CREATE_INFO *create_info,
-                                         Alter_inplace_information *ha_alter_info,
-                                         HA_ALTER_FLAGS *alter_flags)
- { return 0; }
+ virtual bool prepare_inplace_alter_table(HA_CREATE_INFO *create_info,
+                                          Alter_inplace_information *ha_alter_info,
+                                          HA_ALTER_FLAGS *alter_flags)
+ { return false; }
 
 
  /**
@@ -2320,17 +2322,19 @@ public:
     and Alter_inplace_information. The level of concurrency allowed during this
     operation depends on the return value from check_if_supported_inplace_alter().
 
+    @note Storage engines are responsible for reporting any errors.
+
     @param    create_info       Information from the parsing phase about new
                                 table properties.
     @param    ha_alter_info     Structure holding data used during in-place alter.
     @param    alter_flags       Bitmask that shows what will be changed.
 
-    @retval   != 0              Error
-    @retval   0                 Success
+    @retval   true              Error
+    @retval   false             Success
  */
- virtual int inplace_alter_table(HA_CREATE_INFO *create_info,
-                                 Alter_inplace_information *ha_alter_info,
-                                 HA_ALTER_FLAGS *alter_flags);
+ virtual bool inplace_alter_table(HA_CREATE_INFO *create_info,
+                                  Alter_inplace_information *ha_alter_info,
+                                  HA_ALTER_FLAGS *alter_flags);
 
 
  /**
@@ -2341,19 +2345,21 @@ public:
     prepare_inplace_alter_table(). (E.g concurrent writes were blocked during
     prepare, but might not be during commit).
 
+    @note Storage engines are responsible for reporting any errors.
+
     @param    create_info       Information from the parsing phase about new
                                 table properties.
     @param    ha_alter_info     Structure holding data used during in-place alter.
     @param    alter_flags       Bitmask that shows what will be changed.
     @param    commit            True => Commit, False => Rollback.
 
-    @retval   != 0              Error
-    @retval   0                 Success
+    @retval   true              Error
+    @retval   false             Success
  */
- virtual int commit_inplace_alter_table(HA_CREATE_INFO *create_info,
-                                        Alter_inplace_information *ha_alter_info,
-                                        HA_ALTER_FLAGS *alter_flags,
-                                        bool commit);
+ virtual bool commit_inplace_alter_table(HA_CREATE_INFO *create_info,
+                                         Alter_inplace_information *ha_alter_info,
+                                         HA_ALTER_FLAGS *alter_flags,
+                                         bool commit);
 
 
  /**

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2011-09-21 08:17:09 +0000
+++ b/sql/sql_table.cc	2011-09-26 12:59:57 +0000
@@ -6139,7 +6139,6 @@ static bool mysql_inplace_alter_table(TH
   TABLE tab;
   TABLE_LIST tbl;
   handlerton *db_type= table->s->db_type();
-  int error= 0;
 
   DBUG_ENTER("mysql_inplace_alter_table");
 
@@ -6164,16 +6163,16 @@ static bool mysql_inplace_alter_table(TH
 
   // TODO: Fix locking
 
-  if ((error= table->file->prepare_inplace_alter_table(create_info,
-                                                       ha_alter_info,
-                                                       ha_alter_flags)))
+  if (table->file->prepare_inplace_alter_table(create_info,
+                                               ha_alter_info,
+                                               ha_alter_flags))
   {
     goto err;
   }
 
-  if ((error= table->file->inplace_alter_table(create_info,
-                                               ha_alter_info,
-                                               ha_alter_flags)))
+  if (table->file->inplace_alter_table(create_info,
+                                       ha_alter_info,
+                                       ha_alter_flags))
   {
     goto err;
   }
@@ -6181,10 +6180,10 @@ static bool mysql_inplace_alter_table(TH
   if (wait_while_table_is_used(thd, table, HA_EXTRA_PREPARE_FOR_RENAME))
     goto err;
 
-  if ((error= table->file->commit_inplace_alter_table(create_info,
-                                                      ha_alter_info,
-                                                      ha_alter_flags,
-                                                      true)))
+  if (table->file->commit_inplace_alter_table(create_info,
+                                              ha_alter_info,
+                                              ha_alter_flags,
+                                              true))
   {
     goto err;
   }

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk-wl5534 branch (jon.hauglid:3396 to 3397) WL#5534Jon Olav Hauglid26 Sep