summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2018-12-09 14:29:32 +0400
committerSergey Vojtovich <svoj@mariadb.org>2018-12-09 14:29:32 +0400
commit03922bb3871766f58dafbb465c67c8f66e1aad4b (patch)
tree07c92bcb1b22dfcff1ef692cb57029641249b53f
parent09bad0958452df9323fcb9049f62a23468e978f5 (diff)
downloadmariadb-git-03922bb3871766f58dafbb465c67c8f66e1aad4b.tar.gz
Fixed false positive from close_cached_connection_tablesbb-10.4-svoj-backup
-rw-r--r--sql/sql_base.cc9
-rw-r--r--sql/table_cache.cc11
2 files changed, 14 insertions, 6 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 5c33d03f4cd..ccff8568973 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -658,6 +658,7 @@ end:
bool close_cached_connection_tables(THD *thd, LEX_CSTRING *connection)
{
+ bool res= false;
close_cached_connection_tables_arg argument;
DBUG_ENTER("close_cached_connections");
DBUG_ASSERT(thd);
@@ -672,12 +673,12 @@ bool close_cached_connection_tables(THD *thd, LEX_CSTRING *connection)
DBUG_RETURN(true);
for (TABLE_LIST *table= argument.tables; table; table= table->next_local)
- tdc_remove_table(thd, TDC_RT_REMOVE_UNUSED,
- table->db.str,
- table->table_name.str, TRUE);
+ res|= tdc_remove_table(thd, TDC_RT_REMOVE_UNUSED,
+ table->db.str,
+ table->table_name.str, TRUE);
/* Return true if we found any open connections */
- DBUG_RETURN(MY_TEST(argument.tables));
+ DBUG_RETURN(res);
}
diff --git a/sql/table_cache.cc b/sql/table_cache.cc
index 099181cb33c..c23bb53b9a9 100644
--- a/sql/table_cache.cc
+++ b/sql/table_cache.cc
@@ -1094,6 +1094,7 @@ bool tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type,
TABLE *table;
TDC_element *element;
uint my_refs= 1;
+ bool res= false;
DBUG_ENTER("tdc_remove_table");
DBUG_PRINT("enter",("name: %s remove_type: %d", table_name, remove_type));
@@ -1122,7 +1123,7 @@ bool tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type,
mysql_mutex_unlock(&LOCK_unused_shares);
tdc_delete_share_from_hash(element);
- DBUG_RETURN(true);
+ DBUG_RETURN(false);
}
mysql_mutex_unlock(&LOCK_unused_shares);
@@ -1188,10 +1189,16 @@ bool tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type,
#endif
mysql_mutex_unlock(&element->LOCK_table_share);
}
+ else
+ {
+ mysql_mutex_lock(&element->LOCK_table_share);
+ res= element->ref_count > 1;
+ mysql_mutex_unlock(&element->LOCK_table_share);
+ }
tdc_release_share(element->share);
- DBUG_RETURN(true);
+ DBUG_RETURN(res);
}