Commit 0cec7f52 authored by Marc Alff's avatar Marc Alff

Merge mysql-5.1 --> mysql-5.5

parents 937a9381 c8f6ab29
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#define TIME_I_S_DECIMAL_SIZE (TIME_FLOAT_DIGITS*100)+(TIME_FLOAT_DIGITS-3) #define TIME_I_S_DECIMAL_SIZE (TIME_FLOAT_DIGITS*100)+(TIME_FLOAT_DIGITS-3)
#define MAX_QUERY_LENGTH 300 #define MAX_QUERY_LENGTH 300
#define MAX_QUERY_HISTORY 101
/** /**
Connects Information_Schema and Profiling. Connects Information_Schema and Profiling.
...@@ -257,9 +258,12 @@ void PROF_MEASUREMENT::collect() ...@@ -257,9 +258,12 @@ void PROF_MEASUREMENT::collect()
QUERY_PROFILE::QUERY_PROFILE(PROFILING *profiling_arg, const char *status_arg) QUERY_PROFILE::QUERY_PROFILE(PROFILING *profiling_arg, const char *status_arg)
:profiling(profiling_arg), profiling_query_id(0), query_source(NULL) :profiling(profiling_arg), profiling_query_id(0), query_source(NULL)
{ {
profile_start= new PROF_MEASUREMENT(this, status_arg); m_seq_counter= 1;
entries.push_back(profile_start); PROF_MEASUREMENT *prof= new PROF_MEASUREMENT(this, status_arg);
profile_end= profile_start; prof->m_seq= m_seq_counter++;
m_start_time_usecs= prof->time_usecs;
m_end_time_usecs= m_start_time_usecs;
entries.push_back(prof);
} }
QUERY_PROFILE::~QUERY_PROFILE() QUERY_PROFILE::~QUERY_PROFILE()
...@@ -298,9 +302,14 @@ void QUERY_PROFILE::new_status(const char *status_arg, ...@@ -298,9 +302,14 @@ void QUERY_PROFILE::new_status(const char *status_arg,
else else
prof= new PROF_MEASUREMENT(this, status_arg); prof= new PROF_MEASUREMENT(this, status_arg);
profile_end= prof; prof->m_seq= m_seq_counter++;
m_end_time_usecs= prof->time_usecs;
entries.push_back(prof); entries.push_back(prof);
/* Maintain the query history size. */
while (entries.elements > MAX_QUERY_HISTORY)
delete entries.pop();
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -460,8 +469,7 @@ bool PROFILING::show_profiles() ...@@ -460,8 +469,7 @@ bool PROFILING::show_profiles()
String elapsed; String elapsed;
PROF_MEASUREMENT *ps= prof->profile_start; double query_time_usecs= prof->m_end_time_usecs - prof->m_start_time_usecs;
PROF_MEASUREMENT *pe= prof->profile_end;
if (++idx <= unit->offset_limit_cnt) if (++idx <= unit->offset_limit_cnt)
continue; continue;
...@@ -470,7 +478,7 @@ bool PROFILING::show_profiles() ...@@ -470,7 +478,7 @@ bool PROFILING::show_profiles()
protocol->prepare_for_resend(); protocol->prepare_for_resend();
protocol->store((uint32)(prof->profiling_query_id)); protocol->store((uint32)(prof->profiling_query_id));
protocol->store((double)(pe->time_usecs - ps->time_usecs)/(1000.0*1000), protocol->store((double)(query_time_usecs/(1000.0*1000)),
(uint32) TIME_FLOAT_DIGITS-1, &elapsed); (uint32) TIME_FLOAT_DIGITS-1, &elapsed);
if (prof->query_source != NULL) if (prof->query_source != NULL)
protocol->store(prof->query_source, strlen(prof->query_source), protocol->store(prof->query_source, strlen(prof->query_source),
...@@ -530,17 +538,18 @@ int PROFILING::fill_statistics_info(THD *thd_arg, TABLE_LIST *tables, Item *cond ...@@ -530,17 +538,18 @@ int PROFILING::fill_statistics_info(THD *thd_arg, TABLE_LIST *tables, Item *cond
us also include a numbering of each state per query. The query_id and us also include a numbering of each state per query. The query_id and
the "seq" together are unique. the "seq" together are unique.
*/ */
ulonglong seq; ulong seq;
void *entry_iterator; void *entry_iterator;
PROF_MEASUREMENT *entry, *previous= NULL; PROF_MEASUREMENT *entry, *previous= NULL;
/* ...and for each query, go through all its state-change steps. */ /* ...and for each query, go through all its state-change steps. */
for (seq= 0, entry_iterator= query->entries.new_iterator(); for (entry_iterator= query->entries.new_iterator();
entry_iterator != NULL; entry_iterator != NULL;
entry_iterator= query->entries.iterator_next(entry_iterator), entry_iterator= query->entries.iterator_next(entry_iterator),
seq++, previous=entry, row_number++) previous=entry, row_number++)
{ {
entry= query->entries.iterator_value(entry_iterator); entry= query->entries.iterator_value(entry_iterator);
seq= entry->m_seq;
/* Skip the first. We count spans of fence, not fence-posts. */ /* Skip the first. We count spans of fence, not fence-posts. */
if (previous == NULL) continue; if (previous == NULL) continue;
......
...@@ -180,6 +180,7 @@ private: ...@@ -180,6 +180,7 @@ private:
char *file; char *file;
unsigned int line; unsigned int line;
ulong m_seq;
double time_usecs; double time_usecs;
char *allocated_status_memory; char *allocated_status_memory;
...@@ -211,8 +212,9 @@ private: ...@@ -211,8 +212,9 @@ private:
query_id_t profiling_query_id; /* Session-specific id. */ query_id_t profiling_query_id; /* Session-specific id. */
char *query_source; char *query_source;
PROF_MEASUREMENT *profile_start; double m_start_time_usecs;
PROF_MEASUREMENT *profile_end; double m_end_time_usecs;
ulong m_seq_counter;
Queue<PROF_MEASUREMENT> entries; Queue<PROF_MEASUREMENT> entries;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment