summaryrefslogtreecommitdiff
path: root/sql/sql_profile.h
diff options
context:
space:
mode:
authorunknown <cmiller@zippy.cornsilk.net>2007-04-06 09:15:18 -0400
committerunknown <cmiller@zippy.cornsilk.net>2007-04-06 09:15:18 -0400
commitfcb52609e4727cdf6f246e7817c0fa625749c5c4 (patch)
treef80fd4f330f95124b1f5560ce915ec1765b8ec62 /sql/sql_profile.h
parentc717287c22f2e18b31338d6ac7af5bf9c97e0b1f (diff)
downloadmariadb-git-fcb52609e4727cdf6f246e7817c0fa625749c5c4.tar.gz
Changing the state of whether we're recording profiling information
halfway through a query (as happens in "SET SESSION PROFILING = ...") has a few side-effects, the worst of which is a memory leak for prepared statements, which poke directly from the parser into the profiling code (we don't have the query text when we need it) and that overwrites a pointer to heap-allocated memory when the previous statement turns on profiling. Instead, now set a flag when we begin a new statement that tracks whether profiling is on _at the start_ of the query. Use that to track whether we gather info. Additionally, use that AND use the state of the profiling variable after the end of a query to know whether to store information about the query that just finished. mysql-test/r/profiling.result: Testing whether profiling is on at the beginning of a query and at the end of a query makes "SET SESSION PROFILING = ..." statements disappear from the profiling. They were never reliable before. sql/sql_profile.cc: Check to see if profiling was enabled at the beginning of this query before trying to store query_source. This avoids a memory leak for prepared statements, which get here by direct means. If profiling was toggled in this query, then don't store this query profile. sql/sql_profile.h: Keep track of whether profiling is on.
Diffstat (limited to 'sql/sql_profile.h')
-rw-r--r--sql/sql_profile.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/sql/sql_profile.h b/sql/sql_profile.h
index 7913d037551..b82b5ce090c 100644
--- a/sql/sql_profile.h
+++ b/sql/sql_profile.h
@@ -277,6 +277,7 @@ private:
query_id_t profile_id_counter;
THD *thd;
bool keeping;
+ bool enabled;
QUERY_PROFILE *current;
QUERY_PROFILE *last;