summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/ps.result6
-rw-r--r--mysql-test/t/ps.test11
-rw-r--r--sql/mysqld.cc12
3 files changed, 28 insertions, 1 deletions
diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result
index 0334a52c7ae..a6c16a9d15d 100644
--- a/mysql-test/r/ps.result
+++ b/mysql-test/r/ps.result
@@ -898,6 +898,12 @@ show status like 'prepared_stmt_count';
Variable_name Value
Prepared_stmt_count 3
deallocate prepare stmt;
+select @@max_prepared_stmt_count;
+@@max_prepared_stmt_count
+3
+show status like 'prepared_stmt_count';
+Variable_name Value
+Prepared_stmt_count 0
set global max_prepared_stmt_count= @old_max_prepared_stmt_count;
drop table if exists t1;
create temporary table if not exists t1 (a1 int);
diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test
index 0a739c05eda..a64764f623f 100644
--- a/mysql-test/t/ps.test
+++ b/mysql-test/t/ps.test
@@ -950,7 +950,18 @@ select @@max_prepared_stmt_count;
show status like 'prepared_stmt_count';
disconnect con1;
connection default;
+# Wait for the connection to die: deal with a possible race
deallocate prepare stmt;
+let $query= select variable_value from information_schema.global_status
+ where variable_name = 'prepared_stmt_count';
+let $count= `$query`;
+if ($count)
+{
+--sleep 1
+ let $count= `$query`;
+}
+select @@max_prepared_stmt_count;
+show status like 'prepared_stmt_count';
#
# Restore the old value.
#
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 21a37843e51..5d28d0663e7 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -6337,6 +6337,16 @@ static int show_open_tables(THD *thd, SHOW_VAR *var, char *buff)
return 0;
}
+static int show_prepared_stmt_count(THD *thd, SHOW_VAR *var, char *buff)
+{
+ var->type= SHOW_LONG;
+ var->value= buff;
+ pthread_mutex_lock(&LOCK_prepared_stmt_count);
+ *((long *)buff)= (long)prepared_stmt_count;
+ pthread_mutex_unlock(&LOCK_prepared_stmt_count);
+ return 0;
+}
+
static int show_table_definitions(THD *thd, SHOW_VAR *var, char *buff)
{
var->type= SHOW_LONG;
@@ -6747,7 +6757,7 @@ SHOW_VAR status_vars[]= {
{"Open_table_definitions", (char*) &show_table_definitions, SHOW_FUNC},
{"Open_tables", (char*) &show_open_tables, SHOW_FUNC},
{"Opened_tables", (char*) offsetof(STATUS_VAR, opened_tables), SHOW_LONG_STATUS},
- {"Prepared_stmt_count", (char*) &prepared_stmt_count, SHOW_LONG_CONST},
+ {"Prepared_stmt_count", (char*) &show_prepared_stmt_count, SHOW_FUNC},
#ifdef HAVE_QUERY_CACHE
{"Qcache_free_blocks", (char*) &query_cache.free_memory_blocks, SHOW_LONG_NOFLUSH},
{"Qcache_free_memory", (char*) &query_cache.free_memory, SHOW_LONG_NOFLUSH},