This repository was archived by the owner on Aug 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug #23621189 PS_TRACE_STATEMENT_DIGEST FAILS AT EXPLAIN OR NO FOUND …
…QUERIES The ps_trace_statement_digest() procedure did not handle some conditions: * Queries (such as SHOW) that does not support EXPLAIN * Queries where one or more tables is not fully qualified as the table cannot be found when attempting to EXPLAIN it * When no queries with the specified digest is found during the monitored period These issues have been fixed and a new test case, sysschema.pr_ps_trace_statement_digest, has been added.
- Loading branch information
1 parent
4d505f1
commit 76b512c
Showing
4 changed files
with
142 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
mysql-test/suite/sysschema/r/pr_ps_trace_statement_digest.result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use test; | ||
SET @threadid = sys.ps_thread_id(NULL); | ||
CREATE TABLE t1 (id INT PRIMARY KEY, val int); | ||
INSERT INTO test.t1 VALUES (1, 9); | ||
SET @digest.insert = (SELECT DIGEST FROM performance_schema.events_statements_history WHERE THREAD_ID = @threadid AND SQL_TEXT LIKE 'INSERT INTO test.t1 VALUES (1, 9)'); | ||
SELECT * FROM t1; | ||
id val | ||
1 9 | ||
SET @digest.select = (SELECT DIGEST FROM performance_schema.events_statements_history WHERE THREAD_ID = @threadid AND SQL_TEXT LIKE 'SELECT * FROM t1'); | ||
SHOW CREATE TABLE test.t1; | ||
Table Create Table | ||
t1 CREATE TABLE `t1` ( | ||
`id` int(11) NOT NULL, | ||
`val` int(11) DEFAULT NULL, | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 | ||
SET @digest.show = (SELECT DIGEST FROM performance_schema.events_statements_history WHERE THREAD_ID = @threadid AND SQL_TEXT LIKE 'SHOW CREATE TABLE test.t1'); | ||
CREATE SCHEMA test_sys; | ||
use test_sys; | ||
CALL sys.ps_trace_statement_digest(@digest.insert, 0.5, 0.1, FALSE, FALSE); | ||
CALL sys.ps_trace_statement_digest(@digest.select, 0.5, 0.1, FALSE, FALSE); | ||
CALL sys.ps_trace_statement_digest(@digest.show , 0.5, 0.1, FALSE, FALSE); | ||
CALL sys.ps_trace_statement_digest(@digest.insert, 0.5, 0.1, TRUE , FALSE); | ||
use test; | ||
DROP SCHEMA test_sys; | ||
DROP TABLE t1; | ||
SET @threadid = NULL, | ||
@digest.insert = NULL, | ||
@digest.select = NULL, | ||
@digest.show = NULL; |
65 changes: 65 additions & 0 deletions
65
mysql-test/suite/sysschema/t/pr_ps_trace_statement_digest.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
########### suite/sysschema/t/pr_ps_trace_statement_digest.test ############# | ||
# # | ||
# Testing of of the sys.ps_trace_statement_digest() procedure # | ||
# # | ||
# Creation: # | ||
# 2016-06-21 jkrogh Implement this test as part of # | ||
# Bug 23621189 PS_TRACE_STATEMENT_DIGEST FAILS AT EXPLAIN # | ||
# # | ||
############################################################################# | ||
|
||
-- source include/not_embedded.inc | ||
# The ps_trace_statement_digest does not work with prepared statements | ||
# So disable this test with --ps-protocol | ||
-- source include/no_protocol.inc | ||
|
||
use test; | ||
|
||
# Get the thread id of this thread | ||
# Store it in a user variable as otherwise repeated calls to sys.ps_thread_id() | ||
# will keep changing performance_schema.events_statements_history | ||
SET @threadid = sys.ps_thread_id(NULL); | ||
|
||
# Create a table | ||
CREATE TABLE t1 (id INT PRIMARY KEY, val int); | ||
|
||
# Get digest of an INSERT statement with a qualified table name | ||
INSERT INTO test.t1 VALUES (1, 9); | ||
SET @digest.insert = (SELECT DIGEST FROM performance_schema.events_statements_history WHERE THREAD_ID = @threadid AND SQL_TEXT LIKE 'INSERT INTO test.t1 VALUES (1, 9)'); | ||
|
||
# Get digest of an SELECT statement using the default schema | ||
SELECT * FROM t1; | ||
SET @digest.select = (SELECT DIGEST FROM performance_schema.events_statements_history WHERE THREAD_ID = @threadid AND SQL_TEXT LIKE 'SELECT * FROM t1'); | ||
|
||
# Get digets of a SHOW statement (doesn't support EXPLAIN) | ||
SHOW CREATE TABLE test.t1; | ||
SET @digest.show = (SELECT DIGEST FROM performance_schema.events_statements_history WHERE THREAD_ID = @threadid AND SQL_TEXT LIKE 'SHOW CREATE TABLE test.t1'); | ||
|
||
# Don't execute ps_trace_statement_digest() in the same schema as the queries | ||
# to monitor - to ensure we handle queries using the default schema. | ||
CREATE SCHEMA test_sys; | ||
use test_sys; | ||
|
||
# Only do sanity checks - no error should occur, but the actual output is non-deterministic | ||
--disable_result_log | ||
# Regular EXPLAINable SELECT with a qualified table name | ||
CALL sys.ps_trace_statement_digest(@digest.insert, 0.5, 0.1, FALSE, FALSE); | ||
# Table in query is not qualified and is not in the current default schema | ||
CALL sys.ps_trace_statement_digest(@digest.select, 0.5, 0.1, FALSE, FALSE); | ||
# SHOW queries doesn't work with EXPLAIN | ||
CALL sys.ps_trace_statement_digest(@digest.show , 0.5, 0.1, FALSE, FALSE); | ||
# Test that finding no queries works - the TRUE argument resets the P_S tables | ||
# used in ps_trace_statement_digest() | ||
CALL sys.ps_trace_statement_digest(@digest.insert, 0.5, 0.1, TRUE , FALSE); | ||
--enable_result_log | ||
|
||
|
||
|
||
# Clean up | ||
use test; | ||
DROP SCHEMA test_sys; | ||
DROP TABLE t1; | ||
SET @threadid = NULL, | ||
@digest.insert = NULL, | ||
@digest.select = NULL, | ||
@digest.show = NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters