Fixed bug in LOCK TABLE + DROP TABLE when other thread was waiting for a table that was locked bug not droped

client/mysqltest.c:
  Fixed bug that comments did a ping
include/thr_lock.h:
  Added function to abort a lock for a specific thread
mysql-test/mysql-test-run.sh:
  Fixed where mysqltest traces are put
mysql-test/r/lock_multi.result:
  Test for LOCK TABLE + DROP TABLE bug
mysql-test/t/lock_multi.test:
  Test for LOCK TABLE + DROP TABLE bug
mysys/thr_lock.c:
  Added function to abort a lock for a specific thread
sql/handler.cc:
  Indentation cleanup
sql/lock.cc:
  Added function to abort a lock for a specific thread
sql/mysql_priv.h:
  Added function to abort a lock for a specific thread
sql/mysqld.cc:
  Use automatic recover even with --safe
This commit is contained in:
unknown 2003-03-04 12:22:35 +02:00
commit 3446199d8e
11 changed files with 144 additions and 15 deletions

View file

@ -1244,25 +1244,44 @@ bool drop_locked_tables(THD *thd,const char *db, const char *table_name)
}
/* lock table to force abort of any threads trying to use table */
/*
If we have the table open, which only happens when a LOCK TABLE has been
done on the table, change the lock type to a lock that will abort all
other threads trying to get the lock.
*/
void abort_locked_tables(THD *thd,const char *db, const char *table_name)
{
TABLE *table;
for (table=thd->open_tables; table ; table=table->next)
for (table= thd->open_tables; table ; table= table->next)
{
if (!strcmp(table->real_name,table_name) &&
!strcmp(table->table_cache_key,db))
{
mysql_lock_abort(thd,table);
break;
}
}
}
/****************************************************************************
** open_unireg_entry
** Purpose : Load a table definition from file and open unireg table
** Args : entry with DB and table given
** Returns : 0 if ok
** Note that the extra argument for open is taken from thd->open_options
/*
Load a table definition from file and open unireg table
SYNOPSIS
open_unireg_entry()
thd Thread handle
entry Store open table definition here
db Database name
name Table name
alias Alias name
NOTES
Extra argument for open is taken from thd->open_options
RETURN
0 ok
# Error
*/
static int open_unireg_entry(THD *thd, TABLE *entry, const char *db,
@ -2277,6 +2296,17 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
}
pthread_mutex_unlock(&in_use->mysys_var->mutex);
}
/*
Now we must abort all tables locks used by this thread
as the thread may be waiting to get a lock for another table
*/
for (TABLE *thd_table= in_use->open_tables;
thd_table ;
thd_table= thd_table->next)
{
if (thd_table->db_stat) // If table is open
mysql_lock_abort_for_thread(thd, thd_table);
}
}
else
result= result || return_if_owned_by_thd;