BUG#19122: Need to close all handlers before rename/drop phase in ALTER TABLE...

BUG#19122: Need to close all handlers before rename/drop phase in ALTER TABLE ADD/DROP/REORGANIZE partitions
After review fix
parent 1068ab15
......@@ -890,6 +890,11 @@ s1
2
3
drop table t1;
create table t1 (a int) engine=memory
partition by key(a);
insert into t1 values (1);
create index inx1 on t1(a);
drop table t1;
create table t1 (a int)
partition by key (a)
(partition p1 engine = innodb);
......@@ -900,10 +905,6 @@ alter table t1 rebuild partition p1;
alter table t1 rebuild partition p1;
alter table t1 rebuild partition p1;
alter table t1 rebuild partition p1;
create table t1 (a int) engine=memory
partition by key(a);
insert into t1 values (1);
create index inx1 on t1(a);
drop table t1;
create table t1 (a int)
partition by key (a)
......
......@@ -1038,6 +1038,8 @@ alter table t1 rebuild partition p1;
alter table t1 rebuild partition p1;
alter table t1 rebuild partition p1;
drop table t1;
#
# BUG 19304 Partitions: MERGE handler not allowed in partitioned tables
#
......
......@@ -924,16 +924,9 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list, bool check_in_use)
DBUG_RETURN(-1);
}
if (!check_in_use)
{
DBUG_RETURN(0);
}
else
{
/* Return 1 if table is in use */
DBUG_RETURN(test(remove_table_from_cache(thd, db, table_list->table_name,
RTFC_NO_FLAG)));
}
/* Return 1 if table is in use */
DBUG_RETURN(test(remove_table_from_cache(thd, db, table_list->table_name,
check_in_use ? RTFC_NO_FLAG : RTFC_WAIT_OTHER_THREAD_FLAG)));
}
......
......@@ -1206,7 +1206,7 @@ typedef struct st_lock_param_type
List<Key> new_key_list;
TABLE *table;
KEY *key_info_buffer;
char *db;
const char *db;
const char *table_name;
const void *pack_frm_data;
enum thr_lock_type old_lock_type;
......
......@@ -5389,7 +5389,7 @@ static int get_name_lock(ALTER_PARTITION_PARAM_TYPE *lpt)
DBUG_ENTER("get_name_lock");
bzero(&lpt->table_list, sizeof(lpt->table_list));
lpt->table_list.db= lpt->db;
lpt->table_list.db= (char*)lpt->db;
lpt->table_list.table= lpt->table;
lpt->table_list.table_name= (char*)lpt->table_name;
pthread_mutex_lock(&LOCK_open);
......@@ -5775,24 +5775,22 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
(not_completed= FALSE) ||
abort_and_upgrade_lock(lpt) || /* Always returns 0 */
ERROR_INJECT_CRASH("crash_drop_partition_4") ||
get_name_lock(lpt) ||
ERROR_INJECT_CRASH("crash_drop_partition_5") ||
alter_close_tables(lpt) ||
ERROR_INJECT_CRASH("crash_drop_partition_6") ||
((!thd->lex->no_write_to_binlog) &&
(write_bin_log(thd, FALSE,
thd->query, thd->query_length), FALSE)) ||
ERROR_INJECT_CRASH("crash_drop_partition_5") ||
ERROR_INJECT_CRASH("crash_drop_partition_7") ||
((frm_install= TRUE), FALSE) ||
mysql_write_frm(lpt, WFRM_INSTALL_SHADOW) ||
((frm_install= FALSE), FALSE) ||
ERROR_INJECT_CRASH("crash_drop_partition_6") ||
get_name_lock(lpt) || /* Always returns 0 */
ERROR_INJECT_CRASH("crash_drop_partition_7") ||
(close_open_tables_and_downgrade(lpt), FALSE) ||
ERROR_INJECT_CRASH("crash_drop_partition_8") ||
alter_close_tables(lpt) ||
ERROR_INJECT_CRASH("crash_drop_partition_9") ||
mysql_drop_partitions(lpt) ||
ERROR_INJECT_CRASH("crash_drop_partition_10") ||
ERROR_INJECT_CRASH("crash_drop_partition_9") ||
(write_log_completed(lpt, FALSE), FALSE) ||
ERROR_INJECT_CRASH("crash_drop_partition_11") ||
ERROR_INJECT_CRASH("crash_drop_partition_10") ||
(release_name_lock(lpt), FALSE))
{
handle_alter_part_error(lpt, not_completed, TRUE, frm_install);
......@@ -5836,19 +5834,24 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
mysql_change_partitions(lpt) ||
ERROR_INJECT_CRASH("crash_add_partition_3") ||
abort_and_upgrade_lock(lpt) || /* Always returns 0 */
ERROR_INJECT_CRASH("crash_add_partition_3") ||
get_name_lock(lpt) ||
ERROR_INJECT_CRASH("crash_add_partition_4") ||
alter_close_tables(lpt) ||
ERROR_INJECT_CRASH("crash_add_partition_5") ||
((!thd->lex->no_write_to_binlog) &&
(write_bin_log(thd, FALSE,
thd->query, thd->query_length), FALSE)) ||
ERROR_INJECT_CRASH("crash_add_partition_4") ||
ERROR_INJECT_CRASH("crash_add_partition_6") ||
write_log_rename_frm(lpt) ||
(not_completed= FALSE) ||
ERROR_INJECT_CRASH("crash_add_partition_5") ||
ERROR_INJECT_CRASH("crash_add_partition_7") ||
((frm_install= TRUE), FALSE) ||
mysql_write_frm(lpt, WFRM_INSTALL_SHADOW) ||
ERROR_INJECT_CRASH("crash_add_partition_6") ||
(close_open_tables_and_downgrade(lpt), FALSE) ||
ERROR_INJECT_CRASH("crash_add_partition_8") ||
(write_log_completed(lpt, FALSE), FALSE) ||
ERROR_INJECT_CRASH("crash_add_partition_7"))
ERROR_INJECT_CRASH("crash_add_partition_9") ||
(release_name_lock(lpt), FALSE))
{
handle_alter_part_error(lpt, not_completed, FALSE, frm_install);
DBUG_RETURN(TRUE);
......@@ -5924,23 +5927,21 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
(not_completed= FALSE) ||
abort_and_upgrade_lock(lpt) || /* Always returns 0 */
ERROR_INJECT_CRASH("crash_change_partition_5") ||
get_name_lock(lpt) ||
ERROR_INJECT_CRASH("crash_change_partition_6") ||
alter_close_tables(lpt) ||
ERROR_INJECT_CRASH("crash_change_partition_7") ||
((!thd->lex->no_write_to_binlog) &&
(write_bin_log(thd, FALSE,
thd->query, thd->query_length), FALSE)) ||
ERROR_INJECT_CRASH("crash_change_partition_6") ||
mysql_write_frm(lpt, WFRM_INSTALL_SHADOW) ||
ERROR_INJECT_CRASH("crash_change_partition_7") ||
get_name_lock(lpt) ||
ERROR_INJECT_CRASH("crash_change_partition_8") ||
(close_open_tables_and_downgrade(lpt), FALSE) ||
mysql_write_frm(lpt, WFRM_INSTALL_SHADOW) ||
ERROR_INJECT_CRASH("crash_change_partition_9") ||
alter_close_tables(lpt) ||
ERROR_INJECT_CRASH("crash_change_partition_10") ||
mysql_rename_partitions(lpt) ||
((frm_install= TRUE), FALSE) ||
ERROR_INJECT_CRASH("crash_change_partition_11") ||
ERROR_INJECT_CRASH("crash_change_partition_10") ||
(write_log_completed(lpt, FALSE), FALSE) ||
ERROR_INJECT_CRASH("crash_change_partition_12") ||
ERROR_INJECT_CRASH("crash_change_partition_11") ||
(release_name_lock(lpt), FALSE))
{
handle_alter_part_error(lpt, not_completed, FALSE, frm_install);
......
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