summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/profiling.result2
-rw-r--r--sql/sql_profile.cc11
2 files changed, 12 insertions, 1 deletions
diff --git a/mysql-test/r/profiling.result b/mysql-test/r/profiling.result
index a1e994220b9..75977f7f2e8 100644
--- a/mysql-test/r/profiling.result
+++ b/mysql-test/r/profiling.result
@@ -248,6 +248,7 @@ sum(id)
12
show profiles;
Query_ID Duration Query
+15 # select count(*) from t1
16 # insert into t1 select * from t1
17 # insert into t1 select * from t1
18 # insert into t1 select * from t1
@@ -277,7 +278,6 @@ Query_ID Duration Query
42 # insert into t1 values (1), (2), (3)
43 # insert into t1 values (1), (2), (3)
44 # select * from t1
-45 # set session profiling = OFF
set session profiling = ON;
select @@profiling;
@@profiling
diff --git a/sql/sql_profile.cc b/sql/sql_profile.cc
index 4ee8d1ba9c8..b17bb6daa0d 100644
--- a/sql/sql_profile.cc
+++ b/sql/sql_profile.cc
@@ -493,6 +493,9 @@ void PROFILING::store()
while (history.elements > thd->variables.profiling_history_size)
delete history.pop();
+ if (likely(((thd)->options & OPTION_PROFILING) == 0))
+ DBUG_VOID_RETURN;
+
if (current != NULL)
{
if (keeping &&
@@ -519,12 +522,20 @@ void PROFILING::store()
DBUG_VOID_RETURN;
}
+/**
+ Store and clean up the old information and get ready to hold info about this
+ new query. This is called very often so it must be very lightweight if
+ profiling is not active.
+*/
void PROFILING::reset()
{
DBUG_ENTER("PROFILING::reset");
store();
+ if (likely(((thd)->options & OPTION_PROFILING) == 0))
+ DBUG_VOID_RETURN;
+
if (current != NULL)
current->reset();
keep();