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

Commit

Permalink
Merge pull request #93 from MarkLeith/development
Browse files Browse the repository at this point in the history
Release 1.5.0
  • Loading branch information
MarkLeith committed Sep 11, 2015
2 parents e9413d9 + 5454b99 commit 5f17b5c
Show file tree
Hide file tree
Showing 171 changed files with 8,249 additions and 662 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gen/
120 changes: 90 additions & 30 deletions NEWS.md

Large diffs are not rendered by default.

1,460 changes: 1,283 additions & 177 deletions README.md

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions before_setup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,3 @@ SET sql_log_bin = 0;
CREATE DATABASE IF NOT EXISTS sys DEFAULT CHARACTER SET utf8;

USE sys;

CREATE OR REPLACE ALGORITHM = MERGE DEFINER = 'root'@'localhost' SQL SECURITY INVOKER VIEW version AS SELECT '1.4.0' AS sys_version, version() AS mysql_version;
2 changes: 1 addition & 1 deletion functions/format_bytes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ BEGIN
ELSEIF bytes >= 1073741824 THEN RETURN CONCAT(ROUND(bytes / 1073741824, 2), ' GiB');
ELSEIF bytes >= 1048576 THEN RETURN CONCAT(ROUND(bytes / 1048576, 2), ' MiB');
ELSEIF bytes >= 1024 THEN RETURN CONCAT(ROUND(bytes / 1024, 2), ' KiB');
ELSE RETURN CONCAT(bytes, ' bytes');
ELSE RETURN CONCAT(ROUND(bytes, 0), ' bytes');
END IF;
END$$

Expand Down
10 changes: 5 additions & 5 deletions functions/format_path.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ DROP FUNCTION IF EXISTS format_path;
DELIMITER $$

