summaryrefslogtreecommitdiff
path: root/sql/sql_base.cc
diff options
context:
space:
mode:
authorunknown <sasha@mysql.sashanet.com>2000-11-27 23:10:49 -0700
committerunknown <sasha@mysql.sashanet.com>2000-11-27 23:10:49 -0700
commit4c2f946da6186f2d62d6898cbbd09e05751219c6 (patch)
tree39bb69a9d25395c95dbba09f15eba543e26775c8 /sql/sql_base.cc
parent0f9e884d25283f858cb0e9320cae0f4cd75fffda (diff)
parent48c227c76afc014fb1ef879b54b9f07eeaee0517 (diff)
downloadmariadb-git-4c2f946da6186f2d62d6898cbbd09e05751219c6.tar.gz
Merge work.mysql.com:/home/bk/mysql
into mysql.sashanet.com:/home/sasha/src/bk/mysql sql/mysql_priv.h: Auto merged sql/mysqld.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_parse.cc: Auto merged sql/sql_table.cc: Auto merged
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r--sql/sql_base.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 9ec85a9114e..f582b4a85af 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -275,7 +275,7 @@ bool close_cached_tables(THD *thd, bool if_wait_for_refresh,
bool found=0;
for (TABLE_LIST *table=tables ; table ; table=table->next)
{
- if (remove_table_from_cache(thd, table->db, table->name))
+ if (remove_table_from_cache(thd, table->db, table->name, 1))
found=1;
}
if (!found)
@@ -2029,7 +2029,8 @@ void flush_tables()
** Returns true if the table is in use by another thread
*/
-bool remove_table_from_cache(THD *thd, const char *db,const char *table_name)
+bool remove_table_from_cache(THD *thd, const char *db, const char *table_name,
+ bool return_if_owned_by_thd)
{
char key[MAX_DBKEY_LENGTH];
uint key_length;
@@ -2042,13 +2043,12 @@ bool remove_table_from_cache(THD *thd, const char *db,const char *table_name)
table;
table = (TABLE*) hash_next(&open_cache,(byte*) key,key_length))
{
+ THD *in_use;
table->version=0L; /* Free when thread is ready */
- if (!table->in_use)
+ if (!(in_use=table->in_use))
relink_unused(table);
- else if (table->in_use != thd)
+ else if (in_use != thd)
{
- THD *in_use=table->in_use;
-
in_use->some_tables_deleted=1;
if (table->db_stat)
result=1;
@@ -2066,6 +2066,8 @@ bool remove_table_from_cache(THD *thd, const char *db,const char *table_name)
pthread_mutex_unlock(&in_use->mysys_var->mutex);
}
}
+ else
+ result= result || return_if_owned_by_thd;
}
while (unused_tables && !unused_tables->version)
VOID(hash_delete(&open_cache,(byte*) unused_tables));