1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-30 11:22:14 +03:00

Merge to get fix for LOCK TABLES + DROP TABLE in another thread

This commit is contained in:
monty@mashka.mysql.fi
2003-03-07 01:20:56 +02:00
13 changed files with 160 additions and 40 deletions

View File

@@ -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 (lock_table_names(thd, table_list))
goto err;
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)
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);
}
@@ -131,7 +119,7 @@ rename_tables(THD *thd, TABLE_LIST *table_list, bool skip_error)
if (!access(name,F_OK))
{
my_error(ER_TABLE_EXISTS_ERROR,MYF(0),name);
DBUG_RETURN(ren_table); // This can't be skipped
DBUG_RETURN(ren_table); // This can't be skiped
}
sprintf(name,"%s/%s/%s%s",mysql_data_home,
ren_table->db,ren_table->real_name,