CREATE DEFINER='root'@'localhost' FUNCTION format_path (
path VARCHAR(260)
path VARCHAR(512)
)
RETURNS VARCHAR(260) CHARSET UTF8
RETURNS VARCHAR(512) CHARSET UTF8
COMMENT '
Description
-----------
Expand All @@ -34,13 +34,13 @@ CREATE DEFINER='root'@'localhost' FUNCTION format_path (
Parameters
-----------
path (VARCHAR(260)):
path (VARCHAR(512)):
The raw file path value to format.
Returns
-----------
VARCHAR(260) CHARSET UTF8
VARCHAR(512) CHARSET UTF8
Example
-----------
Expand All @@ -65,7 +65,7 @@ CREATE DEFINER='root'@'localhost' FUNCTION format_path (
DETERMINISTIC
NO SQL
BEGIN
DECLARE v_path VARCHAR(260);
DECLARE v_path VARCHAR(512);
DECLARE v_undo_dir VARCHAR(1024);

-- OSX hides /private/ in variables, but Performance Schema does not
Expand Down
97 changes: 97 additions & 0 deletions functions/format_path_57.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
-- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; version 2 of the License.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

DROP FUNCTION IF EXISTS format_path;

DELIMITER $$

CREATE DEFINER='root'@'localhost' FUNCTION format_path (
path VARCHAR(512)
)
RETURNS VARCHAR(512) CHARSET UTF8
COMMENT '
Description
-----------
Takes a raw path value, and strips out the datadir or tmpdir
replacing with @@datadir and @@tmpdir respectively.
Also normalizes the paths across operating systems, so backslashes
on Windows are converted to forward slashes
Parameters
-----------
path (VARCHAR(512)):
The raw file path value to format.
Returns
-----------
VARCHAR(512) CHARSET UTF8
Example
-----------
mysql> select @@datadir;
+-----------------------------------------------+
| @@datadir |
+-----------------------------------------------+
| /Users/mark/sandboxes/SmallTree/AMaster/data/ |
+-----------------------------------------------+
1 row in set (0.06 sec)
mysql> select format_path(\'/Users/mark/sandboxes/SmallTree/AMaster/data/mysql/proc.MYD\') AS path;
+--------------------------+
| path |
+--------------------------+
| @@datadir/mysql/proc.MYD |
+--------------------------+
1 row in set (0.03 sec)
'
SQL SECURITY INVOKER
DETERMINISTIC
NO SQL
BEGIN
DECLARE v_path VARCHAR(512);
DECLARE v_undo_dir VARCHAR(1024);

-- OSX hides /private/ in variables, but Performance Schema does not
IF path LIKE '/private/%'
THEN SET v_path = REPLACE(path, '/private', '');
ELSE SET v_path = path;
END IF;

-- @@global.innodb_undo_directory is only set when separate undo logs are used
SET v_undo_dir = IFNULL((SELECT VARIABLE_NAME FROM performance_schema.global_variables WHERE VARIABLE_NAME = 'innodb_undo_directory'), '');

IF v_path IS NULL THEN RETURN NULL;
ELSEIF v_path LIKE CONCAT(@@global.datadir, '%') ESCAPE '|' THEN
RETURN REPLACE(REPLACE(REPLACE(v_path, @@global.datadir, '@@datadir/'), '\\\\', ''), '\\', '/');
ELSEIF v_path LIKE CONCAT(@@global.tmpdir, '%') ESCAPE '|' THEN
RETURN REPLACE(REPLACE(REPLACE(v_path, @@global.tmpdir, '@@tmpdir/'), '\\\\', ''), '\\', '/');
ELSEIF v_path LIKE CONCAT(@@global.slave_load_tmpdir, '%') ESCAPE '|' THEN
RETURN REPLACE(REPLACE(REPLACE(v_path, @@global.slave_load_tmpdir, '@@slave_load_tmpdir/'), '\\\\', ''), '\\', '/');
ELSEIF v_path LIKE CONCAT(@@global.innodb_data_home_dir, '%') ESCAPE '|' THEN
RETURN REPLACE(REPLACE(REPLACE(v_path, @@global.innodb_data_home_dir, '@@innodb_data_home_dir/'), '\\\\', ''), '\\', '/');
ELSEIF v_path LIKE CONCAT(@@global.innodb_log_group_home_dir, '%') ESCAPE '|' THEN
RETURN REPLACE(REPLACE(REPLACE(v_path, @@global.innodb_log_group_home_dir, '@@innodb_log_group_home_dir/'), '\\\\', ''), '\\', '/');
ELSEIF v_path LIKE CONCAT(v_undo_dir, '%') ESCAPE '|' THEN
RETURN REPLACE(REPLACE(REPLACE(v_path, v_undo_dir, '@@innodb_undo_directory/'), '\\\\', ''), '\\', '/');
ELSE RETURN v_path;
END IF;
END$$

DELIMITER ;
2 changes: 1 addition & 1 deletion functions/format_statement.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ CREATE DEFINER='root'@'localhost' FUNCTION format_statement (
Description
-----------
Formats a normalized statement, truncating it if it\'s > 64 characters long by default.
Formats a normalized statement, truncating it if it is > 64 characters long by default.
To configure the length to truncate the statement to by default, update the `statement_truncate_len`
variable with `sys_config` table to a different value. Alternatively, to change it just for just
Expand Down
90 changes: 90 additions & 0 deletions functions/list_add.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
-- Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; version 2 of the License.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

DROP FUNCTION IF EXISTS list_add;

DELIMITER $$

CREATE DEFINER='root'@'localhost' FUNCTION list_add (
in_list TEXT,
in_add_value TEXT
)
RETURNS TEXT
COMMENT '
Description
-----------
Takes a list, and a value to add to the list, and returns the resulting list.
Useful for altering certain session variables, like sql_mode or optimizer_switch for instance.
Parameters
-----------
in_list (TEXT):
The comma separated list to add a value to
in_add_value (TEXT):
The value to add to the input list
Returns
-----------
TEXT
Example
--------
mysql> select @@sql_mode;
+-----------------------------------------------------------------------------------+
| @@sql_mode |
+-----------------------------------------------------------------------------------+
| ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+-----------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> set sql_mode = sys.list_add(@@sql_mode, ''ANSI_QUOTES'');
Query OK, 0 rows affected (0.06 sec)
mysql> select @@sql_mode;
+-----------------------------------------------------------------------------------------------+
| @@sql_mode |
+-----------------------------------------------------------------------------------------------+
| ANSI_QUOTES,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+-----------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
'
SQL SECURITY INVOKER
DETERMINISTIC
CONTAINS SQL
BEGIN

IF (in_add_value IS NULL) THEN
SIGNAL SQLSTATE '02200'
SET MESSAGE_TEXT = 'Function sys.list_add: in_add_value input variable should not be NULL',
MYSQL_ERRNO = 1138;
END IF;

IF (in_list IS NULL OR LENGTH(in_list) = 0) THEN
-- return the new value as a single value list
RETURN in_add_value;
END IF;

RETURN (SELECT CONCAT(TRIM(BOTH ',' FROM TRIM(in_list)), ',', in_add_value));

END$$

DELIMITER ;
91 changes: 91 additions & 0 deletions functions/list_drop.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
-- Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; version 2 of the License.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

DROP FUNCTION IF EXISTS list_drop;

DELIMITER $$

CREATE DEFINER='root'@'localhost' FUNCTION list_drop (
in_list TEXT,
in_drop_value TEXT
)
RETURNS TEXT
COMMENT '
Description
-----------
Takes a list, and a value to attempt to remove from the list, and returns the resulting list.
Useful for altering certain session variables, like sql_mode or optimizer_switch for instance.
Parameters
-----------
in_list (TEXT):
The comma separated list to drop a value from
in_drop_value (TEXT):
The value to drop from the input list
Returns
-----------
TEXT
Example
--------
mysql> select @@sql_mode;
+-----------------------------------------------------------------------------------------------+
| @@sql_mode |
+-----------------------------------------------------------------------------------------------+
| ANSI_QUOTES,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+-----------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> set sql_mode = sys.list_drop(@@sql_mode, ''ONLY_FULL_GROUP_BY'');
Query OK, 0 rows affected (0.03 sec)
mysql> select @@sql_mode;
+----------------------------------------------------------------------------+
| @@sql_mode |
+----------------------------------------------------------------------------+
| ANSI_QUOTES,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+----------------------------------------------------------------------------+
1 row in set (0.00 sec)
'
SQL SECURITY INVOKER
DETERMINISTIC
CONTAINS SQL
BEGIN

IF (in_drop_value IS NULL) THEN
SIGNAL SQLSTATE '02200'
SET MESSAGE_TEXT = 'Function sys.list_drop: in_drop_value input variable should not be NULL',
MYSQL_ERRNO = 1138;
END IF;

IF (in_list IS NULL OR LENGTH(in_list) = 0) THEN
-- return the list as it was passed in
RETURN in_list;
END IF;

-- ensure that leading / trailing commas are remove, support values with either spaces or not between commas
RETURN (SELECT TRIM(BOTH ',' FROM REPLACE(REPLACE(CONCAT(',', in_list), CONCAT(',', in_drop_value), ''), CONCAT(', ', in_drop_value), '')));

END$$

DELIMITER ;
4 changes: 2 additions & 2 deletions functions/ps_is_account_enabled_57.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ DELIMITER $$

CREATE DEFINER='root'@'localhost' FUNCTION ps_is_account_enabled (
in_host VARCHAR(60),
in_user VARCHAR(16)
in_user VARCHAR(32)
)
RETURNS ENUM('YES', 'NO')
COMMENT '
Expand All @@ -34,7 +34,7 @@ CREATE DEFINER='root'@'localhost' FUNCTION ps_is_account_enabled (
in_host VARCHAR(60):
The hostname of the account to check.
in_user (VARCHAR(16)):
in_user VARCHAR(32):
The username of the account to check.
Returns
Expand Down
8 changes: 7 additions & 1 deletion functions/ps_is_instrument_default_enabled.sql
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ BEGIN
SET v_enabled = IF(in_instrument LIKE 'wait/io/file/%'
OR in_instrument LIKE 'wait/io/table/%'
OR in_instrument LIKE 'statement/%'
OR in_instrument IN ('wait/lock/table/sql/handler', 'idle'),
OR in_instrument LIKE 'memory/performance_schema/%'
OR in_instrument IN ('wait/lock/table/sql/handler', 'idle')
/*!50707
OR in_instrument LIKE 'stage/innodb/%'
OR in_instrument = 'stage/sql/copy to tmp table'
*/
,
'YES',
'NO'
);
Expand Down
7 changes: 6 additions & 1 deletion functions/ps_is_instrument_default_timed.sql
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ BEGIN
SET v_timed = IF(in_instrument LIKE 'wait/io/file/%'
OR in_instrument LIKE 'wait/io/table/%'
OR in_instrument LIKE 'statement/%'
OR in_instrument IN ('wait/lock/table/sql/handler', 'idle'),
OR in_instrument IN ('wait/lock/table/sql/handler', 'idle')
/*!50707
OR in_instrument LIKE 'stage/innodb/%'
OR in_instrument = 'stage/sql/copy to tmp table'
*/
,
'YES',
'NO'
);
Expand Down
Loading

0 comments on commit 5f17b5c

Please sign in to comment.