Skip to content

Commit 17545f1

Browse files
committed
Bug #25244533 : PERFORMANCE_SCHEMA DIGESTS THE SAME QUERY TO MULTIPLE DIFFERENT
DIGESTS Issue: Part1: When there are ';' in the queries, it is assumed that there are multiple queries and therefore parsing is done for each individual query one after another. During this process, digest storage was not reset properly and digest text of old query was seen. Fix: Reset digest storage beforem start parsing next query. Part2: In case of multiple queries, when a ';' is seen, its decided that current query ends here and a new query is about to start. But when delimiter is set to something else, for the first query, ';' is passed to digest code. As a result, ';' was seen in digest text and the digest created for the query is different from the digest which would have been created without the ';' in the query. Fix: Parser passes NUL (i.e. 0) to digest code when the first query parsing is over. Therefore, in digest code when a NUL (0) is encountered, check the last token. If it is ';', pop it out so that it is not included in query digest text and digest.
1 parent 70cc2d8 commit 17545f1

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

sql/sql_digest.cc

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -595,6 +595,16 @@ sql_digest_state* digest_add_token(sql_digest_state *state,
595595
state->m_last_id_index= (int)digest_storage->m_byte_count;
596596
break;
597597
}
598+
case 0:
599+
{
600+
unsigned int temp_tok;
601+
read_token(digest_storage,
602+
digest_storage->m_byte_count-SIZE_OF_A_TOKEN,
603+
& temp_tok);
604+
if (temp_tok == ';')
605+
digest_storage->m_byte_count-= SIZE_OF_A_TOKEN;
606+
break;
607+
}
598608
default:
599609
{
600610
/* Add this token to digest storage. */

sql/sql_parse.cc

+1
Original file line numberDiff line numberDiff line change
@@ -1430,6 +1430,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
14301430

14311431
/* PSI begin */
14321432
thd->m_digest= & thd->m_digest_state;
1433+
thd->m_digest->reset(thd->m_token_array, max_digest_length);
14331434

14341435
thd->m_statement_psi= MYSQL_START_STATEMENT(&thd->m_statement_state,
14351436
com_statement_info[command].m_key,

0 commit comments

Comments
 (0)