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 ...@@ -890,6 +890,11 @@ s1
2 2
3 3
drop table t1; 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) create table t1 (a int)
partition by key (a) partition by key (a)
(partition p1 engine = innodb); (partition p1 engine = innodb);
...@@ -900,10 +905,6 @@ alter table t1 rebuild partition p1; ...@@ -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; 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; drop table t1;
create table t1 (a int) create table t1 (a int)
partition by key (a) partition by key (a)
......
...@@ -1038,6 +1038,8 @@ alter table t1 rebuild partition p1; ...@@ -1038,6 +1038,8 @@ alter table t1 rebuild partition p1;
alter table t1 rebuild partition p1; 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 # 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) ...@@ -924,16 +924,9 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list, bool check_in_use)
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
if (!check_in_use) /* Return 1 if table is in use */
{ DBUG_RETURN(test(remove_table_from_cache(thd, db, table_list->table_name,
DBUG_RETURN(0); check_in_use ? RTFC_NO_FLAG : RTFC_WAIT_OTHER_THREAD_FLAG)));
}
else
{
/* Return 1 if table is in use */
DBUG_RETURN(test(remove_table_from_cache(thd, db, table_list->table_name,
RTFC_NO_FLAG)));
}
} }
......
...@@ -1206,7 +1206,7 @@ typedef struct st_lock_param_type ...@@ -1206,7 +1206,7 @@ typedef struct st_lock_param_type
List<Key> new_key_list; List<Key> new_key_list;
TABLE *table; TABLE *table;
KEY *key_info_buffer; KEY *key_info_buffer;
char *db; const char *db;
const char *table_name; const char *table_name;
const void *pack_frm_data; const void *pack_frm_data;
enum thr_lock_type old_lock_type; enum thr_lock_type old_lock_type;
......
...@@ -5389,7 +5389,7 @@ static int get_name_lock(ALTER_PARTITION_PARAM_TYPE *lpt) ...@@ -5389,7 +5389,7 @@ static int get_name_lock(ALTER_PARTITION_PARAM_TYPE *lpt)
DBUG_ENTER("get_name_lock"); DBUG_ENTER("get_name_lock");
bzero(&lpt->table_list, sizeof(lpt->table_list)); 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= lpt->table;
lpt->table_list.table_name= (char*)lpt->table_name; lpt->table_list.table_name= (char*)lpt->table_name;
pthread_mutex_lock(&LOCK_open); pthread_mutex_lock(&LOCK_open);
...@@ -5775,24 +5775,22 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, ...@@ -5775,24 +5775,22 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
(not_completed= FALSE) || (not_completed= FALSE) ||
abort_and_upgrade_lock(lpt) || /* Always returns 0 */ abort_and_upgrade_lock(lpt) || /* Always returns 0 */
ERROR_INJECT_CRASH("crash_drop_partition_4") || 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) && ((!thd->lex->no_write_to_binlog) &&
(write_bin_log(thd, FALSE, (write_bin_log(thd, FALSE,
thd->query, thd->query_length), 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) || ((frm_install= TRUE), FALSE) ||
mysql_write_frm(lpt, WFRM_INSTALL_SHADOW) || mysql_write_frm(lpt, WFRM_INSTALL_SHADOW) ||
((frm_install= FALSE), FALSE) || ((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") || ERROR_INJECT_CRASH("crash_drop_partition_8") ||
alter_close_tables(lpt) ||
ERROR_INJECT_CRASH("crash_drop_partition_9") ||
mysql_drop_partitions(lpt) || mysql_drop_partitions(lpt) ||
ERROR_INJECT_CRASH("crash_drop_partition_10") || ERROR_INJECT_CRASH("crash_drop_partition_9") ||
(write_log_completed(lpt, FALSE), FALSE) || (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)) (release_name_lock(lpt), FALSE))
{ {
handle_alter_part_error(lpt, not_completed, TRUE, frm_install); handle_alter_part_error(lpt, not_completed, TRUE, frm_install);
...@@ -5836,19 +5834,24 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, ...@@ -5836,19 +5834,24 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
mysql_change_partitions(lpt) || mysql_change_partitions(lpt) ||
ERROR_INJECT_CRASH("crash_add_partition_3") || ERROR_INJECT_CRASH("crash_add_partition_3") ||
abort_and_upgrade_lock(lpt) || /* Always returns 0 */ 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) && ((!thd->lex->no_write_to_binlog) &&
(write_bin_log(thd, FALSE, (write_bin_log(thd, FALSE,
thd->query, thd->query_length), 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) || write_log_rename_frm(lpt) ||
(not_completed= FALSE) || (not_completed= FALSE) ||
ERROR_INJECT_CRASH("crash_add_partition_5") || ERROR_INJECT_CRASH("crash_add_partition_7") ||
((frm_install= TRUE), FALSE) || ((frm_install= TRUE), FALSE) ||
mysql_write_frm(lpt, WFRM_INSTALL_SHADOW) || mysql_write_frm(lpt, WFRM_INSTALL_SHADOW) ||
ERROR_INJECT_CRASH("crash_add_partition_6") || ERROR_INJECT_CRASH("crash_add_partition_8") ||
(close_open_tables_and_downgrade(lpt), FALSE) ||
(write_log_completed(lpt, FALSE), FALSE) || (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); handle_alter_part_error(lpt, not_completed, FALSE, frm_install);
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
...@@ -5924,23 +5927,21 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, ...@@ -5924,23 +5927,21 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
(not_completed= FALSE) || (not_completed= FALSE) ||
abort_and_upgrade_lock(lpt) || /* Always returns 0 */ abort_and_upgrade_lock(lpt) || /* Always returns 0 */
ERROR_INJECT_CRASH("crash_change_partition_5") || 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) && ((!thd->lex->no_write_to_binlog) &&
(write_bin_log(thd, FALSE, (write_bin_log(thd, FALSE,
thd->query, thd->query_length), 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") || 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") || ERROR_INJECT_CRASH("crash_change_partition_9") ||
alter_close_tables(lpt) ||
ERROR_INJECT_CRASH("crash_change_partition_10") ||
mysql_rename_partitions(lpt) || mysql_rename_partitions(lpt) ||
((frm_install= TRUE), FALSE) || ((frm_install= TRUE), FALSE) ||
ERROR_INJECT_CRASH("crash_change_partition_11") || ERROR_INJECT_CRASH("crash_change_partition_10") ||
(write_log_completed(lpt, FALSE), FALSE) || (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)) (release_name_lock(lpt), FALSE))
{ {
handle_alter_part_error(lpt, not_completed, FALSE, frm_install); 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