summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/partition.result9
-rw-r--r--mysql-test/t/partition.test2
-rw-r--r--sql/lock.cc13
-rw-r--r--sql/mysql_priv.h2
-rw-r--r--sql/sql_partition.cc49
5 files changed, 36 insertions, 39 deletions
diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result
index 8bf86056e24..967e30104cf 100644
--- a/mysql-test/r/partition.result
+++ b/mysql-test/r/partition.result
@@ -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)
diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test
index 03c3f6e0a7c..1d3e38a6e16 100644
--- a/mysql-test/t/partition.test
+++ b/mysql-test/t/partition.test
@@ -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
#
diff --git a/sql/lock.cc b/sql/lock.cc
index 3a0aa99218f..efb4d696e67 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -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)));
}
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 443066c5f0c..8c48a84b9f4 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -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;
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 36f4144aaff..15e1c42bbf3 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -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);