summaryrefslogtreecommitdiff
path: root/sql/table_cache.cc
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2016-06-10 17:37:12 +0400
committerSergey Vojtovich <svoj@mariadb.org>2016-06-10 17:37:12 +0400
commit7ecb304996df7d917ef1e857090a9a9c525160f1 (patch)
tree8dc86d3e7cd39c5be91ff9f983f187faca77cbcb /sql/table_cache.cc
parent2dee76f4359d7e87cd7f4094892a2ed287dce1a8 (diff)
downloadmariadb-git-7ecb304996df7d917ef1e857090a9a9c525160f1.tar.gz
Code cleanups
- unused TABLE_SHARE::deleting and TABLE_LIST::deleting flags were removed - kill_delayed_threads_for_table() and intern_close_table() are now private methods of table cache - removed free_share flag of closefrm(): it was never used for temporary tables and was rarely useful for regular tables
Diffstat (limited to 'sql/table_cache.cc')
-rw-r--r--sql/table_cache.cc62
1 files changed, 60 insertions, 2 deletions
diff --git a/sql/table_cache.cc b/sql/table_cache.cc
index acfd3bd63ab..bd50f5b4b3a 100644
--- a/sql/table_cache.cc
+++ b/sql/table_cache.cc
@@ -36,8 +36,6 @@
- get number of TABLE objects in cache (tc_records())
Dependencies:
- - intern_close_table(): frees TABLE object
- - kill_delayed_threads_for_table()
- close_cached_tables(): flush tables on shutdown
- alloc_table_share()
- free_table_share()
@@ -127,6 +125,25 @@ static int fix_thd_pins(THD *thd)
part of table definition cache.
*/
+static void intern_close_table(TABLE *table)
+{
+ DBUG_ENTER("intern_close_table");
+ DBUG_PRINT("tcache", ("table: '%s'.'%s' 0x%lx",
+ table->s ? table->s->db.str : "?",
+ table->s ? table->s->table_name.str : "?",
+ (long) table));
+
+ delete table->triggers;
+ if (table->file) // Not true if placeholder
+ {
+ (void) closefrm(table);
+ tdc_release_share(table->s);
+ }
+ table->alias.free();
+ my_free(table);
+ DBUG_VOID_RETURN;
+}
+
/**
Get number of TABLE objects (used and unused) in table cache.
@@ -939,6 +956,47 @@ void tdc_release_share(TABLE_SHARE *share)
/**
+ Auxiliary function which allows to kill delayed threads for
+ particular table identified by its share.
+
+ @param share Table share.
+
+ @pre Caller should have TABLE_SHARE::tdc.LOCK_table_share mutex.
+*/
+
+static void kill_delayed_threads_for_table(TDC_element *element)
+{
+ TDC_element::All_share_tables_list::Iterator it(element->all_tables);
+ TABLE *tab;
+
+ mysql_mutex_assert_owner(&element->LOCK_table_share);
+
+ if (!delayed_insert_threads)
+ return;
+
+ while ((tab= it++))
+ {
+ THD *in_use= tab->in_use;
+
+ DBUG_ASSERT(in_use && tab->s->tdc->flushed);
+ if ((in_use->system_thread & SYSTEM_THREAD_DELAYED_INSERT) &&
+ ! in_use->killed)
+ {
+ in_use->killed= KILL_SYSTEM_THREAD;
+ mysql_mutex_lock(&in_use->mysys_var->mutex);
+ if (in_use->mysys_var->current_cond)
+ {
+ mysql_mutex_lock(in_use->mysys_var->current_mutex);
+ mysql_cond_broadcast(in_use->mysys_var->current_cond);
+ mysql_mutex_unlock(in_use->mysys_var->current_mutex);
+ }
+ mysql_mutex_unlock(&in_use->mysys_var->mutex);
+ }
+ }
+}
+
+
+/**
Remove all or some (depending on parameter) instances of TABLE and
TABLE_SHARE from the table definition cache.