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

Commit 9c8e8a5

Browse files
committed
Add a new 5.7 version of the ps_is_account_enabled, that takes in to account the setup_actors.enabled column added in 5.7.6
1 parent 60d2488 commit 9c8e8a5

File tree

4 files changed

+73
-3
lines changed

4 files changed

+73
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3187,7 +3187,7 @@ Determines whether instrumentation of an account is enabled within Performance S
31873187

31883188
##### Returns
31893189

3190-
ENUM('YES', 'NO', 'PARTIAL')
3190+
ENUM('YES', 'NO')
31913191

31923192
##### Example
31933193
```SQL

functions/ps_is_account_enabled.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ CREATE DEFINER='root'@'localhost' FUNCTION ps_is_account_enabled (
2121
in_host VARCHAR(60),
2222
in_user VARCHAR(16)
2323
)
24-
RETURNS ENUM('YES', 'NO', 'PARTIAL')
24+
RETURNS ENUM('YES', 'NO')
2525
COMMENT '
2626
Description
2727
-----------
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
-- Copyright (c) 2014, 2015, 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_account_enabled;
17+
18+
DELIMITER $$
19+
20+
CREATE DEFINER='root'@'localhost' FUNCTION ps_is_account_enabled (
21+
in_host VARCHAR(60),
22+
in_user VARCHAR(16)
23+
)
24+
RETURNS ENUM('YES', 'NO')
25+
COMMENT '
26+
Description
27+
-----------
28+
29+
Determines whether instrumentation of an account is enabled
30+
within Performance Schema.
31+
32+
Parameters
33+
-----------
34+
35+
in_host VARCHAR(60):
36+
The hostname of the account to check.
37+
in_user (VARCHAR(16)):
38+
The username of the account to check.
39+
40+
Returns
41+
-----------
42+
43+
ENUM(\'YES\', \'NO\', \'PARTIAL\')
44+
45+
Example
46+
-----------
47+
48+
mysql> SELECT sys.ps_is_account_enabled(\'localhost\', \'root\');
49+
+------------------------------------------------+
50+
| sys.ps_is_account_enabled(\'localhost\', \'root\') |
51+
+------------------------------------------------+
52+
| YES |
53+
+------------------------------------------------+
54+
1 row in set (0.01 sec)
55+
'
56+
SQL SECURITY INVOKER
57+
DETERMINISTIC
58+
READS SQL DATA
59+
BEGIN
60+
RETURN IF(EXISTS(SELECT 1
61+
FROM performance_schema.setup_actors
62+
WHERE (`HOST` = '%' OR in_host LIKE `HOST`)
63+
AND (`USER` = '%' OR `USER` = in_user)
64+
AND (`ENABLED` = 'YES')
65+
),
66+
'YES', 'NO'
67+
);
68+
END$$
69+
70+
DELIMITER ;

sys_57.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ SOURCE ./functions/format_bytes.sql
2727
SOURCE ./functions/format_path.sql
2828
SOURCE ./functions/format_statement.sql
2929
SOURCE ./functions/format_time.sql
30-
SOURCE ./functions/ps_is_account_enabled.sql
30+
SOURCE ./functions/ps_is_account_enabled_57.sql
3131
SOURCE ./functions/ps_is_consumer_enabled.sql
3232
SOURCE ./functions/ps_is_instrument_default_enabled.sql
3333
SOURCE ./functions/ps_is_instrument_default_timed.sql

0 commit comments

Comments
 (0)