Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit 14eede2

Browse files
Adding the function ps_is_instrument_default_enabled() which returns whether a given instrument is enabled by default for the MySQL version used.
1 parent 3d6eaca commit 14eede2

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
2+
3+
This program is free software; you can redistribute it and/or modify
4+
it under the terms of the GNU General Public License as published by
5+
the Free Software Foundation; version 2 of the License.
6+
7+
This program is distributed in the hope that it will be useful,
8+
but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
GNU General Public License for more details.
11+
12+
You should have received a copy of the GNU General Public License
13+
along with this program; if not, write to the Free Software
14+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15+
16+
DROP FUNCTION IF EXISTS ps_is_instrument_default_enabled;
17+
18+
DELIMITER $$
19+
20+
CREATE DEFINER='root'@'localhost' FUNCTION ps_is_instrument_default_enabled (
21+
in_instrument VARCHAR(128)
22+
)
23+
RETURNS ENUM('YES', 'NO')
24+
COMMENT '
25+
Description
26+
-----------
27+
28+
Returns whether an instrument is enabled by default in this version of MySQL.
29+
30+
Parameters
31+
-----------
32+
33+
in_instrument VARCHAR(128):
34+
The instrument to check.
35+
36+
Returns
37+
-----------
38+
39+
ENUM(\'YES\', \'NO\')
40+
41+
Example
42+
-----------
43+
44+
mysql> SELECT sys.ps_is_instrument_default_enabled(\'statement/sql/select\');
45+
+--------------------------------------------------------------+
46+
| sys.ps_is_instrument_default_enabled(\'statement/sql/select\') |
47+
+--------------------------------------------------------------+
48+
| YES |
49+
+--------------------------------------------------------------+
50+
1 row in set (0.00 sec)
51+
'
52+
SQL SECURITY INVOKER
53+
DETERMINISTIC
54+
READS SQL DATA
55+
BEGIN
56+
DECLARE v_enabled ENUM('YES', 'NO');
57+
58+
-- Currently the same in all versions
59+
SET v_enabled = IF(in_instrument LIKE 'wait/io/file/%'
60+
OR in_instrument LIKE 'wait/io/table/%'
61+
OR in_instrument LIKE 'statement/%'
62+
OR in_instrument IN ('wait/lock/table/sql/handler', 'idle'),
63+
'YES',
64+
'NO'
65+
);
66+
67+
RETURN v_enabled;
68+
END$$
69+
70+
DELIMITER ;

0 commit comments

Comments
 (0)