diff options
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r-- | sql/sql_parse.cc | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 04af54ae8d9..ef7f9ac5b1f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1672,7 +1672,8 @@ dispatch_command_return dispatch_command(enum enum_server_command command, THD * command != COM_PING && command != COM_QUIT && command != COM_STMT_PREPARE && - command != COM_STMT_EXECUTE)) + command != COM_STMT_EXECUTE && + command != COM_STMT_CLOSE)) { my_error(ER_MUST_CHANGE_PASSWORD, MYF(0)); goto dispatch_end; @@ -2418,7 +2419,18 @@ resume: thd->update_all_stats(); - log_slow_statement(thd); + /* + Write to slow query log only those statements that received via the text + protocol except the EXECUTE statement. The reason we do that way is + that for statements received via binary protocol and for the EXECUTE + statement, the slow statements have been already written to slow query log + inside the method Prepared_statement::execute(). + */ + if(command == COM_QUERY && + thd->lex->sql_command != SQLCOM_EXECUTE) + log_slow_statement(thd); + else + delete_explain_query(thd->lex); THD_STAGE_INFO(thd, stage_cleaning_up); thd->reset_query(); @@ -3432,7 +3444,7 @@ bool run_set_statement_if_requested(THD *thd, LEX *lex) */ int -mysql_execute_command(THD *thd) +mysql_execute_command(THD *thd, bool is_called_from_prepared_stmt) { int res= 0; int up_result= 0; @@ -5259,7 +5271,7 @@ mysql_execute_command(THD *thd) } while (0); /* Don't do it, if we are inside a SP */ - if (!thd->spcont) + if (!thd->spcont && !is_called_from_prepared_stmt) { sp_head::destroy(lex->sphead); lex->sphead= NULL; |