summaryrefslogtreecommitdiff
path: root/sql/sql_parse.cc
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2013-11-11 16:17:32 +0100
committerSergei Golubchik <sergii@pisem.net>2013-11-11 16:17:32 +0100
commitf486f49e8dca72023f7312da138d71eb504a16f4 (patch)
tree684663b42e3d97ab6e2ad85f113ec05e58eb2735 /sql/sql_parse.cc
parent80a523dbfbeab628a98391d77656442d58ae15a4 (diff)
downloadmariadb-git-f486f49e8dca72023f7312da138d71eb504a16f4.tar.gz
MDEV-4824 userstats - wrong user statistics
(and valgrind warnings) * move thd userstat initialization to the same function that was adding thd userstat to global counters. * initialize thd->start_bytes_received in THD::init (when thd->userstat_running is set)
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r--sql/sql_parse.cc31
1 files changed, 15 insertions, 16 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 2d4293fc1d7..e9adc3b669f 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -717,7 +717,6 @@ bool do_command(THD *thd)
net_new_transaction(net);
-
/* Save for user statistics */
thd->start_bytes_received= thd->status_var.bytes_received;
@@ -926,6 +925,14 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
if (!(server_command_flags[command] & CF_SKIP_QUESTIONS))
statistic_increment(thd->status_var.questions, &LOCK_status);
+ /* Copy data for user stats */
+ if ((thd->userstat_running= opt_userstat_running))
+ {
+ thd->start_cpu_time= my_getcputime();
+ memcpy(&thd->org_status_var, &thd->status_var, sizeof(thd->status_var));
+ thd->select_commands= thd->update_commands= thd->other_commands= 0;
+ }
+
/**
Clear the set of flags that are expected to be cleared at the
beginning of each command.
@@ -1176,7 +1183,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
break;
}
packet= arg_end + 1;
- mysql_reset_thd_for_next_command(thd, opt_userstat_running);
+ mysql_reset_thd_for_next_command(thd);
lex_start(thd);
/* Must be before we init the table list. */
if (lower_case_table_names)
@@ -5446,15 +5453,15 @@ bool my_yyoverflow(short **yyss, YYSTYPE **yyvs, ulong *yystacksize)
@todo Call it after we use THD for queries, not before.
*/
-void mysql_reset_thd_for_next_command(THD *thd, my_bool calculate_userstat)
+void mysql_reset_thd_for_next_command(THD *thd)
{
- thd->reset_for_next_command(calculate_userstat);
+ thd->reset_for_next_command();
}
-void THD::reset_for_next_command(bool calculate_userstat)
+void THD::reset_for_next_command()
{
THD *thd= this;
- DBUG_ENTER("mysql_reset_thd_for_next_command");
+ DBUG_ENTER("THD::reset_for_next_command");
DBUG_ASSERT(!thd->spcont); /* not for substatements of routines */
DBUG_ASSERT(! thd->in_sub_stmt);
DBUG_ASSERT(thd->transaction.on);
@@ -5500,14 +5507,6 @@ void THD::reset_for_next_command(bool calculate_userstat)
thd->sent_row_count= thd->examined_row_count= 0;
thd->accessed_rows_and_keys= 0;
- /* Copy data for user stats */
- if ((thd->userstat_running= calculate_userstat))
- {
- thd->start_cpu_time= my_getcputime();
- memcpy(&thd->org_status_var, &thd->status_var, sizeof(thd->status_var));
- thd->select_commands= thd->update_commands= thd->other_commands= 0;
- }
-
thd->query_plan_flags= QPLAN_INIT;
thd->query_plan_fsort_passes= 0;
@@ -5716,7 +5715,7 @@ void mysql_parse(THD *thd, char *rawbuf, uint length,
FIXME: cleanup the dependencies in the code to simplify this.
*/
lex_start(thd);
- mysql_reset_thd_for_next_command(thd, opt_userstat_running);
+ mysql_reset_thd_for_next_command(thd);
if (query_cache_send_result_to_client(thd, rawbuf, length) <= 0)
{
@@ -5819,7 +5818,7 @@ bool mysql_test_parse_for_slave(THD *thd, char *rawbuf, uint length)
if (!(error= parser_state.init(thd, rawbuf, length)))
{
lex_start(thd);
- mysql_reset_thd_for_next_command(thd, opt_userstat_running);
+ mysql_reset_thd_for_next_command(thd);
if (!parse_sql(thd, & parser_state, NULL) &&
all_tables_not_ok(thd, lex->select_lex.table_list.first))