Commit f3754552 authored by unknown's avatar unknown
Browse files

bug #14354 - data directory and index directory not working for partitions


mysql-test/r/partition_mgm_err.result:
  only the single drop table since we have disabled query logging for the create table
mysql-test/t/partition_mgm_err.test:
  test for bug #14354
  first make sure /tmp/bug14354 is not there, then make the dir
  create a partitioned table with the partition using
  /tmp/bug14354 as it's data dir
  we are disabling query logging since we are using $MYSQL_TEST_DIR
  and we are not certain where the tmp files will be created.
sql/ha_partition.cc:
  pass partition filename with pathname into 
  set_up_table_before_create.
  
  remove the path from the passed in value and then append the filename
  to the data_file_name or index_file_name if those values were
  specified.
sql/ha_partition.h:
  added partition_name_with_path to set_up_table_before_create
sql/mysql_priv.h:
  move append_file_to_dir to mysql_priv.h
sql/sql_parse.cc:
  moving append_file_to_dir to mysql_priv.h
sql/sql_partition.cc:
  add_keyword_string was not writing keyword value with quotes
parent 20d0d10e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -107,3 +107,4 @@ ALTER TABLE t1 DROP PARTITION x1;
ALTER TABLE t1 DROP PARTITION x0;
ERROR HY000: Cannot remove all partitions, use DROP TABLE instead
DROP TABLE t1;
DROP TABLE t1;
+16 −0
Original line number Diff line number Diff line
@@ -158,3 +158,19 @@ ALTER TABLE t1 DROP PARTITION x1;
ALTER TABLE t1 DROP PARTITION x0;

DROP TABLE t1;

#
# BUG: 14354 Partitions: data directory clause fails
#
--exec rm -rf $MYSQL_TEST_DIR/var/tmp/bug14354
--exec mkdir $MYSQL_TEST_DIR/var/tmp/bug14354
disable_query_log;
eval CREATE TABLE t1 (id int) PARTITION BY RANGE(id) (
PARTITION p1 VALUES LESS THAN (20) ENGINE=myiasm 
DATA DIRECTORY="$MYSQL_TEST_DIR/var/tmp/bug14354" 
INDEX DIRECTORY="$MYSQL_TEST_DIR/var/tmp/bug14354");
enable_query_log;
--exec test -f $MYSQL_TEST_DIR/var/tmp/bug14354/t1_p1.MYD
--exec test -f $MYSQL_TEST_DIR/var/tmp/bug14354/t1_p1.MYI
DROP TABLE t1;
--exec rm -rf $MYSQL_TEST_DIR/var/tmp/bug14354
+13 −3
Original line number Diff line number Diff line
@@ -507,7 +507,7 @@ uint ha_partition::del_ren_cre_table(const char *from,
      error= (*file)->delete_table((const char*) from_buff);
    else
    {
      set_up_table_before_create(table_arg, create_info, i);
      set_up_table_before_create(table_arg, from_buff, create_info, i);
      error= (*file)->create(from_buff, table_arg, create_info);
    }
    name_buffer_ptr= strend(name_buffer_ptr) + 1;
@@ -550,6 +550,7 @@ partition_element *ha_partition::find_partition_element(uint part_id)


void ha_partition::set_up_table_before_create(TABLE *table,
                   const char *partition_name_with_path, 
                   HA_CREATE_INFO *info,
                   uint part_id)
{
@@ -565,6 +566,15 @@ void ha_partition::set_up_table_before_create(TABLE *table,
    return;                                     // Fatal error
  table->s->max_rows= part_elem->part_max_rows;
  table->s->min_rows= part_elem->part_min_rows;
  char *partition_name= strrchr(partition_name_with_path, FN_LIBCHAR);
  if (part_elem->index_file_name)
    append_file_to_dir(current_thd,
                       (const char**)&part_elem->index_file_name,
                       partition_name+1);
  if (part_elem->data_file_name)
    append_file_to_dir(current_thd,
                       (const char**)&part_elem->data_file_name,
                       partition_name+1);
  info->index_file_name= part_elem->index_file_name;
  info->data_file_name= part_elem->data_file_name;
}
+4 −2
Original line number Diff line number Diff line
@@ -197,7 +197,9 @@ class ha_partition :public handler
  bool new_handlers_from_part_info();
  bool create_handlers();
  void clear_handler_file();
  void set_up_table_before_create(TABLE * table_arg, HA_CREATE_INFO * info,
  void set_up_table_before_create(TABLE *table_arg,
                                  const char *partition_name_with_path,
                                  HA_CREATE_INFO *info,
                                  uint part_id);
  partition_element *find_partition_element(uint part_id);
public:
+2 −0
Original line number Diff line number Diff line
@@ -636,6 +636,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
		      char* packet, uint packet_length);
void log_slow_statement(THD *thd);
bool check_dup(const char *db, const char *name, TABLE_LIST *tables);
bool append_file_to_dir(THD *thd, const char **filename_ptr, 
                        const char *table_name);

bool table_cache_init(void);
void table_cache_free(void);
Loading