1 line
No EOL
243 KiB
Text
1 line
No EOL
243 KiB
Text
"extract_schema_from_file_name","def","sys","extract_schema_from_file_name","FUNCTION","varchar","64","256","NULL","NULL","NULL","utf8mb4","utf8mb4_0900_ai_ci","varchar(64)","SQL","BEGIN\n RETURN LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(REPLACE(path, '\\', '/'), '/', -2), '/', 1), 64);\nEND","NULL","SQL","SQL","YES","NO SQL","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nTakes a raw file path, and attempts to extract the schema name from it.\n\nUseful for when interacting with Performance Schema data \nconcerning IO statistics, for example.\n\nCurrently relies on the fact that a table data file will be within a \nspecified database directory (will not work with partitions or tables\nthat specify an individual DATA_DIRECTORY).\n\nParameters\n-----------\n\npath (VARCHAR(512)):\n The full file path to a data file to extract the schema name from.\n\nReturns\n-----------\n\nVARCHAR(64)\n\nExample\n-----------\n\nmysql> SELECT sys.extract_schema_from_file_name('/var/lib/mysql/employees/employee.ibd');\n+----------------------------------------------------------------------------+\n| sys.extract_schema_from_file_name('/var/lib/mysql/employees/employee.ibd') |\n+----------------------------------------------------------------------------+\n| employees |\n+----------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""extract_table_from_file_name","def","sys","extract_table_from_file_name","FUNCTION","varchar","64","256","NULL","NULL","NULL","utf8mb4","utf8mb4_0900_ai_ci","varchar(64)","SQL","BEGIN\n RETURN LEFT(SUBSTRING_INDEX(REPLACE(SUBSTRING_INDEX(REPLACE(path, '\\', '/'), '/', -1), '@0024', '$'), '.', 1), 64);\nEND","NULL","SQL","SQL","YES","NO SQL","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nTakes a raw file path, and extracts the table name from it.\n\nUseful for when interacting with Performance Schema data \nconcerning IO statistics, for example.\n\nParameters\n-----------\n\npath (VARCHAR(512)):\n The full file path to a data file to extract the table name from.\n\nReturns\n-----------\n\nVARCHAR(64)\n\nExample\n-----------\n\nmysql> SELECT sys.extract_table_from_file_name('/var/lib/mysql/employees/employee.ibd');\n+---------------------------------------------------------------------------+\n| sys.extract_table_from_file_name('/var/lib/mysql/employees/employee.ibd') |\n+---------------------------------------------------------------------------+\n| employee |\n+---------------------------------------------------------------------------+\n1 row in set (0.02 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""format_bytes","def","sys","format_bytes","FUNCTION","text","65535","65535","NULL","NULL","NULL","utf8mb4","utf8mb4_0900_ai_ci","text","SQL","BEGIN\n IF (bytes IS NULL) THEN\n RETURN NULL;\n ELSE\n RETURN format_bytes(bytes);\n END IF;\nEND","NULL","SQL","SQL","YES","NO SQL","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nTakes a raw bytes value, and converts it to a human readable format.\n\nParameters\n-----------\n\nbytes (TEXT):\n A raw bytes value.\n\nReturns\n-----------\n\nTEXT\n\nExample\n-----------\n\nmysql> SELECT sys.format_bytes(2348723492723746) AS size;\n+----------+\n| size |\n+----------+\n| 2.09 PiB |\n+----------+\n1 row in set (0.00 sec)\n\nmysql> SELECT sys.format_bytes(2348723492723) AS size;\n+----------+\n| size |\n+----------+\n| 2.14 TiB |\n+----------+\n1 row in set (0.00 sec)\n\nmysql> SELECT sys.format_bytes(23487234) AS size;\n+-----------+\n| size |\n+-----------+\n| 22.40 MiB |\n+-----------+\n1 row in set (0.00 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""format_path","def","sys","format_path","FUNCTION","varchar","512","2048","NULL","NULL","NULL","utf8mb4","utf8mb4_0900_ai_ci","varchar(512)","SQL","BEGIN\n DECLARE v_path VARCHAR(512);\n DECLARE v_undo_dir VARCHAR(1024);\n DECLARE path_separator CHAR(1) DEFAULT '/';\n IF @@global.version_compile_os LIKE 'win%' THEN\n SET path_separator = '\\';\n END IF;\n -- OSX hides /private/ in variables, but Performance Schema does not\n IF in_path LIKE '/private/%' THEN\n SET v_path = REPLACE(in_path, '/private', '');\n ELSE\n SET v_path = in_path;\n END IF;\n -- @@global.innodb_undo_directory is only set when separate undo logs are used\n SET v_undo_dir = IFNULL((SELECT VARIABLE_VALUE FROM performance_schema.global_variables WHERE VARIABLE_NAME = 'innodb_undo_directory'), '');\n IF v_path IS NULL THEN\n RETURN NULL;\n ELSEIF v_path LIKE CONCAT(@@global.datadir, IF(SUBSTRING(@@global.datadir, -1) = path_separator, '%', CONCAT(path_separator, '%'))) ESCAPE '|' THEN\n SET v_path = REPLACE(v_path, @@global.datadir, CONCAT('@@datadir', IF(SUBSTRING(@@global.datadir, -1) = path_separator, path_separator, '')));\n ELSEIF v_path LIKE CONCAT(@@global.tmpdir, IF(SUBSTRING(@@global.tmpdir, -1) = path_separator, '%', CONCAT(path_separator, '%'))) ESCAPE '|' THEN\n SET v_path = REPLACE(v_path, @@global.tmpdir, CONCAT('@@tmpdir', IF(SUBSTRING(@@global.tmpdir, -1) = path_separator, path_separator, '')));\n ELSEIF v_path LIKE CONCAT(@@global.replica_load_tmpdir, IF(SUBSTRING(@@global.replica_load_tmpdir, -1) = path_separator, '%', CONCAT(path_separator, '%'))) ESCAPE '|' THEN\n SET v_path = REPLACE(v_path, @@global.replica_load_tmpdir, CONCAT('@@replica_load_tmpdir', IF(SUBSTRING(@@global.replica_load_tmpdir, -1) = path_separator, path_separator, '')));\n ELSEIF v_path LIKE CONCAT(@@global.innodb_data_home_dir, IF(SUBSTRING(@@global.innodb_data_home_dir, -1) = path_separator, '%', CONCAT(path_separator, '%'))) ESCAPE '|' THEN\n SET v_path = REPLACE(v_path, @@global.innodb_data_home_dir, CONCAT('@@innodb_data_home_dir', IF(SUBSTRING(@@global.innodb_data_home_dir, -1) = path_separator, path_separator, '')));\n ELSEIF v_path LIKE CONCAT(@@global.innodb_log_group_home_dir, IF(SUBSTRING(@@global.innodb_log_group_home_dir, -1) = path_separator, '%', CONCAT(path_separator, '%'))) ESCAPE '|' THEN\n SET v_path = REPLACE(v_path, @@global.innodb_log_group_home_dir, CONCAT('@@innodb_log_group_home_dir', IF(SUBSTRING(@@global.innodb_log_group_home_dir, -1) = path_separator, path_separator, '')));\n ELSEIF v_path LIKE CONCAT(v_undo_dir, IF(SUBSTRING(v_undo_dir, -1) = path_separator, '%', CONCAT(path_separator, '%'))) ESCAPE '|' THEN\n SET v_path = REPLACE(v_path, v_undo_dir, CONCAT('@@innodb_undo_directory', IF(SUBSTRING(v_undo_dir, -1) = path_separator, path_separator, '')));\n ELSEIF v_path LIKE CONCAT(@@global.basedir, IF(SUBSTRING(@@global.basedir, -1) = path_separator, '%', CONCAT(path_separator, '%'))) ESCAPE '|' THEN\n SET v_path = REPLACE(v_path, @@global.basedir, CONCAT('@@basedir', IF(SUBSTRING(@@global.basedir, -1) = path_separator, path_separator, '')));\n END IF;\n RETURN v_path;\nEND","NULL","SQL","SQL","YES","NO SQL","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nTakes a raw path value, and strips out the datadir or tmpdir\nreplacing with @@datadir and @@tmpdir respectively.\n\nAlso normalizes the paths across operating systems, so backslashes\non Windows are converted to forward slashes\n\nParameters\n-----------\n\npath (VARCHAR(512)):\n The raw file path value to format.\n\nReturns\n-----------\n\nVARCHAR(512) CHARSET UTF8MB4\n\nExample\n-----------\n\nmysql> select @@datadir;\n+-----------------------------------------------+\n| @@datadir |\n+-----------------------------------------------+\n| /Users/mark/sandboxes/SmallTree/AMaster/data/ |\n+-----------------------------------------------+\n1 row in set (0.06 sec)\n\nmysql> select format_path('/Users/mark/sandboxes/SmallTree/AMaster/data/mysql/proc.MYD') AS path;\n+--------------------------+\n| path |\n+--------------------------+\n| @@datadir/mysql/proc.MYD |\n+--------------------------+\n1 row in set (0.03 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""format_statement","def","sys","format_statement","FUNCTION","longtext","4294967295","4294967295","NULL","NULL","NULL","utf8mb4","utf8mb4_0900_ai_ci","longtext","SQL","BEGIN\n -- Check if we have the configured length, if not, init it\n IF @sys.statement_truncate_len IS NULL THEN\n SET @sys.statement_truncate_len = sys_get_config('statement_truncate_len', 64);\n END IF;\n IF CHAR_LENGTH(statement) > @sys.statement_truncate_len THEN\n RETURN REPLACE(CONCAT(LEFT(statement, (@sys.statement_truncate_len/2)-2), ' ... ', RIGHT(statement, (@sys.statement_truncate_len/2)-2)), '\n', ' ');\n ELSE \n RETURN REPLACE(statement, '\n', ' ');\n END IF;\nEND","NULL","SQL","SQL","YES","NO SQL","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nFormats a normalized statement, truncating it if it is > 64 characters long by default.\n\nTo configure the length to truncate the statement to by default, update the `statement_truncate_len`\nvariable with `sys_config` table to a different value. Alternatively, to change it just for just \nyour particular session, use `SET @sys.statement_truncate_len := <some new value>`.\n\nUseful for printing statement related data from Performance Schema from \nthe command line.\n\nParameters\n-----------\n\nstatement (LONGTEXT): \n The statement to format.\n\nReturns\n-----------\n\nLONGTEXT\n\nExample\n-----------\n\nmysql> SELECT sys.format_statement(digest_text)\n -> FROM performance_schema.events_statements_summary_by_digest\n -> ORDER by sum_timer_wait DESC limit 5;\n+-------------------------------------------------------------------+\n| sys.format_statement(digest_text) |\n+-------------------------------------------------------------------+\n| CREATE SQL SECURITY INVOKER VI ... KE ? AND `variable_value` > ? |\n| CREATE SQL SECURITY INVOKER VI ... ait` IS NOT NULL , `esc` . ... |\n| CREATE SQL SECURITY INVOKER VI ... ait` IS NOT NULL , `sys` . ... |\n| CREATE SQL SECURITY INVOKER VI ... , `compressed_size` ) ) DESC |\n| CREATE SQL SECURITY INVOKER VI ... LIKE ? ORDER BY `timer_start` |\n+-------------------------------------------------------------------+\n5 rows in set (0.00 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""format_time","def","sys","format_time","FUNCTION","text","65535","65535","NULL","NULL","NULL","utf8mb4","utf8mb4_0900_ai_ci","text","SQL","BEGIN\n IF picoseconds IS NULL THEN RETURN NULL;\n ELSEIF picoseconds >= 604800000000000000 THEN RETURN CONCAT(ROUND(picoseconds / 604800000000000000, 2), ' w');\n ELSEIF picoseconds >= 86400000000000000 THEN RETURN CONCAT(ROUND(picoseconds / 86400000000000000, 2), ' d');\n ELSEIF picoseconds >= 3600000000000000 THEN RETURN CONCAT(ROUND(picoseconds / 3600000000000000, 2), ' h');\n ELSEIF picoseconds >= 60000000000000 THEN RETURN CONCAT(ROUND(picoseconds / 60000000000000, 2), ' m');\n ELSEIF picoseconds >= 1000000000000 THEN RETURN CONCAT(ROUND(picoseconds / 1000000000000, 2), ' s');\n ELSEIF picoseconds >= 1000000000 THEN RETURN CONCAT(ROUND(picoseconds / 1000000000, 2), ' ms');\n ELSEIF picoseconds >= 1000000 THEN RETURN CONCAT(ROUND(picoseconds / 1000000, 2), ' us');\n ELSEIF picoseconds >= 1000 THEN RETURN CONCAT(ROUND(picoseconds / 1000, 2), ' ns');\n ELSE RETURN CONCAT(picoseconds, ' ps');\n END IF;\nEND","NULL","SQL","SQL","YES","NO SQL","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nTakes a raw picoseconds value, and converts it to a human readable form.\n\nPicoseconds are the precision that all latency values are printed in\nwithin Performance Schema, however are not user friendly when wanting\nto scan output from the command line.\n\nParameters\n-----------\n\npicoseconds (TEXT):\n The raw picoseconds value to convert.\n\nReturns\n-----------\n\nTEXT CHARSET UTF8MB4\n\nExample\n-----------\n\nmysql> select format_time(342342342342345);\n+------------------------------+\n| format_time(342342342342345) |\n+------------------------------+\n| 00:05:42 |\n+------------------------------+\n1 row in set (0.00 sec)\n\nmysql> select format_time(342342342);\n+------------------------+\n| format_time(342342342) |\n+------------------------+\n| 342.34 us |\n+------------------------+\n1 row in set (0.00 sec)\n\nmysql> select format_time(34234);\n+--------------------+\n| format_time(34234) |\n+--------------------+\n| 34.23 ns |\n+--------------------+\n1 row in set (0.00 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""list_add","def","sys","list_add","FUNCTION","text","65535","65535","NULL","NULL","NULL","utf8mb4","utf8mb4_0900_ai_ci","text","SQL","BEGIN\n IF (in_add_value IS NULL) THEN\n SIGNAL SQLSTATE '02200'\n SET MESSAGE_TEXT = 'Function sys.list_add: in_add_value input variable should not be NULL',\n MYSQL_ERRNO = 1138;\n END IF;\n IF (in_list IS NULL OR LENGTH(in_list) = 0) THEN\n -- return the new value as a single value list\n RETURN in_add_value;\n END IF;\n RETURN (SELECT CONCAT(TRIM(BOTH ',' FROM TRIM(in_list)), ',', in_add_value));\nEND","NULL","SQL","SQL","YES","CONTAINS SQL","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nTakes a list, and a value to add to the list, and returns the resulting list.\n\nUseful for altering certain session variables, like sql_mode or optimizer_switch for instance.\n\nParameters\n-----------\n\nin_list (TEXT):\n The comma separated list to add a value to\n\nin_add_value (TEXT):\n The value to add to the input list\n\nReturns\n-----------\n\nTEXT\n\nExample\n--------\n\nmysql> select @@sql_mode;\n+-----------------------------------------------------------------------------------+\n| @@sql_mode |\n+-----------------------------------------------------------------------------------+\n| ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |\n+-----------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> set sql_mode = sys.list_add(@@sql_mode, 'ANSI_QUOTES');\nQuery OK, 0 rows affected (0.06 sec)\n\nmysql> select @@sql_mode;\n+-----------------------------------------------------------------------------------------------+\n| @@sql_mode |\n+-----------------------------------------------------------------------------------------------+\n| ANSI_QUOTES,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |\n+-----------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""list_drop","def","sys","list_drop","FUNCTION","text","65535","65535","NULL","NULL","NULL","utf8mb4","utf8mb4_0900_ai_ci","text","SQL","BEGIN\n IF (in_drop_value IS NULL) THEN\n SIGNAL SQLSTATE '02200'\n SET MESSAGE_TEXT = 'Function sys.list_drop: in_drop_value input variable should not be NULL',\n MYSQL_ERRNO = 1138;\n END IF;\n IF (in_list IS NULL OR LENGTH(in_list) = 0) THEN\n -- return the list as it was passed in\n RETURN in_list;\n END IF;\n -- ensure that leading / trailing commas are remove, support values with either spaces or not between commas\n RETURN (SELECT TRIM(BOTH ',' FROM REPLACE(REPLACE(CONCAT(',', in_list), CONCAT(',', in_drop_value), ''), CONCAT(', ', in_drop_value), '')));\nEND","NULL","SQL","SQL","YES","CONTAINS SQL","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nTakes a list, and a value to attempt to remove from the list, and returns the resulting list.\n\nUseful for altering certain session variables, like sql_mode or optimizer_switch for instance.\n\nParameters\n-----------\n\nin_list (TEXT):\n The comma separated list to drop a value from\n\nin_drop_value (TEXT):\n The value to drop from the input list\n\nReturns\n-----------\n\nTEXT\n\nExample\n--------\n\nmysql> select @@sql_mode;\n+-----------------------------------------------------------------------------------------------+\n| @@sql_mode |\n+-----------------------------------------------------------------------------------------------+\n| ANSI_QUOTES,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |\n+-----------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> set sql_mode = sys.list_drop(@@sql_mode, 'ONLY_FULL_GROUP_BY');\nQuery OK, 0 rows affected (0.03 sec)\n\nmysql> select @@sql_mode;\n+----------------------------------------------------------------------------+\n| @@sql_mode |\n+----------------------------------------------------------------------------+\n| ANSI_QUOTES,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |\n+----------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_is_account_enabled","def","sys","ps_is_account_enabled","FUNCTION","enum","3","12","NULL","NULL","NULL","utf8mb4","utf8mb4_0900_ai_ci","enum('YES','NO')","SQL","BEGIN\n RETURN IF(EXISTS(SELECT 1\n FROM performance_schema.setup_actors\n WHERE (`HOST` = '%' OR in_host LIKE `HOST`)\n AND (`USER` = '%' OR `USER` = in_user)\n AND (`ENABLED` = 'YES')\n ),\n 'YES', 'NO'\n );\nEND","NULL","SQL","SQL","YES","READS SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nDetermines whether instrumentation of an account is enabled \nwithin Performance Schema.\n\nParameters\n-----------\n\nin_host VARCHAR(255): \n The hostname of the account to check.\nin_user VARCHAR(32):\n The username of the account to check.\n\nReturns\n-----------\n\nENUM('YES', 'NO', 'PARTIAL')\n\nExample\n-----------\n\nmysql> SELECT sys.ps_is_account_enabled('localhost', 'root');\n+------------------------------------------------+\n| sys.ps_is_account_enabled('localhost', 'root') |\n+------------------------------------------------+\n| YES |\n+------------------------------------------------+\n1 row in set (0.01 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_is_consumer_enabled","def","sys","ps_is_consumer_enabled","FUNCTION","enum","3","12","NULL","NULL","NULL","utf8mb4","utf8mb4_0900_ai_ci","enum('YES','NO')","SQL","BEGIN\n DECLARE v_is_enabled ENUM('YES', 'NO') DEFAULT NULL;\n DECLARE v_error_msg VARCHAR(128);\n -- Return NULL for a NULL argument.\n IF (in_consumer IS NULL) THEN\n RETURN NULL;\n END IF;\n SET v_is_enabled = (\n SELECT (CASE\n WHEN c.NAME = 'global_instrumentation' THEN c.ENABLED\n WHEN c.NAME = 'thread_instrumentation' THEN IF(cg.ENABLED = 'YES' AND c.ENABLED = 'YES', 'YES', 'NO')\n WHEN c.NAME LIKE '%\\_digest' THEN IF(cg.ENABLED = 'YES' AND c.ENABLED = 'YES', 'YES', 'NO')\n WHEN c.NAME LIKE '%\\_current' THEN IF(cg.ENABLED = 'YES' AND ct.ENABLED = 'YES' AND c.ENABLED = 'YES', 'YES', 'NO')\n ELSE IF(cg.ENABLED = 'YES' AND ct.ENABLED = 'YES' AND c.ENABLED = 'YES'\n AND ( SELECT cc.ENABLED FROM performance_schema.setup_consumers cc WHERE NAME = CONCAT(SUBSTRING_INDEX(c.NAME, '_', 2), '_current')\n ) = 'YES', 'YES', 'NO')\n END) AS IsEnabled\n FROM performance_schema.setup_consumers c\n INNER JOIN performance_schema.setup_consumers cg\n INNER JOIN performance_schema.setup_consumers ct\n WHERE cg.NAME = 'global_instrumentation'\n AND ct.NAME = 'thread_instrumentation'\n AND c.NAME = in_consumer\n );\n IF (v_is_enabled IS NOT NULL) THEN\n RETURN v_is_enabled;\n ELSE\n -- A value of NULL here means it is an unknown consumer name that was passed as an argument.\n -- Only an input value of NULL is allowed to return a NULL result value, to throw a signal instead.\n SET v_error_msg = CONCAT('Invalid argument error: ', in_consumer, ' in function sys.ps_is_consumer_enabled.');\n SIGNAL SQLSTATE 'HY000'\n SET MESSAGE_TEXT = v_error_msg,\n MYSQL_ERRNO = 3047;\n END IF;\nEND","NULL","SQL","SQL","YES","READS SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nDetermines whether a consumer is enabled (taking the consumer hierarchy into consideration)\nwithin the Performance Schema.\n\nAn exception with errno 3047 is thrown if an unknown consumer name is passed to the function.\nA consumer name of NULL returns NULL.\n\nParameters\n-----------\n\nin_consumer VARCHAR(64): \n The name of the consumer to check.\n\nReturns\n-----------\n\nENUM('YES', 'NO')\n\nExample\n-----------\n\nmysql> SELECT sys.ps_is_consumer_enabled('events_stages_history');\n+-----------------------------------------------------+\n| sys.ps_is_consumer_enabled('events_stages_history') |\n+-----------------------------------------------------+\n| NO |\n+-----------------------------------------------------+\n1 row in set (0.00 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_is_instrument_default_enabled","def","sys","ps_is_instrument_default_enabled","FUNCTION","enum","3","12","NULL","NULL","NULL","utf8mb4","utf8mb4_0900_ai_ci","enum('YES','NO')","SQL","BEGIN\n DECLARE v_enabled ENUM('YES', 'NO');\n IF (in_instrument LIKE 'stage/%') THEN\n BEGIN\n /* Stages are enabled by default if the progress property is set. */\n SET v_enabled = (SELECT\n IF(find_in_set("progress", PROPERTIES) != 0, 'YES', 'NO')\n FROM performance_schema.setup_instruments\n WHERE NAME = in_instrument);\n SET v_enabled = IFNULL(v_enabled, 'NO');\n END;\n ELSE\n SET v_enabled = IF(in_instrument LIKE 'wait/synch/%'\n OR in_instrument LIKE 'wait/io/socket/%'\n ,\n 'NO',\n 'YES'\n );\n END IF;\n RETURN v_enabled;\nEND","NULL","SQL","SQL","YES","READS SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nReturns whether an instrument is enabled by default in this version of MySQL.\n\nParameters\n-----------\n\nin_instrument VARCHAR(128): \n The instrument to check.\n\nReturns\n-----------\n\nENUM('YES', 'NO')\n\nExample\n-----------\n\nmysql> SELECT sys.ps_is_instrument_default_enabled('statement/sql/select');\n+--------------------------------------------------------------+\n| sys.ps_is_instrument_default_enabled('statement/sql/select') |\n+--------------------------------------------------------------+\n| YES |\n+--------------------------------------------------------------+\n1 row in set (0.00 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_is_instrument_default_timed","def","sys","ps_is_instrument_default_timed","FUNCTION","enum","3","12","NULL","NULL","NULL","utf8mb4","utf8mb4_0900_ai_ci","enum('YES','NO')","SQL","BEGIN\n DECLARE v_timed ENUM('YES', 'NO');\n IF (in_instrument LIKE 'stage/%') THEN\n BEGIN\n -- Stages are timed by default if the progress property is set.\n SET v_timed = (SELECT\n IF(find_in_set("progress", PROPERTIES) != 0, 'YES', 'NO')\n FROM performance_schema.setup_instruments\n WHERE NAME = in_instrument);\n SET v_timed = IFNULL(v_timed, 'NO');\n END;\n ELSE\n -- Mutex, rwlock, prlock, sxlock, cond are not timed by default\n -- Memory instruments are never timed.\n SET v_timed = IF(in_instrument LIKE 'wait/synch/%'\n OR in_instrument LIKE 'memory/%'\n ,\n 'NO',\n 'YES'\n );\n END IF;\n RETURN v_timed;\nEND","NULL","SQL","SQL","YES","READS SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nReturns whether an instrument is timed by default in this version of MySQL.\n\nParameters\n-----------\n\nin_instrument VARCHAR(128): \n The instrument to check.\n\nReturns\n-----------\n\nENUM('YES', 'NO')\n\nExample\n-----------\n\nmysql> SELECT sys.ps_is_instrument_default_timed('statement/sql/select');\n+------------------------------------------------------------+\n| sys.ps_is_instrument_default_timed('statement/sql/select') |\n+------------------------------------------------------------+\n| YES |\n+------------------------------------------------------------+\n1 row in set (0.00 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_is_thread_instrumented","def","sys","ps_is_thread_instrumented","FUNCTION","enum","7","28","NULL","NULL","NULL","utf8mb4","utf8mb4_0900_ai_ci","enum('YES','NO','UNKNOWN')","SQL","BEGIN\n DECLARE v_enabled ENUM('YES', 'NO', 'UNKNOWN');\n IF (in_connection_id IS NULL) THEN\n RETURN NULL;\n END IF;\n SELECT INSTRUMENTED INTO v_enabled\n FROM performance_schema.threads \n WHERE PROCESSLIST_ID = in_connection_id;\n IF (v_enabled IS NULL) THEN\n RETURN 'UNKNOWN';\n ELSE\n RETURN v_enabled;\n END IF;\nEND","NULL","SQL","SQL","NO","READS SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nChecks whether the provided connection id is instrumented within Performance Schema.\n\nParameters\n-----------\n\nin_connection_id (BIGINT UNSIGNED):\n The id of the connection to check.\n\nReturns\n-----------\n\nENUM('YES', 'NO', 'UNKNOWN')\n\nExample\n-----------\n\nmysql> SELECT sys.ps_is_thread_instrumented(CONNECTION_ID());\n+------------------------------------------------+\n| sys.ps_is_thread_instrumented(CONNECTION_ID()) |\n+------------------------------------------------+\n| YES |\n+------------------------------------------------+\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_thread_id","def","sys","ps_thread_id","FUNCTION","bigint","NULL","NULL","20","0","NULL","NULL","NULL","bigint unsigned","SQL","BEGIN\n IF (in_connection_id IS NULL) THEN\n RETURN ps_current_thread_id();\n ELSE\n RETURN ps_thread_id(in_connection_id);\n END IF;\nEND","NULL","SQL","SQL","NO","READS SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nReturn the Performance Schema THREAD_ID for the specified connection ID.\n\nParameters\n-----------\n\nin_connection_id (BIGINT UNSIGNED):\n The id of the connection to return the thread id for. If NULL, the current\n connection thread id is returned.\n\nExample\n-----------\n\nmysql> SELECT sys.ps_thread_id(79);\n+----------------------+\n| sys.ps_thread_id(79) |\n+----------------------+\n| 98 |\n+----------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT sys.ps_thread_id(CONNECTION_ID());\n+-----------------------------------+\n| sys.ps_thread_id(CONNECTION_ID()) |\n+-----------------------------------+\n| 98 |\n+-----------------------------------+\n1 row in set (0.00 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_thread_account","def","sys","ps_thread_account","FUNCTION","text","65535","65535","NULL","NULL","NULL","utf8mb4","utf8mb4_0900_ai_ci","text","SQL","BEGIN\n RETURN (SELECT IF(\n type = 'FOREGROUND',\n CONCAT(processlist_user, '@', processlist_host),\n type\n ) AS account\n FROM `performance_schema`.`threads`\n WHERE thread_id = in_thread_id);\nEND","NULL","SQL","SQL","NO","READS SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nReturn the user@host account for the given Performance Schema thread id.\n\nParameters\n-----------\n\nin_thread_id (BIGINT UNSIGNED):\n The id of the thread to return the account for.\n\nExample\n-----------\n\nmysql> select thread_id, processlist_user, processlist_host from performance_schema.threads where type = 'foreground';\n+-----------+------------------+------------------+\n| thread_id | processlist_user | processlist_host |\n+-----------+------------------+------------------+\n| 23 | NULL | NULL |\n| 30 | root | localhost |\n| 31 | msandbox | localhost |\n| 32 | msandbox | localhost |\n+-----------+------------------+------------------+\n4 rows in set (0.00 sec)\n\nmysql> select sys.ps_thread_account(31);\n+---------------------------+\n| sys.ps_thread_account(31) |\n+---------------------------+\n| msandbox@localhost |\n+---------------------------+\n1 row in set (0.00 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_thread_stack","def","sys","ps_thread_stack","FUNCTION","longtext","4294967295","4294967295","NULL","NULL","NULL","latin1","latin1_swedish_ci","longtext","SQL","BEGIN\n DECLARE json_objects LONGTEXT;\n -- Do not track the current thread, it will kill the stack\n UPDATE performance_schema.threads\n SET instrumented = 'NO'\n WHERE processlist_id = CONNECTION_ID();\n SET SESSION group_concat_max_len=@@global.max_allowed_packet;\n -- Select the entire stack of events\n SELECT GROUP_CONCAT(CONCAT( '{'\n , CONCAT_WS( ', '\n , CONCAT('"nesting_event_id": "', IF(nesting_event_id IS NULL, '0', nesting_event_id), '"')\n , CONCAT('"event_id": "', event_id, '"')\n -- Convert from picoseconds to microseconds\n , CONCAT( '"timer_wait": ', ROUND(timer_wait/1000000, 2)) \n , CONCAT( '"event_info": "'\n , CASE\n WHEN event_name NOT LIKE 'wait/io%' THEN REPLACE(SUBSTRING_INDEX(event_name, '/', -2), '\\', '\\\\')\n WHEN event_name NOT LIKE 'wait/io/file%' OR event_name NOT LIKE 'wait/io/socket%' THEN REPLACE(SUBSTRING_INDEX(event_name, '/', -4), '\\', '\\\\')\n ELSE event_name\n END\n , '"'\n )\n -- Always dump the extra wait information gathered for statements\n , CONCAT( '"wait_info": "', IFNULL(wait_info, ''), '"')\n -- If debug is enabled, add the file:lineno information for waits\n , CONCAT( '"source": "', IF(true AND event_name LIKE 'wait%', IFNULL(wait_info, ''), ''), '"')\n -- Depending on the type of event, name it appropriately\n , CASE \n WHEN event_name LIKE 'wait/io/file%' THEN '"event_type": "io/file"'\n WHEN event_name LIKE 'wait/io/table%' THEN '"event_type": "io/table"'\n WHEN event_name LIKE 'wait/io/socket%' THEN '"event_type": "io/socket"'\n WHEN event_name LIKE 'wait/synch/mutex%' THEN '"event_type": "synch/mutex"'\n WHEN event_name LIKE 'wait/synch/cond%' THEN '"event_type": "synch/cond"'\n WHEN event_name LIKE 'wait/synch/rwlock%' THEN '"event_type": "synch/rwlock"'\n WHEN event_name LIKE 'wait/lock%' THEN '"event_type": "lock"'\n WHEN event_name LIKE 'statement/%' THEN '"event_type": "stmt"'\n WHEN event_name LIKE 'stage/%' THEN '"event_type": "stage"'\n WHEN event_name LIKE '%idle%' THEN '"event_type": "idle"'\n ELSE '' \n END \n )\n , '}'\n )\n ORDER BY event_id ASC SEPARATOR ',') event\n INTO json_objects\n FROM (\n -- Select all statements, with the extra tracing information available\n (SELECT thread_id, event_id, event_name, timer_wait, timer_start, nesting_event_id, \n CONCAT(sql_text, '\\n',\n 'errors: ', errors, '\\n',\n 'warnings: ', warnings, '\\n',\n 'lock time: ', ROUND(lock_time/1000000, 2),'us\\n',\n 'rows affected: ', rows_affected, '\\n',\n 'rows sent: ', rows_sent, '\\n',\n 'rows examined: ', rows_examined, '\\n',\n 'tmp tables: ', created_tmp_tables, '\\n',\n 'tmp disk tables: ', created_tmp_disk_tables, '\\n',\n 'select scan: ', select_scan, '\\n',\n 'select full join: ', select_full_join, '\\n',\n 'select full range join: ', select_full_range_join, '\\n',\n 'select range: ', select_range, '\\n',\n 'select range check: ', select_range_check, '\\n', \n 'sort merge passes: ', sort_merge_passes, '\\n',\n 'sort rows: ', sort_rows, '\\n',\n 'sort range: ', sort_range, '\\n',\n 'sort scan: ', sort_scan, '\\n',\n 'no index used: ', IF(no_index_used, 'TRUE', 'FALSE'), '\\n',\n 'no good index used: ', IF(no_good_index_used, 'TRUE', 'FALSE'), '\\n'\n ) AS wait_info\n FROM performance_schema.events_statements_history_long WHERE thread_id = thd_id)\n UNION \n -- Select all stages\n (SELECT thread_id, event_id, event_name, timer_wait, timer_start, nesting_event_id, null AS wait_info\n FROM performance_schema.events_stages_history_long WHERE thread_id = thd_id) \n UNION\n -- Select all events, adding information appropriate to the event\n (SELECT thread_id, event_id, \n CONCAT(event_name , \n IF(event_name NOT LIKE 'wait/synch/mutex%', IFNULL(CONCAT(' - ', operation), ''), ''), \n IF(number_of_bytes IS NOT NULL, CONCAT(' ', number_of_bytes, ' bytes'), ''),\n IF(event_name LIKE 'wait/io/file%', '\\n', ''),\n IF(object_schema IS NOT NULL, CONCAT('\\nObject: ', object_schema, '.'), ''), \n IF(object_name IS NOT NULL, \n IF (event_name LIKE 'wait/io/socket%',\n -- Print the socket if used, else the IP:port as reported\n CONCAT(IF (object_name LIKE ':0%', @@socket, object_name)),\n object_name),\n ''),\n IF(index_name IS NOT NULL, CONCAT(' Index: ', index_name), ''),'\\n'\n ) AS event_name,\n timer_wait, timer_start, nesting_event_id, source AS wait_info\n FROM performance_schema.events_waits_history_long WHERE thread_id = thd_id)) events \n ORDER BY event_id;\n RETURN CONCAT('{', \n CONCAT_WS(',', \n '"rankdir": "LR"',\n '"nodesep": "0.10"',\n CONCAT('"stack_created": "', NOW(), '"'),\n CONCAT('"mysql_version": "', VERSION(), '"'),\n CONCAT('"mysql_user": "', CURRENT_USER(), '"'),\n CONCAT('"events": [', IFNULL(json_objects,''), ']')\n ),\n '}');\nEND","NULL","SQL","SQL","NO","READS SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nOutputs a JSON formatted stack of all statements, stages and events\nwithin Performance Schema for the specified thread.\n\nParameters\n-----------\n\nthd_id (BIGINT UNSIGNED):\n The id of the thread to trace. This should match the thread_id\n column from the performance_schema.threads table.\nin_verbose (BOOLEAN):\n Include file:lineno information in the events.\n\nExample\n-----------\n\n(line separation added for output)\n\nmysql> SELECT sys.ps_thread_stack(37, FALSE) AS thread_stack\\G\n*************************** 1. row ***************************\nthread_stack: {"rankdir": "LR","nodesep": "0.10","stack_created": "2014-02-19 13:39:03",\n"mysql_version": "5.7.3-m13","mysql_user": "root@localhost","events": \n[{"nesting_event_id": "0", "event_id": "10", "timer_wait": 256.35, "event_info": \n"sql/select", "wait_info": "select @@version_comment limit 1\\nerrors: 0\\nwarnings: 0\\nlock time:\n...\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_thread_trx_info","def","sys","ps_thread_trx_info","FUNCTION","longtext","4294967295","4294967295","NULL","NULL","NULL","utf8mb4","utf8mb4_0900_ai_ci","longtext","SQL","BEGIN\n DECLARE v_output LONGTEXT DEFAULT '{}';\n DECLARE v_msg_text TEXT DEFAULT '';\n DECLARE v_signal_msg TEXT DEFAULT '';\n DECLARE v_mysql_errno INT;\n DECLARE v_max_output_len BIGINT;\n -- Capture warnings/errors such as group_concat truncation\n -- and report as JSON error objects\n DECLARE EXIT HANDLER FOR SQLWARNING, SQLEXCEPTION\n BEGIN\n GET DIAGNOSTICS CONDITION 1\n v_msg_text = MESSAGE_TEXT,\n v_mysql_errno = MYSQL_ERRNO;\n IF v_mysql_errno = 1260 THEN\n SET v_signal_msg = CONCAT('{ "error": "Trx info truncated: ', v_msg_text, '" }');\n ELSE\n SET v_signal_msg = CONCAT('{ "error": "', v_msg_text, '" }');\n END IF;\n RETURN v_signal_msg;\n END;\n -- Set configuration options\n IF (@sys.ps_thread_trx_info.max_length IS NULL) THEN\n SET @sys.ps_thread_trx_info.max_length = sys.sys_get_config('ps_thread_trx_info.max_length', 65535);\n END IF;\n IF (@sys.ps_thread_trx_info.max_length != @@session.group_concat_max_len) THEN\n SET @old_group_concat_max_len = @@session.group_concat_max_len;\n -- Convert to int value for the SET, and give some surrounding space\n SET v_max_output_len = (@sys.ps_thread_trx_info.max_length - 5);\n SET SESSION group_concat_max_len = v_max_output_len;\n END IF;\n SET v_output = (\n SELECT CONCAT('[', IFNULL(GROUP_CONCAT(trx_info ORDER BY event_id), ''), '\n]') AS trx_info\n FROM (SELECT trxi.thread_id, \n trxi.event_id,\n GROUP_CONCAT(\n IFNULL(\n CONCAT('\n {\n',\n ' "time": "', IFNULL(format_pico_time(trxi.timer_wait), ''), '",\n',\n ' "state": "', IFNULL(trxi.state, ''), '",\n',\n ' "mode": "', IFNULL(trxi.access_mode, ''), '",\n',\n ' "autocommitted": "', IFNULL(trxi.autocommit, ''), '",\n',\n ' "gtid": "', IFNULL(trxi.gtid, ''), '",\n',\n ' "isolation": "', IFNULL(trxi.isolation_level, ''), '",\n',\n ' "statements_executed": [', IFNULL(s.stmts, ''), IF(s.stmts IS NULL, ' ]\n', '\n ]\n'),\n ' }'\n ), \n '') \n ORDER BY event_id) AS trx_info\n FROM (\n (SELECT thread_id, event_id, timer_wait, state,access_mode, autocommit, gtid, isolation_level\n FROM performance_schema.events_transactions_current\n WHERE thread_id = in_thread_id\n AND end_event_id IS NULL)\n UNION\n (SELECT thread_id, event_id, timer_wait, state,access_mode, autocommit, gtid, isolation_level\n FROM performance_schema.events_transactions_history\n WHERE thread_id = in_thread_id)\n ) AS trxi\n LEFT JOIN (SELECT thread_id,\n nesting_event_id,\n GROUP_CONCAT(\n IFNULL(\n CONCAT('\n {\n',\n ' "sql_text": "', IFNULL(sys.format_statement(REPLACE(sql_text, '\\', '\\\\')), ''), '",\n',\n ' "time": "', IFNULL(format_pico_time(timer_wait), ''), '",\n',\n ' "schema": "', IFNULL(current_schema, ''), '",\n',\n ' "rows_examined": ', IFNULL(rows_examined, ''), ',\n',\n ' "rows_affected": ', IFNULL(rows_affected, ''), ',\n',\n ' "rows_sent": ', IFNULL(rows_sent, ''), ',\n',\n ' "tmp_tables": ', IFNULL(created_tmp_tables, ''), ',\n',\n ' "tmp_disk_tables": ', IFNULL(created_tmp_disk_tables, ''), ',\n',\n ' "sort_rows": ', IFNULL(sort_rows, ''), ',\n',\n ' "sort_merge_passes": ', IFNULL(sort_merge_passes, ''), '\n',\n ' }'), '') ORDER BY event_id) AS stmts\n FROM performance_schema.events_statements_history\n WHERE sql_text IS NOT NULL\n AND thread_id = in_thread_id\n GROUP BY thread_id, nesting_event_id\n ) AS s \n ON trxi.thread_id = s.thread_id \n AND trxi.event_id = s.nesting_event_id\n WHERE trxi.thread_id = in_thread_id\n GROUP BY trxi.thread_id, trxi.event_id\n ) trxs\n GROUP BY thread_id\n );\n IF (@old_group_concat_max_len IS NOT NULL) THEN\n SET SESSION group_concat_max_len = @old_group_concat_max_len;\n END IF;\n RETURN v_output;\nEND","NULL","SQL","SQL","NO","READS SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nReturns a JSON object with info on the given threads current transaction, \nand the statements it has already executed, derived from the\nperformance_schema.events_transactions_current and\nperformance_schema.events_statements_history tables (so the consumers \nfor these also have to be enabled within Performance Schema to get full\ndata in the object).\n\nWhen the output exceeds the default truncation length (65535), a JSON error\nobject is returned, such as:\n\n{ "error": "Trx info truncated: Row 6 was cut by GROUP_CONCAT()" }\n\nSimilar error objects are returned for other warnings/and exceptions raised\nwhen calling the function.\n\nThe max length of the output of this function can be controlled with the\nps_thread_trx_info.max_length variable set via sys_config, or the\n@sys.ps_thread_trx_info.max_length user variable, as appropriate.\n\nParameters\n-----------\n\nin_thread_id (BIGINT UNSIGNED):\n The id of the thread to return the transaction info for.\n\nExample\n-----------\n\nSELECT sys.ps_thread_trx_info(48)\\G\n*************************** 1. row ***************************\nsys.ps_thread_trx_info(48): [\n {\n "time": "790.70 us",\n "state": "COMMITTED",\n "mode": "READ WRITE",\n "autocommitted": "NO",\n "gtid": "AUTOMATIC",\n "isolation": "REPEATABLE READ",\n "statements_executed": [\n {\n "sql_text": "INSERT INTO info VALUES (1, 'foo')",\n "time": "471.02 us",\n "schema": "trx",\n "rows_examined": 0,\n "rows_affected": 1,\n "rows_sent": 0,\n "tmp_tables": 0,\n "tmp_disk_tables": 0,\n "sort_rows": 0,\n "sort_merge_passes": 0\n },\n {\n "sql_text": "COMMIT",\n "time": "254.42 us",\n "schema": "trx",\n "rows_examined": 0,\n "rows_affected": 0,\n "rows_sent": 0,\n "tmp_tables": 0,\n "tmp_disk_tables": 0,\n "sort_rows": 0,\n "sort_merge_passes": 0\n }\n ]\n },\n {\n "time": "426.20 us",\n "state": "COMMITTED",\n "mode": "READ WRITE",\n "autocommitted": "NO",\n "gtid": "AUTOMATIC",\n "isolation": "REPEATABLE READ",\n "statements_executed": [\n {\n "sql_text": "INSERT INTO info VALUES (2, 'bar')",\n "time": "107.33 us",\n "schema": "trx",\n "rows_examined": 0,\n "rows_affected": 1,\n "rows_sent": 0,\n "tmp_tables": 0,\n "tmp_disk_tables": 0,\n "sort_rows": 0,\n "sort_merge_passes": 0\n },\n {\n "sql_text": "COMMIT",\n "time": "213.23 us",\n "schema": "trx",\n "rows_examined": 0,\n "rows_affected": 0,\n "rows_sent": 0,\n "tmp_tables": 0,\n "tmp_disk_tables": 0,\n "sort_rows": 0,\n "sort_merge_passes": 0\n }\n ]\n }\n]\n1 row in set (0.03 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""quote_identifier","def","sys","quote_identifier","FUNCTION","text","65535","65535","NULL","NULL","NULL","utf8mb4","utf8mb4_0900_ai_ci","text","SQL","BEGIN\n RETURN CONCAT('`', REPLACE(in_identifier, '`', '``'), '`');\nEND","NULL","SQL","SQL","YES","NO SQL","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nTakes an unquoted identifier (schema name, table name, etc.) and\nreturns the identifier quoted with backticks.\n\nParameters\n-----------\n\nin_identifier (TEXT):\n The identifier to quote.\n\nReturns\n-----------\n\nTEXT CHARSET UTF8MB4\n\nExample\n-----------\n\nmysql> SELECT sys.quote_identifier('my_identifier') AS Identifier;\n+-----------------+\n| Identifier |\n+-----------------+\n| `my_identifier` |\n+-----------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT sys.quote_identifier('my`idenfier') AS Identifier;\n+----------------+\n| Identifier |\n+----------------+\n| `my``idenfier` |\n+----------------+\n1 row in set (0.00 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""sys_get_config","def","sys","sys_get_config","FUNCTION","varchar","128","512","NULL","NULL","NULL","utf8mb4","utf8mb4_0900_ai_ci","varchar(128)","SQL","BEGIN\n DECLARE v_value VARCHAR(128) DEFAULT NULL;\n -- Check if we have the variable in the sys.sys_config table\n SET v_value = (SELECT value FROM sys.sys_config WHERE variable = in_variable_name);\n -- Protection against the variable not existing in sys_config\n IF (v_value IS NULL) THEN\n SET v_value = in_default_value;\n END IF;\n RETURN v_value;\nEND","NULL","SQL","SQL","YES","READS SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nReturns the value for the requested variable using the following logic:\n\n 1. If the option exists in sys.sys_config return the value from there.\n 2. Else fall back on the provided default value.\n\nNotes for using sys_get_config():\n\n * If the default value argument to sys_get_config() is NULL and case 2. is reached, NULL is returned.\n It is then expected that the caller is able to handle NULL for the given configuration option.\n * The convention is to name the user variables @sys.<name of variable>. It is <name of variable> that\n is stored in the sys_config table and is what is expected as the argument to sys_get_config().\n * If you want to check whether the configuration option has already been set and if not assign with\n the return value of sys_get_config() you can use IFNULL(...) (see example below). However this should\n not be done inside a loop (e.g. for each row in a result set) as for repeated calls where assignment\n is only needed in the first iteration using IFNULL(...) is expected to be significantly slower than\n using an IF (...) THEN ... END IF; block (see example below).\n\nParameters\n-----------\n\nin_variable_name (VARCHAR(128)):\n The name of the config option to return the value for.\n\nin_default_value (VARCHAR(128)):\n The default value to return if the variable does not exist in sys.sys_config.\n\nReturns\n-----------\n\nVARCHAR(128)\n\nExample\n-----------\n\n-- Get the configuration value from sys.sys_config falling back on 128 if the option is not present in the table.\nmysql> SELECT sys.sys_get_config('statement_truncate_len', 128) AS Value;\n+-------+\n| Value |\n+-------+\n| 64 |\n+-------+\n1 row in set (0.00 sec)\n\n-- Check whether the option is already set, if not assign - IFNULL(...) one liner example.\nmysql> SET @sys.statement_truncate_len = IFNULL(@sys.statement_truncate_len, sys.sys_get_config('statement_truncate_len', 64));\nQuery OK, 0 rows affected (0.00 sec)\n\n-- Check whether the option is already set, if not assign - IF ... THEN ... END IF example.\nIF (@sys.statement_truncate_len IS NULL) THEN\n SET @sys.statement_truncate_len = sys.sys_get_config('statement_truncate_len', 64);\nEND IF;\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""version_major","def","sys","version_major","FUNCTION","tinyint","NULL","NULL","3","0","NULL","NULL","NULL","tinyint unsigned","SQL","BEGIN\n RETURN SUBSTRING_INDEX(SUBSTRING_INDEX(VERSION(), '-', 1), '.', 1);\nEND","NULL","SQL","SQL","NO","NO SQL","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nReturns the major version of MySQL Server.\n\nReturns\n-----------\n\nTINYINT UNSIGNED\n\nExample\n-----------\n\nmysql> SELECT VERSION(), sys.version_major();\n+--------------------------------------+---------------------+\n| VERSION() | sys.version_major() |\n+--------------------------------------+---------------------+\n| 5.7.9-enterprise-commercial-advanced | 5 |\n+--------------------------------------+---------------------+\n1 row in set (0.00 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""version_minor","def","sys","version_minor","FUNCTION","tinyint","NULL","NULL","3","0","NULL","NULL","NULL","tinyint unsigned","SQL","BEGIN\n RETURN SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING_INDEX(VERSION(), '-', 1), '.', 2), '.', -1);\nEND","NULL","SQL","SQL","NO","NO SQL","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nReturns the minor (release series) version of MySQL Server.\n\nReturns\n-----------\n\nTINYINT UNSIGNED\n\nExample\n-----------\n\nmysql> SELECT VERSION(), sys.server_minor();\n+--------------------------------------+---------------------+\n| VERSION() | sys.version_minor() |\n+--------------------------------------+---------------------+\n| 5.7.9-enterprise-commercial-advanced | 7 |\n+--------------------------------------+---------------------+\n1 row in set (0.00 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""version_patch","def","sys","version_patch","FUNCTION","tinyint","NULL","NULL","3","0","NULL","NULL","NULL","tinyint unsigned","SQL","BEGIN\n RETURN SUBSTRING_INDEX(SUBSTRING_INDEX(VERSION(), '-', 1), '.', -1);\nEND","NULL","SQL","SQL","NO","NO SQL","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nReturns the patch release version of MySQL Server.\n\nReturns\n-----------\n\nTINYINT UNSIGNED\n\nExample\n-----------\n\nmysql> SELECT VERSION(), sys.version_patch();\n+--------------------------------------+---------------------+\n| VERSION() | sys.version_patch() |\n+--------------------------------------+---------------------+\n| 5.7.9-enterprise-commercial-advanced | 9 |\n+--------------------------------------+---------------------+\n1 row in set (0.00 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""create_synonym_db","def","sys","create_synonym_db","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","BEGIN\n DECLARE v_done bool DEFAULT FALSE;\n DECLARE v_db_name_check VARCHAR(64);\n DECLARE v_db_err_msg TEXT;\n DECLARE v_table VARCHAR(64);\n DECLARE v_views_created INT DEFAULT 0;\n DECLARE db_doesnt_exist CONDITION FOR SQLSTATE '42000';\n DECLARE db_name_exists CONDITION FOR SQLSTATE 'HY000';\n DECLARE c_table_names CURSOR FOR \n SELECT TABLE_NAME \n FROM INFORMATION_SCHEMA.TABLES \n WHERE TABLE_SCHEMA = in_db_name;\n DECLARE CONTINUE HANDLER FOR NOT FOUND SET v_done = TRUE;\n -- Check if the source database exists\n SELECT SCHEMA_NAME INTO v_db_name_check\n FROM INFORMATION_SCHEMA.SCHEMATA\n WHERE SCHEMA_NAME = in_db_name;\n IF v_db_name_check IS NULL THEN\n SET v_db_err_msg = CONCAT('Unknown database ', in_db_name);\n SIGNAL SQLSTATE 'HY000'\n SET MESSAGE_TEXT = v_db_err_msg;\n END IF;\n -- Check if a database of the synonym name already exists\n SELECT SCHEMA_NAME INTO v_db_name_check\n FROM INFORMATION_SCHEMA.SCHEMATA\n WHERE SCHEMA_NAME = in_synonym;\n IF v_db_name_check = in_synonym THEN\n SET v_db_err_msg = CONCAT('Can't create database ', in_synonym, '; database exists');\n SIGNAL SQLSTATE 'HY000'\n SET MESSAGE_TEXT = v_db_err_msg;\n END IF;\n -- All good, create the database and views\n SET @create_db_stmt := CONCAT('CREATE DATABASE ', sys.quote_identifier(in_synonym));\n PREPARE create_db_stmt FROM @create_db_stmt;\n EXECUTE create_db_stmt;\n DEALLOCATE PREPARE create_db_stmt;\n SET v_done = FALSE;\n OPEN c_table_names;\n c_table_names: LOOP\n FETCH c_table_names INTO v_table;\n IF v_done THEN\n LEAVE c_table_names;\n END IF;\n SET @create_view_stmt = CONCAT(\n 'CREATE SQL SECURITY INVOKER VIEW ',\n sys.quote_identifier(in_synonym),\n '.',\n sys.quote_identifier(v_table),\n ' AS SELECT * FROM ',\n sys.quote_identifier(in_db_name),\n '.',\n sys.quote_identifier(v_table)\n );\n PREPARE create_view_stmt FROM @create_view_stmt;\n EXECUTE create_view_stmt;\n DEALLOCATE PREPARE create_view_stmt;\n SET v_views_created = v_views_created + 1;\n END LOOP;\n CLOSE c_table_names;\n SELECT CONCAT(\n 'Created ', v_views_created, ' view',\n IF(v_views_created != 1, 's', ''), ' in the ',\n sys.quote_identifier(in_synonym), ' database'\n ) AS summary;\nEND","NULL","SQL","SQL","NO","MODIFIES SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nTakes a source database name and synonym name, and then creates the \nsynonym database with views that point to all of the tables within\nthe source database.\n\nUseful for creating a "ps" synonym for "performance_schema",\nor "is" instead of "information_schema", for example.\n\nParameters\n-----------\n\nin_db_name (VARCHAR(64)):\n The database name that you would like to create a synonym for.\nin_synonym (VARCHAR(64)):\n The database synonym name.\n\nExample\n-----------\n\nmysql> SHOW DATABASES;\n+--------------------+\n| Database |\n+--------------------+\n| information_schema |\n| mysql |\n| performance_schema |\n| sys |\n| test |\n+--------------------+\n5 rows in set (0.00 sec)\n\nmysql> CALL sys.create_synonym_db('performance_schema', 'ps');\n+---------------------------------------+\n| summary |\n+---------------------------------------+\n| Created 74 views in the `ps` database |\n+---------------------------------------+\n1 row in set (8.57 sec)\n\nQuery OK, 0 rows affected (8.57 sec)\n\nmysql> SHOW DATABASES;\n+--------------------+\n| Database |\n+--------------------+\n| information_schema |\n| mysql |\n| performance_schema |\n| ps |\n| sys |\n| test |\n+--------------------+\n6 rows in set (0.00 sec)\n\nmysql> SHOW FULL TABLES FROM ps;\n+------------------------------------------------------+------------+\n| Tables_in_ps | Table_type |\n+------------------------------------------------------+------------+\n| accounts | VIEW |\n| cond_instances | VIEW |\n| events_stages_current | VIEW |\n| events_stages_history | VIEW |\n...\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""execute_prepared_stmt","def","sys","execute_prepared_stmt","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","BEGIN\n -- Set configuration options\n IF (@sys.debug IS NULL) THEN\n SET @sys.debug = sys.sys_get_config('debug', 'OFF');\n END IF;\n -- Verify the query exists\n -- The shortest possible query is "DO 1"\n IF (in_query IS NULL OR LENGTH(in_query) < 4) THEN\n SIGNAL SQLSTATE '45000'\n SET MESSAGE_TEXT = "The @sys.execute_prepared_stmt.sql must contain a query";\n END IF;\n SET @sys.execute_prepared_stmt.sql = in_query;\n IF (@sys.debug = 'ON') THEN\n SELECT @sys.execute_prepared_stmt.sql AS 'Debug';\n END IF;\n PREPARE sys_execute_prepared_stmt FROM @sys.execute_prepared_stmt.sql;\n EXECUTE sys_execute_prepared_stmt;\n DEALLOCATE PREPARE sys_execute_prepared_stmt;\n SET @sys.execute_prepared_stmt.sql = NULL;\nEND","NULL","SQL","SQL","NO","READS SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nTakes the query in the argument and executes it using a prepared statement. The prepared statement is deallocated,\nso the procedure is mainly useful for executing one off dynamically created queries.\n\nThe sys_execute_prepared_stmt prepared statement name is used for the query and is required not to exist.\n\n\nParameters\n-----------\n\nin_query (longtext CHARACTER SET UTF8MB4):\n The query to execute.\n\n\nConfiguration Options\n----------------------\n\nsys.debug\n Whether to provide debugging output.\n Default is 'OFF'. Set to 'ON' to include.\n\n\nExample\n--------\n\nmysql> CALL sys.execute_prepared_stmt('SELECT * FROM sys.sys_config');\n+------------------------+-------+---------------------+--------+\n| variable | value | set_time | set_by |\n+------------------------+-------+---------------------+--------+\n| statement_truncate_len | 64 | 2015-06-30 13:06:00 | NULL |\n+------------------------+-------+---------------------+--------+\n1 row in set (0.00 sec)\n\nQuery OK, 0 rows affected (0.00 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""diagnostics","def","sys","diagnostics","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","BEGIN\n DECLARE v_start, v_runtime, v_iter_start, v_sleep DECIMAL(20,2) DEFAULT 0.0;\n DECLARE v_has_innodb, v_has_ndb, v_has_ps, v_has_replication, v_has_ps_replication VARCHAR(8) CHARSET utf8mb4 DEFAULT 'NO';\n DECLARE v_this_thread_enabled ENUM('YES', 'NO');\n DECLARE v_table_name, v_banner VARCHAR(64) CHARSET utf8mb4;\n DECLARE v_sql_status_summary_select, v_sql_status_summary_delta, v_sql_status_summary_from, v_no_delta_names TEXT;\n DECLARE v_output_time, v_output_time_prev DECIMAL(20,3) UNSIGNED;\n DECLARE v_output_count, v_count, v_old_group_concat_max_len INT UNSIGNED DEFAULT 0;\n -- The width of each of the status outputs in the summery\n DECLARE v_status_summary_width TINYINT UNSIGNED DEFAULT 50;\n DECLARE v_done BOOLEAN DEFAULT FALSE;\n -- Do not include the following ndbinfo views:\n -- 'blocks' Static\n -- 'config_params' Static\n -- 'dict_obj_types' Static\n -- 'disk_write_speed_base' Can generate lots of output - only include aggregate views here\n -- 'memory_per_fragment' Can generate lots of output\n -- 'memoryusage' Handled separately\n -- 'operations_per_fragment' Can generate lots of output\n -- 'threadblocks' Only needed once\n DECLARE c_ndbinfo CURSOR FOR\n SELECT TABLE_NAME\n FROM information_schema.TABLES\n WHERE TABLE_SCHEMA = 'ndbinfo'\n AND TABLE_NAME NOT IN (\n 'blocks',\n 'config_params',\n 'dict_obj_types',\n 'disk_write_speed_base',\n 'memory_per_fragment',\n 'memoryusage',\n 'operations_per_fragment',\n 'threadblocks'\n );\n DECLARE c_sysviews_w_delta CURSOR FOR\n SELECT table_name\n FROM tmp_sys_views_delta\n ORDER BY table_name;\n DECLARE CONTINUE HANDLER FOR NOT FOUND SET v_done = TRUE;\n -- Do not track the current thread - no reason to clutter the output\n SELECT INSTRUMENTED INTO v_this_thread_enabled FROM performance_schema.threads WHERE PROCESSLIST_ID = CONNECTION_ID();\n IF (v_this_thread_enabled = 'YES') THEN\n CALL sys.ps_setup_disable_thread(CONNECTION_ID());\n END IF;\n -- Check options are sane\n IF (in_max_runtime < in_interval) THEN\n SIGNAL SQLSTATE '45000'\n SET MESSAGE_TEXT = 'in_max_runtime must be greater than or equal to in_interval';\n END IF;\n IF (in_max_runtime = 0) THEN\n SIGNAL SQLSTATE '45000'\n SET MESSAGE_TEXT = 'in_max_runtime must be greater than 0';\n END IF;\n IF (in_interval = 0) THEN\n SIGNAL SQLSTATE '45000'\n SET MESSAGE_TEXT = 'in_interval must be greater than 0';\n END IF;\n -- Set configuration options\n IF (@sys.diagnostics.allow_i_s_tables IS NULL) THEN\n SET @sys.diagnostics.allow_i_s_tables = sys.sys_get_config('diagnostics.allow_i_s_tables', 'OFF');\n END IF;\n IF (@sys.diagnostics.include_raw IS NULL) THEN\n SET @sys.diagnostics.include_raw = sys.sys_get_config('diagnostics.include_raw' , 'OFF');\n END IF;\n IF (@sys.debug IS NULL) THEN\n SET @sys.debug = sys.sys_get_config('debug' , 'OFF');\n END IF;\n IF (@sys.statement_truncate_len IS NULL) THEN\n SET @sys.statement_truncate_len = sys.sys_get_config('statement_truncate_len' , '64' );\n END IF;\n -- Temporary table are used - disable sql_log_bin if necessary to prevent them replicating\n SET @log_bin := @@sql_log_bin;\n IF ((@log_bin = 1) AND (@@binlog_format = 'STATEMENT')) THEN\n SET sql_log_bin = 0;\n END IF;\n -- Some metrics variables doesn't make sense in delta and rate calculations even if they are numeric\n -- as they really are more like settings or "current" status.\n SET v_no_delta_names = CONCAT('s%{COUNT}.Variable_name NOT IN (',\n ''innodb_buffer_pool_pages_total', ',\n ''innodb_page_size', ',\n ''last_query_cost', ',\n ''last_query_partial_plans', ',\n ''qcache_total_blocks', ',\n ''slave_last_heartbeat', ',\n ''ssl_ctx_verify_depth', ',\n ''ssl_ctx_verify_mode', ',\n ''ssl_session_cache_size', ',\n ''ssl_verify_depth', ',\n ''ssl_verify_mode', ',\n ''ssl_version', ',\n ''buffer_flush_lsn_avg_rate', ',\n ''buffer_flush_pct_for_dirty', ',\n ''buffer_flush_pct_for_lsn', ',\n ''buffer_pool_pages_total', ',\n ''lock_row_lock_time_avg', ',\n ''lock_row_lock_time_max', ',\n ''innodb_page_size'',\n ')');\n IF (in_auto_config <> 'current') THEN\n IF (@sys.debug = 'ON') THEN\n SELECT CONCAT('Updating Performance Schema configuration to ', in_auto_config) AS 'Debug';\n END IF;\n CALL sys.ps_setup_save(0);\n IF (in_auto_config = 'medium') THEN\n -- Enable all consumers except %history and %history_long\n UPDATE performance_schema.setup_consumers\n SET ENABLED = 'YES'\n WHERE NAME NOT LIKE '%\\_history%';\n -- Enable all instruments except wait/synch/%\n UPDATE performance_schema.setup_instruments\n SET ENABLED = 'YES',\n TIMED = 'YES'\n WHERE NAME NOT LIKE 'wait/synch/%';\n ELSEIF (in_auto_config = 'full') THEN\n UPDATE performance_schema.setup_consumers\n SET ENABLED = 'YES';\n UPDATE performance_schema.setup_instruments\n SET ENABLED = 'YES',\n TIMED = 'YES';\n END IF;\n -- Enable all threads except this one\n UPDATE performance_schema.threads\n SET INSTRUMENTED = 'YES'\n WHERE PROCESSLIST_ID <> CONNECTION_ID();\n END IF;\n SET v_start = UNIX_TIMESTAMP(NOW(2)),\n in_interval = IFNULL(in_interval, 30),\n in_max_runtime = IFNULL(in_max_runtime, 60);\n -- Get a quick ref with hostname, server UUID, and the time for the report.\n SET v_banner = REPEAT(\n '-',\n LEAST(\n GREATEST(\n 36,\n CHAR_LENGTH(VERSION()),\n CHAR_LENGTH(@@global.version_comment),\n CHAR_LENGTH(@@global.version_compile_os),\n CHAR_LENGTH(@@global.version_compile_machine),\n CHAR_LENGTH(@@global.socket),\n CHAR_LENGTH(@@global.datadir)\n ),\n 64\n )\n );\n SELECT 'Hostname' AS 'Name', @@global.hostname AS 'Value'\n UNION ALL\n SELECT 'Port' AS 'Name', @@global.port AS 'Value'\n UNION ALL\n SELECT 'Socket' AS 'Name', @@global.socket AS 'Value'\n UNION ALL\n SELECT 'Datadir' AS 'Name', @@global.datadir AS 'Value'\n UNION ALL\n SELECT 'Server UUID' AS 'Name', @@global.server_uuid AS 'Value'\n UNION ALL\n SELECT REPEAT('-', 23) AS 'Name', v_banner AS 'Value'\n UNION ALL\n SELECT 'MySQL Version' AS 'Name', VERSION() AS 'Value'\n UNION ALL\n SELECT 'Sys Schema Version' AS 'Name', (SELECT sys_version FROM sys.version) AS 'Value'\n UNION ALL\n SELECT 'Version Comment' AS 'Name', @@global.version_comment AS 'Value'\n UNION ALL\n SELECT 'Version Compile OS' AS 'Name', @@global.version_compile_os AS 'Value'\n UNION ALL\n SELECT 'Version Compile Machine' AS 'Name', @@global.version_compile_machine AS 'Value'\n UNION ALL\n SELECT REPEAT('-', 23) AS 'Name', v_banner AS 'Value'\n UNION ALL\n SELECT 'UTC Time' AS 'Name', UTC_TIMESTAMP() AS 'Value'\n UNION ALL\n SELECT 'Local Time' AS 'Name', NOW() AS 'Value'\n UNION ALL\n SELECT 'Time Zone' AS 'Name', @@global.time_zone AS 'Value'\n UNION ALL\n SELECT 'System Time Zone' AS 'Name', @@global.system_time_zone AS 'Value'\n UNION ALL\n SELECT 'Time Zone Offset' AS 'Name', TIMEDIFF(NOW(), UTC_TIMESTAMP()) AS 'Value';\n -- Are the InnoDB, NDBCluster, and Performance Schema storage engines present?\n SET v_has_innodb = IFNULL((SELECT SUPPORT FROM information_schema.ENGINES WHERE ENGINE = 'InnoDB'), 'NO'),\n v_has_ndb = IFNULL((SELECT SUPPORT FROM information_schema.ENGINES WHERE ENGINE = 'NDBCluster'), 'NO'),\n v_has_ps = IFNULL((SELECT SUPPORT FROM information_schema.ENGINES WHERE ENGINE = 'PERFORMANCE_SCHEMA'), 'NO'),\n v_has_ps_replication = v_has_ps,\n v_has_replication = IF(v_has_ps_replication = 'YES', IF((SELECT COUNT(*) FROM performance_schema.replication_connection_status) > 0, 'YES', 'NO'),\n IF(@@master_info_repository = 'TABLE', IF((SELECT COUNT(*) FROM mysql.slave_master_info) > 0, 'YES', 'NO'),\n IF(@@relay_log_info_repository = 'TABLE', IF((SELECT COUNT(*) FROM mysql.slave_relay_log_info) > 0, 'YES', 'NO'),\n 'MAYBE')));\n IF (@sys.debug = 'ON') THEN\n SELECT v_has_innodb AS 'Has_InnoDB', v_has_ndb AS 'Has_NDBCluster',\n v_has_ps AS 'Has_Performance_Schema',\n v_has_ps_replication 'AS Has_P_S_Replication', v_has_replication AS 'Has_Replication';\n END IF;\n IF (v_has_innodb IN ('DEFAULT', 'YES')) THEN\n -- Need to use prepared statement as just having the query as a plain command\n -- will generate an error if the InnoDB storage engine is not present\n SET @sys.diagnostics.sql = 'SHOW ENGINE InnoDB STATUS';\n PREPARE stmt_innodb_status FROM @sys.diagnostics.sql;\n END IF;\n IF (v_has_ps = 'YES') THEN\n -- Need to use prepared statement as just having the query as a plain command\n -- will generate an error if the InnoDB storage engine is not present\n SET @sys.diagnostics.sql = 'SHOW ENGINE PERFORMANCE_SCHEMA STATUS';\n PREPARE stmt_ps_status FROM @sys.diagnostics.sql;\n END IF;\n IF (v_has_ndb IN ('DEFAULT', 'YES')) THEN\n -- Need to use prepared statement as just having the query as a plain command\n -- will generate an error if the NDBCluster storage engine is not present\n SET @sys.diagnostics.sql = 'SHOW ENGINE NDBCLUSTER STATUS';\n PREPARE stmt_ndbcluster_status FROM @sys.diagnostics.sql;\n END IF;\n SET @sys.diagnostics.sql_gen_query_template = 'SELECT CONCAT(\n 'SELECT ',\n GROUP_CONCAT(\n CASE WHEN (SUBSTRING(TABLE_NAME, 3), COLUMN_NAME) IN (\n ('io_global_by_file_by_bytes', 'total'),\n ('io_global_by_wait_by_bytes', 'total_requested')\n )\n THEN CONCAT('format_bytes(', COLUMN_NAME, ') AS ', COLUMN_NAME)\n WHEN COLUMN_NAME LIKE '%latency'\n THEN CONCAT('format_pico_time(', COLUMN_NAME, ') AS ', COLUMN_NAME)\n WHEN SUBSTRING(COLUMN_NAME, -7) = '_memory' OR SUBSTRING(COLUMN_NAME, -17) = '_memory_allocated'\n OR ((SUBSTRING(COLUMN_NAME, -5) = '_read' OR SUBSTRING(COLUMN_NAME, -8) = '_written' OR SUBSTRING(COLUMN_NAME, -6) = '_write') AND SUBSTRING(COLUMN_NAME, 1, 6) <> 'COUNT_')\n THEN CONCAT('format_bytes(', COLUMN_NAME, ') AS ', COLUMN_NAME)\n ELSE COLUMN_NAME\n END\n ORDER BY ORDINAL_POSITION\n SEPARATOR ',\n '\n ),\n '\n FROM tmp_', SUBSTRING(TABLE_NAME FROM 3), '_%{OUTPUT}'\n ) AS Query INTO @sys.diagnostics.sql_select\n FROM information_schema.COLUMNS\n WHERE TABLE_SCHEMA = 'sys' AND TABLE_NAME = ?\n GROUP BY TABLE_NAME';\n SET @sys.diagnostics.sql_gen_query_delta = 'SELECT CONCAT(\n 'SELECT ',\n GROUP_CONCAT(\n CASE WHEN FIND_IN_SET(COLUMN_NAME COLLATE utf8mb3_general_ci, diag.pk)\n THEN COLUMN_NAME\n WHEN diag.TABLE_NAME = 'io_global_by_file_by_bytes' AND COLUMN_NAME COLLATE utf8mb3_general_ci = 'write_pct'\n THEN CONCAT('IFNULL(ROUND(100-(((e.total_read-IFNULL(s.total_read, 0))',\n '/NULLIF(((e.total_read-IFNULL(s.total_read, 0))+(e.total_written-IFNULL(s.total_written, 0))), 0))*100), 2), 0.00) AS ',\n COLUMN_NAME)\n WHEN (diag.TABLE_NAME, COLUMN_NAME) IN (\n ('io_global_by_file_by_bytes', 'total'),\n ('io_global_by_wait_by_bytes', 'total_requested')\n )\n THEN CONCAT('format_bytes(e.', COLUMN_NAME, '-IFNULL(s.', COLUMN_NAME, ', 0)) AS ', COLUMN_NAME)\n WHEN SUBSTRING(COLUMN_NAME, 1, 4) IN ('max_', 'min_') AND SUBSTRING(COLUMN_NAME, -8) = '_latency'\n THEN CONCAT('format_pico_time(e.', COLUMN_NAME, ') AS ', COLUMN_NAME)\n WHEN COLUMN_NAME COLLATE utf8mb3_general_ci = 'avg_latency'\n THEN CONCAT('format_pico_time((e.total_latency - IFNULL(s.total_latency, 0))',\n '/NULLIF(e.total - IFNULL(s.total, 0), 0)) AS ', COLUMN_NAME)\n WHEN SUBSTRING(COLUMN_NAME, -12) = '_avg_latency'\n THEN CONCAT('format_pico_time((e.', SUBSTRING(COLUMN_NAME FROM 1 FOR CHAR_LENGTH(COLUMN_NAME)-12), '_latency - IFNULL(s.', SUBSTRING(COLUMN_NAME FROM 1 FOR CHAR_LENGTH(COLUMN_NAME)-12), '_latency, 0))',\n '/NULLIF(e.', SUBSTRING(COLUMN_NAME FROM 1 FOR CHAR_LENGTH(COLUMN_NAME)-12), 's - IFNULL(s.', SUBSTRING(COLUMN_NAME FROM 1 FOR CHAR_LENGTH(COLUMN_NAME)-12), 's, 0), 0)) AS ', COLUMN_NAME)\n WHEN COLUMN_NAME LIKE '%latency'\n THEN CONCAT('format_pico_time(e.', COLUMN_NAME, ' - IFNULL(s.', COLUMN_NAME, ', 0)) AS ', COLUMN_NAME)\n WHEN COLUMN_NAME IN ('avg_read', 'avg_write', 'avg_written')\n THEN CONCAT('format_bytes(IFNULL((e.total_', IF(COLUMN_NAME = 'avg_read', 'read', 'written'), '-IFNULL(s.total_', IF(COLUMN_NAME = 'avg_read', 'read', 'written'), ', 0))',\n '/NULLIF(e.count_', IF(COLUMN_NAME = 'avg_read', 'read', 'write'), '-IFNULL(s.count_', IF(COLUMN_NAME = 'avg_read', 'read', 'write'), ', 0), 0), 0)) AS ',\n COLUMN_NAME)\n WHEN SUBSTRING(COLUMN_NAME, -7) = '_memory' OR SUBSTRING(COLUMN_NAME, -17) = '_memory_allocated'\n OR ((SUBSTRING(COLUMN_NAME, -5) = '_read' OR SUBSTRING(COLUMN_NAME, -8) = '_written' OR SUBSTRING(COLUMN_NAME, -6) = '_write') AND SUBSTRING(COLUMN_NAME, 1, 6) <> 'COUNT_')\n THEN CONCAT('format_bytes(e.', COLUMN_NAME, ' - IFNULL(s.', COLUMN_NAME, ', 0)) AS ', COLUMN_NAME)\n ELSE CONCAT('(e.', COLUMN_NAME, ' - IFNULL(s.', COLUMN_NAME, ', 0)) AS ', COLUMN_NAME)\n END\n ORDER BY ORDINAL_POSITION\n SEPARATOR ',\n '\n ),\n '\n FROM tmp_', diag.TABLE_NAME, '_end e\n LEFT OUTER JOIN tmp_', diag.TABLE_NAME, '_start s USING (', diag.pk, ')'\n ) AS Query INTO @sys.diagnostics.sql_select\n FROM tmp_sys_views_delta diag\n INNER JOIN information_schema.COLUMNS c ON c.TABLE_NAME COLLATE utf8mb3_general_ci = CONCAT('x$', diag.TABLE_NAME)\n WHERE c.TABLE_SCHEMA = 'sys' AND diag.TABLE_NAME = ?\n GROUP BY diag.TABLE_NAME';\n IF (v_has_ps = 'YES') THEN\n -- Create temporary table with the ORDER BY clauses. Will be required both for the initial (if included) and end queries\n DROP TEMPORARY TABLE IF EXISTS tmp_sys_views_delta;\n CREATE TEMPORARY TABLE tmp_sys_views_delta (\n TABLE_NAME varchar(64) NOT NULL,\n order_by text COMMENT 'ORDER BY clause for the initial and overall views',\n order_by_delta text COMMENT 'ORDER BY clause for the delta views',\n where_delta text COMMENT 'WHERE clause to use for delta views to only include rows with a "count" > 0',\n limit_rows int unsigned COMMENT 'The maximum number of rows to include for the view',\n pk varchar(128) COMMENT 'Used with the FIND_IN_SET() function so use comma separated list without whitespace',\n PRIMARY KEY (TABLE_NAME)\n );\n -- %{OUTPUT} will be replace by the suffix used for the output.\n IF (@sys.debug = 'ON') THEN\n SELECT 'Populating tmp_sys_views_delta' AS 'Debug';\n END IF;\n INSERT INTO tmp_sys_views_delta\n VALUES ('host_summary' , '%{TABLE}.statement_latency DESC',\n '(e.statement_latency-IFNULL(s.statement_latency, 0)) DESC',\n '(e.statements - IFNULL(s.statements, 0)) > 0', NULL, 'host'),\n ('host_summary_by_file_io' , '%{TABLE}.io_latency DESC',\n '(e.io_latency-IFNULL(s.io_latency, 0)) DESC',\n '(e.ios - IFNULL(s.ios, 0)) > 0', NULL, 'host'),\n ('host_summary_by_file_io_type' , '%{TABLE}.host, %{TABLE}.total_latency DESC',\n 'e.host, (e.total_latency-IFNULL(s.total_latency, 0)) DESC',\n '(e.total - IFNULL(s.total, 0)) > 0', NULL, 'host,event_name'),\n ('host_summary_by_stages' , '%{TABLE}.host, %{TABLE}.total_latency DESC',\n 'e.host, (e.total_latency-IFNULL(s.total_latency, 0)) DESC',\n '(e.total - IFNULL(s.total, 0)) > 0', NULL, 'host,event_name'),\n ('host_summary_by_statement_latency' , '%{TABLE}.total_latency DESC',\n '(e.total_latency-IFNULL(s.total_latency, 0)) DESC',\n '(e.total - IFNULL(s.total, 0)) > 0', NULL, 'host'),\n ('host_summary_by_statement_type' , '%{TABLE}.host, %{TABLE}.total_latency DESC',\n 'e.host, (e.total_latency-IFNULL(s.total_latency, 0)) DESC',\n '(e.total - IFNULL(s.total, 0)) > 0', NULL, 'host,statement'),\n ('io_by_thread_by_latency' , '%{TABLE}.total_latency DESC',\n '(e.total_latency-IFNULL(s.total_latency, 0)) DESC',\n '(e.total - IFNULL(s.total, 0)) > 0', NULL, 'user,thread_id,processlist_id'),\n ('io_global_by_file_by_bytes' , '%{TABLE}.total DESC',\n '(e.total-IFNULL(s.total, 0)) DESC',\n '(e.total - IFNULL(s.total, 0)) > 0', 100, 'file'),\n ('io_global_by_file_by_latency' , '%{TABLE}.total_latency DESC',\n '(e.total_latency-IFNULL(s.total_latency, 0)) DESC',\n '(e.total - IFNULL(s.total, 0)) > 0', 100, 'file'),\n ('io_global_by_wait_by_bytes' , '%{TABLE}.total_requested DESC',\n '(e.total_requested-IFNULL(s.total_requested, 0)) DESC',\n '(e.total - IFNULL(s.total, 0)) > 0', NULL, 'event_name'),\n ('io_global_by_wait_by_latency' , '%{TABLE}.total_latency DESC',\n '(e.total_latency-IFNULL(s.total_latency, 0)) DESC',\n '(e.total - IFNULL(s.total, 0)) > 0', NULL, 'event_name'),\n ('schema_index_statistics' , '(%{TABLE}.select_latency+%{TABLE}.insert_latency+%{TABLE}.update_latency+%{TABLE}.delete_latency) DESC',\n '((e.select_latency+e.insert_latency+e.update_latency+e.delete_latency)-IFNULL(s.select_latency+s.insert_latency+s.update_latency+s.delete_latency, 0)) DESC',\n '((e.rows_selected+e.insert_latency+e.rows_updated+e.rows_deleted)-IFNULL(s.rows_selected+s.rows_inserted+s.rows_updated+s.rows_deleted, 0)) > 0',\n 100, 'table_schema,table_name,index_name'),\n ('schema_table_statistics' , '%{TABLE}.total_latency DESC',\n '(e.total_latency-IFNULL(s.total_latency, 0)) DESC',\n '(e.total_latency-IFNULL(s.total_latency, 0)) > 0', 100, 'table_schema,table_name'),\n ('schema_tables_with_full_table_scans', '%{TABLE}.rows_full_scanned DESC',\n '(e.rows_full_scanned-IFNULL(s.rows_full_scanned, 0)) DESC',\n '(e.rows_full_scanned-IFNULL(s.rows_full_scanned, 0)) > 0', 100, 'object_schema,object_name'),\n ('user_summary' , '%{TABLE}.statement_latency DESC',\n '(e.statement_latency-IFNULL(s.statement_latency, 0)) DESC',\n '(e.statements - IFNULL(s.statements, 0)) > 0', NULL, 'user'),\n ('user_summary_by_file_io' , '%{TABLE}.io_latency DESC',\n '(e.io_latency-IFNULL(s.io_latency, 0)) DESC',\n '(e.ios - IFNULL(s.ios, 0)) > 0', NULL, 'user'),\n ('user_summary_by_file_io_type' , '%{TABLE}.user, %{TABLE}.latency DESC',\n 'e.user, (e.latency-IFNULL(s.latency, 0)) DESC',\n '(e.total - IFNULL(s.total, 0)) > 0', NULL, 'user,event_name'),\n ('user_summary_by_stages' , '%{TABLE}.user, %{TABLE}.total_latency DESC',\n 'e.user, (e.total_latency-IFNULL(s.total_latency, 0)) DESC',\n '(e.total - IFNULL(s.total, 0)) > 0', NULL, 'user,event_name'),\n ('user_summary_by_statement_latency' , '%{TABLE}.total_latency DESC',\n '(e.total_latency-IFNULL(s.total_latency, 0)) DESC',\n '(e.total - IFNULL(s.total, 0)) > 0', NULL, 'user'),\n ('user_summary_by_statement_type' , '%{TABLE}.user, %{TABLE}.total_latency DESC',\n 'e.user, (e.total_latency-IFNULL(s.total_latency, 0)) DESC',\n '(e.total - IFNULL(s.total, 0)) > 0', NULL, 'user,statement'),\n ('wait_classes_global_by_avg_latency' , 'IFNULL(%{TABLE}.total_latency / NULLIF(%{TABLE}.total, 0), 0) DESC',\n 'IFNULL((e.total_latency-IFNULL(s.total_latency, 0)) / NULLIF((e.total - IFNULL(s.total, 0)), 0), 0) DESC',\n '(e.total - IFNULL(s.total, 0)) > 0', NULL, 'event_class'),\n ('wait_classes_global_by_latency' , '%{TABLE}.total_latency DESC',\n '(e.total_latency-IFNULL(s.total_latency, 0)) DESC',\n '(e.total - IFNULL(s.total, 0)) > 0', NULL, 'event_class'),\n ('waits_by_host_by_latency' , '%{TABLE}.host, %{TABLE}.total_latency DESC',\n 'e.host, (e.total_latency-IFNULL(s.total_latency, 0)) DESC',\n '(e.total - IFNULL(s.total, 0)) > 0', NULL, 'host,event'),\n ('waits_by_user_by_latency' , '%{TABLE}.user, %{TABLE}.total_latency DESC',\n 'e.user, (e.total_latency-IFNULL(s.total_latency, 0)) DESC',\n '(e.total - IFNULL(s.total, 0)) > 0', NULL, 'user,event'),\n ('waits_global_by_latency' , '%{TABLE}.total_latency DESC',\n '(e.total_latency-IFNULL(s.total_latency, 0)) DESC',\n '(e.total - IFNULL(s.total, 0)) > 0', NULL, 'events')\n ;\n END IF;\n SELECT '\n\n=======================\n\n Configuration\n\n=======================\n\n' AS '';\n -- Get the configuration.\n SELECT 'GLOBAL VARIABLES' AS 'The following output is:';\n SELECT LOWER(VARIABLE_NAME) AS Variable_name, VARIABLE_VALUE AS Variable_value FROM performance_schema.global_variables ORDER BY VARIABLE_NAME;\n IF (v_has_ps = 'YES') THEN\n -- Overview of the Performance Schema dynamic settings used for this report.\n SELECT 'Performance Schema Setup - Actors' AS 'The following output is:';\n SELECT * FROM performance_schema.setup_actors;\n SELECT 'Performance Schema Setup - Consumers' AS 'The following output is:';\n SELECT NAME AS Consumer, ENABLED, sys.ps_is_consumer_enabled(NAME) AS COLLECTS\n FROM performance_schema.setup_consumers;\n SELECT 'Performance Schema Setup - Instruments' AS 'The following output is:';\n SELECT SUBSTRING_INDEX(NAME, '/', 2) AS 'InstrumentClass',\n ROUND(100*SUM(IF(ENABLED = 'YES', 1, 0))/COUNT(*), 2) AS 'EnabledPct',\n ROUND(100*SUM(IF(TIMED = 'YES', 1, 0))/COUNT(*), 2) AS 'TimedPct'\n FROM performance_schema.setup_instruments\n GROUP BY SUBSTRING_INDEX(NAME, '/', 2)\n ORDER BY SUBSTRING_INDEX(NAME, '/', 2);\n SELECT 'Performance Schema Setup - Objects' AS 'The following output is:';\n SELECT * FROM performance_schema.setup_objects;\n SELECT 'Performance Schema Setup - Threads' AS 'The following output is:';\n SELECT `TYPE` AS ThreadType, COUNT(*) AS 'Total', ROUND(100*SUM(IF(INSTRUMENTED = 'YES', 1, 0))/COUNT(*), 2) AS 'InstrumentedPct'\n FROM performance_schema.threads\n GROUP BY TYPE;\n END IF;\n IF (v_has_replication = 'NO') THEN\n SELECT 'No Replication Configured' AS 'Replication Status';\n ELSE\n -- No guarantee that replication is actually configured, but we can't really know\n SELECT CONCAT('Replication Configured: ', v_has_replication, ' - Performance Schema Replication Tables: ', v_has_ps_replication) AS 'Replication Status';\n IF (v_has_ps_replication = 'YES') THEN\n SELECT 'Replication - Connection Configuration' AS 'The following output is:';\n SELECT * FROM performance_schema.replication_connection_configuration ORDER BY CHANNEL_NAME;\n END IF;\n IF (v_has_ps_replication = 'YES') THEN\n SELECT 'Replication - Applier Configuration' AS 'The following output is:';\n SELECT * FROM performance_schema.replication_applier_configuration ORDER BY CHANNEL_NAME;\n END IF;\n IF (@@master_info_repository = 'TABLE') THEN\n SELECT 'Replication - Master Info Repository Configuration' AS 'The following output is:';\n -- Can't just do SELECT * as the password may be present in plain text\n -- Don't include binary log file and position as that will be determined in each iteration as well\n SELECT Channel_name, Host, User_name, Port, Connect_retry,\n Enabled_ssl, Ssl_ca, Ssl_capath, Ssl_cert, Ssl_cipher, Ssl_key, Ssl_verify_server_cert,\n Heartbeat, Bind, Ignored_server_ids, Uuid, Retry_count, Ssl_crl, Ssl_crlpath,\n Tls_version, Enabled_auto_position\n FROM mysql.slave_master_info ORDER BY Channel_name;\n END IF;\n IF (@@relay_log_info_repository = 'TABLE') THEN\n SELECT 'Replication - Relay Log Repository Configuration' AS 'The following output is:';\n SELECT Channel_name, Sql_delay, Number_of_workers, Id\n FROM mysql.slave_relay_log_info ORDER BY Channel_name;\n END IF;\n END IF;\n IF (v_has_ndb IN ('DEFAULT', 'YES')) THEN\n SELECT 'Cluster Thread Blocks' AS 'The following output is:';\n SELECT * FROM ndbinfo.threadblocks;\n END IF;\n -- For a number of sys views as well as events_statements_summary_by_digest,\n -- just get the start data and then at the end output the overall and delta values\n IF (v_has_ps = 'YES') THEN\n IF (@sys.diagnostics.include_raw = 'ON') THEN\n SELECT '\n\n========================\n\n Initial Status\n\n========================\n\n' AS '';\n END IF;\n DROP TEMPORARY TABLE IF EXISTS tmp_digests_start;\n CALL sys.statement_performance_analyzer('create_tmp', 'tmp_digests_start', NULL);\n CALL sys.statement_performance_analyzer('snapshot', NULL, NULL);\n CALL sys.statement_performance_analyzer('save', 'tmp_digests_start', NULL);\n -- Loop over the sys views where deltas should be calculated.\n IF (@sys.diagnostics.include_raw = 'ON') THEN\n SET @sys.diagnostics.sql = REPLACE(@sys.diagnostics.sql_gen_query_template, '%{OUTPUT}', 'start');\n IF (@sys.debug = 'ON') THEN\n SELECT 'The following query will be used to generate the query for each sys view' AS 'Debug';\n SELECT @sys.diagnostics.sql AS 'Debug';\n END IF;\n PREPARE stmt_gen_query FROM @sys.diagnostics.sql;\n END IF;\n SET v_done = FALSE;\n OPEN c_sysviews_w_delta;\n c_sysviews_w_delta_loop: LOOP\n FETCH c_sysviews_w_delta INTO v_table_name;\n IF v_done THEN\n LEAVE c_sysviews_w_delta_loop;\n END IF;\n IF (@sys.debug = 'ON') THEN\n SELECT CONCAT('The following queries are for storing the initial content of ', v_table_name) AS 'Debug';\n END IF;\n CALL sys.execute_prepared_stmt(CONCAT('DROP TEMPORARY TABLE IF EXISTS `tmp_', v_table_name, '_start`'));\n CALL sys.execute_prepared_stmt(CONCAT('CREATE TEMPORARY TABLE `tmp_', v_table_name, '_start` SELECT * FROM `sys`.`x$', v_table_name, '`'));\n IF (@sys.diagnostics.include_raw = 'ON') THEN\n SET @sys.diagnostics.table_name = CONCAT('x$', v_table_name);\n EXECUTE stmt_gen_query USING @sys.diagnostics.table_name;\n -- If necessary add ORDER BY and LIMIT\n SELECT CONCAT(@sys.diagnostics.sql_select,\n IF(order_by IS NOT NULL, CONCAT('\n ORDER BY ', REPLACE(order_by, '%{TABLE}', CONCAT('tmp_', v_table_name, '_start'))), ''),\n IF(limit_rows IS NOT NULL, CONCAT('\n LIMIT ', limit_rows), '')\n )\n INTO @sys.diagnostics.sql_select\n FROM tmp_sys_views_delta\n WHERE TABLE_NAME COLLATE utf8mb4_0900_as_ci = v_table_name;\n SELECT CONCAT('Initial ', v_table_name) AS 'The following output is:';\n CALL sys.execute_prepared_stmt(@sys.diagnostics.sql_select);\n END IF;\n END LOOP;\n CLOSE c_sysviews_w_delta;\n IF (@sys.diagnostics.include_raw = 'ON') THEN\n DEALLOCATE PREPARE stmt_gen_query;\n END IF;\n END IF;\n -- If in_include_status_summary is TRUE then a temporary table is required to store the data\n SET v_sql_status_summary_select = 'SELECT Variable_name',\n v_sql_status_summary_delta = '',\n v_sql_status_summary_from = '';\n -- Start the loop\n REPEAT\n SET v_output_count = v_output_count + 1;\n IF (v_output_count > 1) THEN\n -- Don't sleep on the first execution\n SET v_sleep = in_interval-(UNIX_TIMESTAMP(NOW(2))-v_iter_start);\n SELECT NOW() AS 'Time', CONCAT('Going to sleep for ', v_sleep, ' seconds. Please do not interrupt') AS 'The following output is:';\n DO SLEEP(in_interval);\n END IF;\n SET v_iter_start = UNIX_TIMESTAMP(NOW(2));\n SELECT NOW(), CONCAT('Iteration Number ', IFNULL(v_output_count, 'NULL')) AS 'The following output is:';\n -- Even in 5.7 there is no way to get all the info from SHOW MASTER|SLAVE STATUS using the Performance Schema or\n -- other tables, so include them even though they are no longer optimal solutions and if present get the additional\n -- information from the other tables available.\n IF (@@log_bin = 1) THEN\n SELECT 'SHOW MASTER STATUS' AS 'The following output is:';\n SHOW MASTER STATUS;\n END IF;\n IF (v_has_replication <> 'NO') THEN\n SELECT 'SHOW SLAVE STATUS' AS 'The following output is:';\n SHOW SLAVE STATUS;\n IF (v_has_ps_replication = 'YES') THEN\n SELECT 'Replication Connection Status' AS 'The following output is:';\n SELECT * FROM performance_schema.replication_connection_status;\n SELECT 'Replication Applier Status' AS 'The following output is:';\n SELECT * FROM performance_schema.replication_applier_status ORDER BY CHANNEL_NAME;\n SELECT 'Replication Applier Status - Coordinator' AS 'The following output is:';\n SELECT * FROM performance_schema.replication_applier_status_by_coordinator ORDER BY CHANNEL_NAME;\n SELECT 'Replication Applier Status - Worker' AS 'The following output is:';\n SELECT * FROM performance_schema.replication_applier_status_by_worker ORDER BY CHANNEL_NAME, WORKER_ID;\n END IF;\n IF (@@master_info_repository = 'TABLE') THEN\n SELECT 'Replication - Master Log Status' AS 'The following output is:';\n SELECT Master_log_name, Master_log_pos FROM mysql.slave_master_info;\n END IF;\n IF (@@relay_log_info_repository = 'TABLE') THEN\n SELECT 'Replication - Relay Log Status' AS 'The following output is:';\n SELECT sys.format_path(Relay_log_name) AS Relay_log_name, Relay_log_pos, Master_log_name, Master_log_pos FROM mysql.slave_relay_log_info;\n SELECT 'Replication - Worker Status' AS 'The following output is:';\n SELECT Id, sys.format_path(Relay_log_name) AS Relay_log_name, Relay_log_pos, Master_log_name, Master_log_pos,\n sys.format_path(Checkpoint_relay_log_name) AS Checkpoint_relay_log_name, Checkpoint_relay_log_pos,\n Checkpoint_master_log_name, Checkpoint_master_log_pos, Checkpoint_seqno, Checkpoint_group_size,\n HEX(Checkpoint_group_bitmap) AS Checkpoint_group_bitmap, Channel_name\n FROM mysql.slave_worker_info\n ORDER BY Channel_name, Id;\n END IF;\n END IF;\n -- We need one table per output as a temporary table cannot be opened twice in the same query, and we need to\n -- join the outputs in the summary at the end.\n SET v_table_name = CONCAT('tmp_metrics_', v_output_count);\n CALL sys.execute_prepared_stmt(CONCAT('DROP TEMPORARY TABLE IF EXISTS ', v_table_name));\n -- Currently information_schema.GLOBAL_STATUS has VARIABLE_VALUE as varchar(1024)\n CALL sys.execute_prepared_stmt(CONCAT('CREATE TEMPORARY TABLE ', v_table_name, ' (\n Variable_name VARCHAR(193) NOT NULL,\n Variable_value VARCHAR(1024),\n Type VARCHAR(225) NOT NULL,\n Enabled ENUM('YES', 'NO', 'PARTIAL') NOT NULL,\n PRIMARY KEY (Type, Variable_name)\n) ENGINE = InnoDB DEFAULT CHARSET=utf8mb4'));\n SET @sys.diagnostics.sql = CONCAT(\n 'INSERT INTO ', v_table_name,\n ' SELECT Variable_name, REPLACE(Variable_value, '\n', '\\\\n') AS Variable_value, Type, Enabled FROM sys.metrics'\n );\n CALL sys.execute_prepared_stmt(@sys.diagnostics.sql);\n -- Prepare the query to retrieve the summary\n CALL sys.execute_prepared_stmt(\n CONCAT('(SELECT Variable_value INTO @sys.diagnostics.output_time FROM ', v_table_name, ' WHERE Type = 'System Time' AND Variable_name = 'UNIX_TIMESTAMP()')')\n );\n SET v_output_time = @sys.diagnostics.output_time;\n -- Limit each value to v_status_summary_width chars (when v_has_ndb = TRUE the values can be very wide - refer to the output here for the full values)\n -- v_sql_status_summary_select, v_sql_status_summary_delta, v_sql_status_summary_from\n SET v_sql_status_summary_select = CONCAT(v_sql_status_summary_select, ',\n CONCAT(\n LEFT(s', v_output_count, '.Variable_value, ', v_status_summary_width, '),\n IF(', REPLACE(v_no_delta_names, '%{COUNT}', v_output_count), ' AND s', v_output_count, '.Variable_value REGEXP '^[0-9]+(\\\\.[0-9]+)?$', CONCAT(' (', ROUND(s', v_output_count, '.Variable_value/', v_output_time, ', 2), '/sec)'), '')\n ) AS 'Output ', v_output_count, '''),\n v_sql_status_summary_from = CONCAT(v_sql_status_summary_from, '\n',\n IF(v_output_count = 1, ' FROM ', ' INNER JOIN '),\n v_table_name, ' s', v_output_count,\n IF (v_output_count = 1, '', ' USING (Type, Variable_name)'));\n IF (v_output_count > 1) THEN\n SET v_sql_status_summary_delta = CONCAT(v_sql_status_summary_delta, ',\n IF(', REPLACE(v_no_delta_names, '%{COUNT}', v_output_count), ' AND s', (v_output_count-1), '.Variable_value REGEXP '^[0-9]+(\\\\.[0-9]+)?$' AND s', v_output_count, '.Variable_value REGEXP '^[0-9]+(\\\\.[0-9]+)?$',\n CONCAT(IF(s', (v_output_count-1), '.Variable_value REGEXP '^[0-9]+\\\\.[0-9]+$' OR s', v_output_count, '.Variable_value REGEXP '^[0-9]+\\\\.[0-9]+$',\n ROUND((s', v_output_count, '.Variable_value-s', (v_output_count-1), '.Variable_value), 2),\n (s', v_output_count, '.Variable_value-s', (v_output_count-1), '.Variable_value)\n ),\n ' (', ROUND((s', v_output_count, '.Variable_value-s', (v_output_count-1), '.Variable_value)/(', v_output_time, '-', v_output_time_prev, '), 2), '/sec)'\n ),\n ''\n ) AS 'Delta (', (v_output_count-1), ' -> ', v_output_count, ')'');\n END IF;\n SET v_output_time_prev = v_output_time;\n IF (@sys.diagnostics.include_raw = 'ON') THEN\n SELECT 'SELECT * FROM sys.metrics' AS 'The following output is:';\n -- Ensures that the output here is the same as the one used in the status summary at the end\n CALL sys.execute_prepared_stmt(CONCAT('SELECT Type, Variable_name, Enabled, Variable_value FROM ', v_table_name, ' ORDER BY Type, Variable_name'));\n END IF;\n -- InnoDB\n IF (v_has_innodb IN ('DEFAULT', 'YES')) THEN\n SELECT 'SHOW ENGINE INNODB STATUS' AS 'The following output is:';\n EXECUTE stmt_innodb_status;\n SELECT 'InnoDB - Transactions' AS 'The following output is:';\n SELECT * FROM information_schema.INNODB_TRX;\n END IF;\n -- NDBCluster\n IF (v_has_ndb IN ('DEFAULT', 'YES')) THEN\n SELECT 'SHOW ENGINE NDBCLUSTER STATUS' AS 'The following output is:';\n EXECUTE stmt_ndbcluster_status;\n SELECT 'ndbinfo.memoryusage' AS 'The following output is:';\n SELECT node_id, memory_type, format_bytes(used) AS used, used_pages, format_bytes(total) AS total, total_pages,\n ROUND(100*(used/total), 2) AS 'Used %'\n FROM ndbinfo.memoryusage;\n -- Loop over the ndbinfo tables (except memoryusage which was handled separately above).\n -- The exact tables available are version dependent, so get the list from the Information Schema.\n SET v_done = FALSE;\n OPEN c_ndbinfo;\n c_ndbinfo_loop: LOOP\n FETCH c_ndbinfo INTO v_table_name;\n IF v_done THEN\n LEAVE c_ndbinfo_loop;\n END IF;\n SELECT CONCAT('SELECT * FROM ndbinfo.', v_table_name) AS 'The following output is:';\n CALL sys.execute_prepared_stmt(CONCAT('SELECT * FROM `ndbinfo`.`', v_table_name, '`'));\n END LOOP;\n CLOSE c_ndbinfo;\n SELECT * FROM information_schema.FILES;\n END IF;\n SELECT 'SELECT * FROM sys.processlist' AS 'The following output is:';\n SELECT processlist.* FROM sys.processlist;\n IF (v_has_ps = 'YES') THEN\n -- latest_file_io\n IF (sys.ps_is_consumer_enabled('events_waits_history_long') = 'YES') THEN\n SELECT 'SELECT * FROM sys.latest_file_io' AS 'The following output is:';\n SELECT * FROM sys.latest_file_io;\n END IF;\n -- current memory usage\n IF (EXISTS(SELECT 1 FROM performance_schema.setup_instruments WHERE NAME LIKE 'memory/%' AND ENABLED = 'YES')) THEN\n SELECT 'SELECT * FROM sys.memory_by_host_by_current_bytes' AS 'The following output is:';\n SELECT * FROM sys.memory_by_host_by_current_bytes;\n SELECT 'SELECT * FROM sys.memory_by_thread_by_current_bytes' AS 'The following output is:';\n SELECT * FROM sys.memory_by_thread_by_current_bytes;\n SELECT 'SELECT * FROM sys.memory_by_user_by_current_bytes' AS 'The following output is:';\n SELECT * FROM sys.memory_by_user_by_current_bytes;\n SELECT 'SELECT * FROM sys.memory_global_by_current_bytes' AS 'The following output is:';\n SELECT * FROM sys.memory_global_by_current_bytes;\n END IF;\n END IF;\n SET v_runtime = (UNIX_TIMESTAMP(NOW(2)) - v_start);\n UNTIL (v_runtime + in_interval >= in_max_runtime) END REPEAT;\n -- Get Performance Schema status\n IF (v_has_ps = 'YES') THEN\n SELECT 'SHOW ENGINE PERFORMANCE_SCHEMA STATUS' AS 'The following output is:';\n EXECUTE stmt_ps_status;\n END IF;\n -- Deallocate prepared statements\n IF (v_has_innodb IN ('DEFAULT', 'YES')) THEN\n DEALLOCATE PREPARE stmt_innodb_status;\n END IF;\n IF (v_has_ps = 'YES') THEN\n DEALLOCATE PREPARE stmt_ps_status;\n END IF;\n IF (v_has_ndb IN ('DEFAULT', 'YES')) THEN\n DEALLOCATE PREPARE stmt_ndbcluster_status;\n END IF;\n SELECT '\n\n============================\n\n Schema Information\n\n============================\n\n' AS '';\n SELECT COUNT(*) AS 'Total Number of Tables' FROM information_schema.TABLES;\n -- The cost of information_schema.TABLES.DATA_LENGTH depends mostly on the number of tables\n IF (@sys.diagnostics.allow_i_s_tables = 'ON') THEN\n SELECT 'Storage Engine Usage' AS 'The following output is:';\n SELECT ENGINE, COUNT(*) AS NUM_TABLES,\n format_bytes(SUM(DATA_LENGTH)) AS DATA_LENGTH,\n format_bytes(SUM(INDEX_LENGTH)) AS INDEX_LENGTH,\n format_bytes(SUM(DATA_LENGTH+INDEX_LENGTH)) AS TOTAL\n FROM information_schema.TABLES\n GROUP BY ENGINE;\n SELECT 'Schema Object Overview' AS 'The following output is:';\n SELECT * FROM sys.schema_object_overview;\n SELECT 'Tables without a PRIMARY KEY' AS 'The following output is:';\n SELECT TABLES.TABLE_SCHEMA, ENGINE, COUNT(*) AS NumTables\n FROM information_schema.TABLES\n LEFT OUTER JOIN information_schema.STATISTICS ON STATISTICS.TABLE_SCHEMA = TABLES.TABLE_SCHEMA\n AND STATISTICS.TABLE_NAME = TABLES.TABLE_NAME\n AND STATISTICS.INDEX_NAME = 'PRIMARY'\n WHERE STATISTICS.TABLE_NAME IS NULL\n AND TABLES.TABLE_SCHEMA NOT IN ('mysql', 'information_schema', 'performance_schema', 'sys')\n AND TABLES.TABLE_TYPE = 'BASE TABLE'\n GROUP BY TABLES.TABLE_SCHEMA, ENGINE;\n END IF;\n IF (v_has_ps = 'YES') THEN\n SELECT 'Unused Indexes' AS 'The following output is:';\n SELECT object_schema, COUNT(*) AS NumUnusedIndexes\n FROM performance_schema.table_io_waits_summary_by_index_usage\n WHERE index_name IS NOT NULL\n AND count_star = 0\n AND object_schema NOT IN ('mysql', 'sys')\n AND index_name != 'PRIMARY'\n GROUP BY object_schema;\n END IF;\n IF (v_has_ps = 'YES') THEN\n SELECT '\n\n=========================\n\n Overall Status\n\n=========================\n\n' AS '';\n SELECT 'CALL sys.ps_statement_avg_latency_histogram()' AS 'The following output is:';\n CALL sys.ps_statement_avg_latency_histogram();\n CALL sys.statement_performance_analyzer('snapshot', NULL, NULL);\n CALL sys.statement_performance_analyzer('overall', NULL, 'with_runtimes_in_95th_percentile');\n SET @sys.diagnostics.sql = REPLACE(@sys.diagnostics.sql_gen_query_template, '%{OUTPUT}', 'end');\n IF (@sys.debug = 'ON') THEN\n SELECT 'The following query will be used to generate the query for each sys view' AS 'Debug';\n SELECT @sys.diagnostics.sql AS 'Debug';\n END IF;\n PREPARE stmt_gen_query FROM @sys.diagnostics.sql;\n SET v_done = FALSE;\n OPEN c_sysviews_w_delta;\n c_sysviews_w_delta_loop: LOOP\n FETCH c_sysviews_w_delta INTO v_table_name;\n IF v_done THEN\n LEAVE c_sysviews_w_delta_loop;\n END IF;\n IF (@sys.debug = 'ON') THEN\n SELECT CONCAT('The following queries are for storing the final content of ', v_table_name) AS 'Debug';\n END IF;\n CALL sys.execute_prepared_stmt(CONCAT('DROP TEMPORARY TABLE IF EXISTS `tmp_', v_table_name, '_end`'));\n CALL sys.execute_prepared_stmt(CONCAT('CREATE TEMPORARY TABLE `tmp_', v_table_name, '_end` SELECT * FROM `sys`.`x$', v_table_name, '`'));\n SET @sys.diagnostics.table_name = CONCAT('x$', v_table_name);\n EXECUTE stmt_gen_query USING @sys.diagnostics.table_name;\n -- If necessary add ORDER BY and LIMIT\n SELECT CONCAT(@sys.diagnostics.sql_select,\n IF(order_by IS NOT NULL, CONCAT('\n ORDER BY ', REPLACE(order_by, '%{TABLE}', CONCAT('tmp_', v_table_name, '_end'))), ''),\n IF(limit_rows IS NOT NULL, CONCAT('\n LIMIT ', limit_rows), '')\n )\n INTO @sys.diagnostics.sql_select\n FROM tmp_sys_views_delta\n WHERE TABLE_NAME COLLATE utf8mb4_0900_as_ci = v_table_name;\n SELECT CONCAT('Overall ', v_table_name) AS 'The following output is:';\n CALL sys.execute_prepared_stmt(@sys.diagnostics.sql_select);\n END LOOP;\n CLOSE c_sysviews_w_delta;\n DEALLOCATE PREPARE stmt_gen_query;\n SELECT '\n\n======================\n\n Delta Status\n\n======================\n\n' AS '';\n CALL sys.statement_performance_analyzer('delta', 'tmp_digests_start', 'with_runtimes_in_95th_percentile');\n CALL sys.statement_performance_analyzer('cleanup', NULL, NULL);\n DROP TEMPORARY TABLE tmp_digests_start;\n -- @sys.diagnostics.sql_gen_query_delta is defined near the to together with @sys.diagnostics.sql_gen_query_template\n IF (@sys.debug = 'ON') THEN\n SELECT 'The following query will be used to generate the query for each sys view delta' AS 'Debug';\n SELECT @sys.diagnostics.sql_gen_query_delta AS 'Debug';\n END IF;\n PREPARE stmt_gen_query_delta FROM @sys.diagnostics.sql_gen_query_delta;\n SET v_old_group_concat_max_len = @@session.group_concat_max_len;\n SET @@session.group_concat_max_len = 2048;\n SET v_done = FALSE;\n OPEN c_sysviews_w_delta;\n c_sysviews_w_delta_loop: LOOP\n FETCH c_sysviews_w_delta INTO v_table_name;\n IF v_done THEN\n LEAVE c_sysviews_w_delta_loop;\n END IF;\n SET @sys.diagnostics.table_name = v_table_name;\n EXECUTE stmt_gen_query_delta USING @sys.diagnostics.table_name;\n -- If necessary add WHERE, ORDER BY, and LIMIT\n SELECT CONCAT(@sys.diagnostics.sql_select,\n IF(where_delta IS NOT NULL, CONCAT('\n WHERE ', where_delta), ''),\n IF(order_by_delta IS NOT NULL, CONCAT('\n ORDER BY ', order_by_delta), ''),\n IF(limit_rows IS NOT NULL, CONCAT('\n LIMIT ', limit_rows), '')\n )\n INTO @sys.diagnostics.sql_select\n FROM tmp_sys_views_delta\n WHERE TABLE_NAME COLLATE utf8mb4_0900_as_ci = v_table_name;\n SELECT CONCAT('Delta ', v_table_name) AS 'The following output is:';\n CALL sys.execute_prepared_stmt(@sys.diagnostics.sql_select);\n CALL sys.execute_prepared_stmt(CONCAT('DROP TEMPORARY TABLE `tmp_', v_table_name, '_end`'));\n CALL sys.execute_prepared_stmt(CONCAT('DROP TEMPORARY TABLE `tmp_', v_table_name, '_start`'));\n END LOOP;\n CLOSE c_sysviews_w_delta;\n SET @@session.group_concat_max_len = v_old_group_concat_max_len;\n DEALLOCATE PREPARE stmt_gen_query_delta;\n DROP TEMPORARY TABLE tmp_sys_views_delta;\n END IF;\n SELECT 'SELECT * FROM sys.metrics' AS 'The following output is:';\n CALL sys.execute_prepared_stmt(\n CONCAT(v_sql_status_summary_select, v_sql_status_summary_delta, ', Type, s1.Enabled', v_sql_status_summary_from,\n '\n ORDER BY Type, Variable_name'\n )\n );\n -- Remove all the metrics temporary tables again\n SET v_count = 0;\n WHILE (v_count < v_output_count) DO\n SET v_count = v_count + 1;\n SET v_table_name = CONCAT('tmp_metrics_', v_count);\n CALL sys.execute_prepared_stmt(CONCAT('DROP TEMPORARY TABLE IF EXISTS ', v_table_name));\n END WHILE;\n IF (in_auto_config <> 'current') THEN\n CALL sys.ps_setup_reload_saved();\n IF ((@log_bin = 1) AND (@@binlog_format = 'STATEMENT')) THEN\n SET sql_log_bin = @log_bin;\n END IF;\n END IF;\n -- Reset the @sys.diagnostics.% user variables internal to this procedure\n SET @sys.diagnostics.output_time = NULL,\n @sys.diagnostics.sql = NULL,\n @sys.diagnostics.sql_gen_query_delta = NULL,\n @sys.diagnostics.sql_gen_query_template = NULL,\n @sys.diagnostics.sql_select = NULL,\n @sys.diagnostics.table_name = NULL;\n -- Restore INSTRUMENTED for this thread\n IF (v_this_thread_enabled = 'YES') THEN\n CALL sys.ps_setup_enable_thread(CONNECTION_ID());\n END IF;\n IF ((@log_bin = 1) AND (@@binlog_format = 'STATEMENT')) THEN\n SET sql_log_bin = @log_bin;\n END IF;\nEND","NULL","SQL","SQL","NO","READS SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nCreate a report of the current status of the server for diagnostics purposes. Data collected includes (some items depends on versions and settings):\n\n * The GLOBAL VARIABLES\n * Several sys schema views including metrics or equivalent (depending on version and settings)\n * Queries in the 95th percentile\n * Several ndbinfo views for MySQL Cluster\n * Replication (both master and slave) information.\n\nSome of the sys schema views are calculated as initial (optional), overall, delta:\n\n * The initial view is the content of the view at the start of this procedure.\n This output will be the same as the the start values used for the delta view.\n The initial view is included if @sys.diagnostics.include_raw = 'ON'.\n * The overall view is the content of the view at the end of this procedure.\n This output is the same as the end values used for the delta view.\n The overall view is always included.\n * The delta view is the difference from the beginning to the end. Note that for min and max values\n they are simply the min or max value from the end view respectively, so does not necessarily reflect\n the minimum/maximum value in the monitored period.\n Note: except for the metrics views the delta is only calculation between the first and last outputs.\n\nRequires the SUPER privilege for "SET sql_log_bin = 0;".\n\nParameters\n-----------\n\nin_max_runtime (INT UNSIGNED):\n The maximum time to keep collecting data.\n Use NULL to get the default which is 60 seconds, otherwise enter a value greater than 0.\nin_interval (INT UNSIGNED):\n How long to sleep between data collections.\n Use NULL to get the default which is 30 seconds, otherwise enter a value greater than 0.\nin_auto_config (ENUM('current', 'medium', 'full'))\n Automatically enable Performance Schema instruments and consumers.\n NOTE: The more that are enabled, the more impact on the performance.\n Supported values are:\n * current - use the current settings.\n * medium - enable some settings. This requires the SUPER privilege.\n * full - enables all settings. This will have a big impact on the\n performance - be careful using this option. This requires\n the SUPER privilege.\n If another setting the 'current' is chosen, the current settings\n are restored at the end of the procedure.\n\n\nConfiguration Options\n----------------------\n\nsys.diagnostics.allow_i_s_tables\n Specifies whether it is allowed to do table scan queries on information_schema.TABLES. This can be expensive if there\n are many tables. Set to 'ON' to allow, 'OFF' to not allow.\n Default is 'OFF'.\n\nsys.diagnostics.include_raw\n Set to 'ON' to include the raw data (e.g. the original output of "SELECT * FROM sys.metrics").\n Use this to get the initial values of the various views.\n Default is 'OFF'.\n\nsys.statement_truncate_len\n How much of queries in the process list output to include.\n Default is 64.\n\nsys.debug\n Whether to provide debugging output.\n Default is 'OFF'. Set to 'ON' to include.\n\n\nExample\n--------\n\nTo create a report and append it to the file diag.out:\n\nmysql> TEE diag.out;\nmysql> CALL sys.diagnostics(120, 30, 'current');\n...\nmysql> NOTEE;\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_statement_avg_latency_histogram","def","sys","ps_statement_avg_latency_histogram","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","BEGIN\nSELECT CONCAT('\n',\n '\n . = 1 unit',\n '\n * = 2 units',\n '\n # = 3 units\n',\n @label := CONCAT(@label_inner := CONCAT('\n(0 - ',\n ROUND((@bucket_size := (SELECT ROUND((MAX(avg_us) - MIN(avg_us)) / (@buckets := 16)) AS size\n FROM sys.x$ps_digest_avg_latency_distribution)) / (@unit_div := 1000)),\n (@unit := 'ms'), ')'),\n REPEAT(' ', (@max_label_size := ((1 + LENGTH(ROUND((@bucket_size * 15) / @unit_div)) + 3 + LENGTH(ROUND(@bucket_size * 16) / @unit_div)) + 1)) - LENGTH(@label_inner)),\n @count_in_bucket := IFNULL((SELECT SUM(cnt)\n FROM sys.x$ps_digest_avg_latency_distribution AS b1 \n WHERE b1.avg_us <= @bucket_size), 0)),\n REPEAT(' ', (@max_label_len := (@max_label_size + LENGTH((@total_queries := (SELECT SUM(cnt) FROM sys.x$ps_digest_avg_latency_distribution)))) + 1) - LENGTH(@label)), '| ',\n IFNULL(REPEAT(IF(@count_in_bucket < (@one_unit := 40), '.', IF(@count_in_bucket < (@two_unit := 80), '*', '#')), \n \t IF(@count_in_bucket < @one_unit, @count_in_bucket,\n \t \tIF(@count_in_bucket < @two_unit, @count_in_bucket / 2, @count_in_bucket / 3))), ''),\n @label := CONCAT(@label_inner := CONCAT('\n(', ROUND(@bucket_size / @unit_div), ' - ', ROUND((@bucket_size * 2) / @unit_div), @unit, ')'),\n REPEAT(' ', @max_label_size - LENGTH(@label_inner)),\n @count_in_bucket := IFNULL((SELECT SUM(cnt)\n FROM sys.x$ps_digest_avg_latency_distribution AS b1 \n WHERE b1.avg_us > @bucket_size AND b1.avg_us <= @bucket_size * 2), 0)),\n REPEAT(' ', @max_label_len - LENGTH(@label)), '| ',\n IFNULL(REPEAT(IF(@count_in_bucket < @one_unit, '.', IF(@count_in_bucket < @two_unit, '*', '#')), \n \t IF(@count_in_bucket < @one_unit, @count_in_bucket,\n \t \tIF(@count_in_bucket < @two_unit, @count_in_bucket / 2, @count_in_bucket / 3))), ''),\n @label := CONCAT(@label_inner := CONCAT('\n(', ROUND((@bucket_size * 2) / @unit_div), ' - ', ROUND((@bucket_size * 3) / @unit_div), @unit, ')'),\n REPEAT(' ', @max_label_size - LENGTH(@label_inner)),\n @count_in_bucket := IFNULL((SELECT SUM(cnt)\n FROM sys.x$ps_digest_avg_latency_distribution AS b1 \n WHERE b1.avg_us > @bucket_size * 2 AND b1.avg_us <= @bucket_size * 3), 0)),\n REPEAT(' ', @max_label_len - LENGTH(@label)), '| ',\n IFNULL(REPEAT(IF(@count_in_bucket < @one_unit, '.', IF(@count_in_bucket < @two_unit, '*', '#')), \n \t IF(@count_in_bucket < @one_unit, @count_in_bucket,\n \t \tIF(@count_in_bucket < @two_unit, @count_in_bucket / 2, @count_in_bucket / 3))), ''),\n @label := CONCAT(@label_inner := CONCAT('\n(', ROUND((@bucket_size * 3) / @unit_div), ' - ', ROUND((@bucket_size * 4) / @unit_div), @unit, ')'),\n REPEAT(' ', @max_label_size - LENGTH(@label_inner)),\n @count_in_bucket := IFNULL((SELECT SUM(cnt)\n FROM sys.x$ps_digest_avg_latency_distribution AS b1 \n WHERE b1.avg_us > @bucket_size * 3 AND b1.avg_us <= @bucket_size * 4), 0)),\n REPEAT(' ', @max_label_len - LENGTH(@label)), '| ',\n IFNULL(REPEAT(IF(@count_in_bucket < @one_unit, '.', IF(@count_in_bucket < @two_unit, '*', '#')), \n \t IF(@count_in_bucket < @one_unit, @count_in_bucket,\n \t \tIF(@count_in_bucket < @two_unit, @count_in_bucket / 2, @count_in_bucket / 3))), ''),\n @label := CONCAT(@label_inner := CONCAT('\n(', ROUND((@bucket_size * 4) / @unit_div), ' - ', ROUND((@bucket_size * 5) / @unit_div), @unit, ')'),\n REPEAT(' ', @max_label_size - LENGTH(@label_inner)),\n @count_in_bucket := IFNULL((SELECT SUM(cnt)\n FROM sys.x$ps_digest_avg_latency_distribution AS b1 \n WHERE b1.avg_us > @bucket_size * 4 AND b1.avg_us <= @bucket_size * 5), 0)),\n REPEAT(' ', @max_label_len - LENGTH(@label)), '| ',\n IFNULL(REPEAT(IF(@count_in_bucket < @one_unit, '.', IF(@count_in_bucket < @two_unit, '*', '#')), \n \t IF(@count_in_bucket < @one_unit, @count_in_bucket,\n \t \tIF(@count_in_bucket < @two_unit, @count_in_bucket / 2, @count_in_bucket / 3))), ''),\n @label := CONCAT(@label_inner := CONCAT('\n(', ROUND((@bucket_size * 5) / @unit_div), ' - ', ROUND((@bucket_size * 6) / @unit_div), @unit, ')'),\n REPEAT(' ', @max_label_size - LENGTH(@label_inner)),\n @count_in_bucket := IFNULL((SELECT SUM(cnt)\n FROM sys.x$ps_digest_avg_latency_distribution AS b1 \n WHERE b1.avg_us > @bucket_size * 5 AND b1.avg_us <= @bucket_size * 6), 0)),\n REPEAT(' ', @max_label_len - LENGTH(@label)), '| ',\n IFNULL(REPEAT(IF(@count_in_bucket < @one_unit, '.', IF(@count_in_bucket < @two_unit, '*', '#')), \n \t IF(@count_in_bucket < @one_unit, @count_in_bucket,\n \t \tIF(@count_in_bucket < @two_unit, @count_in_bucket / 2, @count_in_bucket / 3))), ''),\n @label := CONCAT(@label_inner := CONCAT('\n(', ROUND((@bucket_size * 6) / @unit_div), ' - ', ROUND((@bucket_size * 7) / @unit_div), @unit, ')'),\n REPEAT(' ', @max_label_size - LENGTH(@label_inner)),\n @count_in_bucket := IFNULL((SELECT SUM(cnt)\n FROM sys.x$ps_digest_avg_latency_distribution AS b1 \n WHERE b1.avg_us > @bucket_size * 6 AND b1.avg_us <= @bucket_size * 7), 0)),\n REPEAT(' ', @max_label_len - LENGTH(@label)), '| ',\n IFNULL(REPEAT(IF(@count_in_bucket < @one_unit, '.', IF(@count_in_bucket < @two_unit, '*', '#')), \n \t IF(@count_in_bucket < @one_unit, @count_in_bucket,\n \t \tIF(@count_in_bucket < @two_unit, @count_in_bucket / 2, @count_in_bucket / 3))), ''),\n @label := CONCAT(@label_inner := CONCAT('\n(', ROUND((@bucket_size * 7) / @unit_div), ' - ', ROUND((@bucket_size * 8) / @unit_div), @unit, ')'),\n REPEAT(' ', @max_label_size - LENGTH(@label_inner)),\n @count_in_bucket := IFNULL((SELECT SUM(cnt)\n FROM sys.x$ps_digest_avg_latency_distribution AS b1 \n WHERE b1.avg_us > @bucket_size * 7 AND b1.avg_us <= @bucket_size * 8), 0)),\n REPEAT(' ', @max_label_len - LENGTH(@label)), '| ',\n IFNULL(REPEAT(IF(@count_in_bucket < @one_unit, '.', IF(@count_in_bucket < @two_unit, '*', '#')), \n \t IF(@count_in_bucket < @one_unit, @count_in_bucket,\n \t \tIF(@count_in_bucket < @two_unit, @count_in_bucket / 2, @count_in_bucket / 3))), ''),\n @label := CONCAT(@label_inner := CONCAT('\n(', ROUND((@bucket_size * 8) / @unit_div), ' - ', ROUND((@bucket_size * 9) / @unit_div), @unit, ')'),\n REPEAT(' ', @max_label_size - LENGTH(@label_inner)),\n @count_in_bucket := IFNULL((SELECT SUM(cnt)\n FROM sys.x$ps_digest_avg_latency_distribution AS b1 \n WHERE b1.avg_us > @bucket_size * 8 AND b1.avg_us <= @bucket_size * 9), 0)),\n REPEAT(' ', @max_label_len - LENGTH(@label)), '| ',\n IFNULL(REPEAT(IF(@count_in_bucket < @one_unit, '.', IF(@count_in_bucket < @two_unit, '*', '#')), \n \t IF(@count_in_bucket < @one_unit, @count_in_bucket,\n \t \tIF(@count_in_bucket < @two_unit, @count_in_bucket / 2, @count_in_bucket / 3))), ''),\n @label := CONCAT(@label_inner := CONCAT('\n(', ROUND((@bucket_size * 9) / @unit_div), ' - ', ROUND((@bucket_size * 10) / @unit_div), @unit, ')'),\n REPEAT(' ', @max_label_size - LENGTH(@label_inner)),\n @count_in_bucket := IFNULL((SELECT SUM(cnt)\n FROM sys.x$ps_digest_avg_latency_distribution AS b1 \n WHERE b1.avg_us > @bucket_size * 9 AND b1.avg_us <= @bucket_size * 10), 0)),\n REPEAT(' ', @max_label_len - LENGTH(@label)), '| ',\n IFNULL(REPEAT(IF(@count_in_bucket < @one_unit, '.', IF(@count_in_bucket < @two_unit, '*', '#')), \n \t IF(@count_in_bucket < @one_unit, @count_in_bucket,\n \t \tIF(@count_in_bucket < @two_unit, @count_in_bucket / 2, @count_in_bucket / 3))), ''),\n @label := CONCAT(@label_inner := CONCAT('\n(', ROUND((@bucket_size * 10) / @unit_div), ' - ', ROUND((@bucket_size * 11) / @unit_div), @unit, ')'),\n REPEAT(' ', @max_label_size - LENGTH(@label_inner)),\n @count_in_bucket := IFNULL((SELECT SUM(cnt)\n FROM sys.x$ps_digest_avg_latency_distribution AS b1 \n WHERE b1.avg_us > @bucket_size * 10 AND b1.avg_us <= @bucket_size * 11), 0)),\n REPEAT(' ', @max_label_len - LENGTH(@label)), '| ',\n IFNULL(REPEAT(IF(@count_in_bucket < @one_unit, '.', IF(@count_in_bucket < @two_unit, '*', '#')), \n \t IF(@count_in_bucket < @one_unit, @count_in_bucket,\n \t \tIF(@count_in_bucket < @two_unit, @count_in_bucket / 2, @count_in_bucket / 3))), ''),\n @label := CONCAT(@label_inner := CONCAT('\n(', ROUND((@bucket_size * 11) / @unit_div), ' - ', ROUND((@bucket_size * 12) / @unit_div), @unit, ')'),\n REPEAT(' ', @max_label_size - LENGTH(@label_inner)),\n @count_in_bucket := IFNULL((SELECT SUM(cnt)\n FROM sys.x$ps_digest_avg_latency_distribution AS b1 \n WHERE b1.avg_us > @bucket_size * 11 AND b1.avg_us <= @bucket_size * 12), 0)),\n REPEAT(' ', @max_label_len - LENGTH(@label)), '| ',\n IFNULL(REPEAT(IF(@count_in_bucket < @one_unit, '.', IF(@count_in_bucket < @two_unit, '*', '#')), \n \t IF(@count_in_bucket < @one_unit, @count_in_bucket,\n \t \tIF(@count_in_bucket < @two_unit, @count_in_bucket / 2, @count_in_bucket / 3))), ''),\n @label := CONCAT(@label_inner := CONCAT('\n(', ROUND((@bucket_size * 12) / @unit_div), ' - ', ROUND((@bucket_size * 13) / @unit_div), @unit, ')'),\n REPEAT(' ', @max_label_size - LENGTH(@label_inner)),\n @count_in_bucket := IFNULL((SELECT SUM(cnt)\n FROM sys.x$ps_digest_avg_latency_distribution AS b1 \n WHERE b1.avg_us > @bucket_size * 12 AND b1.avg_us <= @bucket_size * 13), 0)),\n REPEAT(' ', @max_label_len - LENGTH(@label)), '| ',\n IFNULL(REPEAT(IF(@count_in_bucket < @one_unit, '.', IF(@count_in_bucket < @two_unit, '*', '#')), \n \t IF(@count_in_bucket < @one_unit, @count_in_bucket,\n \t \tIF(@count_in_bucket < @two_unit, @count_in_bucket / 2, @count_in_bucket / 3))), ''),\n @label := CONCAT(@label_inner := CONCAT('\n(', ROUND((@bucket_size * 13) / @unit_div), ' - ', ROUND((@bucket_size * 14) / @unit_div), @unit, ')'),\n REPEAT(' ', @max_label_size - LENGTH(@label_inner)),\n @count_in_bucket := IFNULL((SELECT SUM(cnt)\n FROM sys.x$ps_digest_avg_latency_distribution AS b1 \n WHERE b1.avg_us > @bucket_size * 13 AND b1.avg_us <= @bucket_size * 14), 0)),\n REPEAT(' ', @max_label_len - LENGTH(@label)), '| ',\n IFNULL(REPEAT(IF(@count_in_bucket < @one_unit, '.', IF(@count_in_bucket < @two_unit, '*', '#')), \n \t IF(@count_in_bucket < @one_unit, @count_in_bucket,\n \t \tIF(@count_in_bucket < @two_unit, @count_in_bucket / 2, @count_in_bucket / 3))), ''),\n @label := CONCAT(@label_inner := CONCAT('\n(', ROUND((@bucket_size * 14) / @unit_div), ' - ', ROUND((@bucket_size * 15) / @unit_div), @unit, ')'),\n REPEAT(' ', @max_label_size - LENGTH(@label_inner)),\n @count_in_bucket := IFNULL((SELECT SUM(cnt)\n FROM sys.x$ps_digest_avg_latency_distribution AS b1 \n WHERE b1.avg_us > @bucket_size * 14 AND b1.avg_us <= @bucket_size * 15), 0)),\n REPEAT(' ', @max_label_len - LENGTH(@label)), '| ',\n IFNULL(REPEAT(IF(@count_in_bucket < @one_unit, '.', IF(@count_in_bucket < @two_unit, '*', '#')), \n \t IF(@count_in_bucket < @one_unit, @count_in_bucket,\n \t \tIF(@count_in_bucket < @two_unit, @count_in_bucket / 2, @count_in_bucket / 3))), ''),\n @label := CONCAT(@label_inner := CONCAT('\n(', ROUND((@bucket_size * 15) / @unit_div), ' - ', ROUND((@bucket_size * 16) / @unit_div), @unit, ')'),\n REPEAT(' ', @max_label_size - LENGTH(@label_inner)),\n @count_in_bucket := IFNULL((SELECT SUM(cnt)\n FROM sys.x$ps_digest_avg_latency_distribution AS b1 \n WHERE b1.avg_us > @bucket_size * 15 AND b1.avg_us <= @bucket_size * 16), 0)),\n REPEAT(' ', @max_label_len - LENGTH(@label)), '| ',\n IFNULL(REPEAT(IF(@count_in_bucket < @one_unit, '.', IF(@count_in_bucket < @two_unit, '*', '#')), \n \t IF(@count_in_bucket < @one_unit, @count_in_bucket,\n \t \tIF(@count_in_bucket < @two_unit, @count_in_bucket / 2, @count_in_bucket / 3))), ''),\n '\n\n Total Statements: ', @total_queries, '; Buckets: ', @buckets , '; Bucket Size: ', ROUND(@bucket_size / @unit_div) , ' ', @unit, ';\n'\n ) AS `Performance Schema Statement Digest Average Latency Histogram`;\nEND","NULL","SQL","SQL","NO","READS SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nOutputs a textual histogram graph of the average latency values\nacross all normalized queries tracked within the Performance Schema\nevents_statements_summary_by_digest table.\n\nCan be used to show a very high level picture of what kind of \nlatency distribution statements running within this instance have.\n\nParameters\n-----------\n\nNone.\n\nExample\n-----------\n\nmysql> CALL sys.ps_statement_avg_latency_histogram()\\G\n*************************** 1. row ***************************\nPerformance Schema Statement Digest Average Latency Histogram:\n\n . = 1 unit\n * = 2 units\n # = 3 units\n\n(0 - 38ms) 240 | ################################################################################\n(38 - 77ms) 38 | ......................................\n(77 - 115ms) 3 | ...\n(115 - 154ms) 62 | *******************************\n(154 - 192ms) 3 | ...\n(192 - 231ms) 0 |\n(231 - 269ms) 0 |\n(269 - 307ms) 0 |\n(307 - 346ms) 0 |\n(346 - 384ms) 1 | .\n(384 - 423ms) 1 | .\n(423 - 461ms) 0 |\n(461 - 499ms) 0 |\n(499 - 538ms) 0 |\n(538 - 576ms) 0 |\n(576 - 615ms) 1 | .\n\n Total Statements: 350; Buckets: 16; Bucket Size: 38 ms;\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_trace_statement_digest","def","sys","ps_trace_statement_digest","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","BEGIN\n DECLARE v_start_fresh BOOLEAN DEFAULT false;\n DECLARE v_auto_enable BOOLEAN DEFAULT false;\n DECLARE v_explain BOOLEAN DEFAULT true;\n DECLARE v_this_thread_enabed ENUM('YES', 'NO');\n DECLARE v_runtime INT DEFAULT 0;\n DECLARE v_start INT DEFAULT 0;\n DECLARE v_found_stmts INT;\n SET @log_bin := @@sql_log_bin;\n SET sql_log_bin = 0;\n -- Do not track the current thread, it will kill the stack\n SELECT INSTRUMENTED INTO v_this_thread_enabed FROM performance_schema.threads WHERE PROCESSLIST_ID = CONNECTION_ID();\n CALL sys.ps_setup_disable_thread(CONNECTION_ID());\n DROP TEMPORARY TABLE IF EXISTS stmt_trace;\n CREATE TEMPORARY TABLE stmt_trace (\n thread_id BIGINT UNSIGNED,\n timer_start BIGINT UNSIGNED,\n event_id BIGINT UNSIGNED,\n sql_text longtext,\n timer_wait BIGINT UNSIGNED,\n lock_time BIGINT UNSIGNED,\n errors BIGINT UNSIGNED,\n mysql_errno INT,\n rows_sent BIGINT UNSIGNED,\n rows_affected BIGINT UNSIGNED,\n rows_examined BIGINT UNSIGNED,\n created_tmp_tables BIGINT UNSIGNED,\n created_tmp_disk_tables BIGINT UNSIGNED,\n no_index_used BIGINT UNSIGNED,\n PRIMARY KEY (thread_id, timer_start)\n );\n DROP TEMPORARY TABLE IF EXISTS stmt_stages;\n CREATE TEMPORARY TABLE stmt_stages (\n event_id BIGINT UNSIGNED,\n stmt_id BIGINT UNSIGNED,\n event_name VARCHAR(128),\n timer_wait BIGINT UNSIGNED,\n PRIMARY KEY (event_id)\n );\n SET v_start_fresh = in_start_fresh;\n IF v_start_fresh THEN\n TRUNCATE TABLE performance_schema.events_statements_history_long;\n TRUNCATE TABLE performance_schema.events_stages_history_long;\n END IF;\n SET v_auto_enable = in_auto_enable;\n IF v_auto_enable THEN\n CALL sys.ps_setup_save(0);\n UPDATE performance_schema.threads\n SET INSTRUMENTED = IF(PROCESSLIST_ID IS NOT NULL, 'YES', 'NO');\n -- Only the events_statements_history_long and events_stages_history_long tables and their ancestors are needed\n UPDATE performance_schema.setup_consumers\n SET ENABLED = 'YES'\n WHERE NAME NOT LIKE '%\\_history'\n AND NAME NOT LIKE 'events_wait%'\n AND NAME NOT LIKE 'events_transactions%'\n AND NAME <> 'statements_digest';\n UPDATE performance_schema.setup_instruments\n SET ENABLED = 'YES',\n TIMED = 'YES'\n WHERE NAME LIKE 'statement/%' OR NAME LIKE 'stage/%';\n END IF;\n WHILE v_runtime < in_runtime DO\n SELECT UNIX_TIMESTAMP() INTO v_start;\n INSERT IGNORE INTO stmt_trace\n SELECT thread_id, timer_start, event_id, sql_text, timer_wait, lock_time, errors, mysql_errno, \n rows_sent, rows_affected, rows_examined, created_tmp_tables, created_tmp_disk_tables, no_index_used\n FROM performance_schema.events_statements_history_long\n WHERE digest = in_digest;\n INSERT IGNORE INTO stmt_stages\n SELECT stages.event_id, stmt_trace.event_id,\n stages.event_name, stages.timer_wait\n FROM performance_schema.events_stages_history_long AS stages\n JOIN stmt_trace ON stages.nesting_event_id = stmt_trace.event_id;\n SELECT SLEEP(in_interval) INTO @sleep;\n SET v_runtime = v_runtime + (UNIX_TIMESTAMP() - v_start);\n END WHILE;\n SELECT "SUMMARY STATISTICS";\n SELECT COUNT(*) executions,\n format_pico_time(SUM(timer_wait)) AS exec_time,\n format_pico_time(SUM(lock_time)) AS lock_time,\n SUM(rows_sent) AS rows_sent,\n SUM(rows_affected) AS rows_affected,\n SUM(rows_examined) AS rows_examined,\n SUM(created_tmp_tables) AS tmp_tables,\n SUM(no_index_used) AS full_scans\n FROM stmt_trace;\n SELECT event_name,\n COUNT(*) as count,\n format_pico_time(SUM(timer_wait)) as latency\n FROM stmt_stages\n GROUP BY event_name\n ORDER BY SUM(timer_wait) DESC;\n SELECT "LONGEST RUNNING STATEMENT";\n SELECT thread_id,\n format_pico_time(timer_wait) AS exec_time,\n format_pico_time(lock_time) AS lock_time,\n rows_sent,\n rows_affected,\n rows_examined,\n created_tmp_tables AS tmp_tables,\n no_index_used AS full_scan\n FROM stmt_trace\n ORDER BY timer_wait DESC LIMIT 1;\n SELECT sql_text\n FROM stmt_trace\n ORDER BY timer_wait DESC LIMIT 1;\n SELECT sql_text, event_id INTO @sql, @sql_id\n FROM stmt_trace\n ORDER BY timer_wait DESC LIMIT 1;\n IF (@sql_id IS NOT NULL) THEN\n SELECT event_name,\n format_pico_time(timer_wait) as latency\n FROM stmt_stages\n WHERE stmt_id = @sql_id\n ORDER BY event_id;\n END IF;\n DROP TEMPORARY TABLE stmt_trace;\n DROP TEMPORARY TABLE stmt_stages;\n IF (@sql IS NOT NULL) THEN\n SET @stmt := CONCAT("EXPLAIN FORMAT=JSON ", @sql);\n BEGIN\n -- Not all queries support EXPLAIN, so catch the cases that are\n -- not supported. Currently that includes cases where the table\n -- is not fully qualified and is not in the default schema for this\n -- procedure as it's not possible to change the default schema inside\n -- a procedure.\n --\n -- Errno = 1064: You have an error in your SQL syntax\n -- Errno = 1146: Table '...' doesn't exist\n DECLARE CONTINUE HANDLER FOR 1064, 1146 SET v_explain = false;\n PREPARE explain_stmt FROM @stmt;\n END;\n IF (v_explain) THEN\n EXECUTE explain_stmt;\n DEALLOCATE PREPARE explain_stmt;\n END IF;\n END IF;\n IF v_auto_enable THEN\n CALL sys.ps_setup_reload_saved();\n END IF;\n -- Restore INSTRUMENTED for this thread\n IF (v_this_thread_enabed = 'YES') THEN\n CALL sys.ps_setup_enable_thread(CONNECTION_ID());\n END IF;\n SET sql_log_bin = @log_bin;\nEND","NULL","SQL","SQL","NO","MODIFIES SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nTraces all instrumentation within Performance Schema for a specific\nStatement Digest.\n\nWhen finding a statement of interest within the\nperformance_schema.events_statements_summary_by_digest table, feed\nthe DIGEST value in to this procedure, set how long to poll for,\nand at what interval to poll, and it will generate a report of all\nstatistics tracked within Performance Schema for that digest for the\ninterval.\n\nIt will also attempt to generate an EXPLAIN for the longest running\nexample of the digest during the interval. Note this may fail, as:\n\n * Performance Schema truncates long SQL_TEXT values (and hence the\n EXPLAIN will fail due to parse errors)\n * the default schema is sys (so tables that are not fully qualified\n in the query may not be found)\n * some queries such as SHOW are not supported in EXPLAIN.\n\nWhen the EXPLAIN fails, the error will be ignored and no EXPLAIN\noutput generated.\n\nRequires the SUPER privilege for "SET sql_log_bin = 0;".\n\nParameters\n-----------\n\nin_digest (VARCHAR(64)):\n The statement digest identifier you would like to analyze\nin_runtime (INT):\n The number of seconds to run analysis for\nin_interval (DECIMAL(2,2)):\n The interval (in seconds, may be fractional) at which to try\n and take snapshots\nin_start_fresh (BOOLEAN):\n Whether to TRUNCATE the events_statements_history_long and\n events_stages_history_long tables before starting\nin_auto_enable (BOOLEAN):\n Whether to automatically turn on required consumers\n\nExample\n-----------\n\nmysql> call ps_trace_statement_digest('891ec6860f98ba46d89dd20b0c03652c', 10, 0.1, true, true);\n+--------------------+\n| SUMMARY STATISTICS |\n+--------------------+\n| SUMMARY STATISTICS |\n+--------------------+\n1 row in set (9.11 sec)\n\n+------------+-----------+-----------+-----------+---------------+------------+------------+\n| executions | exec_time | lock_time | rows_sent | rows_examined | tmp_tables | full_scans |\n+------------+-----------+-----------+-----------+---------------+------------+------------+\n| 21 | 4.11 ms | 2.00 ms | 0 | 21 | 0 | 0 |\n+------------+-----------+-----------+-----------+---------------+------------+------------+\n1 row in set (9.11 sec)\n\n+------------------------------------------+-------+-----------+\n| event_name | count | latency |\n+------------------------------------------+-------+-----------+\n| stage/sql/checking query cache for query | 16 | 724.37 us |\n| stage/sql/statistics | 16 | 546.92 us |\n| stage/sql/freeing items | 18 | 520.11 us |\n| stage/sql/init | 51 | 466.80 us |\n...\n| stage/sql/cleaning up | 18 | 11.92 us |\n| stage/sql/executing | 16 | 6.95 us |\n+------------------------------------------+-------+-----------+\n17 rows in set (9.12 sec)\n\n+---------------------------+\n| LONGEST RUNNING STATEMENT |\n+---------------------------+\n| LONGEST RUNNING STATEMENT |\n+---------------------------+\n1 row in set (9.16 sec)\n\n+-----------+-----------+-----------+-----------+---------------+------------+-----------+\n| thread_id | exec_time | lock_time | rows_sent | rows_examined | tmp_tables | full_scan |\n+-----------+-----------+-----------+-----------+---------------+------------+-----------+\n| 166646 | 618.43 us | 1.00 ms | 0 | 1 | 0 | 0 |\n+-----------+-----------+-----------+-----------+---------------+------------+-----------+\n1 row in set (9.16 sec)\n\n// Truncated for clarity...\n+-----------------------------------------------------------------+\n| sql_text |\n+-----------------------------------------------------------------+\n| select hibeventhe0_.id as id1382_, hibeventhe0_.createdTime ... |\n+-----------------------------------------------------------------+\n1 row in set (9.17 sec)\n\n+------------------------------------------+-----------+\n| event_name | latency |\n+------------------------------------------+-----------+\n| stage/sql/init | 8.61 us |\n| stage/sql/Waiting for query cache lock | 453.23 us |\n| stage/sql/init | 331.07 ns |\n| stage/sql/checking query cache for query | 43.04 us |\n...\n| stage/sql/freeing items | 30.46 us |\n| stage/sql/cleaning up | 662.13 ns |\n+------------------------------------------+-----------+\n18 rows in set (9.23 sec)\n\n+----+-------------+--------------+-------+---------------+-----------+---------+-------------+------+-------+\n| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |\n+----+-------------+--------------+-------+---------------+-----------+---------+-------------+------+-------+\n| 1 | SIMPLE | hibeventhe0_ | const | fixedTime | fixedTime | 775 | const,const | 1 | NULL |\n+----+-------------+--------------+-------+---------------+-----------+---------+-------------+------+-------+\n1 row in set (9.27 sec)\n\nQuery OK, 0 rows affected (9.28 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_trace_thread","def","sys","ps_trace_thread","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","BEGIN\n DECLARE v_done bool DEFAULT FALSE;\n DECLARE v_start, v_runtime DECIMAL(20,2) DEFAULT 0.0;\n DECLARE v_min_event_id bigint unsigned DEFAULT 0;\n DECLARE v_this_thread_enabed ENUM('YES', 'NO');\n DECLARE v_event longtext;\n DECLARE c_stack CURSOR FOR\n SELECT CONCAT(IF(nesting_event_id IS NOT NULL, CONCAT(nesting_event_id, ' -> '), ''), \n event_id, '; ', event_id, ' [label="',\n -- Convert from picoseconds to microseconds\n '(', format_pico_time(timer_wait), ') ',\n IF (event_name NOT LIKE 'wait/io%', \n SUBSTRING_INDEX(event_name, '/', -2), \n IF (event_name NOT LIKE 'wait/io/file%' OR event_name NOT LIKE 'wait/io/socket%',\n SUBSTRING_INDEX(event_name, '/', -4),\n event_name)\n ),\n -- Always dump the extra wait information gathered for transactions and statements\n IF (event_name LIKE 'transaction', IFNULL(CONCAT('\\n', wait_info), ''), ''),\n IF (event_name LIKE 'statement/%', IFNULL(CONCAT('\\n', wait_info), ''), ''),\n -- If debug is enabled, add the file:lineno information for waits\n IF (in_debug AND event_name LIKE 'wait%', wait_info, ''),\n '", ', \n -- Depending on the type of event, style appropriately\n CASE WHEN event_name LIKE 'wait/io/file%' THEN \n 'shape=box, style=filled, color=red'\n WHEN event_name LIKE 'wait/io/table%' THEN \n 'shape=box, style=filled, color=green'\n WHEN event_name LIKE 'wait/io/socket%' THEN\n 'shape=box, style=filled, color=yellow'\n WHEN event_name LIKE 'wait/synch/mutex%' THEN\n 'style=filled, color=lightskyblue'\n WHEN event_name LIKE 'wait/synch/cond%' THEN\n 'style=filled, color=darkseagreen3'\n WHEN event_name LIKE 'wait/synch/rwlock%' THEN\n 'style=filled, color=orchid'\n WHEN event_name LIKE 'wait/synch/sxlock%' THEN\n 'style=filled, color=palevioletred' \n WHEN event_name LIKE 'wait/lock%' THEN\n 'shape=box, style=filled, color=tan'\n WHEN event_name LIKE 'statement/%' THEN\n CONCAT('shape=box, style=bold',\n -- Style statements depending on COM vs SQL\n CASE WHEN event_name LIKE 'statement/com/%' THEN\n ' style=filled, color=darkseagreen'\n ELSE\n -- Use long query time from the server to\n -- flag long running statements in red\n IF((timer_wait/1000000000000) > @@long_query_time, \n ' style=filled, color=red', \n ' style=filled, color=lightblue')\n END\n )\n WHEN event_name LIKE 'transaction' THEN\n 'shape=box, style=filled, color=lightblue3'\n WHEN event_name LIKE 'stage/%' THEN\n 'style=filled, color=slategray3'\n -- IDLE events are on their own, call attention to them\n WHEN event_name LIKE '%idle%' THEN\n 'shape=box, style=filled, color=firebrick3'\n ELSE '' END,\n '];\n'\n ) event, event_id\n FROM (\n -- Select all transactions\n (SELECT thread_id, event_id, event_name, timer_wait, timer_start, nesting_event_id,\n CONCAT('trx_id: ', IFNULL(trx_id, ''), '\\n',\n 'gtid: ', IFNULL(gtid, ''), '\\n',\n 'state: ', state, '\\n',\n 'mode: ', access_mode, '\\n',\n 'isolation: ', isolation_level, '\\n',\n 'autocommit: ', autocommit, '\\n',\n 'savepoints: ', number_of_savepoints, '\\n'\n ) AS wait_info\n FROM performance_schema.events_transactions_history_long\n WHERE thread_id = in_thread_id AND event_id > v_min_event_id)\n UNION\n -- Select all statements, with the extra tracing information available\n (SELECT thread_id, event_id, event_name, timer_wait, timer_start, nesting_event_id, \n CONCAT('statement: ', sql_text, '\\n',\n 'errors: ', errors, '\\n',\n 'warnings: ', warnings, '\\n',\n 'lock time: ', format_pico_time(lock_time),'\\n',\n 'rows affected: ', rows_affected, '\\n',\n 'rows sent: ', rows_sent, '\\n',\n 'rows examined: ', rows_examined, '\\n',\n 'tmp tables: ', created_tmp_tables, '\\n',\n 'tmp disk tables: ', created_tmp_disk_tables, '\\n'\n 'select scan: ', select_scan, '\\n',\n 'select full join: ', select_full_join, '\\n',\n 'select full range join: ', select_full_range_join, '\\n',\n 'select range: ', select_range, '\\n',\n 'select range check: ', select_range_check, '\\n', \n 'sort merge passes: ', sort_merge_passes, '\\n',\n 'sort rows: ', sort_rows, '\\n',\n 'sort range: ', sort_range, '\\n',\n 'sort scan: ', sort_scan, '\\n',\n 'no index used: ', IF(no_index_used, 'TRUE', 'FALSE'), '\\n',\n 'no good index used: ', IF(no_good_index_used, 'TRUE', 'FALSE'), '\\n'\n ) AS wait_info\n FROM performance_schema.events_statements_history_long\n WHERE thread_id = in_thread_id AND event_id > v_min_event_id)\n UNION\n -- Select all stages\n (SELECT thread_id, event_id, event_name, timer_wait, timer_start, nesting_event_id, null AS wait_info\n FROM performance_schema.events_stages_history_long \n WHERE thread_id = in_thread_id AND event_id > v_min_event_id)\n UNION \n -- Select all events, adding information appropriate to the event\n (SELECT thread_id, event_id, \n CONCAT(event_name, \n IF(event_name NOT LIKE 'wait/synch/mutex%', IFNULL(CONCAT(' - ', operation), ''), ''), \n IF(number_of_bytes IS NOT NULL, CONCAT(' ', number_of_bytes, ' bytes'), ''),\n IF(event_name LIKE 'wait/io/file%', '\\n', ''),\n IF(object_schema IS NOT NULL, CONCAT('\\nObject: ', object_schema, '.'), ''), \n IF(object_name IS NOT NULL, \n IF (event_name LIKE 'wait/io/socket%',\n -- Print the socket if used, else the IP:port as reported\n CONCAT('\\n', IF (object_name LIKE ':0%', @@socket, object_name)),\n object_name),\n ''\n ),\n IF(index_name IS NOT NULL, CONCAT(' Index: ', index_name), ''), '\\n'\n ) AS event_name,\n timer_wait, timer_start, nesting_event_id, source AS wait_info\n FROM performance_schema.events_waits_history_long\n WHERE thread_id = in_thread_id AND event_id > v_min_event_id)\n ) events \n ORDER BY event_id;\n DECLARE CONTINUE HANDLER FOR NOT FOUND SET v_done = TRUE;\n SET @log_bin := @@sql_log_bin;\n SET sql_log_bin = 0;\n -- Do not track the current thread, it will kill the stack\n SELECT INSTRUMENTED INTO v_this_thread_enabed FROM performance_schema.threads WHERE PROCESSLIST_ID = CONNECTION_ID();\n CALL sys.ps_setup_disable_thread(CONNECTION_ID());\n IF (in_auto_setup) THEN\n CALL sys.ps_setup_save(0);\n -- Ensure only the thread to create the stack trace for is instrumented and that we instrument everything.\n DELETE FROM performance_schema.setup_actors;\n UPDATE performance_schema.threads\n SET INSTRUMENTED = IF(THREAD_ID = in_thread_id, 'YES', 'NO');\n -- only the %_history_long tables and it ancestors are needed\n UPDATE performance_schema.setup_consumers\n SET ENABLED = 'YES'\n WHERE NAME NOT LIKE '%\\_history';\n UPDATE performance_schema.setup_instruments\n SET ENABLED = 'YES',\n TIMED = 'YES';\n END IF;\n IF (in_start_fresh) THEN\n TRUNCATE performance_schema.events_transactions_history_long;\n TRUNCATE performance_schema.events_statements_history_long;\n TRUNCATE performance_schema.events_stages_history_long;\n TRUNCATE performance_schema.events_waits_history_long;\n END IF;\n DROP TEMPORARY TABLE IF EXISTS tmp_events;\n CREATE TEMPORARY TABLE tmp_events (\n event_id bigint unsigned NOT NULL,\n event longblob,\n PRIMARY KEY (event_id)\n );\n -- Print headers for a .dot file\n INSERT INTO tmp_events VALUES (0, CONCAT('digraph events { rankdir=LR; nodesep=0.10;\n',\n '// Stack created .....: ', NOW(), '\n',\n '// MySQL version .....: ', VERSION(), '\n',\n '// MySQL hostname ....: ', @@hostname, '\n',\n '// MySQL port ........: ', @@port, '\n',\n '// MySQL socket ......: ', @@socket, '\n',\n '// MySQL user ........: ', CURRENT_USER(), '\n'));\n SELECT CONCAT('Data collection starting for THREAD_ID = ', in_thread_id) AS 'Info';\n SET v_min_event_id = 0,\n v_start = UNIX_TIMESTAMP(),\n in_interval = IFNULL(in_interval, 1.00),\n in_max_runtime = IFNULL(in_max_runtime, 60.00);\n WHILE (v_runtime < in_max_runtime\n AND (SELECT INSTRUMENTED FROM performance_schema.threads WHERE THREAD_ID = in_thread_id) = 'YES') DO\n SET v_done = FALSE;\n OPEN c_stack;\n c_stack_loop: LOOP\n FETCH c_stack INTO v_event, v_min_event_id;\n IF v_done THEN\n LEAVE c_stack_loop;\n END IF;\n IF (LENGTH(v_event) > 0) THEN\n INSERT INTO tmp_events VALUES (v_min_event_id, v_event);\n END IF;\n END LOOP;\n CLOSE c_stack;\n SELECT SLEEP(in_interval) INTO @sleep;\n SET v_runtime = (UNIX_TIMESTAMP() - v_start);\n END WHILE;\n INSERT INTO tmp_events VALUES (v_min_event_id+1, '}');\n SET @query = CONCAT('SELECT event FROM tmp_events ORDER BY event_id INTO OUTFILE '', in_outfile, '' FIELDS ESCAPED BY '' LINES TERMINATED BY ''');\n PREPARE stmt_output FROM @query;\n EXECUTE stmt_output;\n DEALLOCATE PREPARE stmt_output;\n SELECT CONCAT('Stack trace written to ', in_outfile) AS 'Info';\n SELECT CONCAT('dot -Tpdf -o /tmp/stack_', in_thread_id, '.pdf ', in_outfile) AS 'Convert to PDF';\n SELECT CONCAT('dot -Tpng -o /tmp/stack_', in_thread_id, '.png ', in_outfile) AS 'Convert to PNG';\n DROP TEMPORARY TABLE tmp_events;\n -- Reset the settings for the performance schema\n IF (in_auto_setup) THEN\n CALL sys.ps_setup_reload_saved();\n END IF;\n -- Restore INSTRUMENTED for this thread\n IF (v_this_thread_enabed = 'YES') THEN\n CALL sys.ps_setup_enable_thread(CONNECTION_ID());\n END IF;\n SET sql_log_bin = @log_bin;\nEND","NULL","SQL","SQL","NO","MODIFIES SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nDumps all data within Performance Schema for an instrumented thread,\nto create a DOT formatted graph file. \n\nEach resultset returned from the procedure should be used for a complete graph\n\nRequires the SUPER privilege for "SET sql_log_bin = 0;".\n\nParameters\n-----------\n\nin_thread_id (BIGINT UNSIGNED):\n The thread that you would like a stack trace for\nin_outfile (VARCHAR(255)):\n The filename the dot file will be written to\nin_max_runtime (DECIMAL(20,2)):\n The maximum time to keep collecting data.\n Use NULL to get the default which is 60 seconds.\nin_interval (DECIMAL(20,2)): \n How long to sleep between data collections. \n Use NULL to get the default which is 1 second.\nin_start_fresh (BOOLEAN):\n Whether to reset all Performance Schema data before tracing.\nin_auto_setup (BOOLEAN):\n Whether to disable all other threads and enable all consumers/instruments. \n This will also reset the settings at the end of the run.\nin_debug (BOOLEAN):\n Whether you would like to include file:lineno in the graph\n\nExample\n-----------\n\nmysql> CALL sys.ps_trace_thread(25, CONCAT('/tmp/stack-', REPLACE(NOW(), ' ', '-'), '.dot'), NULL, NULL, TRUE, TRUE, TRUE);\n+-------------------+\n| summary |\n+-------------------+\n| Disabled 1 thread |\n+-------------------+\n1 row in set (0.00 sec)\n\n+---------------------------------------------+\n| Info |\n+---------------------------------------------+\n| Data collection starting for THREAD_ID = 25 |\n+---------------------------------------------+\n1 row in set (0.03 sec)\n\n+-----------------------------------------------------------+\n| Info |\n+-----------------------------------------------------------+\n| Stack trace written to /tmp/stack-2014-02-16-21:18:41.dot |\n+-----------------------------------------------------------+\n1 row in set (60.07 sec)\n\n+-------------------------------------------------------------------+\n| Convert to PDF |\n+-------------------------------------------------------------------+\n| dot -Tpdf -o /tmp/stack_25.pdf /tmp/stack-2014-02-16-21:18:41.dot |\n+-------------------------------------------------------------------+\n1 row in set (60.07 sec)\n\n+-------------------------------------------------------------------+\n| Convert to PNG |\n+-------------------------------------------------------------------+\n| dot -Tpng -o /tmp/stack_25.png /tmp/stack-2014-02-16-21:18:41.dot |\n+-------------------------------------------------------------------+\n1 row in set (60.07 sec)\n\n+------------------+\n| summary |\n+------------------+\n| Enabled 1 thread |\n+------------------+\n1 row in set (60.32 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_setup_disable_background_threads","def","sys","ps_setup_disable_background_threads","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","BEGIN\n UPDATE performance_schema.threads\n SET instrumented = 'NO'\n WHERE type = 'BACKGROUND';\n SELECT CONCAT('Disabled ', @rows := ROW_COUNT(), ' background thread', IF(@rows != 1, 's', '')) AS summary;\nEND","NULL","SQL","SQL","NO","MODIFIES SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nDisable all background thread instrumentation within Performance Schema.\n\nParameters\n-----------\n\nNone.\n\nExample\n-----------\n\nmysql> CALL sys.ps_setup_disable_background_threads();\n+--------------------------------+\n| summary |\n+--------------------------------+\n| Disabled 18 background threads |\n+--------------------------------+\n1 row in set (0.00 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_setup_disable_consumer","def","sys","ps_setup_disable_consumer","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","BEGIN\n UPDATE performance_schema.setup_consumers\n SET enabled = 'NO'\n WHERE name LIKE CONCAT('%', consumer, '%');\n SELECT CONCAT('Disabled ', @rows := ROW_COUNT(), ' consumer', IF(@rows != 1, 's', '')) AS summary;\nEND","NULL","SQL","SQL","NO","MODIFIES SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nDisables consumers within Performance Schema \nmatching the input pattern.\n\nParameters\n-----------\n\nconsumer (VARCHAR(128)):\n A LIKE pattern match (using "%consumer%") of consumers to disable\n\nExample\n-----------\n\nTo disable all consumers:\n\nmysql> CALL sys.ps_setup_disable_consumer('');\n+--------------------------+\n| summary |\n+--------------------------+\n| Disabled 15 consumers |\n+--------------------------+\n1 row in set (0.02 sec)\n\nTo disable just the event_stage consumers:\n\nmysql> CALL sys.ps_setup_disable_comsumers('stage');\n+------------------------+\n| summary |\n+------------------------+\n| Disabled 3 consumers |\n+------------------------+\n1 row in set (0.00 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_setup_disable_instrument","def","sys","ps_setup_disable_instrument","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","BEGIN\n UPDATE performance_schema.setup_instruments\n SET enabled = 'NO', timed = 'NO'\n WHERE name LIKE CONCAT('%', in_pattern, '%');\n SELECT CONCAT('Disabled ', @rows := ROW_COUNT(), ' instrument', IF(@rows != 1, 's', '')) AS summary;\nEND","NULL","SQL","SQL","NO","MODIFIES SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nDisables instruments within Performance Schema \nmatching the input pattern.\n\nParameters\n-----------\n\nin_pattern (VARCHAR(128)):\n A LIKE pattern match (using "%in_pattern%") of events to disable\n\nExample\n-----------\n\nTo disable all mutex instruments:\n\nmysql> CALL sys.ps_setup_disable_instrument('wait/synch/mutex');\n+--------------------------+\n| summary |\n+--------------------------+\n| Disabled 155 instruments |\n+--------------------------+\n1 row in set (0.02 sec)\n\nTo disable just a specific TCP/IP based network IO instrument:\n\nmysql> CALL sys.ps_setup_disable_instrument('wait/io/socket/sql/server_tcpip_socket');\n+------------------------+\n| summary |\n+------------------------+\n| Disabled 1 instruments |\n+------------------------+\n1 row in set (0.00 sec)\n\nTo disable all instruments:\n\nmysql> CALL sys.ps_setup_disable_instrument('');\n+--------------------------+\n| summary |\n+--------------------------+\n| Disabled 547 instruments |\n+--------------------------+\n1 row in set (0.01 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_setup_disable_thread","def","sys","ps_setup_disable_thread","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","BEGIN\n UPDATE performance_schema.threads\n SET instrumented = 'NO'\n WHERE processlist_id = in_connection_id;\n SELECT CONCAT('Disabled ', @rows := ROW_COUNT(), ' thread', IF(@rows != 1, 's', '')) AS summary;\nEND","NULL","SQL","SQL","NO","MODIFIES SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nDisable the given connection/thread in Performance Schema.\n\nParameters\n-----------\n\nin_connection_id (BIGINT):\n The connection ID (PROCESSLIST_ID from performance_schema.threads\n or the ID shown within SHOW PROCESSLIST)\n\nExample\n-----------\n\nmysql> CALL sys.ps_setup_disable_thread(3);\n+-------------------+\n| summary |\n+-------------------+\n| Disabled 1 thread |\n+-------------------+\n1 row in set (0.01 sec)\n\nTo disable the current connection:\n\nmysql> CALL sys.ps_setup_disable_thread(CONNECTION_ID());\n+-------------------+\n| summary |\n+-------------------+\n| Disabled 1 thread |\n+-------------------+\n1 row in set (0.00 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_setup_enable_background_threads","def","sys","ps_setup_enable_background_threads","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","BEGIN\n UPDATE performance_schema.threads\n SET instrumented = 'YES'\n WHERE type = 'BACKGROUND';\n SELECT CONCAT('Enabled ', @rows := ROW_COUNT(), ' background thread', IF(@rows != 1, 's', '')) AS summary;\nEND","NULL","SQL","SQL","NO","MODIFIES SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nEnable all background thread instrumentation within Performance Schema.\n\nParameters\n-----------\n\nNone.\n\nExample\n-----------\n\nmysql> CALL sys.ps_setup_enable_background_threads();\n+-------------------------------+\n| summary |\n+-------------------------------+\n| Enabled 18 background threads |\n+-------------------------------+\n1 row in set (0.00 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_setup_enable_consumer","def","sys","ps_setup_enable_consumer","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","BEGIN\n UPDATE performance_schema.setup_consumers\n SET enabled = 'YES'\n WHERE name LIKE CONCAT('%', consumer, '%');\n SELECT CONCAT('Enabled ', @rows := ROW_COUNT(), ' consumer', IF(@rows != 1, 's', '')) AS summary;\nEND","NULL","SQL","SQL","NO","MODIFIES SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nEnables consumers within Performance Schema \nmatching the input pattern.\n\nParameters\n-----------\n\nconsumer (VARCHAR(128)):\n A LIKE pattern match (using "%consumer%") of consumers to enable\n\nExample\n-----------\n\nTo enable all consumers:\n\nmysql> CALL sys.ps_setup_enable_consumer('');\n+-------------------------+\n| summary |\n+-------------------------+\n| Enabled 10 consumers |\n+-------------------------+\n1 row in set (0.02 sec)\n\nQuery OK, 0 rows affected (0.02 sec)\n\nTo enable just "waits" consumers:\n\nmysql> CALL sys.ps_setup_enable_consumer('waits');\n+-----------------------+\n| summary |\n+-----------------------+\n| Enabled 3 consumers |\n+-----------------------+\n1 row in set (0.00 sec)\n\nQuery OK, 0 rows affected (0.00 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_setup_enable_instrument","def","sys","ps_setup_enable_instrument","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","BEGIN\n UPDATE performance_schema.setup_instruments\n SET enabled = 'YES', timed = 'YES'\n WHERE name LIKE CONCAT('%', in_pattern, '%');\n SELECT CONCAT('Enabled ', @rows := ROW_COUNT(), ' instrument', IF(@rows != 1, 's', '')) AS summary;\nEND","NULL","SQL","SQL","NO","MODIFIES SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nEnables instruments within Performance Schema \nmatching the input pattern.\n\nParameters\n-----------\n\nin_pattern (VARCHAR(128)):\n A LIKE pattern match (using "%in_pattern%") of events to enable\n\nExample\n-----------\n\nTo enable all mutex instruments:\n\nmysql> CALL sys.ps_setup_enable_instrument('wait/synch/mutex');\n+-------------------------+\n| summary |\n+-------------------------+\n| Enabled 155 instruments |\n+-------------------------+\n1 row in set (0.02 sec)\n\nQuery OK, 0 rows affected (0.02 sec)\n\nTo enable just a specific TCP/IP based network IO instrument:\n\nmysql> CALL sys.ps_setup_enable_instrument('wait/io/socket/sql/server_tcpip_socket');\n+-----------------------+\n| summary |\n+-----------------------+\n| Enabled 1 instruments |\n+-----------------------+\n1 row in set (0.00 sec)\n\nQuery OK, 0 rows affected (0.00 sec)\n\nTo enable all instruments:\n\nmysql> CALL sys.ps_setup_enable_instrument('');\n+-------------------------+\n| summary |\n+-------------------------+\n| Enabled 547 instruments |\n+-------------------------+\n1 row in set (0.01 sec)\n\nQuery OK, 0 rows affected (0.01 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_setup_enable_thread","def","sys","ps_setup_enable_thread","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","BEGIN\n UPDATE performance_schema.threads\n SET instrumented = 'YES'\n WHERE processlist_id = in_connection_id;\n SELECT CONCAT('Enabled ', @rows := ROW_COUNT(), ' thread', IF(@rows != 1, 's', '')) AS summary;\nEND","NULL","SQL","SQL","NO","MODIFIES SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nEnable the given connection/thread in Performance Schema.\n\nParameters\n-----------\n\nin_connection_id (BIGINT):\n The connection ID (PROCESSLIST_ID from performance_schema.threads\n or the ID shown within SHOW PROCESSLIST)\n\nExample\n-----------\n\nmysql> CALL sys.ps_setup_enable_thread(3);\n+------------------+\n| summary |\n+------------------+\n| Enabled 1 thread |\n+------------------+\n1 row in set (0.01 sec)\n\nTo enable the current connection:\n\nmysql> CALL sys.ps_setup_enable_thread(CONNECTION_ID());\n+------------------+\n| summary |\n+------------------+\n| Enabled 1 thread |\n+------------------+\n1 row in set (0.00 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_setup_reload_saved","def","sys","ps_setup_reload_saved","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","BEGIN\n DECLARE v_done bool DEFAULT FALSE;\n DECLARE v_lock_result INT;\n DECLARE v_lock_used_by BIGINT;\n DECLARE v_signal_message TEXT;\n DECLARE EXIT HANDLER FOR SQLEXCEPTION\n BEGIN\n SIGNAL SQLSTATE VALUE '90001'\n SET MESSAGE_TEXT = 'An error occurred, was sys.ps_setup_save() run before this procedure?';\n END;\n SET @log_bin := @@sql_log_bin;\n SET sql_log_bin = 0;\n SELECT IS_USED_LOCK('sys.ps_setup_save') INTO v_lock_used_by;\n IF (v_lock_used_by != CONNECTION_ID()) THEN\n SET v_signal_message = CONCAT('The sys.ps_setup_save lock is currently owned by ', v_lock_used_by);\n SIGNAL SQLSTATE VALUE '90002'\n SET MESSAGE_TEXT = v_signal_message;\n END IF;\n DELETE FROM performance_schema.setup_actors;\n INSERT INTO performance_schema.setup_actors SELECT * FROM tmp_setup_actors;\n BEGIN\n -- Workaround for http://bugs.mysql.com/bug.php?id=70025\n DECLARE v_name varchar(64);\n DECLARE v_enabled enum('YES', 'NO');\n DECLARE c_consumers CURSOR FOR SELECT NAME, ENABLED FROM tmp_setup_consumers;\n DECLARE CONTINUE HANDLER FOR NOT FOUND SET v_done = TRUE;\n SET v_done = FALSE;\n OPEN c_consumers;\n c_consumers_loop: LOOP\n FETCH c_consumers INTO v_name, v_enabled;\n IF v_done THEN\n LEAVE c_consumers_loop;\n END IF;\n UPDATE performance_schema.setup_consumers\n SET ENABLED = v_enabled\n WHERE NAME = v_name;\n END LOOP;\n CLOSE c_consumers;\n END;\n UPDATE performance_schema.setup_instruments\n INNER JOIN tmp_setup_instruments USING (NAME)\n SET performance_schema.setup_instruments.ENABLED = tmp_setup_instruments.ENABLED,\n performance_schema.setup_instruments.TIMED = tmp_setup_instruments.TIMED;\n BEGIN\n -- Workaround for http://bugs.mysql.com/bug.php?id=70025\n DECLARE v_thread_id bigint unsigned;\n DECLARE v_instrumented enum('YES', 'NO');\n DECLARE c_threads CURSOR FOR SELECT THREAD_ID, INSTRUMENTED FROM tmp_threads;\n DECLARE CONTINUE HANDLER FOR NOT FOUND SET v_done = TRUE;\n SET v_done = FALSE;\n OPEN c_threads;\n c_threads_loop: LOOP\n FETCH c_threads INTO v_thread_id, v_instrumented;\n IF v_done THEN\n LEAVE c_threads_loop;\n END IF;\n UPDATE performance_schema.threads\n SET INSTRUMENTED = v_instrumented\n WHERE THREAD_ID = v_thread_id;\n END LOOP;\n CLOSE c_threads;\n END;\n UPDATE performance_schema.threads\n SET INSTRUMENTED = IF(PROCESSLIST_USER IS NOT NULL,\n sys.ps_is_account_enabled(PROCESSLIST_HOST, PROCESSLIST_USER),\n 'YES')\n WHERE THREAD_ID NOT IN (SELECT THREAD_ID FROM tmp_threads);\n DROP TEMPORARY TABLE tmp_setup_actors;\n DROP TEMPORARY TABLE tmp_setup_consumers;\n DROP TEMPORARY TABLE tmp_setup_instruments;\n DROP TEMPORARY TABLE tmp_threads;\n SELECT RELEASE_LOCK('sys.ps_setup_save') INTO v_lock_result;\n SET sql_log_bin = @log_bin; \nEND","NULL","SQL","SQL","NO","MODIFIES SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nReloads a saved Performance Schema configuration,\nso that you can alter the setup for debugging purposes, \nbut restore it to a previous state.\n\nUse the companion procedure - ps_setup_save(), to \nsave a configuration.\n\nRequires the SUPER privilege for "SET sql_log_bin = 0;".\n\nParameters\n-----------\n\nNone.\n\nExample\n-----------\n\nmysql> CALL sys.ps_setup_save();\nQuery OK, 0 rows affected (0.08 sec)\n\nmysql> UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES';\nQuery OK, 547 rows affected (0.40 sec)\nRows matched: 784 Changed: 547 Warnings: 0\n\n/* Run some tests that need more detailed instrumentation here */\n\nmysql> CALL sys.ps_setup_reload_saved();\nQuery OK, 0 rows affected (0.32 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_setup_reset_to_default","def","sys","ps_setup_reset_to_default","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","BEGIN\n SET @query = 'DELETE\n FROM performance_schema.setup_actors\n WHERE NOT (HOST = '%' AND USER = '%' AND `ROLE` = '%')';\n IF (in_verbose) THEN\n SELECT CONCAT('Resetting: setup_actors\n', REPLACE(@query, ' ', '')) AS status;\n END IF;\n PREPARE reset_stmt FROM @query;\n EXECUTE reset_stmt;\n DEALLOCATE PREPARE reset_stmt;\n SET @query = 'INSERT IGNORE INTO performance_schema.setup_actors\n VALUES ('%', '%', '%', 'YES', 'YES')';\n IF (in_verbose) THEN\n SELECT CONCAT('Resetting: setup_actors\n', REPLACE(@query, ' ', '')) AS status;\n END IF;\n PREPARE reset_stmt FROM @query;\n EXECUTE reset_stmt;\n DEALLOCATE PREPARE reset_stmt;\n SET @query = 'UPDATE performance_schema.setup_instruments\n SET ENABLED = sys.ps_is_instrument_default_enabled(NAME),\n TIMED = sys.ps_is_instrument_default_timed(NAME)';\n IF (in_verbose) THEN\n SELECT CONCAT('Resetting: setup_instruments\n', REPLACE(@query, ' ', '')) AS status;\n END IF;\n PREPARE reset_stmt FROM @query;\n EXECUTE reset_stmt;\n DEALLOCATE PREPARE reset_stmt;\n SET @query = 'UPDATE performance_schema.setup_consumers\n SET ENABLED = IF(NAME IN ('events_statements_current', 'events_transactions_current', 'global_instrumentation', 'thread_instrumentation', 'statements_digest'), 'YES', 'NO')';\n IF (in_verbose) THEN\n SELECT CONCAT('Resetting: setup_consumers\n', REPLACE(@query, ' ', '')) AS status;\n END IF;\n PREPARE reset_stmt FROM @query;\n EXECUTE reset_stmt;\n DEALLOCATE PREPARE reset_stmt;\n SET @query = 'DELETE\n FROM performance_schema.setup_objects\n WHERE NOT (OBJECT_TYPE IN ('EVENT', 'FUNCTION', 'PROCEDURE', 'TABLE', 'TRIGGER') AND OBJECT_NAME = '%' \n AND (OBJECT_SCHEMA = 'mysql' AND ENABLED = 'NO' AND TIMED = 'NO' )\n OR (OBJECT_SCHEMA = 'performance_schema' AND ENABLED = 'NO' AND TIMED = 'NO' )\n OR (OBJECT_SCHEMA = 'information_schema' AND ENABLED = 'NO' AND TIMED = 'NO' )\n OR (OBJECT_SCHEMA = '%' AND ENABLED = 'YES' AND TIMED = 'YES'))';\n IF (in_verbose) THEN\n SELECT CONCAT('Resetting: setup_objects\n', REPLACE(@query, ' ', '')) AS status;\n END IF;\n PREPARE reset_stmt FROM @query;\n EXECUTE reset_stmt;\n DEALLOCATE PREPARE reset_stmt;\n SET @query = 'INSERT IGNORE INTO performance_schema.setup_objects\n VALUES ('EVENT' , 'mysql' , '%', 'NO' , 'NO' ),\n ('EVENT' , 'performance_schema', '%', 'NO' , 'NO' ),\n ('EVENT' , 'information_schema', '%', 'NO' , 'NO' ),\n ('EVENT' , '%' , '%', 'YES', 'YES'),\n ('FUNCTION' , 'mysql' , '%', 'NO' , 'NO' ),\n ('FUNCTION' , 'performance_schema', '%', 'NO' , 'NO' ),\n ('FUNCTION' , 'information_schema', '%', 'NO' , 'NO' ),\n ('FUNCTION' , '%' , '%', 'YES', 'YES'),\n ('PROCEDURE', 'mysql' , '%', 'NO' , 'NO' ),\n ('PROCEDURE', 'performance_schema', '%', 'NO' , 'NO' ),\n ('PROCEDURE', 'information_schema', '%', 'NO' , 'NO' ),\n ('PROCEDURE', '%' , '%', 'YES', 'YES'),\n ('TABLE' , 'mysql' , '%', 'NO' , 'NO' ),\n ('TABLE' , 'performance_schema', '%', 'NO' , 'NO' ),\n ('TABLE' , 'information_schema', '%', 'NO' , 'NO' ),\n ('TABLE' , '%' , '%', 'YES', 'YES'),\n ('TRIGGER' , 'mysql' , '%', 'NO' , 'NO' ),\n ('TRIGGER' , 'performance_schema', '%', 'NO' , 'NO' ),\n ('TRIGGER' , 'information_schema', '%', 'NO' , 'NO' ),\n ('TRIGGER' , '%' , '%', 'YES', 'YES')';\n IF (in_verbose) THEN\n SELECT CONCAT('Resetting: setup_objects\n', REPLACE(@query, ' ', '')) AS status;\n END IF;\n PREPARE reset_stmt FROM @query;\n EXECUTE reset_stmt;\n DEALLOCATE PREPARE reset_stmt;\n SET @query = 'UPDATE performance_schema.threads\n SET INSTRUMENTED = 'YES'';\n IF (in_verbose) THEN\n SELECT CONCAT('Resetting: threads\n', REPLACE(@query, ' ', '')) AS status;\n END IF;\n PREPARE reset_stmt FROM @query;\n EXECUTE reset_stmt;\n DEALLOCATE PREPARE reset_stmt;\nEND","NULL","SQL","SQL","NO","MODIFIES SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nResets the Performance Schema setup to the default settings.\n\nParameters\n-----------\n\nin_verbose (BOOLEAN):\n Whether to print each setup stage (including the SQL) whilst running.\n\nExample\n-----------\n\nmysql> CALL sys.ps_setup_reset_to_default(true)\\G\n*************************** 1. row ***************************\nstatus: Resetting: setup_actors\nDELETE\nFROM performance_schema.setup_actors\n WHERE NOT (HOST = '%' AND USER = '%' AND `ROLE` = '%')\n1 row in set (0.00 sec)\n\n*************************** 1. row ***************************\nstatus: Resetting: setup_actors\nINSERT IGNORE INTO performance_schema.setup_actors\nVALUES ('%', '%', '%')\n1 row in set (0.00 sec)\n...\n\nmysql> CALL sys.ps_setup_reset_to_default(false)\\G\nQuery OK, 0 rows affected (0.00 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_setup_save","def","sys","ps_setup_save","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","BEGIN\n DECLARE v_lock_result INT;\n SET @log_bin := @@sql_log_bin;\n SET sql_log_bin = 0;\n SELECT GET_LOCK('sys.ps_setup_save', in_timeout) INTO v_lock_result;\n IF v_lock_result THEN\n DROP TEMPORARY TABLE IF EXISTS tmp_setup_actors;\n DROP TEMPORARY TABLE IF EXISTS tmp_setup_consumers;\n DROP TEMPORARY TABLE IF EXISTS tmp_setup_instruments;\n DROP TEMPORARY TABLE IF EXISTS tmp_threads;\n CREATE TEMPORARY TABLE tmp_setup_actors SELECT * FROM performance_schema.setup_actors LIMIT 0;\n CREATE TEMPORARY TABLE tmp_setup_consumers LIKE performance_schema.setup_consumers;\n CREATE TEMPORARY TABLE tmp_setup_instruments LIKE performance_schema.setup_instruments;\n CREATE TEMPORARY TABLE tmp_threads (THREAD_ID bigint unsigned NOT NULL PRIMARY KEY, INSTRUMENTED enum('YES','NO') NOT NULL);\n INSERT INTO tmp_setup_actors SELECT * FROM performance_schema.setup_actors;\n INSERT INTO tmp_setup_consumers SELECT * FROM performance_schema.setup_consumers;\n INSERT INTO tmp_setup_instruments SELECT * FROM performance_schema.setup_instruments;\n INSERT INTO tmp_threads SELECT THREAD_ID, INSTRUMENTED FROM performance_schema.threads;\n ELSE\n SIGNAL SQLSTATE VALUE '90000'\n SET MESSAGE_TEXT = 'Could not lock the sys.ps_setup_save user lock, another thread has a saved configuration';\n END IF;\n SET sql_log_bin = @log_bin;\nEND","NULL","SQL","SQL","NO","MODIFIES SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nSaves the current configuration of Performance Schema, \nso that you can alter the setup for debugging purposes, \nbut restore it to a previous state.\n\nUse the companion procedure - ps_setup_reload_saved(), to \nrestore the saved config.\n\nThe named lock "sys.ps_setup_save" is taken before the\ncurrent configuration is saved. If the attempt to get the named\nlock times out, an error occurs.\n\nThe lock is released after the settings have been restored by\ncalling ps_setup_reload_saved().\n\nRequires the SUPER privilege for "SET sql_log_bin = 0;".\n\nParameters\n-----------\n\nin_timeout INT\n The timeout in seconds used when trying to obtain the lock.\n A negative timeout means infinite timeout.\n\nExample\n-----------\n\nmysql> CALL sys.ps_setup_save(-1);\nQuery OK, 0 rows affected (0.08 sec)\n\nmysql> UPDATE performance_schema.setup_instruments \n -> SET enabled = 'YES', timed = 'YES';\nQuery OK, 547 rows affected (0.40 sec)\nRows matched: 784 Changed: 547 Warnings: 0\n\n/* Run some tests that need more detailed instrumentation here */\n\nmysql> CALL sys.ps_setup_reload_saved();\nQuery OK, 0 rows affected (0.32 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_setup_show_disabled","def","sys","ps_setup_show_disabled","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","BEGIN\n SELECT @@performance_schema AS performance_schema_enabled;\n SELECT CONCAT(''', user, ''@'', host, ''') AS disabled_users\n FROM performance_schema.setup_actors\n WHERE enabled = 'NO'\n ORDER BY disabled_users;\n SELECT object_type,\n CONCAT(object_schema, '.', object_name) AS objects,\n enabled,\n timed\n FROM performance_schema.setup_objects\n WHERE enabled = 'NO'\n ORDER BY object_type, objects;\n SELECT name AS disabled_consumers\n FROM performance_schema.setup_consumers\n WHERE enabled = 'NO'\n ORDER BY disabled_consumers;\n IF (in_show_threads) THEN\n SELECT IF(name = 'thread/sql/one_connection', \n CONCAT(processlist_user, '@', processlist_host), \n REPLACE(name, 'thread/', '')) AS disabled_threads,\n TYPE AS thread_type\n FROM performance_schema.threads\n WHERE INSTRUMENTED = 'NO'\n ORDER BY disabled_threads;\n END IF;\n IF (in_show_instruments) THEN\n SELECT name AS disabled_instruments,\n timed\n FROM performance_schema.setup_instruments\n WHERE enabled = 'NO'\n ORDER BY disabled_instruments;\n END IF;\nEND","NULL","SQL","SQL","NO","READS SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nShows all currently disable Performance Schema configuration.\n\nDisabled users is only available for MySQL 5.7.6 and later.\nIn earlier versions it was only possible to enable users.\n\nParameters\n-----------\n\nin_show_instruments (BOOLEAN):\n Whether to print disabled instruments (can print many items)\n\nin_show_threads (BOOLEAN):\n Whether to print disabled threads\n\nExample\n-----------\n\nmysql> CALL sys.ps_setup_show_disabled(TRUE, TRUE);\n+----------------------------+\n| performance_schema_enabled |\n+----------------------------+\n| 1 |\n+----------------------------+\n1 row in set (0.00 sec)\n\n+--------------------+\n| disabled_users |\n+--------------------+\n| 'mark'@'localhost' |\n+--------------------+\n1 row in set (0.00 sec)\n\n+-------------+----------------------+---------+-------+\n| object_type | objects | enabled | timed |\n+-------------+----------------------+---------+-------+\n| EVENT | mysql.% | NO | NO |\n| EVENT | performance_schema.% | NO | NO |\n| EVENT | information_schema.% | NO | NO |\n| FUNCTION | mysql.% | NO | NO |\n| FUNCTION | performance_schema.% | NO | NO |\n| FUNCTION | information_schema.% | NO | NO |\n| PROCEDURE | mysql.% | NO | NO |\n| PROCEDURE | performance_schema.% | NO | NO |\n| PROCEDURE | information_schema.% | NO | NO |\n| TABLE | mysql.% | NO | NO |\n| TABLE | performance_schema.% | NO | NO |\n| TABLE | information_schema.% | NO | NO |\n| TRIGGER | mysql.% | NO | NO |\n| TRIGGER | performance_schema.% | NO | NO |\n| TRIGGER | information_schema.% | NO | NO |\n+-------------+----------------------+---------+-------+\n15 rows in set (0.00 sec)\n\n+----------------------------------+\n| disabled_consumers |\n+----------------------------------+\n| events_stages_current |\n| events_stages_history |\n| events_stages_history_long |\n| events_statements_history |\n| events_statements_history_long |\n| events_transactions_history |\n| events_transactions_history_long |\n| events_waits_current |\n| events_waits_history |\n| events_waits_history_long |\n+----------------------------------+\n10 rows in set (0.00 sec)\n\nEmpty set (0.00 sec)\n\n+---------------------------------------------------------------------------------------+-------+\n| disabled_instruments | timed |\n+---------------------------------------------------------------------------------------+-------+\n| wait/synch/mutex/sql/TC_LOG_MMAP::LOCK_tc | NO |\n| wait/synch/mutex/sql/LOCK_des_key_file | NO |\n| wait/synch/mutex/sql/MYSQL_BIN_LOG::LOCK_commit | NO |\n...\n| memory/sql/servers_cache | NO |\n| memory/sql/udf_mem | NO |\n| wait/lock/metadata/sql/mdl | NO |\n+---------------------------------------------------------------------------------------+-------+\n547 rows in set (0.00 sec)\n\nQuery OK, 0 rows affected (0.01 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_setup_show_disabled_consumers","def","sys","ps_setup_show_disabled_consumers","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","BEGIN\n SELECT name AS disabled_consumers\n FROM performance_schema.setup_consumers\n WHERE enabled = 'NO'\n ORDER BY disabled_consumers;\nEND","NULL","SQL","SQL","YES","READS SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nShows all currently disabled consumers.\n\nParameters\n-----------\n\nNone\n\nExample\n-----------\n\nmysql> CALL sys.ps_setup_show_disabled_consumers();\n\n+---------------------------+\n| disabled_consumers |\n+---------------------------+\n| events_statements_current |\n| global_instrumentation |\n| thread_instrumentation |\n| statements_digest |\n+---------------------------+\n4 rows in set (0.05 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_setup_show_disabled_instruments","def","sys","ps_setup_show_disabled_instruments","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","BEGIN\n SELECT name AS disabled_instruments, timed\n FROM performance_schema.setup_instruments\n WHERE enabled = 'NO'\n ORDER BY disabled_instruments;\nEND","NULL","SQL","SQL","YES","READS SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nShows all currently disabled instruments.\n\nParameters\n-----------\n\nNone\n\nExample\n-----------\n\nmysql> CALL sys.ps_setup_show_disabled_instruments();\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_setup_show_enabled","def","sys","ps_setup_show_enabled","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","BEGIN\n SELECT @@performance_schema AS performance_schema_enabled;\n SELECT CONCAT(''', user, ''@'', host, ''') AS enabled_users\n FROM performance_schema.setup_actors\n WHERE enabled = 'YES'\n ORDER BY enabled_users;\n SELECT object_type,\n CONCAT(object_schema, '.', object_name) AS objects,\n enabled,\n timed\n FROM performance_schema.setup_objects\n WHERE enabled = 'YES'\n ORDER BY object_type, objects;\n SELECT name AS enabled_consumers\n FROM performance_schema.setup_consumers\n WHERE enabled = 'YES'\n ORDER BY enabled_consumers;\n IF (in_show_threads) THEN\n SELECT IF(name = 'thread/sql/one_connection', \n CONCAT(processlist_user, '@', processlist_host), \n REPLACE(name, 'thread/', '')) AS enabled_threads,\n TYPE AS thread_type\n FROM performance_schema.threads\n WHERE INSTRUMENTED = 'YES'\n ORDER BY enabled_threads;\n END IF;\n IF (in_show_instruments) THEN\n SELECT name AS enabled_instruments,\n timed\n FROM performance_schema.setup_instruments\n WHERE enabled = 'YES'\n ORDER BY enabled_instruments;\n END IF;\nEND","NULL","SQL","SQL","YES","READS SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nShows all currently enabled Performance Schema configuration.\n\nParameters\n-----------\n\nin_show_instruments (BOOLEAN):\n Whether to print enabled instruments (can print many items)\n\nin_show_threads (BOOLEAN):\n Whether to print enabled threads\n\nExample\n-----------\n\nmysql> CALL sys.ps_setup_show_enabled(TRUE, TRUE);\n+----------------------------+\n| performance_schema_enabled |\n+----------------------------+\n| 1 |\n+----------------------------+\n1 row in set (0.00 sec)\n\n+---------------+\n| enabled_users |\n+---------------+\n| '%'@'%' |\n+---------------+\n1 row in set (0.01 sec)\n\n+-------------+---------+---------+-------+\n| object_type | objects | enabled | timed |\n+-------------+---------+---------+-------+\n| EVENT | %.% | YES | YES |\n| FUNCTION | %.% | YES | YES |\n| PROCEDURE | %.% | YES | YES |\n| TABLE | %.% | YES | YES |\n| TRIGGER | %.% | YES | YES |\n+-------------+---------+---------+-------+\n5 rows in set (0.01 sec)\n\n+---------------------------+\n| enabled_consumers |\n+---------------------------+\n| events_statements_current |\n| global_instrumentation |\n| thread_instrumentation |\n| statements_digest |\n+---------------------------+\n4 rows in set (0.05 sec)\n\n+---------------------------------+-------------+\n| enabled_threads | thread_type |\n+---------------------------------+-------------+\n| sql/main | BACKGROUND |\n| sql/thread_timer_notifier | BACKGROUND |\n| innodb/io_ibuf_thread | BACKGROUND |\n| innodb/io_log_thread | BACKGROUND |\n| innodb/io_read_thread | BACKGROUND |\n| innodb/io_read_thread | BACKGROUND |\n| innodb/io_write_thread | BACKGROUND |\n| innodb/io_write_thread | BACKGROUND |\n| innodb/page_cleaner_thread | BACKGROUND |\n| innodb/srv_lock_timeout_thread | BACKGROUND |\n| innodb/srv_error_monitor_thread | BACKGROUND |\n| innodb/srv_monitor_thread | BACKGROUND |\n| innodb/srv_master_thread | BACKGROUND |\n| innodb/srv_purge_thread | BACKGROUND |\n| innodb/srv_worker_thread | BACKGROUND |\n| innodb/srv_worker_thread | BACKGROUND |\n| innodb/srv_worker_thread | BACKGROUND |\n| innodb/buf_dump_thread | BACKGROUND |\n| innodb/dict_stats_thread | BACKGROUND |\n| sql/signal_handler | BACKGROUND |\n| sql/compress_gtid_table | FOREGROUND |\n| root@localhost | FOREGROUND |\n+---------------------------------+-------------+\n22 rows in set (0.01 sec)\n\n+-------------------------------------+-------+\n| enabled_instruments | timed |\n+-------------------------------------+-------+\n| wait/io/file/sql/map | YES |\n| wait/io/file/sql/binlog | YES |\n...\n| statement/com/Error | YES |\n| statement/com/ | YES |\n| idle | YES |\n+-------------------------------------+-------+\n210 rows in set (0.08 sec)\n\nQuery OK, 0 rows affected (0.89 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_setup_show_enabled_consumers","def","sys","ps_setup_show_enabled_consumers","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","BEGIN\n SELECT name AS enabled_consumers\n FROM performance_schema.setup_consumers\n WHERE enabled = 'YES'\n ORDER BY enabled_consumers;\nEND","NULL","SQL","SQL","YES","READS SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nShows all currently enabled consumers.\n\nParameters\n-----------\n\nNone\n\nExample\n-----------\n\nmysql> CALL sys.ps_setup_show_enabled_consumers();\n\n+---------------------------+\n| enabled_consumers |\n+---------------------------+\n| events_statements_current |\n| global_instrumentation |\n| thread_instrumentation |\n| statements_digest |\n+---------------------------+\n4 rows in set (0.05 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_setup_show_enabled_instruments","def","sys","ps_setup_show_enabled_instruments","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","BEGIN\n SELECT name AS enabled_instruments, timed\n FROM performance_schema.setup_instruments\n WHERE enabled = 'YES'\n ORDER BY enabled_instruments;\nEND","NULL","SQL","SQL","YES","READS SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nShows all currently enabled instruments.\n\nParameters\n-----------\n\nNone\n\nExample\n-----------\n\nmysql> CALL sys.ps_setup_show_enabled_instruments();\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""ps_truncate_all_tables","def","sys","ps_truncate_all_tables","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","BEGIN\n DECLARE v_done INT DEFAULT FALSE;\n DECLARE v_total_tables INT DEFAULT 0;\n DECLARE v_ps_table VARCHAR(64);\n DECLARE ps_tables CURSOR FOR\n SELECT table_name \n FROM INFORMATION_SCHEMA.TABLES \n WHERE table_schema = 'performance_schema' \n AND (table_name LIKE '%summary%' \n OR table_name LIKE '%history%');\n DECLARE CONTINUE HANDLER FOR NOT FOUND SET v_done = TRUE;\n OPEN ps_tables;\n ps_tables_loop: LOOP\n FETCH ps_tables INTO v_ps_table;\n IF v_done THEN\n LEAVE ps_tables_loop;\n END IF;\n SET @truncate_stmt := CONCAT('TRUNCATE TABLE performance_schema.', v_ps_table);\n IF in_verbose THEN\n SELECT CONCAT('Running: ', @truncate_stmt) AS status;\n END IF;\n PREPARE truncate_stmt FROM @truncate_stmt;\n EXECUTE truncate_stmt;\n DEALLOCATE PREPARE truncate_stmt;\n SET v_total_tables = v_total_tables + 1;\n END LOOP;\n CLOSE ps_tables;\n SELECT CONCAT('Truncated ', v_total_tables, ' tables') AS summary;\nEND","NULL","SQL","SQL","YES","MODIFIES SQL DATA","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nTruncates all summary tables within Performance Schema, \nresetting all aggregated instrumentation as a snapshot.\n\nParameters\n-----------\n\nin_verbose (BOOLEAN):\n Whether to print each TRUNCATE statement before running\n\nExample\n-----------\n\nmysql> CALL sys.ps_truncate_all_tables(false);\n+---------------------+\n| summary |\n+---------------------+\n| Truncated 44 tables |\n+---------------------+\n1 row in set (0.10 sec)\n\nQuery OK, 0 rows affected (0.10 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""statement_performance_analyzer","def","sys","statement_performance_analyzer","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","BEGIN\n DECLARE v_table_exists, v_tmp_digests_table_exists, v_custom_view_exists ENUM('', 'BASE TABLE', 'VIEW', 'TEMPORARY') DEFAULT '';\n DECLARE v_this_thread_enabled ENUM('YES', 'NO');\n DECLARE v_force_new_snapshot BOOLEAN DEFAULT FALSE;\n DECLARE v_digests_table VARCHAR(133);\n DECLARE v_quoted_table, v_quoted_custom_view VARCHAR(133) DEFAULT '';\n DECLARE v_table_db, v_table_name, v_custom_db, v_custom_name VARCHAR(64);\n DECLARE v_digest_table_template, v_checksum_ref, v_checksum_table text;\n DECLARE v_sql longtext;\n -- Maximum supported length for MESSAGE_TEXT with the SIGNAL command is 128 chars.\n DECLARE v_error_msg VARCHAR(128);\n DECLARE v_old_group_concat_max_len INT UNSIGNED DEFAULT 0;\n -- Don't instrument this thread\n SELECT INSTRUMENTED INTO v_this_thread_enabled FROM performance_schema.threads WHERE PROCESSLIST_ID = CONNECTION_ID();\n IF (v_this_thread_enabled = 'YES') THEN\n CALL sys.ps_setup_disable_thread(CONNECTION_ID());\n END IF;\n -- Temporary table are used - disable sql_log_bin if necessary to prevent them replicating\n SET @log_bin := @@sql_log_bin;\n IF ((@log_bin = 1) AND (@@binlog_format = 'STATEMENT')) THEN\n SET sql_log_bin = 0;\n END IF;\n -- Set configuration options\n IF (@sys.statement_performance_analyzer.limit IS NULL) THEN\n SET @sys.statement_performance_analyzer.limit = sys.sys_get_config('statement_performance_analyzer.limit', '100');\n END IF;\n IF (@sys.debug IS NULL) THEN\n SET @sys.debug = sys.sys_get_config('debug' , 'OFF');\n END IF;\n -- If in_table is set, break in_table into a db and table component and check whether it exists\n -- in_table = NOW() is considered like it's not set.\n IF (in_table = 'NOW()') THEN\n SET v_force_new_snapshot = TRUE,\n in_table = NULL;\n ELSEIF (in_table IS NOT NULL) THEN\n IF (NOT INSTR(in_table, '.')) THEN\n -- No . in the table name - use current database\n -- DATABASE() will be the database of the procedure\n SET v_table_db = DATABASE(),\n v_table_name = in_table;\n ELSE\n SET v_table_db = SUBSTRING_INDEX(in_table, '.', 1);\n SET v_table_name = SUBSTRING(in_table, CHAR_LENGTH(v_table_db)+2);\n END IF;\n SET v_quoted_table = CONCAT('`', v_table_db, '`.`', v_table_name, '`');\n IF (@sys.debug = 'ON') THEN\n SELECT CONCAT('in_table is: db = '', v_table_db, '', table = '', v_table_name, ''') AS 'Debug';\n END IF;\n IF (v_table_db = DATABASE() AND (v_table_name = 'tmp_digests' OR v_table_name = 'tmp_digests_delta')) THEN\n SET v_error_msg = CONCAT('Invalid value for in_table: ', v_quoted_table, ' is reserved table name.');\n SIGNAL SQLSTATE '45000'\n SET MESSAGE_TEXT = v_error_msg;\n END IF;\n CALL sys.table_exists(v_table_db, v_table_name, v_table_exists);\n IF (@sys.debug = 'ON') THEN\n SELECT CONCAT('v_table_exists = ', v_table_exists) AS 'Debug';\n END IF;\n IF (v_table_exists = 'BASE TABLE') THEN\n SET v_old_group_concat_max_len = @@session.group_concat_max_len;\n SET @@session.group_concat_max_len = 2048;\n -- Verify that the table has the correct table definition\n -- This can only be done for base tables as temporary aren't in information_schema.COLUMNS.\n -- This also minimises the risk of using a production table.\n SET v_checksum_ref = (\n SELECT GROUP_CONCAT(CONCAT(COLUMN_NAME, COLUMN_TYPE) ORDER BY ORDINAL_POSITION) AS Checksum\n FROM information_schema.COLUMNS\n WHERE TABLE_SCHEMA = 'performance_schema' AND TABLE_NAME = 'events_statements_summary_by_digest'\n ),\n v_checksum_table = (\n SELECT GROUP_CONCAT(CONCAT(COLUMN_NAME, COLUMN_TYPE) ORDER BY ORDINAL_POSITION) AS Checksum\n FROM information_schema.COLUMNS\n WHERE TABLE_SCHEMA = v_table_db AND TABLE_NAME = v_table_name\n );\n SET @@session.group_concat_max_len = v_old_group_concat_max_len;\n IF (v_checksum_ref <> v_checksum_table) THEN\n -- The table does not have the correct definition, so abandon\n SET v_error_msg = CONCAT('The table ',\n IF(CHAR_LENGTH(v_quoted_table) > 93, CONCAT('...', SUBSTRING(v_quoted_table, -90)), v_quoted_table),\n ' has the wrong definition.');\n SIGNAL SQLSTATE '45000'\n SET MESSAGE_TEXT = v_error_msg;\n END IF;\n END IF;\n END IF;\n IF (in_views IS NULL OR in_views = '') THEN\n -- Set to default\n SET in_views = 'with_runtimes_in_95th_percentile,analysis,with_errors_or_warnings,with_full_table_scans,with_sorting,with_temp_tables';\n END IF;\n -- Validate settings\n CALL sys.table_exists(DATABASE(), 'tmp_digests', v_tmp_digests_table_exists);\n IF (@sys.debug = 'ON') THEN\n SELECT CONCAT('v_tmp_digests_table_exists = ', v_tmp_digests_table_exists) AS 'Debug';\n END IF;\n CASE\n WHEN in_action IN ('snapshot', 'overall') THEN\n -- in_table must be NULL, NOW(), or an existing table\n IF (in_table IS NOT NULL) THEN\n IF (NOT v_table_exists IN ('TEMPORARY', 'BASE TABLE')) THEN\n SET v_error_msg = CONCAT('The ', in_action, ' action requires in_table to be NULL, NOW() or specify an existing table.',\n ' The table ',\n IF(CHAR_LENGTH(v_quoted_table) > 16, CONCAT('...', SUBSTRING(v_quoted_table, -13)), v_quoted_table),\n ' does not exist.');\n SIGNAL SQLSTATE '45000'\n SET MESSAGE_TEXT = v_error_msg;\n END IF;\n END IF;\n WHEN in_action IN ('delta', 'save') THEN\n -- in_table must be an existing table\n IF (v_table_exists NOT IN ('TEMPORARY', 'BASE TABLE')) THEN\n SET v_error_msg = CONCAT('The ', in_action, ' action requires in_table to be an existing table.',\n IF(in_table IS NOT NULL, CONCAT(' The table ',\n IF(CHAR_LENGTH(v_quoted_table) > 39, CONCAT('...', SUBSTRING(v_quoted_table, -36)), v_quoted_table),\n ' does not exist.'), ''));\n SIGNAL SQLSTATE '45000'\n SET MESSAGE_TEXT = v_error_msg;\n END IF;\n IF (in_action = 'delta' AND v_tmp_digests_table_exists <> 'TEMPORARY') THEN\n SIGNAL SQLSTATE '45000'\n SET MESSAGE_TEXT = 'An existing snapshot generated with the statement_performance_analyzer() must exist.';\n END IF;\n WHEN in_action = 'create_tmp' THEN\n -- in_table must not exists as a temporary table\n IF (v_table_exists = 'TEMPORARY') THEN\n SET v_error_msg = CONCAT('Cannot create the table ',\n IF(CHAR_LENGTH(v_quoted_table) > 72, CONCAT('...', SUBSTRING(v_quoted_table, -69)), v_quoted_table),\n ' as it already exists.');\n SIGNAL SQLSTATE '45000'\n SET MESSAGE_TEXT = v_error_msg;\n END IF;\n WHEN in_action = 'create_table' THEN\n -- in_table must not exists at all\n IF (v_table_exists <> '') THEN\n SET v_error_msg = CONCAT('Cannot create the table ',\n IF(CHAR_LENGTH(v_quoted_table) > 52, CONCAT('...', SUBSTRING(v_quoted_table, -49)), v_quoted_table),\n ' as it already exists',\n IF(v_table_exists = 'TEMPORARY', ' as a temporary table.', '.'));\n SIGNAL SQLSTATE '45000'\n SET MESSAGE_TEXT = v_error_msg;\n END IF;\n WHEN in_action = 'cleanup' THEN\n -- doesn't use any of the arguments\n DO (SELECT 1);\n ELSE\n SIGNAL SQLSTATE '45000'\n SET MESSAGE_TEXT = 'Unknown action. Supported actions are: cleanup, create_table, create_tmp, delta, overall, save, snapshot';\n END CASE;\n SET v_digest_table_template = 'CREATE %{TEMPORARY}TABLE %{TABLE_NAME} (\n `SCHEMA_NAME` varchar(64) DEFAULT NULL,\n `DIGEST` varchar(64) DEFAULT NULL,\n `DIGEST_TEXT` longtext,\n `COUNT_STAR` bigint unsigned NOT NULL,\n `SUM_TIMER_WAIT` bigint unsigned NOT NULL,\n `MIN_TIMER_WAIT` bigint unsigned NOT NULL,\n `AVG_TIMER_WAIT` bigint unsigned NOT NULL,\n `MAX_TIMER_WAIT` bigint unsigned NOT NULL,\n `SUM_LOCK_TIME` bigint unsigned NOT NULL,\n `SUM_ERRORS` bigint unsigned NOT NULL,\n `SUM_WARNINGS` bigint unsigned NOT NULL,\n `SUM_ROWS_AFFECTED` bigint unsigned NOT NULL,\n `SUM_ROWS_SENT` bigint unsigned NOT NULL,\n `SUM_ROWS_EXAMINED` bigint unsigned NOT NULL,\n `SUM_CREATED_TMP_DISK_TABLES` bigint unsigned NOT NULL,\n `SUM_CREATED_TMP_TABLES` bigint unsigned NOT NULL,\n `SUM_SELECT_FULL_JOIN` bigint unsigned NOT NULL,\n `SUM_SELECT_FULL_RANGE_JOIN` bigint unsigned NOT NULL,\n `SUM_SELECT_RANGE` bigint unsigned NOT NULL,\n `SUM_SELECT_RANGE_CHECK` bigint unsigned NOT NULL,\n `SUM_SELECT_SCAN` bigint unsigned NOT NULL,\n `SUM_SORT_MERGE_PASSES` bigint unsigned NOT NULL,\n `SUM_SORT_RANGE` bigint unsigned NOT NULL,\n `SUM_SORT_ROWS` bigint unsigned NOT NULL,\n `SUM_SORT_SCAN` bigint unsigned NOT NULL,\n `SUM_NO_INDEX_USED` bigint unsigned NOT NULL,\n `SUM_NO_GOOD_INDEX_USED` bigint unsigned NOT NULL,\n `SUM_CPU_TIME` bigint unsigned NOT NULL,\n `MAX_CONTROLLED_MEMORY` bigint unsigned NOT NULL,\n `MAX_TOTAL_MEMORY` bigint unsigned NOT NULL,\n `COUNT_SECONDARY` bigint unsigned NOT NULL,\n `FIRST_SEEN` timestamp(6) NULL DEFAULT NULL,\n `LAST_SEEN` timestamp(6) NULL DEFAULT NULL,\n `QUANTILE_95` bigint unsigned NOT NULL,\n `QUANTILE_99` bigint unsigned NOT NULL,\n `QUANTILE_999` bigint unsigned NOT NULL,\n `QUERY_SAMPLE_TEXT` longtext,\n `QUERY_SAMPLE_SEEN` timestamp(6) NULL DEFAULT NULL,\n `QUERY_SAMPLE_TIMER_WAIT` bigint unsigned NOT NULL,\n INDEX (SCHEMA_NAME, DIGEST)\n) DEFAULT CHARSET=utf8mb4';\n -- Do the action\n -- The actions snapshot, ... requires a fresh snapshot - create it now\n IF (v_force_new_snapshot\n OR in_action = 'snapshot'\n OR (in_action = 'overall' AND in_table IS NULL)\n OR (in_action = 'save' AND v_tmp_digests_table_exists <> 'TEMPORARY')\n ) THEN\n IF (v_tmp_digests_table_exists = 'TEMPORARY') THEN\n IF (@sys.debug = 'ON') THEN\n SELECT 'DROP TEMPORARY TABLE IF EXISTS tmp_digests' AS 'Debug';\n END IF;\n DROP TEMPORARY TABLE IF EXISTS tmp_digests;\n END IF;\n CALL sys.execute_prepared_stmt(REPLACE(REPLACE(v_digest_table_template, '%{TEMPORARY}', 'TEMPORARY '), '%{TABLE_NAME}', 'tmp_digests'));\n SET v_sql = CONCAT('INSERT INTO tmp_digests SELECT * FROM ',\n IF(in_table IS NULL OR in_action = 'save', 'performance_schema.events_statements_summary_by_digest', v_quoted_table));\n CALL sys.execute_prepared_stmt(v_sql);\n END IF;\n -- Go through the remaining actions\n IF (in_action IN ('create_table', 'create_tmp')) THEN\n IF (in_action = 'create_table') THEN\n CALL sys.execute_prepared_stmt(REPLACE(REPLACE(v_digest_table_template, '%{TEMPORARY}', ''), '%{TABLE_NAME}', v_quoted_table));\n ELSE\n CALL sys.execute_prepared_stmt(REPLACE(REPLACE(v_digest_table_template, '%{TEMPORARY}', 'TEMPORARY '), '%{TABLE_NAME}', v_quoted_table));\n END IF;\n ELSEIF (in_action = 'save') THEN\n CALL sys.execute_prepared_stmt(CONCAT('DELETE FROM ', v_quoted_table));\n CALL sys.execute_prepared_stmt(CONCAT('INSERT INTO ', v_quoted_table, ' SELECT * FROM tmp_digests'));\n ELSEIF (in_action = 'cleanup') THEN\n DROP TEMPORARY TABLE IF EXISTS sys.tmp_digests;\n DROP TEMPORARY TABLE IF EXISTS sys.tmp_digests_delta;\n ELSEIF (in_action IN ('overall', 'delta')) THEN\n -- These are almost the same - for delta calculate the delta in tmp_digests_delta and use that instead of tmp_digests.\n -- And overall allows overriding the table to use.\n IF (in_action = 'overall') THEN\n IF (in_table IS NULL) THEN\n SET v_digests_table = 'tmp_digests';\n ELSE\n SET v_digests_table = v_quoted_table;\n END IF;\n ELSE\n SET v_digests_table = 'tmp_digests_delta';\n DROP TEMPORARY TABLE IF EXISTS tmp_digests_delta;\n CREATE TEMPORARY TABLE tmp_digests_delta LIKE tmp_digests;\n SET v_sql = CONCAT('INSERT INTO tmp_digests_delta\nSELECT `d_end`.`SCHEMA_NAME`,\n `d_end`.`DIGEST`,\n `d_end`.`DIGEST_TEXT`,\n `d_end`.`COUNT_STAR`-IFNULL(`d_start`.`COUNT_STAR`, 0) AS 'COUNT_STAR',\n `d_end`.`SUM_TIMER_WAIT`-IFNULL(`d_start`.`SUM_TIMER_WAIT`, 0) AS 'SUM_TIMER_WAIT',\n `d_end`.`MIN_TIMER_WAIT` AS 'MIN_TIMER_WAIT',\n IFNULL((`d_end`.`SUM_TIMER_WAIT`-IFNULL(`d_start`.`SUM_TIMER_WAIT`, 0))/NULLIF(`d_end`.`COUNT_STAR`-IFNULL(`d_start`.`COUNT_STAR`, 0), 0), 0) AS 'AVG_TIMER_WAIT',\n `d_end`.`MAX_TIMER_WAIT` AS 'MAX_TIMER_WAIT',\n `d_end`.`SUM_LOCK_TIME`-IFNULL(`d_start`.`SUM_LOCK_TIME`, 0) AS 'SUM_LOCK_TIME',\n `d_end`.`SUM_ERRORS`-IFNULL(`d_start`.`SUM_ERRORS`, 0) AS 'SUM_ERRORS',\n `d_end`.`SUM_WARNINGS`-IFNULL(`d_start`.`SUM_WARNINGS`, 0) AS 'SUM_WARNINGS',\n `d_end`.`SUM_ROWS_AFFECTED`-IFNULL(`d_start`.`SUM_ROWS_AFFECTED`, 0) AS 'SUM_ROWS_AFFECTED',\n `d_end`.`SUM_ROWS_SENT`-IFNULL(`d_start`.`SUM_ROWS_SENT`, 0) AS 'SUM_ROWS_SENT',\n `d_end`.`SUM_ROWS_EXAMINED`-IFNULL(`d_start`.`SUM_ROWS_EXAMINED`, 0) AS 'SUM_ROWS_EXAMINED',\n `d_end`.`SUM_CREATED_TMP_DISK_TABLES`-IFNULL(`d_start`.`SUM_CREATED_TMP_DISK_TABLES`, 0) AS 'SUM_CREATED_TMP_DISK_TABLES',\n `d_end`.`SUM_CREATED_TMP_TABLES`-IFNULL(`d_start`.`SUM_CREATED_TMP_TABLES`, 0) AS 'SUM_CREATED_TMP_TABLES',\n `d_end`.`SUM_SELECT_FULL_JOIN`-IFNULL(`d_start`.`SUM_SELECT_FULL_JOIN`, 0) AS 'SUM_SELECT_FULL_JOIN',\n `d_end`.`SUM_SELECT_FULL_RANGE_JOIN`-IFNULL(`d_start`.`SUM_SELECT_FULL_RANGE_JOIN`, 0) AS 'SUM_SELECT_FULL_RANGE_JOIN',\n `d_end`.`SUM_SELECT_RANGE`-IFNULL(`d_start`.`SUM_SELECT_RANGE`, 0) AS 'SUM_SELECT_RANGE',\n `d_end`.`SUM_SELECT_RANGE_CHECK`-IFNULL(`d_start`.`SUM_SELECT_RANGE_CHECK`, 0) AS 'SUM_SELECT_RANGE_CHECK',\n `d_end`.`SUM_SELECT_SCAN`-IFNULL(`d_start`.`SUM_SELECT_SCAN`, 0) AS 'SUM_SELECT_SCAN',\n `d_end`.`SUM_SORT_MERGE_PASSES`-IFNULL(`d_start`.`SUM_SORT_MERGE_PASSES`, 0) AS 'SUM_SORT_MERGE_PASSES',\n `d_end`.`SUM_SORT_RANGE`-IFNULL(`d_start`.`SUM_SORT_RANGE`, 0) AS 'SUM_SORT_RANGE',\n `d_end`.`SUM_SORT_ROWS`-IFNULL(`d_start`.`SUM_SORT_ROWS`, 0) AS 'SUM_SORT_ROWS',\n `d_end`.`SUM_SORT_SCAN`-IFNULL(`d_start`.`SUM_SORT_SCAN`, 0) AS 'SUM_SORT_SCAN',\n `d_end`.`SUM_NO_INDEX_USED`-IFNULL(`d_start`.`SUM_NO_INDEX_USED`, 0) AS 'SUM_NO_INDEX_USED',\n `d_end`.`SUM_NO_GOOD_INDEX_USED`-IFNULL(`d_start`.`SUM_NO_GOOD_INDEX_USED`, 0) AS 'SUM_NO_GOOD_INDEX_USED',\n `d_end`.`SUM_CPU_TIME`-IFNULL(`d_start`.`SUM_CPU_TIME`, 0) AS 'SUM_CPU_TIME',\n `d_end`.`MAX_CONTROLLED_MEMORY` AS 'MAX_CONTROLLED_MEMORY',\n `d_end`.`MAX_TOTAL_MEMORY` AS 'MAX_TOTAL_MEMORY',\n `d_end`.`COUNT_SECONDARY`-IFNULL(`d_start`.`COUNT_SECONDARY`, 0) AS 'COUNT_SECONDARY',\n `d_end`.`FIRST_SEEN`,\n `d_end`.`LAST_SEEN`,\n `d_end`.`QUANTILE_95`,\n `d_end`.`QUANTILE_99`,\n `d_end`.`QUANTILE_999`,\n `d_end`.`QUERY_SAMPLE_TEXT`,\n `d_end`.`QUERY_SAMPLE_SEEN`,\n `d_end`.`QUERY_SAMPLE_TIMER_WAIT`\n FROM tmp_digests d_end\n LEFT OUTER JOIN ', v_quoted_table, ' d_start ON `d_start`.`DIGEST` = `d_end`.`DIGEST`\n AND (`d_start`.`SCHEMA_NAME` = `d_end`.`SCHEMA_NAME`\n OR (`d_start`.`SCHEMA_NAME` IS NULL AND `d_end`.`SCHEMA_NAME` IS NULL)\n )\n WHERE `d_end`.`COUNT_STAR`-IFNULL(`d_start`.`COUNT_STAR`, 0) > 0');\n CALL sys.execute_prepared_stmt(v_sql);\n END IF;\n IF (FIND_IN_SET('with_runtimes_in_95th_percentile', in_views)) THEN\n SELECT 'Queries with Runtime in 95th Percentile' AS 'Next Output';\n DROP TEMPORARY TABLE IF EXISTS tmp_digest_avg_latency_distribution1;\n DROP TEMPORARY TABLE IF EXISTS tmp_digest_avg_latency_distribution2;\n DROP TEMPORARY TABLE IF EXISTS tmp_digest_95th_percentile_by_avg_us;\n CREATE TEMPORARY TABLE tmp_digest_avg_latency_distribution1 (\n cnt bigint unsigned NOT NULL,\n avg_us decimal(21,0) NOT NULL,\n PRIMARY KEY (avg_us)\n ) ENGINE=InnoDB;\n SET v_sql = CONCAT('INSERT INTO tmp_digest_avg_latency_distribution1\nSELECT COUNT(*) cnt,\n ROUND(avg_timer_wait/1000000) AS avg_us\n FROM ', v_digests_table, '\n GROUP BY avg_us');\n CALL sys.execute_prepared_stmt(v_sql);\n CREATE TEMPORARY TABLE tmp_digest_avg_latency_distribution2 LIKE tmp_digest_avg_latency_distribution1;\n INSERT INTO tmp_digest_avg_latency_distribution2 SELECT * FROM tmp_digest_avg_latency_distribution1;\n CREATE TEMPORARY TABLE tmp_digest_95th_percentile_by_avg_us (\n avg_us decimal(21,0) NOT NULL,\n percentile decimal(46,4) NOT NULL,\n PRIMARY KEY (avg_us)\n ) ENGINE=InnoDB;\n SET v_sql = CONCAT('INSERT INTO tmp_digest_95th_percentile_by_avg_us\nSELECT s2.avg_us avg_us,\n IFNULL(SUM(s1.cnt)/NULLIF((SELECT COUNT(*) FROM ', v_digests_table, '), 0), 0) percentile\n FROM tmp_digest_avg_latency_distribution1 AS s1\n JOIN tmp_digest_avg_latency_distribution2 AS s2 ON s1.avg_us <= s2.avg_us\n GROUP BY s2.avg_us\nHAVING percentile > 0.95\n ORDER BY percentile\n LIMIT 1');\n CALL sys.execute_prepared_stmt(v_sql);\n SET v_sql =\n REPLACE(\n REPLACE(\n (SELECT VIEW_DEFINITION\n FROM information_schema.VIEWS\n WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'statements_with_runtimes_in_95th_percentile'\n ),\n '`performance_schema`.`events_statements_summary_by_digest`',\n v_digests_table\n ),\n 'sys.x$ps_digest_95th_percentile_by_avg_us',\n '`sys`.`x$ps_digest_95th_percentile_by_avg_us`'\n );\n CALL sys.execute_prepared_stmt(v_sql);\n DROP TEMPORARY TABLE tmp_digest_avg_latency_distribution1;\n DROP TEMPORARY TABLE tmp_digest_avg_latency_distribution2;\n DROP TEMPORARY TABLE tmp_digest_95th_percentile_by_avg_us;\n END IF;\n IF (FIND_IN_SET('analysis', in_views)) THEN\n SELECT CONCAT('Top ', @sys.statement_performance_analyzer.limit, ' Queries Ordered by Total Latency') AS 'Next Output';\n SET v_sql =\n REPLACE(\n (SELECT VIEW_DEFINITION\n FROM information_schema.VIEWS\n WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'statement_analysis'\n ),\n '`performance_schema`.`events_statements_summary_by_digest`',\n v_digests_table\n );\n IF (@sys.statement_performance_analyzer.limit > 0) THEN\n SET v_sql = CONCAT(v_sql, ' LIMIT ', @sys.statement_performance_analyzer.limit);\n END IF;\n CALL sys.execute_prepared_stmt(v_sql);\n END IF;\n IF (FIND_IN_SET('with_errors_or_warnings', in_views)) THEN\n SELECT CONCAT('Top ', @sys.statement_performance_analyzer.limit, ' Queries with Errors') AS 'Next Output';\n SET v_sql =\n REPLACE(\n (SELECT VIEW_DEFINITION\n FROM information_schema.VIEWS\n WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'statements_with_errors_or_warnings'\n ),\n '`performance_schema`.`events_statements_summary_by_digest`',\n v_digests_table\n );\n IF (@sys.statement_performance_analyzer.limit > 0) THEN\n SET v_sql = CONCAT(v_sql, ' LIMIT ', @sys.statement_performance_analyzer.limit);\n END IF;\n CALL sys.execute_prepared_stmt(v_sql);\n END IF;\n IF (FIND_IN_SET('with_full_table_scans', in_views)) THEN\n SELECT CONCAT('Top ', @sys.statement_performance_analyzer.limit, ' Queries with Full Table Scan') AS 'Next Output';\n SET v_sql =\n REPLACE(\n (SELECT VIEW_DEFINITION\n FROM information_schema.VIEWS\n WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'statements_with_full_table_scans'\n ),\n '`performance_schema`.`events_statements_summary_by_digest`',\n v_digests_table\n );\n IF (@sys.statement_performance_analyzer.limit > 0) THEN\n SET v_sql = CONCAT(v_sql, ' LIMIT ', @sys.statement_performance_analyzer.limit);\n END IF;\n CALL sys.execute_prepared_stmt(v_sql);\n END IF;\n IF (FIND_IN_SET('with_sorting', in_views)) THEN\n SELECT CONCAT('Top ', @sys.statement_performance_analyzer.limit, ' Queries with Sorting') AS 'Next Output';\n SET v_sql =\n REPLACE(\n (SELECT VIEW_DEFINITION\n FROM information_schema.VIEWS\n WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'statements_with_sorting'\n ),\n '`performance_schema`.`events_statements_summary_by_digest`',\n v_digests_table\n );\n IF (@sys.statement_performance_analyzer.limit > 0) THEN\n SET v_sql = CONCAT(v_sql, ' LIMIT ', @sys.statement_performance_analyzer.limit);\n END IF;\n CALL sys.execute_prepared_stmt(v_sql);\n END IF;\n IF (FIND_IN_SET('with_temp_tables', in_views)) THEN\n SELECT CONCAT('Top ', @sys.statement_performance_analyzer.limit, ' Queries with Internal Temporary Tables') AS 'Next Output';\n SET v_sql =\n REPLACE(\n (SELECT VIEW_DEFINITION\n FROM information_schema.VIEWS\n WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'statements_with_temp_tables'\n ),\n '`performance_schema`.`events_statements_summary_by_digest`',\n v_digests_table\n );\n IF (@sys.statement_performance_analyzer.limit > 0) THEN\n SET v_sql = CONCAT(v_sql, ' LIMIT ', @sys.statement_performance_analyzer.limit);\n END IF;\n CALL sys.execute_prepared_stmt(v_sql);\n END IF;\n IF (FIND_IN_SET('custom', in_views)) THEN\n SELECT CONCAT('Top ', @sys.statement_performance_analyzer.limit, ' Queries Using Custom View') AS 'Next Output';\n IF (@sys.statement_performance_analyzer.view IS NULL) THEN\n SET @sys.statement_performance_analyzer.view = sys.sys_get_config('statement_performance_analyzer.view', NULL);\n END IF;\n IF (@sys.statement_performance_analyzer.view IS NULL) THEN\n SIGNAL SQLSTATE '45000'\n SET MESSAGE_TEXT = 'The @sys.statement_performance_analyzer.view user variable must be set with the view or query to use.';\n END IF;\n IF (NOT INSTR(@sys.statement_performance_analyzer.view, ' ')) THEN\n -- No spaces, so can't be a query\n IF (NOT INSTR(@sys.statement_performance_analyzer.view, '.')) THEN\n -- No . in the table name - use current database\n -- DATABASE() will be the database of the procedure\n SET v_custom_db = DATABASE(),\n v_custom_name = @sys.statement_performance_analyzer.view;\n ELSE\n SET v_custom_db = SUBSTRING_INDEX(@sys.statement_performance_analyzer.view, '.', 1);\n SET v_custom_name = SUBSTRING(@sys.statement_performance_analyzer.view, CHAR_LENGTH(v_custom_db)+2);\n END IF;\n CALL sys.table_exists(v_custom_db, v_custom_name, v_custom_view_exists);\n IF (v_custom_view_exists <> 'VIEW') THEN\n SIGNAL SQLSTATE '45000'\n SET MESSAGE_TEXT = 'The @sys.statement_performance_analyzer.view user variable is set but specified neither an existing view nor a query.';\n END IF;\n SET v_sql =\n REPLACE(\n (SELECT VIEW_DEFINITION\n FROM information_schema.VIEWS\n WHERE TABLE_SCHEMA = v_custom_db AND TABLE_NAME = v_custom_name\n ),\n '`performance_schema`.`events_statements_summary_by_digest`',\n v_digests_table\n );\n ELSE\n SET v_sql = REPLACE(@sys.statement_performance_analyzer.view, '`performance_schema`.`events_statements_summary_by_digest`', v_digests_table);\n END IF;\n IF (@sys.statement_performance_analyzer.limit > 0) THEN\n SET v_sql = CONCAT(v_sql, ' LIMIT ', @sys.statement_performance_analyzer.limit);\n END IF;\n CALL sys.execute_prepared_stmt(v_sql);\n END IF;\n END IF;\n -- Restore INSTRUMENTED for this thread\n IF (v_this_thread_enabled = 'YES') THEN\n CALL sys.ps_setup_enable_thread(CONNECTION_ID());\n END IF;\n IF ((@log_bin = 1) AND (@@binlog_format = 'STATEMENT')) THEN\n SET sql_log_bin = @log_bin;\n END IF;\nEND","NULL","SQL","SQL","NO","CONTAINS SQL","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nCreate a report of the statements running on the server.\n\nThe views are calculated based on the overall and/or delta activity.\n\nRequires the SUPER privilege for "SET sql_log_bin = 0;".\n\nParameters\n-----------\n\nin_action (ENUM('snapshot', 'overall', 'delta', 'create_tmp', 'create_table', 'save', 'cleanup')):\n The action to take. Supported actions are:\n * snapshot Store a snapshot. The default is to make a snapshot of the current content of\n performance_schema.events_statements_summary_by_digest, but by setting in_table\n this can be overwritten to copy the content of the specified table.\n The snapshot is stored in the sys.tmp_digests temporary table.\n * overall Generate analyzis based on the content specified by in_table. For the overall analyzis,\n in_table can be NOW() to use a fresh snapshot. This will overwrite an existing snapshot.\n Use NULL for in_table to use the existing snapshot. If in_table IS NULL and no snapshot\n exists, a new will be created.\n See also in_views and @sys.statement_performance_analyzer.limit.\n * delta Generate a delta analysis. The delta will be calculated between the reference table in\n in_table and the snapshot. An existing snapshot must exist.\n The action uses the sys.tmp_digests_delta temporary table.\n See also in_views and @sys.statement_performance_analyzer.limit.\n * create_table Create a regular table suitable for storing the snapshot for later use, e.g. for\n calculating deltas.\n * create_tmp Create a temporary table suitable for storing the snapshot for later use, e.g. for\n calculating deltas.\n * save Save the snapshot in the table specified by in_table. The table must exists and have\n the correct structure.\n If no snapshot exists, a new is created.\n * cleanup Remove the temporary tables used for the snapshot and delta.\n\nin_table (VARCHAR(129)):\n The table argument used for some actions. Use the format 'db1.t1' or 't1' without using any backticks (`)\n for quoting. Periods (.) are not supported in the database and table names.\n\n The meaning of the table for each action supporting the argument is:\n\n * snapshot The snapshot is created based on the specified table. Set to NULL or NOW() to use\n the current content of performance_schema.events_statements_summary_by_digest.\n * overall The table with the content to create the overall analyzis for. The following values\n can be used:\n - A table name - use the content of that table.\n - NOW() - create a fresh snapshot and overwrite the existing snapshot.\n - NULL - use the last stored snapshot.\n * delta The table name is mandatory and specified the reference view to compare the currently\n stored snapshot against. If no snapshot exists, a new will be created.\n * create_table The name of the regular table to create.\n * create_tmp The name of the temporary table to create.\n * save The name of the table to save the currently stored snapshot into.\n\nin_views (SET ('with_runtimes_in_95th_percentile', 'analysis', 'with_errors_or_warnings',\n 'with_full_table_scans', 'with_sorting', 'with_temp_tables', 'custom'))\n Which views to include:\n\n * with_runtimes_in_95th_percentile Based on the sys.statements_with_runtimes_in_95th_percentile view\n * analysis Based on the sys.statement_analysis view\n * with_errors_or_warnings Based on the sys.statements_with_errors_or_warnings view\n * with_full_table_scans Based on the sys.statements_with_full_table_scans view\n * with_sorting Based on the sys.statements_with_sorting view\n * with_temp_tables Based on the sys.statements_with_temp_tables view\n * custom Use a custom view. This view must be specified in @sys.statement_performance_analyzer.view to an existing view or a query\n\nDefault is to include all except 'custom'.\n\n\nConfiguration Options\n----------------------\n\nsys.statement_performance_analyzer.limit\n The maximum number of rows to include for the views that does not have a built-in limit (e.g. the 95th percentile view).\n If not set the limit is 100.\n\nsys.statement_performance_analyzer.view\n Used together with the 'custom' view. If the value contains a space, it is considered a query, otherwise it must be\n an existing view querying the performance_schema.events_statements_summary_by_digest table. There cannot be any limit\n clause including in the query or view definition if @sys.statement_performance_analyzer.limit > 0.\n If specifying a view, use the same format as for in_table.\n\nsys.debug\n Whether to provide debugging output.\n Default is 'OFF'. Set to 'ON' to include.\n\n\nExample\n--------\n\nTo create a report with the queries in the 95th percentile since last truncate of performance_schema.events_statements_summary_by_digest\nand the delta for a 1 minute period:\n\n 1. Create a temporary table to store the initial snapshot.\n 2. Create the initial snapshot.\n 3. Save the initial snapshot in the temporary table.\n 4. Wait one minute.\n 5. Create a new snapshot.\n 6. Perform analyzis based on the new snapshot.\n 7. Perform analyzis based on the delta between the initial and new snapshots.\n\nmysql> CALL sys.statement_performance_analyzer('create_tmp', 'mydb.tmp_digests_ini', NULL);\nQuery OK, 0 rows affected (0.08 sec)\n\nmysql> CALL sys.statement_performance_analyzer('snapshot', NULL, NULL);\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> CALL sys.statement_performance_analyzer('save', 'mydb.tmp_digests_ini', NULL);\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> DO SLEEP(60);\nQuery OK, 0 rows affected (1 min 0.00 sec)\n\nmysql> CALL sys.statement_performance_analyzer('snapshot', NULL, NULL);\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> CALL sys.statement_performance_analyzer('overall', NULL, 'with_runtimes_in_95th_percentile');\n+-----------------------------------------+\n| Next Output |\n+-----------------------------------------+\n| Queries with Runtime in 95th Percentile |\n+-----------------------------------------+\n1 row in set (0.05 sec)\n\n...\n\nmysql> CALL sys.statement_performance_analyzer('delta', 'mydb.tmp_digests_ini', 'with_runtimes_in_95th_percentile');\n+-----------------------------------------+\n| Next Output |\n+-----------------------------------------+\n| Queries with Runtime in 95th Percentile |\n+-----------------------------------------+\n1 row in set (0.03 sec)\n\n...\n\n\nTo create an overall report of the 95th percentile queries and the top 10 queries with full table scans:\n\nmysql> CALL sys.statement_performance_analyzer('snapshot', NULL, NULL);\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> SET @sys.statement_performance_analyzer.limit = 10;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> CALL sys.statement_performance_analyzer('overall', NULL, 'with_runtimes_in_95th_percentile,with_full_table_scans');\n+-----------------------------------------+\n| Next Output |\n+-----------------------------------------+\n| Queries with Runtime in 95th Percentile |\n+-----------------------------------------+\n1 row in set (0.01 sec)\n\n...\n\n+-------------------------------------+\n| Next Output |\n+-------------------------------------+\n| Top 10 Queries with Full Table Scan |\n+-------------------------------------+\n1 row in set (0.09 sec)\n\n...\n\n\nUse a custom view showing the top 10 query sorted by total execution time refreshing the view every minute using\nthe watch command in Linux.\n\nmysql> CREATE OR REPLACE VIEW mydb.my_statements AS\n -> SELECT sys.format_statement(DIGEST_TEXT) AS query,\n -> SCHEMA_NAME AS db,\n -> COUNT_STAR AS exec_count,\n -> format_pico_time(SUM_TIMER_WAIT) AS total_latency,\n -> format_pico_time(AVG_TIMER_WAIT) AS avg_latency,\n -> ROUND(IFNULL(SUM_ROWS_SENT / NULLIF(COUNT_STAR, 0), 0)) AS rows_sent_avg,\n -> ROUND(IFNULL(SUM_ROWS_EXAMINED / NULLIF(COUNT_STAR, 0), 0)) AS rows_examined_avg,\n -> ROUND(IFNULL(SUM_ROWS_AFFECTED / NULLIF(COUNT_STAR, 0), 0)) AS rows_affected_avg,\n -> DIGEST AS digest\n -> FROM performance_schema.events_statements_summary_by_digest\n -> ORDER BY SUM_TIMER_WAIT DESC;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> CALL sys.statement_performance_analyzer('create_table', 'mydb.digests_prev', NULL);\nQuery OK, 0 rows affected (0.10 sec)\n\nshell$ watch -n 60 "mysql sys --table -e "\n> SET @sys.statement_performance_analyzer.view = 'mydb.my_statements';\n> SET @sys.statement_performance_analyzer.limit = 10;\n> CALL statement_performance_analyzer('snapshot', NULL, NULL);\n> CALL statement_performance_analyzer('delta', 'mydb.digests_prev', 'custom');\n> CALL statement_performance_analyzer('save', 'mydb.digests_prev', NULL);\n> ""\n\nEvery 60.0s: mysql sys --table -e " ... Mon Dec 22 10:58:51 2014\n\n+----------------------------------+\n| Next Output |\n+----------------------------------+\n| Top 10 Queries Using Custom View |\n+----------------------------------+\n+-------------------+-------+------------+---------------+-------------+---------------+-------------------+-------------------+----------------------------------+\n| query | db | exec_count | total_latency | avg_latency | rows_sent_avg | rows_examined_avg | rows_affected_avg | digest |\n+-------------------+-------+------------+---------------+-------------+---------------+-------------------+-------------------+----------------------------------+\n...\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci""table_exists","def","sys","table_exists","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","BEGIN\n DECLARE v_error BOOLEAN DEFAULT FALSE;\n DECLARE CONTINUE HANDLER FOR 1050 SET v_error = TRUE;\n DECLARE CONTINUE HANDLER FOR 1146 SET v_error = TRUE;\n SET out_exists = '';\n -- Verify whether the table name exists as a normal table\n IF (EXISTS(SELECT 1 FROM information_schema.TABLES WHERE TABLE_SCHEMA = in_db AND TABLE_NAME = in_table)) THEN\n -- Unfortunately the only way to determine whether there is also a temporary table is to try to create\n -- a temporary table with the same name. If it succeeds the table didn't exist as a temporary table.\n SET @sys.tmp.table_exists.SQL = CONCAT('CREATE TEMPORARY TABLE `', in_db, '`.`', in_table, '` (id INT PRIMARY KEY)');\n PREPARE stmt_create_table FROM @sys.tmp.table_exists.SQL;\n EXECUTE stmt_create_table;\n DEALLOCATE PREPARE stmt_create_table;\n IF (v_error) THEN\n SET out_exists = 'TEMPORARY';\n ELSE\n -- The temporary table was created, i.e. it didn't exist. Remove it again so we don't leave garbage around.\n SET @sys.tmp.table_exists.SQL = CONCAT('DROP TEMPORARY TABLE `', in_db, '`.`', in_table, '`');\n PREPARE stmt_drop_table FROM @sys.tmp.table_exists.SQL;\n EXECUTE stmt_drop_table;\n DEALLOCATE PREPARE stmt_drop_table;\n SET out_exists = (SELECT TABLE_TYPE FROM information_schema.TABLES WHERE TABLE_SCHEMA = in_db AND TABLE_NAME = in_table);\n END IF;\n ELSE\n -- Check whether a temporary table exists with the same name.\n -- If it does it's possible to SELECT from the table without causing an error.\n -- If it does not exist even a PREPARE using the table will fail.\n SET @sys.tmp.table_exists.SQL = CONCAT('SELECT COUNT(*) FROM `', in_db, '`.`', in_table, '`');\n PREPARE stmt_select FROM @sys.tmp.table_exists.SQL;\n IF (NOT v_error) THEN\n DEALLOCATE PREPARE stmt_select;\n SET out_exists = 'TEMPORARY';\n END IF;\n END IF;\nEND","NULL","SQL","SQL","NO","CONTAINS SQL","NULL","INVOKER","2023-03-21 14:43:52","2023-03-21 14:43:52","ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION","\nDescription\n-----------\n\nTests whether the table specified in in_db and in_table exists either as a regular\ntable, or as a temporary table. The returned value corresponds to the table that\nwill be used, so if there's both a temporary and a permanent table with the given\nname, then 'TEMPORARY' will be returned.\n\nParameters\n-----------\n\nin_db (VARCHAR(64)):\n The database name to check for the existance of the table in.\n\nin_table (VARCHAR(64)):\n The name of the table to check the existance of.\n\nout_exists ENUM('', 'BASE TABLE', 'VIEW', 'TEMPORARY'):\n The return value: whether the table exists. The value is one of:\n * '' - the table does not exist neither as a base table, view, nor temporary table.\n * 'BASE TABLE' - the table name exists as a permanent base table table.\n * 'VIEW' - the table name exists as a view.\n * 'TEMPORARY' - the table name exists as a temporary table.\n\nExample\n--------\n\nmysql> CREATE DATABASE db1;\nQuery OK, 1 row affected (0.07 sec)\n\nmysql> use db1;\nDatabase changed\nmysql> CREATE TABLE t1 (id INT PRIMARY KEY);\nQuery OK, 0 rows affected (0.08 sec)\n\nmysql> CREATE TABLE t2 (id INT PRIMARY KEY);\nQuery OK, 0 rows affected (0.08 sec)\n\nmysql> CREATE view v_t1 AS SELECT * FROM t1;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> CREATE TEMPORARY TABLE t1 (id INT PRIMARY KEY);\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> CALL sys.table_exists('db1', 't1', @exists); SELECT @exists;\nQuery OK, 0 rows affected (0.00 sec)\n\n+------------+\n| @exists |\n+------------+\n| TEMPORARY |\n+------------+\n1 row in set (0.00 sec)\n\nmysql> CALL sys.table_exists('db1', 't2', @exists); SELECT @exists;\nQuery OK, 0 rows affected (0.00 sec)\n\n+------------+\n| @exists |\n+------------+\n| BASE TABLE |\n+------------+\n1 row in set (0.01 sec)\n\nmysql> CALL sys.table_exists('db1', 'v_t1', @exists); SELECT @exists;\nQuery OK, 0 rows affected (0.00 sec)\n\n+---------+\n| @exists |\n+---------+\n| VIEW |\n+---------+\n1 row in set (0.00 sec)\n\nmysql> CALL sys.table_exists('db1', 't3', @exists); SELECT @exists;\nQuery OK, 0 rows affected (0.01 sec)\n\n+---------+\n| @exists |\n+---------+\n| |\n+---------+\n1 row in set (0.00 sec)\n","mysql.sys@localhost","utf8mb4","utf8mb4_0900_ai_ci","utf8mb4_0900_ai_ci" |