diff options
author | unknown <monty@narttu.mysql.fi> | 2003-03-04 13:36:59 +0200 |
---|---|---|
committer | unknown <monty@narttu.mysql.fi> | 2003-03-04 13:36:59 +0200 |
commit | 8970a67d520a499d150d0d90c45e7ac74e398cac (patch) | |
tree | 013fc022f7bca8766f16eff8ae9714126b96160f /sql/sql_rename.cc | |
parent | d292ce6b09b69bac234461d1a31347c3ce085a4d (diff) | |
parent | 5603e43291b9e82037e345edae7f8036f92ebcae (diff) | |
download | mariadb-git-8970a67d520a499d150d0d90c45e7ac74e398cac.tar.gz |
Merge with 3.23 to get fix for deadlock when doing LOCK TABLES in one thread and DROP TABLE in another thread
sql/lock.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/sql_rename.cc:
merge
sql/sql_table.cc:
merge
Diffstat (limited to 'sql/sql_rename.cc')
-rw-r--r-- | sql/sql_rename.cc | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index 3eddd2646d5..d7e998264f3 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -31,8 +31,8 @@ static TABLE_LIST *rename_tables(THD *thd, TABLE_LIST *table_list, bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list) { - bool error=1,got_all_locks=1; - TABLE_LIST *lock_table,*ren_table=0; + bool error= 1; + TABLE_LIST *ren_table= 0; DBUG_ENTER("mysql_rename_tables"); /* @@ -47,23 +47,11 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list) } VOID(pthread_mutex_lock(&LOCK_open)); - for (lock_table=table_list ; lock_table ; lock_table=lock_table->next) - { - int got_lock; - if ((got_lock=lock_table_name(thd,lock_table)) < 0) - goto end; - if (got_lock) - got_all_locks=0; - } - - if (!got_all_locks && wait_for_locked_table_names(thd,table_list)) - goto end; - - if (!(ren_table=rename_tables(thd,table_list,0))) - error=0; - -end: - if (ren_table) + if (lock_table_names(thd, table_list)) + goto err; + + error=0; + if ((ren_table=rename_tables(thd,table_list,0))) { /* Rename didn't succeed; rename back the tables in reverse order */ TABLE_LIST *prev=0,*table; @@ -85,7 +73,7 @@ end: table=table->next->next; // Skip error table /* Revert to old names */ rename_tables(thd, table, 1); - /* Note that lock_table == 0 here, so the unlock loop will work */ + error= 1; } /* Lets hope this doesn't fail as the result will be messy */ @@ -100,9 +88,9 @@ end: send_ok(&thd->net); } - for (TABLE_LIST *table=table_list ; table != lock_table ; table=table->next) - unlock_table_name(thd,table); - pthread_cond_broadcast(&COND_refresh); + unlock_table_names(thd,table_list); + +err: pthread_mutex_unlock(&LOCK_open); DBUG_RETURN(error); } |