Commit 9a40c5bf authored by unknown's avatar unknown
Browse files

WL 2826: Error handling of ALTER TABLE for partitioning

After review changes


mysql-test/r/ndb_partition_key.result:
  Fixed result file
sql/ha_ndbcluster.cc:
  Fixed interface to create_handler_files
sql/ha_ndbcluster.h:
  Fixed interface to create_handler_files
sql/ha_partition.cc:
  Fixed interface to create_handler_files and made it two-stage for rename
  Removed print_error and now it's used by MySQL Server parts instead
sql/ha_partition.h:
  Fixed interface to create_handler_files
sql/mysql_priv.h:
  Fixed error injects
  Externalised Global DDL log mutex
  Some interface changes
sql/mysqld.cc:
  Moved close of DDL log until all user threads been closed
sql/sql_base.cc:
  Interface changes
sql/sql_partition.cc:
  Moved print_error to mysql server part
sql/sql_table.cc:
  Lots of after review changes
sql/table.cc:
  Fixed upgrade code
parent b7b95ecf
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -178,6 +178,7 @@ ALTER TABLE t1 ANALYZE PARTITION p0;
ERROR HY000: Table storage engine for 't1' doesn't have this option
ALTER TABLE t1 REBUILD PARTITION p0;
ERROR HY000: Table storage engine for 't1' doesn't have this option
DROP TABLE t1;
CREATE TABLE t1 (
c1 MEDIUMINT NOT NULL AUTO_INCREMENT,
c2 TEXT NOT NULL,
+2 −2
Original line number Diff line number Diff line
@@ -4689,7 +4689,7 @@ int ha_ndbcluster::create(const char *name,

int ha_ndbcluster::create_handler_files(const char *file,
                                        const char *old_name,
                                        bool rename_flag) 
                                        int action_flag) 
{ 
  const char *name;
  Ndb* ndb;
@@ -4700,7 +4700,7 @@ int ha_ndbcluster::create_handler_files(const char *file,

  DBUG_ENTER("create_handler_files");

  if (rename_flag)
  if (action_flag)
  {
    DBUG_RETURN(FALSE);
  }
+1 −1
Original line number Diff line number Diff line
@@ -612,7 +612,7 @@ class ha_ndbcluster: public handler
  int delete_table(const char *name);
  int create(const char *name, TABLE *form, HA_CREATE_INFO *info);
  int create_handler_files(const char *file, const char *old_name,
                           bool rename_flag);
                           int action_flag);
  int get_default_no_partitions(ulonglong max_rows);
  bool get_no_parts(const char *name, uint *no_parts);
  void set_auto_partitions(partition_info *part_info);
+12 −12
Original line number Diff line number Diff line
@@ -495,7 +495,7 @@ int ha_partition::rename_table(const char *from, const char *to)

int ha_partition::create_handler_files(const char *path,
                                       const char *old_path,
                                       bool rename_flag)
                                       int action_flag)
{
  DBUG_ENTER("ha_partition::create_handler_files()");

@@ -503,15 +503,17 @@ int ha_partition::create_handler_files(const char *path,
    We need to update total number of parts since we might write the handler
    file as part of a partition management command
  */
  if (rename_flag)
  if (action_flag)
  {
    char name[FN_REFLEN];
    char old_name[FN_REFLEN];

    strxmov(name, path, ha_par_ext, NullS);
    strxmov(old_name, old_path, ha_par_ext, NullS);
    if (my_delete(name, MYF(MY_WME)) ||
        my_rename(old_name, name, MYF(MY_WME)))
    if ((action_flag == CHF_DELETE_FLAG &&
         my_delete(name, MYF(MY_WME))) ||
        (action_flag == CHF_RENAME_FLAG &&
         my_rename(old_name, name, MYF(MY_WME))))
    {
      DBUG_RETURN(TRUE);
    }
@@ -1153,7 +1155,6 @@ int ha_partition::prepare_new_partition(TABLE *table,
error:
  if (create_flag)
    VOID(file->delete_table(part_name));
  print_error(error, MYF(0));
  DBUG_RETURN(error);
}

@@ -1280,7 +1281,7 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
                                              (m_reorged_parts + 1))))
  {
    mem_alloc_error(sizeof(partition_element*)*(m_reorged_parts+1));
    DBUG_RETURN(TRUE);
    DBUG_RETURN(ER_OUTOFMEMORY);
  }

  /*
@@ -1312,7 +1313,7 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
                                              (2*(no_remain_partitions + 1)))))
  {
    mem_alloc_error(sizeof(handler*)*2*(no_remain_partitions+1));
    DBUG_RETURN(TRUE);
    DBUG_RETURN(ER_OUTOFMEMORY);
  }
  m_added_file= &new_file_array[no_remain_partitions + 1];

@@ -1384,7 +1385,7 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
                                            part_elem->engine_type)))
        {
          mem_alloc_error(sizeof(handler));
          DBUG_RETURN(TRUE);
          DBUG_RETURN(ER_OUTOFMEMORY);
        }
      } while (++j < no_subparts);
    }
@@ -1432,7 +1433,7 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
                                            (const char *)part_name_buff)))
          {
            cleanup_new_partition(part_count);
            DBUG_RETURN(TRUE);
            DBUG_RETURN(error);
          }
          m_added_file[part_count++]= new_file_array[part];
        } while (++j < no_subparts);
@@ -1448,7 +1449,7 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
                                          (const char *)part_name_buff)))
        {
          cleanup_new_partition(part_count);
          DBUG_RETURN(TRUE);
          DBUG_RETURN(error);
        }
        m_added_file[part_count++]= new_file_array[i];
      }
@@ -1554,8 +1555,7 @@ int ha_partition::copy_partitions(ulonglong *copied, ulonglong *deleted)
  }
  DBUG_RETURN(FALSE);
error:
  print_error(result, MYF(0));
  DBUG_RETURN(TRUE);
  DBUG_RETURN(result);
}


+1 −1
Original line number Diff line number Diff line
@@ -180,7 +180,7 @@ class ha_partition :public handler
  virtual int create(const char *name, TABLE *form,
		     HA_CREATE_INFO *create_info);
  virtual int create_handler_files(const char *name,
                                   const char *old_name, bool rename_flag);
                                   const char *old_name, int action_flag);
  virtual void update_create_info(HA_CREATE_INFO *create_info);
  virtual char *update_table_comment(const char *comment);
  virtual int change_partitions(HA_CREATE_INFO *create_info,
Loading