summaryrefslogtreecommitdiff
path: root/sql/sql_profile.h
diff options
context:
space:
mode:
authorunknown <cmiller@zippy.cornsilk.net>2007-11-14 15:11:58 -0500
committerunknown <cmiller@zippy.cornsilk.net>2007-11-14 15:11:58 -0500
commitc1a36d80ef50b7cd23da893a08e7610d9e9dd02e (patch)
tree413750c08da07f9695b1935432266bfa83cc4f4b /sql/sql_profile.h
parenta49d3f018b9562e847578d06766ced772519a333 (diff)
downloadmariadb-git-c1a36d80ef50b7cd23da893a08e7610d9e9dd02e.tar.gz
Push history-limiting code until after the code that adds new
history entries. Lazy deletion isn't smart or useful here. Backport from 5.1 . include/my_sys.h: Prepare for rename in 5.1. mysql-test/r/profiling.result: Backport tests from 5.1. mysql-test/t/profiling.test: Backport tests from 5.1. sql/mysql_priv.h: Backport changes from 5.1 . sql/sp_head.cc: Backport changes from 5.1 . sql/sql_class.cc: Backport changes from 5.1 . sql/sql_parse.cc: Backport changes from 5.1 . sql/sql_profile.cc: Push history-limiting code until after the code that adds new history entries. Lazy deletion isn't smart or useful here. Correct for 5.0 member existance and execution. sql/sql_profile.h: Backport changes from 5.1 . sql/sql_show.cc: Backport changes from 5.1 .
Diffstat (limited to 'sql/sql_profile.h')
-rw-r--r--sql/sql_profile.h82
1 files changed, 19 insertions, 63 deletions
diff --git a/sql/sql_profile.h b/sql/sql_profile.h
index 5a28bc32442..022422fbb81 100644
--- a/sql/sql_profile.h
+++ b/sql/sql_profile.h
@@ -54,24 +54,7 @@ int make_profile_table_for_show(THD *thd, ST_SCHEMA_TABLE *schema_table);
#define PROFILE_ALL (~0)
-#ifndef ENABLED_PROFILING
-
-# define thd_proc_info(thd, msg) do { (thd)->proc_info= (msg); } while (0)
-
-#else
-
-# define thd_proc_info(thd, msg) \
- do { \
- if (unlikely(((thd)->options & OPTION_PROFILING) != 0)) \
- { \
- (thd)->profiling.status_change((msg), __func__, __FILE__, __LINE__); \
- } \
- else \
- { \
- (thd)->proc_info= (msg); \
- } \
- } while (0)
-
+#if defined(ENABLED_PROFILING)
#include "mysql_priv.h"
#ifdef HAVE_SYS_RESOURCE_H
@@ -79,7 +62,7 @@ int make_profile_table_for_show(THD *thd, ST_SCHEMA_TABLE *schema_table);
#endif
-class PROFILE_ENTRY;
+class PROF_MEASUREMENT;
class QUERY_PROFILE;
class PROFILING;
@@ -193,7 +176,7 @@ public:
/**
A single entry in a single profile.
*/
-class PROFILE_ENTRY
+class PROF_MEASUREMENT
{
private:
friend class QUERY_PROFILE;
@@ -212,22 +195,22 @@ private:
double time_usecs;
char *allocated_status_memory;
- void set_status(const char *status_arg, const char *function_arg,
+ void set_label(const char *status_arg, const char *function_arg,
const char *file_arg, unsigned int line_arg);
void clean_up();
- PROFILE_ENTRY();
- PROFILE_ENTRY(QUERY_PROFILE *profile_arg, const char *status_arg);
- PROFILE_ENTRY(QUERY_PROFILE *profile_arg, const char *status_arg,
+ PROF_MEASUREMENT();
+ PROF_MEASUREMENT(QUERY_PROFILE *profile_arg, const char *status_arg);
+ PROF_MEASUREMENT(QUERY_PROFILE *profile_arg, const char *status_arg,
const char *function_arg,
const char *file_arg, unsigned int line_arg);
- ~PROFILE_ENTRY();
+ ~PROF_MEASUREMENT();
void collect();
};
/**
- The full profile for a single query, and includes multiple PROFILE_ENTRY
+ The full profile for a single query, and includes multiple PROF_MEASUREMENT
objects.
*/
class QUERY_PROFILE
@@ -237,21 +220,21 @@ private:
PROFILING *profiling;
- query_id_t server_query_id; /* Global id. */
query_id_t profiling_query_id; /* Session-specific id. */
char *query_source;
- PROFILE_ENTRY profile_start;
- PROFILE_ENTRY *profile_end;
- Queue<PROFILE_ENTRY> entries;
+
+ PROF_MEASUREMENT *profile_start;
+ PROF_MEASUREMENT *profile_end;
+ Queue<PROF_MEASUREMENT> entries;
- QUERY_PROFILE(PROFILING *profiling_arg, char *query_source_arg, uint query_length_arg);
+ QUERY_PROFILE(PROFILING *profiling_arg, const char *status_arg);
~QUERY_PROFILE();
void set_query_source(char *query_source_arg, uint query_length_arg);
/* Add a profile status change to the current profile. */
- void status(const char *status_arg,
+ void new_status(const char *status_arg,
const char *function_arg,
const char *file_arg, unsigned int line_arg);
@@ -269,7 +252,7 @@ private:
class PROFILING
{
private:
- friend class PROFILE_ENTRY;
+ friend class PROF_MEASUREMENT;
friend class QUERY_PROFILE;
/*
@@ -291,39 +274,12 @@ public:
~PROFILING();
void set_query_source(char *query_source_arg, uint query_length_arg);
- /** Reset the current profile and state of profiling for the next query. */
- void reset();
-
- /**
- Do we intend to keep the currently collected profile?
-
- We don't keep profiles for some commands, such as SHOW PROFILE, SHOW
- PROFILES, and some SQLCOM commands which aren't useful to profile. The
- keep() and discard() functions can be called many times, only the final
- setting when the query finishes is used to decide whether to discard the
- profile.
-
- The default is to keep the profile for all queries.
- */
- inline void keep() { keeping= true; };
+ void start_new_query(const char *initial_state= "starting");
- /**
- Do we intend to keep the currently collected profile?
- @see keep()
- */
- inline void discard() { keeping= false; };
+ void discard_current_query();
- /**
- Stash this profile in the profile history and remove the oldest
- profile if the history queue is full, as defined by the
- profiling_history_size system variable.
- */
- void store();
+ void finish_current_query();
- /**
- Called with every update of the status via thd_proc_info() , and is
- therefore the main hook into the profiling code.
- */
void status_change(const char *status_arg,
const char *function_arg,
const char *file_arg, unsigned int line_arg);