summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/table_cache.cc16
1 files changed, 13 insertions, 3 deletions
diff --git a/sql/table_cache.cc b/sql/table_cache.cc
index 7dfd1c2ac8e..7be5f5f771b 100644
--- a/sql/table_cache.cc
+++ b/sql/table_cache.cc
@@ -1123,11 +1123,10 @@ bool tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type,
All_share_tables_list::Iterator it(element->all_tables);
while ((table= it++))
{
- my_refs++;
- DBUG_ASSERT(table->in_use == thd);
+ if (table->in_use == thd)
+ my_refs++;
}
}
- DBUG_ASSERT(element->all_tables.is_empty() || remove_type != TDC_RT_REMOVE_ALL);
mysql_mutex_unlock(&element->LOCK_table_share);
while ((table= purge_tables.pop_front()))
@@ -1159,6 +1158,17 @@ bool tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type,
mysql_mutex_lock(&element->LOCK_table_share);
while (element->ref_count > my_refs)
mysql_cond_wait(&element->COND_release, &element->LOCK_table_share);
+ DBUG_ASSERT(element->all_tables.is_empty() ||
+ remove_type != TDC_RT_REMOVE_ALL);
+#ifndef DBUG_OFF
+ if (remove_type == TDC_RT_REMOVE_NOT_OWN ||
+ remove_type == TDC_RT_REMOVE_NOT_OWN_KEEP_SHARE)
+ {
+ All_share_tables_list::Iterator it(element->all_tables);
+ while ((table= it++))
+ DBUG_ASSERT(table->in_use == thd);
+ }
+#endif
mysql_mutex_unlock(&element->LOCK_table_share);
}