summaryrefslogtreecommitdiff
path: root/sql/sql_class.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_class.cc')
-rw-r--r--sql/sql_class.cc21
1 files changed, 10 insertions, 11 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 3881f6f28ad..2efdf91f6a9 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -1513,6 +1513,7 @@ void THD::cleanup(void)
auto_inc_intervals_in_cur_stmt_for_binlog.empty();
mysql_ull_cleanup(this);
+ stmt_map.reset();
/* All metadata locks must have been released by now. */
DBUG_ASSERT(!mdl_context.has_locks());
@@ -3983,11 +3984,13 @@ void Statement_map::erase(Statement *statement)
void Statement_map::reset()
{
/* Must be first, hash_free will reset st_hash.records */
- mysql_mutex_lock(&LOCK_prepared_stmt_count);
- DBUG_ASSERT(prepared_stmt_count >= st_hash.records);
- prepared_stmt_count-= st_hash.records;
- mysql_mutex_unlock(&LOCK_prepared_stmt_count);
-
+ if (st_hash.records)
+ {
+ mysql_mutex_lock(&LOCK_prepared_stmt_count);
+ DBUG_ASSERT(prepared_stmt_count >= st_hash.records);
+ prepared_stmt_count-= st_hash.records;
+ mysql_mutex_unlock(&LOCK_prepared_stmt_count);
+ }
my_hash_reset(&names_hash);
my_hash_reset(&st_hash);
last_found_statement= 0;
@@ -3996,12 +3999,8 @@ void Statement_map::reset()
Statement_map::~Statement_map()
{
- /* Must go first, hash_free will reset st_hash.records */
- mysql_mutex_lock(&LOCK_prepared_stmt_count);
- DBUG_ASSERT(prepared_stmt_count >= st_hash.records);
- prepared_stmt_count-= st_hash.records;
- mysql_mutex_unlock(&LOCK_prepared_stmt_count);
-
+ /* Statement_map::reset() should be called prior to destructor. */
+ DBUG_ASSERT(!st_hash.records);
my_hash_free(&names_hash);
my_hash_free(&st_hash);
}