BUG#19305: COALESCE partition left partition files undropped

parent e9056d85
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (f_date DATE, f_varchar VARCHAR(30))
PARTITION BY HASH(CAST(YEAR(f_date) AS SIGNED INTEGER)) PARTITIONS 2;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f_date` date DEFAULT NULL,
`f_varchar` varchar(30) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH (CAST(YEAR(f_date) AS SIGNED INTEGER)) PARTITIONS 2
/home/pappa/bug19305/mysql-test/var/master-data/test/t1#P#p0.MYD
/home/pappa/bug19305/mysql-test/var/master-data/test/t1#P#p0.MYI
/home/pappa/bug19305/mysql-test/var/master-data/test/t1#P#p1.MYD
/home/pappa/bug19305/mysql-test/var/master-data/test/t1#P#p1.MYI
/home/pappa/bug19305/mysql-test/var/master-data/test/t1.frm
/home/pappa/bug19305/mysql-test/var/master-data/test/t1.par
ALTER TABLE t1 COALESCE PARTITION 1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`f_date` date DEFAULT NULL,
`f_varchar` varchar(30) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH (CAST(YEAR(f_date) AS SIGNED INTEGER)) PARTITIONS 1
/home/pappa/bug19305/mysql-test/var/master-data/test/t1#P#p0.MYD
/home/pappa/bug19305/mysql-test/var/master-data/test/t1#P#p0.MYI
/home/pappa/bug19305/mysql-test/var/master-data/test/t1.frm
/home/pappa/bug19305/mysql-test/var/master-data/test/t1.par
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
CREATE TABLE t1 (f_date DATE, f_varchar VARCHAR(30))
PARTITION BY HASH(CAST(YEAR(f_date) AS SIGNED INTEGER)) PARTITIONS 2;
SHOW CREATE TABLE t1;
--exec ls $MYSQLTEST_VARDIR/master-data/test/t1*
ALTER TABLE t1 COALESCE PARTITION 1;
SHOW CREATE TABLE t1;
--exec ls $MYSQLTEST_VARDIR/master-data/test/t1*
...@@ -634,6 +634,8 @@ int ha_partition::drop_partitions(const char *path) ...@@ -634,6 +634,8 @@ int ha_partition::drop_partitions(const char *path)
DBUG_PRINT("info", ("Drop subpartition %s", part_name_buff)); DBUG_PRINT("info", ("Drop subpartition %s", part_name_buff));
if ((ret_error= file->delete_table((const char *) part_name_buff))) if ((ret_error= file->delete_table((const char *) part_name_buff)))
error= ret_error; error= ret_error;
if (deactivate_ddl_log_entry(sub_elem->log_entry->entry_pos))
error= 1;
} while (++j < no_subparts); } while (++j < no_subparts);
} }
else else
...@@ -645,6 +647,8 @@ int ha_partition::drop_partitions(const char *path) ...@@ -645,6 +647,8 @@ int ha_partition::drop_partitions(const char *path)
DBUG_PRINT("info", ("Drop partition %s", part_name_buff)); DBUG_PRINT("info", ("Drop partition %s", part_name_buff));
if ((ret_error= file->delete_table((const char *) part_name_buff))) if ((ret_error= file->delete_table((const char *) part_name_buff)))
error= ret_error; error= ret_error;
if (deactivate_ddl_log_entry(part_elem->log_entry->entry_pos))
error= 1;
} }
if (part_elem->part_state == PART_IS_CHANGED) if (part_elem->part_state == PART_IS_CHANGED)
part_elem->part_state= PART_NORMAL; part_elem->part_state= PART_NORMAL;
...@@ -652,6 +656,7 @@ int ha_partition::drop_partitions(const char *path) ...@@ -652,6 +656,7 @@ int ha_partition::drop_partitions(const char *path)
part_elem->part_state= PART_IS_DROPPED; part_elem->part_state= PART_IS_DROPPED;
} }
} while (++i < no_parts); } while (++i < no_parts);
VOID(sync_ddl_log());
DBUG_RETURN(error); DBUG_RETURN(error);
} }
...@@ -768,6 +773,7 @@ int ha_partition::rename_partitions(const char *path) ...@@ -768,6 +773,7 @@ int ha_partition::rename_partitions(const char *path)
*/ */
part_elem= part_it++; part_elem= part_it++;
if (part_elem->part_state == PART_IS_CHANGED || if (part_elem->part_state == PART_IS_CHANGED ||
part_elem->part_state == PART_TO_BE_DROPPED ||
(part_elem->part_state == PART_IS_ADDED && temp_partitions)) (part_elem->part_state == PART_IS_ADDED && temp_partitions))
{ {
if (m_is_sub_partitioned) if (m_is_sub_partitioned)
......
...@@ -1203,6 +1203,7 @@ typedef struct st_lock_param_type ...@@ -1203,6 +1203,7 @@ typedef struct st_lock_param_type
ulonglong deleted; ulonglong deleted;
THD *thd; THD *thd;
HA_CREATE_INFO *create_info; HA_CREATE_INFO *create_info;
ALTER_INFO *alter_info;
List<create_field> *create_list; List<create_field> *create_list;
List<create_field> new_create_list; List<create_field> new_create_list;
List<Key> *key_list; List<Key> *key_list;
......
...@@ -4968,8 +4968,7 @@ static bool write_log_dropped_partitions(ALTER_PARTITION_PARAM_TYPE *lpt, ...@@ -4968,8 +4968,7 @@ static bool write_log_dropped_partitions(ALTER_PARTITION_PARAM_TYPE *lpt,
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
*next_entry= log_entry->entry_pos; *next_entry= log_entry->entry_pos;
if (temp_list) sub_elem->log_entry= log_entry;
sub_elem->log_entry= log_entry;
insert_part_info_log_entry_list(part_info, log_entry); insert_part_info_log_entry_list(part_info, log_entry);
} while (++j < no_subparts); } while (++j < no_subparts);
} }
...@@ -4987,8 +4986,7 @@ static bool write_log_dropped_partitions(ALTER_PARTITION_PARAM_TYPE *lpt, ...@@ -4987,8 +4986,7 @@ static bool write_log_dropped_partitions(ALTER_PARTITION_PARAM_TYPE *lpt,
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
*next_entry= log_entry->entry_pos; *next_entry= log_entry->entry_pos;
if (temp_list) part_elem->log_entry= log_entry;
part_elem->log_entry= log_entry;
insert_part_info_log_entry_list(part_info, log_entry); insert_part_info_log_entry_list(part_info, log_entry);
} }
} }
...@@ -5262,7 +5260,7 @@ static bool write_log_final_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt) ...@@ -5262,7 +5260,7 @@ static bool write_log_final_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt)
lpt->table_name, "#"); lpt->table_name, "#");
pthread_mutex_lock(&LOCK_gdl); pthread_mutex_lock(&LOCK_gdl);
if (write_log_dropped_partitions(lpt, &next_entry, (const char*)path, if (write_log_dropped_partitions(lpt, &next_entry, (const char*)path,
TRUE)) lpt->alter_info->flags & ALTER_REORGANIZE_PARTITION))
goto error; goto error;
if (write_log_changed_partitions(lpt, &next_entry, (const char*)path)) if (write_log_changed_partitions(lpt, &next_entry, (const char*)path))
goto error; goto error;
...@@ -5516,6 +5514,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, ...@@ -5516,6 +5514,7 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
lpt->thd= thd; lpt->thd= thd;
lpt->part_info= part_info; lpt->part_info= part_info;
lpt->alter_info= alter_info;
lpt->create_info= create_info; lpt->create_info= create_info;
lpt->create_list= create_list; lpt->create_list= create_list;
lpt->key_list= key_list; lpt->key_list= key_list;
...@@ -5818,6 +5817,8 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, ...@@ -5818,6 +5817,8 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
ERROR_INJECT_CRASH("crash_change_partition_5") || ERROR_INJECT_CRASH("crash_change_partition_5") ||
(table->file->extra(HA_EXTRA_PREPARE_FOR_DELETE), FALSE) || (table->file->extra(HA_EXTRA_PREPARE_FOR_DELETE), FALSE) ||
ERROR_INJECT_CRASH("crash_change_partition_6") || ERROR_INJECT_CRASH("crash_change_partition_6") ||
mysql_drop_partitions(lpt) ||
ERROR_INJECT_CRASH("crash_change_partition_61") ||
mysql_rename_partitions(lpt) || mysql_rename_partitions(lpt) ||
((frm_install= TRUE), FALSE) || ((frm_install= TRUE), FALSE) ||
ERROR_INJECT_CRASH("crash_change_partition_7") || ERROR_INJECT_CRASH("crash_change_partition_7") ||
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment