diff options
author | unknown <monty@narttu.mysql.fi> | 2003-03-03 20:42:49 +0200 |
---|---|---|
committer | unknown <monty@narttu.mysql.fi> | 2003-03-03 20:42:49 +0200 |
commit | 374ea106f5098e4a6ee79f217bf799d181d20a25 (patch) | |
tree | bb5b30b61dc86c58f8550645b5e1dd2dd91770ed /sql/sql_table.cc | |
parent | 391bc11a2121919a29a2579639bc476b6c25fa6a (diff) | |
download | mariadb-git-374ea106f5098e4a6ee79f217bf799d181d20a25.tar.gz |
Fixed a deadlock problem when using LOCK TABLE in one thread and DROP TABLE in another
sql/lock.cc:
Added functions to handle list of table name locks
sql/mysql_priv.h:
Added functions to handle list of named locks
sql/sql_rename.cc:
Use new general table name lock functions
sql/sql_table.cc:
Require table name locks when doing drop table.
This fixed a deadlock problem when using LOCK TABLE in one thread and DROP TABLE in another
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r-- | sql/sql_table.cc | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 4691c2fd494..2ff7c9c1a75 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -49,7 +49,7 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists) char path[FN_REFLEN]; String wrong_tables; bool some_tables_deleted=0; - uint error; + uint error= 1; db_type table_type; TABLE_LIST *table; DBUG_ENTER("mysql_rm_table"); @@ -66,7 +66,6 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists) { my_error(ER_TABLE_NOT_LOCKED_FOR_WRITE,MYF(0), tables->real_name); - error = 1; goto err; } while (global_read_lock && ! thd->killed) @@ -76,9 +75,12 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists) } + if (lock_table_names(thd, tables)) + goto err; + for (table=tables ; table ; table=table->next) { - char *db=table->db ? table->db : thd->db; + char *db=table->db ? table->db : (thd->db ? thd->db : (char*) ""); if (!close_temporary_table(thd, db, table->real_name)) { some_tables_deleted=1; // Log query @@ -149,9 +151,10 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists) } error = 0; + unlock_table_names(thd, tables); + err: pthread_mutex_unlock(&LOCK_open); - VOID(pthread_cond_broadcast(&COND_refresh)); // Signal to refresh pthread_mutex_lock(&thd->mysys_var->mutex); thd->mysys_var->current_mutex= 0; |