summaryrefslogtreecommitdiff
path: root/sql/sql_base.cc
diff options
context:
space:
mode:
authorunknown <monty@narttu.mysql.fi>2002-08-05 18:50:38 +0300
committerunknown <monty@narttu.mysql.fi>2002-08-05 18:50:38 +0300
commit7952914415e351973d1a572827bb1679e5b7b89e (patch)
tree6883369fca2aebcf1dec08665dd0146a1ebc9303 /sql/sql_base.cc
parente2cf3f8e4501befbae0f785a422cb832fb3466c2 (diff)
downloadmariadb-git-7952914415e351973d1a572827bb1679e5b7b89e.tar.gz
Added some missing mutex_locks() when manipulating the table cache.
This should fix some possible table cache corruptions when doing OPTIMIZE or REPAIR table when other threads are opening new tables. sql/sql_base.cc: Added missing mutex unlock on error condition sql/sql_insert.cc: Added TODO item sql/sql_show.cc: Added missing pthread_mutex_lock(&LOCK_open) when calling query_table_status(). sql/sql_table.cc: Added missing pthread_mutex_lock(&LOCK_open) when calling hash_delete(), unlock_table_name() and remove_table_from_cache(). BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r--sql/sql_base.cc16
1 files changed, 14 insertions, 2 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index ee8c1097fb2..bd8a570ccea 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -279,6 +279,16 @@ void intern_close_table(TABLE *table)
VOID(closefrm(table)); // close file
}
+/*
+ Remove table from the open table cache
+
+ SYNOPSIS
+ free_cache_entry()
+ table Table to remove
+
+ NOTE
+ We need to have a lock on LOCK_open when calling this
+*/
static void free_cache_entry(TABLE *table)
{
@@ -833,7 +843,10 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name,
/* make a new table */
if (!(table=(TABLE*) my_malloc(sizeof(*table),MYF(MY_WME))))
+ {
+ VOID(pthread_mutex_unlock(&LOCK_open));
DBUG_RETURN(NULL);
+ }
if (open_unireg_entry(thd, table,db,table_name,alias,1) ||
!(table->table_cache_key=memdup_root(&table->mem_root,(char*) key,
key_length)))
@@ -1181,7 +1194,6 @@ bool wait_for_tables(THD *thd)
/* Now we can open all tables without any interference */
thd->proc_info="Reopen tables";
result=reopen_tables(thd,0,0);
-
}
pthread_mutex_unlock(&LOCK_open);
thd->proc_info=0;
@@ -1372,9 +1384,9 @@ int open_tables(THD *thd,TABLE_LIST *start)
}
}
*prev_table=0;
+ pthread_mutex_unlock(&LOCK_open);
if (found)
VOID(pthread_cond_broadcast(&COND_refresh)); // Signal to refresh
- pthread_mutex_unlock(&LOCK_open);
goto restart;
}
result= -1; // Fatal error