Commit ac180f82 authored by unknown's avatar unknown

Don't start profiling too soon. Begin timing when the packet is

read.

Do not store profiling information when there is no query text.  We
don't wish to capture non-COM_QUERY packets.


sql/sql_parse.cc:
  Start profiling immediately after a command packet is read from 
  the network.
sql/sql_profile.cc:
  Do not store items for which there is no query, i.e., protocol API 
  calls (non-COM_QUERY) and such.
parent 74da84cd
...@@ -668,9 +668,6 @@ bool do_command(THD *thd) ...@@ -668,9 +668,6 @@ bool do_command(THD *thd)
enum enum_server_command command; enum enum_server_command command;
DBUG_ENTER("do_command"); DBUG_ENTER("do_command");
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
thd->profiling.start_new_query();
#endif
/* /*
indicator of uninitialized lex => normal flow of errors handling indicator of uninitialized lex => normal flow of errors handling
(see my_message_sql) (see my_message_sql)
...@@ -688,7 +685,12 @@ bool do_command(THD *thd) ...@@ -688,7 +685,12 @@ bool do_command(THD *thd)
thd->clear_error(); // Clear error message thd->clear_error(); // Clear error message
net_new_transaction(net); net_new_transaction(net);
if ((packet_length=my_net_read(net)) == packet_error)
packet_length= my_net_read(net);
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
thd->profiling.start_new_query();
#endif
if (packet_length == packet_error)
{ {
DBUG_PRINT("info",("Got error %d reading command from socket %s", DBUG_PRINT("info",("Got error %d reading command from socket %s",
net->error, net->error,
......
...@@ -378,6 +378,7 @@ void PROFILING::finish_current_query() ...@@ -378,6 +378,7 @@ void PROFILING::finish_current_query()
if ((enabled) && /* ON at start? */ if ((enabled) && /* ON at start? */
((thd->options & OPTION_PROFILING) != 0) && /* and ON at end? */ ((thd->options & OPTION_PROFILING) != 0) && /* and ON at end? */
(current->query_source != NULL) &&
(! current->entries.is_empty())) (! current->entries.is_empty()))
{ {
current->profiling_query_id= next_profile_id(); /* assign an id */ current->profiling_query_id= next_profile_id(); /* assign an id */
......
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