diff options
Diffstat (limited to 'storage/perfschema/pfs.cc')
-rw-r--r-- | storage/perfschema/pfs.cc | 83 |
1 files changed, 61 insertions, 22 deletions
diff --git a/storage/perfschema/pfs.cc b/storage/perfschema/pfs.cc index 876baa47fa6..7c556ba4407 100644 --- a/storage/perfschema/pfs.cc +++ b/storage/perfschema/pfs.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -4455,7 +4455,7 @@ get_thread_statement_locker_v1(PSI_statement_locker_state *state, pfs->m_sort_scan= 0; pfs->m_no_index_used= 0; pfs->m_no_good_index_used= 0; - digest_reset(& pfs->m_digest_storage); + pfs->m_digest_storage.reset(); /* New stages will have this statement as parent */ PFS_events_stages *child_stage= & pfs_thread->m_stage_current; @@ -4484,11 +4484,7 @@ get_thread_statement_locker_v1(PSI_statement_locker_state *state, if (flag_statements_digest) { - const CHARSET_INFO *cs= static_cast <const CHARSET_INFO*> (charset); flags|= STATE_FLAG_DIGEST; - state->m_digest_state.m_last_id_index= 0; - digest_reset(& state->m_digest_state.m_digest_storage); - state->m_digest_state.m_digest_storage.m_charset_number= cs->number; } state->m_discarded= false; @@ -4512,6 +4508,8 @@ get_thread_statement_locker_v1(PSI_statement_locker_state *state, state->m_no_index_used= 0; state->m_no_good_index_used= 0; + state->m_digest= NULL; + state->m_schema_name_length= 0; return reinterpret_cast<PSI_statement_locker*> (state); @@ -4781,11 +4779,11 @@ static void end_statement_v1(PSI_statement_locker *locker, void *stmt_da) PFS_statement_stat *event_name_array; uint index= klass->m_event_name_index; PFS_statement_stat *stat; - + /* Capture statement stats by digest. */ - PSI_digest_storage *digest_storage= NULL; + const sql_digest_storage *digest_storage= NULL; PFS_statement_stat *digest_stat= NULL; if (flags & STATE_FLAG_THREAD) @@ -4798,11 +4796,15 @@ static void end_statement_v1(PSI_statement_locker *locker, void *stmt_da) if (flags & STATE_FLAG_DIGEST) { - digest_storage= &state->m_digest_state.m_digest_storage; - /* Populate PFS_statements_digest_stat with computed digest information.*/ - digest_stat= find_or_create_digest(thread, digest_storage, - state->m_schema_name, - state->m_schema_name_length); + digest_storage= state->m_digest; + + if (digest_storage != NULL) + { + /* Populate PFS_statements_digest_stat with computed digest information.*/ + digest_stat= find_or_create_digest(thread, digest_storage, + state->m_schema_name, + state->m_schema_name_length); + } } if (flags & STATE_FLAG_EVENT) @@ -4839,7 +4841,7 @@ static void end_statement_v1(PSI_statement_locker *locker, void *stmt_da) pfs->m_timer_end= timer_end; pfs->m_end_event_id= thread->m_event_id; - if (flags & STATE_FLAG_DIGEST) + if (digest_storage != NULL) { /* The following columns in events_statement_current: @@ -4847,7 +4849,7 @@ static void end_statement_v1(PSI_statement_locker *locker, void *stmt_da) - DIGEST_TEXT are computed from the digest storage. */ - digest_copy(& pfs->m_digest_storage, digest_storage); + pfs->m_digest_storage.copy(digest_storage); } if (flag_events_statements_history) @@ -4870,11 +4872,15 @@ static void end_statement_v1(PSI_statement_locker *locker, void *stmt_da) if (thread != NULL) { /* Set digest stat. */ - digest_storage= &state->m_digest_state.m_digest_storage; - /* Populate statements_digest_stat with computed digest information. */ - digest_stat= find_or_create_digest(thread, digest_storage, - state->m_schema_name, - state->m_schema_name_length); + digest_storage= state->m_digest; + + if (digest_storage != NULL) + { + /* Populate statements_digest_stat with computed digest information. */ + digest_stat= find_or_create_digest(thread, digest_storage, + state->m_schema_name, + state->m_schema_name_length); + } } } @@ -4921,7 +4927,7 @@ static void end_statement_v1(PSI_statement_locker *locker, void *stmt_da) { digest_stat->aggregate_counted(); } - + digest_stat->m_lock_time+= state->m_lock_time; digest_stat->m_rows_sent+= state->m_rows_sent; digest_stat->m_rows_examined+= state->m_rows_examined; @@ -5106,6 +5112,39 @@ static void set_socket_thread_owner_v1(PSI_socket *socket) pfs_socket->m_thread_owner= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS); } +struct PSI_digest_locker* +pfs_digest_start_v1(PSI_statement_locker *locker) +{ + PSI_statement_locker_state *statement_state; + statement_state= reinterpret_cast<PSI_statement_locker_state*> (locker); + DBUG_ASSERT(statement_state != NULL); + + if (statement_state->m_discarded) + return NULL; + + if (statement_state->m_flags & STATE_FLAG_DIGEST) + { + return reinterpret_cast<PSI_digest_locker*> (locker); + } + + return NULL; +} + +void pfs_digest_end_v1(PSI_digest_locker *locker, const sql_digest_storage *digest) +{ + PSI_statement_locker_state *statement_state; + statement_state= reinterpret_cast<PSI_statement_locker_state*> (locker); + DBUG_ASSERT(statement_state != NULL); + DBUG_ASSERT(digest != NULL); + + if (statement_state->m_discarded) + return; + + if (statement_state->m_flags & STATE_FLAG_DIGEST) + { + statement_state->m_digest= digest; + } +} /** Implementation of the thread attribute connection interface @@ -5243,7 +5282,7 @@ PSI_v1 PFS_v1= set_socket_info_v1, set_socket_thread_owner_v1, pfs_digest_start_v1, - pfs_digest_add_token_v1, + pfs_digest_end_v1, set_thread_connect_attrs_v1, }; |