diff --git a/mysql-test/include/check_digest.inc b/mysql-test/include/check_digest.inc new file mode 100644 index 00000000000..9e5d6cccc8b --- /dev/null +++ b/mysql-test/include/check_digest.inc @@ -0,0 +1,34 @@ +# +# check_digest() checks digests validity from performance_schema.events_statements_summary_by_digest +# + +--disable_query_log +create table test._digests(d varchar(32) primary key); + +delimiter ~~; +create function test.check_digest(digest varchar(255)) +returns tinyint +not deterministic +begin + declare digest_exists tinyint; + if length(digest) != 32 or conv(digest, 16, 10) = 0 then + return 0; + end if; + select exists (select d from test._digests where d = digest) into digest_exists; + if digest_exists then + return 0; + end if; + #insert into test._digests values (digest); + return 1; +end~~ + +create procedure test.reset_digests() +begin + delete from test._digests; +end~~ +delimiter ;~~ + +--disable_result_log +call sys.ps_truncate_all_tables(false); +--enable_result_log +--enable_query_log diff --git a/mysql-test/include/check_digest_end.inc b/mysql-test/include/check_digest_end.inc new file mode 100644 index 00000000000..7d4adf8a7db --- /dev/null +++ b/mysql-test/include/check_digest_end.inc @@ -0,0 +1,9 @@ +# +# Deinit for check_digest.inc +# + +--disable_query_log +drop table test._digests; +drop function test.check_digest; +drop procedure test.reset_digests; +--enable_query_log diff --git a/mysql-test/suite/perfschema/r/digest_view.result b/mysql-test/suite/perfschema/r/digest_view.result index e6913994177..2bc6059c5f4 100644 --- a/mysql-test/suite/perfschema/r/digest_view.result +++ b/mysql-test/suite/perfschema/r/digest_view.result @@ -187,21 +187,21 @@ b a # # DIGESTS SEEN ON TABLE # -SELECT SCHEMA_NAME, DIGEST, DIGEST_TEXT, COUNT_STAR +SELECT SCHEMA_NAME, check_digest(DIGEST), DIGEST_TEXT, COUNT_STAR FROM performance_schema.events_statements_summary_by_digest ORDER BY DIGEST_TEXT; -SCHEMA_NAME DIGEST DIGEST_TEXT COUNT_STAR -test b662d7ab4e8aa67e3aaeb81957a38e97 EXPLAIN SELECT * FROM `test` . `v1` 1 -test 4a6602212e0e1386dada25a12dc2315f EXPLAIN SELECT * FROM `test` . `v1` WHERE `a` = ? 1 -test 7b3a13b2c268ba0a72aade33fb3b9d7d EXPLAIN SELECT * FROM `test` . `v1` WHERE `b` > ? 1 -test 840a987076e3bd7b25603240595f47b9 EXPLAIN SELECT `a` , `b` FROM `test` . `v1` 1 -test 955679ae1c2068ade1003c820f1cdd58 EXPLAIN SELECT `b` , `a` FROM `test` . `v1` 1 -test 3fe51e497b828a521e0b404f7c0e0ac6 SELECT * FROM `test` . `v1` 1 -test 2bec69e086533e335e311b159eee104a SELECT * FROM `test` . `v1` WHERE `a` = ? 1 -test 4e995969bf7999998047ed967d8ebf45 SELECT * FROM `test` . `v1` WHERE `b` > ? 1 -test 51f783c563f3af0cdca3065baace1236 SELECT `a` , `b` FROM `test` . `v1` 1 -test be34ebc622c2d81afca10cc511a06af9 SELECT `b` , `a` FROM `test` . `v1` 1 -test af6cd26b7f88eafb1ff05602a49ce39e TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1 +SCHEMA_NAME check_digest(DIGEST) DIGEST_TEXT COUNT_STAR +test 1 EXPLAIN SELECT * FROM `test` . `v1` 1 +test 1 EXPLAIN SELECT * FROM `test` . `v1` WHERE `a` = ? 1 +test 1 EXPLAIN SELECT * FROM `test` . `v1` WHERE `b` > ? 1 +test 1 EXPLAIN SELECT `a` , `b` FROM `test` . `v1` 1 +test 1 EXPLAIN SELECT `b` , `a` FROM `test` . `v1` 1 +test 1 SELECT * FROM `test` . `v1` 1 +test 1 SELECT * FROM `test` . `v1` WHERE `a` = ? 1 +test 1 SELECT * FROM `test` . `v1` WHERE `b` > ? 1 +test 1 SELECT `a` , `b` FROM `test` . `v1` 1 +test 1 SELECT `b` , `a` FROM `test` . `v1` 1 +test 1 TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1 DROP TABLE test.v1; CREATE VIEW test.v1 AS SELECT * FROM test.t1; EXPLAIN SELECT * from test.v1; @@ -244,23 +244,25 @@ b a # # DIGESTS SEEN ON VIEW # -SELECT SCHEMA_NAME, DIGEST, DIGEST_TEXT, COUNT_STAR +call reset_digests; +SELECT SCHEMA_NAME, check_digest(DIGEST), DIGEST_TEXT, COUNT_STAR FROM performance_schema.events_statements_summary_by_digest ORDER BY DIGEST_TEXT; -SCHEMA_NAME DIGEST DIGEST_TEXT COUNT_STAR -test 1c3d8fb894f91a3cca115966b8c99921 CREATE VIEW `test` . `v1` AS SELECT * FROM `test` . `t1` 1 -test 6b0df2c35a3d2ac98a4e4b43a6e78fe2 DROP TABLE `test` . `v1` 1 -test b662d7ab4e8aa67e3aaeb81957a38e97 EXPLAIN SELECT * FROM `test` . `v1` 2 -test 4a6602212e0e1386dada25a12dc2315f EXPLAIN SELECT * FROM `test` . `v1` WHERE `a` = ? 2 -test 7b3a13b2c268ba0a72aade33fb3b9d7d EXPLAIN SELECT * FROM `test` . `v1` WHERE `b` > ? 2 -test 840a987076e3bd7b25603240595f47b9 EXPLAIN SELECT `a` , `b` FROM `test` . `v1` 2 -test 955679ae1c2068ade1003c820f1cdd58 EXPLAIN SELECT `b` , `a` FROM `test` . `v1` 2 -test 3fe51e497b828a521e0b404f7c0e0ac6 SELECT * FROM `test` . `v1` 2 -test 2bec69e086533e335e311b159eee104a SELECT * FROM `test` . `v1` WHERE `a` = ? 2 -test 4e995969bf7999998047ed967d8ebf45 SELECT * FROM `test` . `v1` WHERE `b` > ? 2 -test 68543d0eacb67ded0fe3280a7be99f73 SELECT SCHEMA_NAME , `DIGEST` , `DIGEST_TEXT` , `COUNT_STAR` FROM `performance_schema` . `events_statements_summary_by_digest` ORDER BY `DIGEST_TEXT` 1 -test 51f783c563f3af0cdca3065baace1236 SELECT `a` , `b` FROM `test` . `v1` 2 -test be34ebc622c2d81afca10cc511a06af9 SELECT `b` , `a` FROM `test` . `v1` 2 -test af6cd26b7f88eafb1ff05602a49ce39e TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1 +SCHEMA_NAME check_digest(DIGEST) DIGEST_TEXT COUNT_STAR +test 1 CALL `reset_digests` 1 +test 1 CREATE VIEW `test` . `v1` AS SELECT * FROM `test` . `t1` 1 +test 1 DROP TABLE `test` . `v1` 1 +test 1 EXPLAIN SELECT * FROM `test` . `v1` 2 +test 1 EXPLAIN SELECT * FROM `test` . `v1` WHERE `a` = ? 2 +test 1 EXPLAIN SELECT * FROM `test` . `v1` WHERE `b` > ? 2 +test 1 EXPLAIN SELECT `a` , `b` FROM `test` . `v1` 2 +test 1 EXPLAIN SELECT `b` , `a` FROM `test` . `v1` 2 +test 1 SELECT * FROM `test` . `v1` 2 +test 1 SELECT * FROM `test` . `v1` WHERE `a` = ? 2 +test 1 SELECT * FROM `test` . `v1` WHERE `b` > ? 2 +test 1 SELECT SCHEMA_NAME , `check_digest` ( `DIGEST` ) , `DIGEST_TEXT` , `COUNT_STAR` FROM `performance_schema` . `events_statements_summary_by_digest` ORDER BY `DIGEST_TEXT` 1 +test 1 SELECT `a` , `b` FROM `test` . `v1` 2 +test 1 SELECT `b` , `a` FROM `test` . `v1` 2 +test 1 TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1 DROP VIEW test.v1; DROP TABLE test.t1; diff --git a/mysql-test/suite/perfschema/r/start_server_low_digest_sql_length.result b/mysql-test/suite/perfschema/r/start_server_low_digest_sql_length.result index 9d6925daabf..2ceeb714291 100644 --- a/mysql-test/suite/perfschema/r/start_server_low_digest_sql_length.result +++ b/mysql-test/suite/perfschema/r/start_server_low_digest_sql_length.result @@ -6,7 +6,9 @@ SELECT 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1 #################################### # QUERYING PS STATEMENT DIGEST #################################### -SELECT event_name, digest, digest_text, sql_text FROM events_statements_history_long; -event_name digest digest_text sql_text -statement/sql/select 141772a2d94a8dd7d4795ffcf2cb1e6c SELECT ? + ? + SELECT ... -statement/sql/truncate 188ff5124e67b3e6d57b8d5b7fd10694 TRUNCATE TABLE truncat... +create table test.events_long select * from events_statements_history_long; +SELECT event_name, test.check_digest(digest), digest_text, sql_text FROM test.events_long; +event_name test.check_digest(digest) digest_text sql_text +statement/sql/select 1 SELECT ? + ? + SELECT ... +statement/sql/truncate 1 TRUNCATE TABLE truncat... +drop table test.events_long; diff --git a/mysql-test/suite/perfschema/t/digest_view.test b/mysql-test/suite/perfschema/t/digest_view.test index dd862aebd52..747ac8536ea 100644 --- a/mysql-test/suite/perfschema/t/digest_view.test +++ b/mysql-test/suite/perfschema/t/digest_view.test @@ -9,6 +9,7 @@ --source include/no_protocol.inc --source include/not_embedded.inc --source include/have_perfschema.inc +--source include/check_digest.inc CREATE TABLE test.v1 (a int, b int); INSERT INTO test.v1 VALUES (1, 100), (2, 200), (3, 300); @@ -116,7 +117,7 @@ SELECT b, a from test.v1; --echo # DIGESTS SEEN ON TABLE --echo # -SELECT SCHEMA_NAME, DIGEST, DIGEST_TEXT, COUNT_STAR +SELECT SCHEMA_NAME, check_digest(DIGEST), DIGEST_TEXT, COUNT_STAR FROM performance_schema.events_statements_summary_by_digest ORDER BY DIGEST_TEXT; @@ -144,10 +145,13 @@ SELECT b, a from test.v1; --echo # DIGESTS SEEN ON VIEW --echo # -SELECT SCHEMA_NAME, DIGEST, DIGEST_TEXT, COUNT_STAR +call reset_digests; + +SELECT SCHEMA_NAME, check_digest(DIGEST), DIGEST_TEXT, COUNT_STAR FROM performance_schema.events_statements_summary_by_digest ORDER BY DIGEST_TEXT; DROP VIEW test.v1; DROP TABLE test.t1; +--source include/check_digest_end.inc diff --git a/mysql-test/suite/perfschema/t/start_server_low_digest_sql_length.test b/mysql-test/suite/perfschema/t/start_server_low_digest_sql_length.test index ce8233a98ce..5a57a3c69ae 100644 --- a/mysql-test/suite/perfschema/t/start_server_low_digest_sql_length.test +++ b/mysql-test/suite/perfschema/t/start_server_low_digest_sql_length.test @@ -5,6 +5,7 @@ --source include/not_embedded.inc --source include/have_perfschema.inc --source include/no_protocol.inc +--source include/check_digest.inc USE performance_schema; truncate table events_statements_history_long; @@ -19,5 +20,8 @@ SELECT 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1 --echo #################################### --echo # QUERYING PS STATEMENT DIGEST --echo #################################### +create table test.events_long select * from events_statements_history_long; --sorted_result -SELECT event_name, digest, digest_text, sql_text FROM events_statements_history_long; +SELECT event_name, test.check_digest(digest), digest_text, sql_text FROM test.events_long; +--source include/check_digest_end.inc +drop table test.events_long;