static bool mysql_change_partitions(ALTER_PARTITION_PARAM_TYPE *lpt)
{
  char path[FN_REFLEN+1];
  int error;
  handler *file= lpt->table->file;
  THD *thd= lpt->thd;
  DBUG_ENTER("mysql_change_partitions");

  build_table_filename(path, sizeof(path) - 1, lpt->db, lpt->table_name, "", 0);

  /* First lock the original tables */
  if (file->ha_external_lock(thd, F_WRLCK))
    DBUG_RETURN(TRUE);

  /* Disable transactions for all new tables */
  if (mysql_trans_prepare_alter_copy_data(thd))
    DBUG_RETURN(TRUE);

  /* TODO: test if bulk_insert would increase the performance */

  if ((error= file->ha_change_partitions(lpt->create_info, path, &lpt->copied,
                                         &lpt->deleted, lpt->pack_frm_data,
                                         lpt->pack_frm_len)))
  {
    file->print_error(error, MYF(error != ER_OUTOFMEMORY ? 0 : ME_FATALERROR));
  }

  if (mysql_trans_commit_alter_copy_data(thd))
    error= 1;                                /* The error has been reported */

  if (file->ha_external_lock(thd, F_UNLCK))
    error= 1;

  DBUG_RETURN(test(error));
}
static bool mysql_change_partitions(ALTER_PARTITION_PARAM_TYPE *lpt)
{
  char path[FN_REFLEN+1];
  int error;
  handler *file= lpt->table->file;
  THD *thd= lpt->thd;
  DBUG_ENTER("mysql_change_partitions");

  build_table_filename(path, sizeof(path) - 1, lpt->db, lpt->table_name, "", 0);

   
  if (file->ha_external_lock(thd, F_WRLCK))
    DBUG_RETURN(TRUE);

   
  if (mysql_trans_prepare_alter_copy_data(thd))
    DBUG_RETURN(TRUE);

   

  if ((error= file->ha_change_partitions(lpt->create_info, path, &lpt->copied,
                                         &lpt->deleted, lpt->pack_frm_data,
                                         lpt->pack_frm_len)))
  {
    file->print_error(error, MYF(error != ER_OUTOFMEMORY ? 0 : ME_FATALERROR));
  }

  if (mysql_trans_commit_alter_copy_data(thd))
    error= 1;                                 

  if (file->ha_external_lock(thd, F_UNLCK))
    error= 1;

  DBUG_RETURN(test(error));
}