|
| 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 ; |
0 commit comments