Commit a83a4136 authored by Sergei Golubchik's avatar Sergei Golubchik

revno: 5265

committer: Christopher Powers <chris.powers@oracle.com>
branch nick: mysql-5.6-bug16750433
timestamp: Fri 2013-06-28 07:48:12 -0500
message:
  Bug#16750433 - THE STATEMENT DIGEST DOES NOT SHOW THE SLAVE SQL
                 THREAD STATEMENTS

revno: 5414.1.1
committer: Marc Alff <marc.alff@oracle.com>
branch nick: mysql-5.6-bug17271055
timestamp: Thu 2013-08-29 12:29:25 +0200
message:
  Bug#17271055 "STATEMENT/COM" EVENT MEANING IS UNCLEAR

(test case was merged with perfschema 5.6.17)
parent bff1b52a
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "transaction.h" #include "transaction.h"
#include <my_dir.h> #include <my_dir.h>
#include "sql_show.h" // append_identifier #include "sql_show.h" // append_identifier
#include <mysql/psi/mysql_statement.h>
#include <strfunc.h> #include <strfunc.h>
#include "compat56.h" #include "compat56.h"
...@@ -4272,6 +4273,13 @@ int Query_log_event::do_apply_event(rpl_group_info *rgi, ...@@ -4272,6 +4273,13 @@ int Query_log_event::do_apply_event(rpl_group_info *rgi,
Parser_state parser_state; Parser_state parser_state;
if (!parser_state.init(thd, thd->query(), thd->query_length())) if (!parser_state.init(thd, thd->query(), thd->query_length()))
{ {
thd->m_statement_psi= MYSQL_START_STATEMENT(&thd->m_statement_state,
stmt_info_rpl.m_key,
thd->db, thd->db_length,
thd->charset());
THD_STAGE_INFO(thd, stage_init);
MYSQL_SET_STATEMENT_TEXT(thd->m_statement_psi, thd->query(), thd->query_length());
mysql_parse(thd, thd->query(), thd->query_length(), &parser_state); mysql_parse(thd, thd->query(), thd->query_length(), &parser_state);
/* Finalize server status flags after executing a statement. */ /* Finalize server status flags after executing a statement. */
thd->update_server_status(); thd->update_server_status();
...@@ -4455,6 +4463,11 @@ Default database: '%s'. Query: '%s'", ...@@ -4455,6 +4463,11 @@ Default database: '%s'. Query: '%s'",
thd->set_db(NULL, 0); /* will free the current database */ thd->set_db(NULL, 0); /* will free the current database */
thd->reset_query(); thd->reset_query();
DBUG_PRINT("info", ("end: query= 0")); DBUG_PRINT("info", ("end: query= 0"));
/* Mark the statement completed. */
MYSQL_END_STATEMENT(thd->m_statement_psi, thd->get_stmt_da());
thd->m_statement_psi= NULL;
/* /*
As a disk space optimization, future masters will not log an event for As a disk space optimization, future masters will not log an event for
LAST_INSERT_ID() if that function returned 0 (and thus they will be able LAST_INSERT_ID() if that function returned 0 (and thus they will be able
......
...@@ -338,6 +338,13 @@ static PSI_rwlock_key key_rwlock_openssl; ...@@ -338,6 +338,13 @@ static PSI_rwlock_key key_rwlock_openssl;
volatile sig_atomic_t ld_assume_kernel_is_set= 0; volatile sig_atomic_t ld_assume_kernel_is_set= 0;
#endif #endif
/**
Statement instrumentation key for replication.
*/
#ifdef HAVE_PSI_STATEMENT_INTERFACE
PSI_statement_info stmt_info_rpl;
#endif
/* the default log output is log tables */ /* the default log output is log tables */
static bool lower_case_table_names_used= 0; static bool lower_case_table_names_used= 0;
static bool max_long_data_size_used= false; static bool max_long_data_size_used= false;
...@@ -3791,7 +3798,7 @@ void init_com_statement_info() ...@@ -3791,7 +3798,7 @@ void init_com_statement_info()
com_statement_info[index].m_flags= 0; com_statement_info[index].m_flags= 0;
} }
/* "statement/com/query" can mutate into "statement/sql/..." */ /* "statement/abstract/query" can mutate into "statement/sql/..." */
com_statement_info[(uint) COM_QUERY].m_flags= PSI_FLAG_MUTABLE; com_statement_info[(uint) COM_QUERY].m_flags= PSI_FLAG_MUTABLE;
} }
#endif #endif
...@@ -9617,23 +9624,49 @@ void init_server_psi_keys(void) ...@@ -9617,23 +9624,49 @@ void init_server_psi_keys(void)
category= "com"; category= "com";
init_com_statement_info(); init_com_statement_info();
count= array_elements(com_statement_info);
/*
Register [0 .. COM_QUERY - 1] as "statement/com/..."
*/
count= (int) COM_QUERY;
mysql_statement_register(category, com_statement_info, count); mysql_statement_register(category, com_statement_info, count);
/*
Register [COM_QUERY + 1 .. COM_END] as "statement/com/..."
*/
count= (int) COM_END - (int) COM_QUERY;
mysql_statement_register(category, & com_statement_info[(int) COM_QUERY + 1], count);
category= "abstract";
/*
Register [COM_QUERY] as "statement/abstract/com_query"
*/
mysql_statement_register(category, & com_statement_info[(int) COM_QUERY], 1);
/* /*
When a new packet is received, When a new packet is received,
it is instrumented as "statement/com/". it is instrumented as "statement/abstract/new_packet".
Based on the packet type found, it later mutates to the Based on the packet type found, it later mutates to the
proper narrow type, for example proper narrow type, for example
"statement/com/query" or "statement/com/ping". "statement/abstract/query" or "statement/com/ping".
In cases of "statement/com/query", SQL queries are given to In cases of "statement/abstract/query", SQL queries are given to
the parser, which mutates the statement type to an even more the parser, which mutates the statement type to an even more
narrow classification, for example "statement/sql/select". narrow classification, for example "statement/sql/select".
*/ */
stmt_info_new_packet.m_key= 0; stmt_info_new_packet.m_key= 0;
stmt_info_new_packet.m_name= ""; stmt_info_new_packet.m_name= "new_packet";
stmt_info_new_packet.m_flags= PSI_FLAG_MUTABLE; stmt_info_new_packet.m_flags= PSI_FLAG_MUTABLE;
mysql_statement_register(category, & stmt_info_new_packet, 1); mysql_statement_register(category, &stmt_info_new_packet, 1);
/*
Statements processed from the relay log are initially instrumented as
"statement/abstract/relay_log". The parser will mutate the statement type to
a more specific classification, for example "statement/sql/insert".
*/
stmt_info_rpl.m_key= 0;
stmt_info_rpl.m_name= "relay_log";
stmt_info_rpl.m_flags= PSI_FLAG_MUTABLE;
mysql_statement_register(category, &stmt_info_rpl, 1);
#endif #endif
} }
......
...@@ -461,6 +461,11 @@ extern PSI_statement_info sql_statement_info[(uint) SQLCOM_END + 1]; ...@@ -461,6 +461,11 @@ extern PSI_statement_info sql_statement_info[(uint) SQLCOM_END + 1];
*/ */
extern PSI_statement_info com_statement_info[(uint) COM_END + 1]; extern PSI_statement_info com_statement_info[(uint) COM_END + 1];
/**
Statement instrumentation key for replication.
*/
extern PSI_statement_info stmt_info_rpl;
void init_sql_statement_info(); void init_sql_statement_info();
void init_com_statement_info(); void init_com_statement_info();
#endif /* HAVE_PSI_STATEMENT_INTERFACE */ #endif /* HAVE_PSI_STATEMENT_INTERFACE */
......
...@@ -287,14 +287,15 @@ static Sys_var_long Sys_pfs_events_stages_history_size( ...@@ -287,14 +287,15 @@ static Sys_var_long Sys_pfs_events_stages_history_size(
- 1 for "statement/com/new_packet", for unknown enum_server_command - 1 for "statement/com/new_packet", for unknown enum_server_command
- 1 for "statement/com/Error", for invalid enum_server_command - 1 for "statement/com/Error", for invalid enum_server_command
- SQLCOM_END for all regular "statement/sql/...", - SQLCOM_END for all regular "statement/sql/...",
- 1 for "statement/sql/error", for invalid enum_sql_command. - 1 for "statement/sql/error", for invalid enum_sql_command
- 1 for "statement/rpl/relay_log", for replicated statements.
*/ */
static Sys_var_ulong Sys_pfs_max_statement_classes( static Sys_var_ulong Sys_pfs_max_statement_classes(
"performance_schema_max_statement_classes", "performance_schema_max_statement_classes",
"Maximum number of statement instruments.", "Maximum number of statement instruments.",
PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_statement_class_sizing), PARSED_EARLY READ_ONLY GLOBAL_VAR(pfs_param.m_statement_class_sizing),
CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 256), CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 256),
DEFAULT((ulong) SQLCOM_END + (ulong) COM_END + 3), DEFAULT((ulong) SQLCOM_END + (ulong) COM_END + 4),
BLOCK_SIZE(1)); BLOCK_SIZE(1));
static Sys_var_long Sys_pfs_events_statements_history_long_size( static Sys_var_long Sys_pfs_events_statements_history_long_size(
......
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