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

Commit 4fc4310

Browse files
committed
Merge pull request #20 from JesperWisborgKrogh/dev/issue_15_reset_to_default
Dev/issue 15 reset to default
2 parents 7c98db9 + ebce8fe commit 4fc4310

File tree

7 files changed

+198
-10
lines changed

7 files changed

+198
-10
lines changed

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,6 +1434,56 @@ mysql> SELECT sys.ps_is_account_enabled('localhost', 'root');
14341434
1 row in set (0.01 sec)
14351435
```
14361436

1437+
#### ps_is_instrument_default_enabled
1438+
1439+
##### Description
1440+
1441+
Returns whether an instrument is enabled by default in this version of MySQL.
1442+
1443+
##### Parameters
1444+
1445+
* in_instrument VARCHAR(128): The instrument to check.
1446+
1447+
##### Returns
1448+
1449+
ENUM('YES', 'NO')
1450+
1451+
##### Example
1452+
```SQL
1453+
mysql> SELECT sys.ps_is_instrument_default_enabled('statement/sql/select');
1454+
+--------------------------------------------------------------+
1455+
| sys.ps_is_instrument_default_enabled('statement/sql/select') |
1456+
+--------------------------------------------------------------+
1457+
| YES |
1458+
+--------------------------------------------------------------+
1459+
1 row in set (0.00 sec)
1460+
```
1461+
1462+
#### ps_is_instrument_default_timed
1463+
1464+
##### Description
1465+
1466+
Returns whether an instrument is timed by default in this version of MySQL.
1467+
1468+
##### Parameters
1469+
1470+
* in_instrument VARCHAR(128): The instrument to check.
1471+
1472+
##### Returns
1473+
1474+
ENUM('YES', 'NO')
1475+
1476+
##### Example
1477+
```SQL
1478+
mysql> SELECT sys.ps_is_instrument_default_timed('statement/sql/select');
1479+
+------------------------------------------------------------+
1480+
| sys.ps_is_instrument_default_timed('statement/sql/select') |
1481+
+------------------------------------------------------------+
1482+
| YES |
1483+
+------------------------------------------------------------+
1484+
1 row in set (0.00 sec)
1485+
```
1486+
14371487
#### ps_thread_id
14381488

14391489
##### Description
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 ;
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_timed;
17+
18+
DELIMITER $$
19+
20+
CREATE DEFINER='root'@'localhost' FUNCTION ps_is_instrument_default_timed (
21+
in_instrument VARCHAR(128)
22+
)
23+
RETURNS ENUM('YES', 'NO')
24+
COMMENT '
25+
Description
26+
-----------
27+
28+
Returns whether an instrument is timed 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_timed(\'statement/sql/select\');
45+
+------------------------------------------------------------+
46+
| sys.ps_is_instrument_default_timed(\'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_timed ENUM('YES', 'NO');
57+
58+
-- Currently the same in all versions
59+
SET v_timed = 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_timed;
68+
END$$
69+
70+
DELIMITER ;

procedures/ps_setup_reset_to_default.sql

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,8 @@ BEGIN
8181
DEALLOCATE PREPARE reset_stmt;
8282

8383
SET @query = 'UPDATE performance_schema.setup_instruments
84-
SET ENABLED = ''NO'', TIMED = ''NO''
85-
WHERE NAME NOT LIKE ''wait/io/file/%''
86-
AND NAME NOT LIKE ''wait/io/table/%''
87-
AND NAME NOT LIKE ''statement/%''
88-
AND NAME NOT IN (''wait/lock/table/sql/handler'', ''idle'')';
84+
SET ENABLED = sys.ps_is_instrument_default_enabled(NAME),
85+
TIMED = sys.ps_is_instrument_default_timed(NAME)';
8986

9087
IF (in_verbose) THEN
9188
SELECT CONCAT('Resetting: setup_instruments\n', REPLACE(@query, ' ', '')) AS status;

procedures/ps_setup_reset_to_default_57.sql

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,8 @@ BEGIN
8585
DEALLOCATE PREPARE reset_stmt;
8686

8787
SET @query = 'UPDATE performance_schema.setup_instruments
88-
SET ENABLED = ''NO'', TIMED = ''NO''
89-
WHERE NAME NOT LIKE ''wait/io/file/%''
90-
AND NAME NOT LIKE ''wait/io/table/%''
91-
AND NAME NOT LIKE ''statement/%''
92-
AND NAME NOT IN (''wait/lock/table/sql/handler'', ''idle'')';
88+
SET ENABLED = sys.ps_is_instrument_default_enabled(NAME),
89+
TIMED = sys.ps_is_instrument_default_timed(NAME)';
9390

9491
IF (in_verbose) THEN
9592
SELECT CONCAT('Resetting: setup_instruments\n', REPLACE(@query, ' ', '')) AS status;

sys_56.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ SOURCE ./functions/format_path.sql
2222
SOURCE ./functions/format_statement.sql
2323
SOURCE ./functions/format_time.sql
2424
SOURCE ./functions/ps_is_account_enabled.sql
25+
SOURCE ./functions/ps_is_instrument_default_enabled.sql
26+
SOURCE ./functions/ps_is_instrument_default_timed.sql
2527
SOURCE ./functions/ps_thread_id.sql
2628
SOURCE ./functions/ps_thread_stack.sql
2729

sys_57.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ SOURCE ./functions/format_path.sql
2222
SOURCE ./functions/format_statement.sql
2323
SOURCE ./functions/format_time.sql
2424
SOURCE ./functions/ps_is_account_enabled.sql
25+
SOURCE ./functions/ps_is_instrument_default_enabled.sql
26+
SOURCE ./functions/ps_is_instrument_default_timed.sql
2527
SOURCE ./functions/ps_thread_id.sql
2628
SOURCE ./functions/ps_thread_stack.sql
2729

0 commit comments

Comments
 (0)