"AddGeometryColumn","def","mysql","AddGeometryColumn","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","begin\n  set @qwe= concat('ALTER TABLE ', t_schema, '.', t_name, ' ADD ', geometry_column,' GEOMETRY REF_SYSTEM_ID=', t_srid); PREPARE ls from @qwe; execute ls; deallocate prepare ls; end","NULL","NULL","SQL","NO","CONTAINS SQL","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","latin1_swedish_ci""DropGeometryColumn","def","mysql","DropGeometryColumn","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","begin\n  set @qwe= concat('ALTER TABLE ', t_schema, '.', t_name, ' DROP ', geometry_column); PREPARE ls from @qwe; execute ls; deallocate prepare ls; end","NULL","NULL","SQL","NO","CONTAINS SQL","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","latin1_swedish_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 v_table_exists ENUM('', 'BASE TABLE', 'VIEW', 'TEMPORARY') DEFAULT '';\n    DECLARE v_temp_table TEXT;\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    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    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    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        CALL sys.table_exists(in_db_name, v_table, v_table_exists);\n        IF (v_table_exists = 'TEMPORARY') THEN\n            SET v_temp_table =\n            CONCAT(\n                'Table',\n                 sys.quote_identifier(in_db_name),\n                 '.',\n                 sys.quote_identifier(v_table),\n                 'shadows base table. View cannot be created! Terminating!');\n             SIGNAL SQLSTATE 'HY000'\n                 SET MESSAGE_TEXT = v_temp_table;\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","NULL","SQL","NO","MODIFIES SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Takes a source database name and synonym name, and then creates the\n             synonym database with views that point to all of the tables within\n             the source database.\n             Useful for creating a "ps" synonym for "performance_schema",\n             or "is" instead of "information_schema", for example.\n             Parameters\n             in_db_name (VARCHAR(64)):\n               The database name that you would like to create a synonym for.\n             in_synonym (VARCHAR(64)):\n               The database synonym name.\n             Example\n             mysql> SHOW DATABASES;\n             +--------------------+\n             | Database           |\n             +--------------------+\n             | information_schema |\n             | mysql              |\n             | performance_schema |\n             | sys                |\n             | test               |\n             +--------------------+\n             5 rows in set (0.00 sec)\n             mysql> CALL sys.create_synonym_db('performance_schema', 'ps');\n             +---------------------------------------+\n             | summary                               |\n             +---------------------------------------+\n             | Created 74 views in the `ps` database |\n             +---------------------------------------+\n             1 row in set (8.57 sec)\n             Query OK, 0 rows affected (8.57 sec)\n             mysql> SHOW DATABASES;\n             +--------------------+\n             | Database           |\n             +--------------------+\n             | information_schema |\n             | mysql              |\n             | performance_schema |\n             | ps                 |\n             | sys                |\n             | test               |\n             +--------------------+\n             6 rows in set (0.00 sec)\n             mysql> 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            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_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 utf8 DEFAULT 'NO';\n    DECLARE v_this_thread_enabled, v_has_ps_vars, v_has_metrics ENUM('YES', 'NO');\n    DECLARE v_table_name, v_banner VARCHAR(64) CHARSET utf8;\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    DECLARE v_status_summary_width TINYINT UNSIGNED DEFAULT 50;\n    DECLARE v_done BOOLEAN DEFAULT FALSE;\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    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    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    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    SET @log_bin := @@sql_log_bin;\n    IF (@log_bin = 1) THEN\n        SET sql_log_bin = 0;\n    END IF;\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            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            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        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    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 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    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 = IF(v_has_ps = 'YES'\n                                   AND EXISTS(SELECT 1 FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'performance_schema' AND TABLE_NAME = 'replication_applier_status'),\n                                   'YES',\n                                   'NO'\n                               ),\n        v_has_replication    = 'MAYBE',\n        v_has_metrics        = IF(v_has_ps = 'YES' OR (sys.version_major() = 5 AND sys.version_minor() = 6), 'YES', 'NO'),\n        v_has_ps_vars        = 'NO';\n    \n    \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', v_has_ps_vars AS 'Has_P_S_SHOW_Variables',\n              v_has_metrics AS 'Has_metrics',\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        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        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        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(''sys.format_bytes('', COLUMN_NAME, '') AS '', COLUMN_NAME)\\n                    WHEN SUBSTRING(COLUMN_NAME, -8) = ''_latency''\\n                         THEN CONCAT(''sys.format_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(''sys.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, diag.pk)\\n                         THEN COLUMN_NAME\\n                    WHEN diag.TABLE_NAME = ''io_global_by_file_by_bytes'' AND COLUMN_NAME = ''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(''sys.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(''sys.format_time(e.'', COLUMN_NAME, '') AS '', COLUMN_NAME)\\n                    WHEN COLUMN_NAME = ''avg_latency''\\n                         THEN CONCAT(''sys.format_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(''sys.format_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 SUBSTRING(COLUMN_NAME, -8) = ''_latency''\\n                         THEN CONCAT(''sys.format_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(''sys.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(''sys.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 = 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        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        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     Configuration\\n=======================\\n' AS '';\n    SELECT 'GLOBAL VARIABLES' AS 'The following output is:';\n    IF (v_has_ps_vars = 'YES') THEN\n        SELECT LOWER(VARIABLE_NAME) AS Variable_name, VARIABLE_VALUE AS Variable_value FROM performance_schema.global_variables ORDER BY VARIABLE_NAME;\n    ELSE\n        SELECT LOWER(VARIABLE_NAME) AS Variable_name, VARIABLE_VALUE AS Variable_value FROM information_schema.GLOBAL_VARIABLES ORDER BY VARIABLE_NAME;\n    END IF;\n    IF (v_has_ps = 'YES') THEN\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        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;\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    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    IF (v_has_ps = 'YES') THEN\n        IF (@sys.diagnostics.include_raw = 'ON') THEN\n            SELECT '\\n========================\\n     Initial Status\\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        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                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 = 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    SET v_sql_status_summary_select = 'SELECT Variable_name',\n        v_sql_status_summary_delta  = '',\n        v_sql_status_summary_from   = '';\n    REPEAT\n        SET v_output_count = v_output_count + 1;\n        IF (v_output_count > 1) THEN\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        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        END IF;\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        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(100) NOT NULL,\\n  Enabled ENUM(''YES'', ''NO'', ''PARTIAL'') NOT NULL,\\n  PRIMARY KEY (Type, Variable_name)\\n) ENGINE = InnoDB DEFAULT CHARSET=utf8'));\n        IF (v_has_metrics) THEN\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        ELSE\n            SET @sys.diagnostics.sql = CONCAT(\n                'INSERT INTO ', v_table_name,\n                '(SELECT LOWER(VARIABLE_NAME) AS Variable_name, REPLACE(VARIABLE_VALUE, ''\\n'', ''\\\\n'') AS Variable_value,\\n                         ''Global Status'' AS Type, ''YES'' AS Enabled\\n  FROM performance_schema.global_status\\n) UNION ALL (\\nSELECT NAME AS Variable_name, COUNT AS Variable_value,\\n       CONCAT(''InnoDB Metrics - '', SUBSYSTEM) AS Type,\\n       IF(STATUS = ''enabled'', ''YES'', ''NO'') AS Enabled\\n  FROM information_schema.INNODB_METRICS\\n WHERE NAME NOT IN (\\n     ''lock_row_lock_time'', ''lock_row_lock_time_avg'', ''lock_row_lock_time_max'', ''lock_row_lock_waits'',\\n     ''buffer_pool_reads'', ''buffer_pool_read_requests'', ''buffer_pool_write_requests'', ''buffer_pool_wait_free'',\\n     ''buffer_pool_read_ahead'', ''buffer_pool_read_ahead_evicted'', ''buffer_pool_pages_total'', ''buffer_pool_pages_misc'',\\n     ''buffer_pool_pages_data'', ''buffer_pool_bytes_data'', ''buffer_pool_pages_dirty'', ''buffer_pool_bytes_dirty'',\\n     ''buffer_pool_pages_free'', ''buffer_pages_created'', ''buffer_pages_written'', ''buffer_pages_read'',\\n     ''buffer_data_reads'', ''buffer_data_written'', ''file_num_open_files'',\\n     ''os_log_bytes_written'', ''os_log_fsyncs'', ''os_log_pending_fsyncs'', ''os_log_pending_writes'',\\n     ''log_waits'', ''log_write_requests'', ''log_writes'', ''innodb_dblwr_writes'', ''innodb_dblwr_pages_written'', ''innodb_page_size'')\\n) UNION ALL (\\nSELECT ''NOW()'' AS Variable_name, NOW(3) AS Variable_value, ''System Time'' AS Type, ''YES'' AS Enabled\\n) UNION ALL (\\nSELECT ''UNIX_TIMESTAMP()'' AS Variable_name, ROUND(UNIX_TIMESTAMP(NOW(3)), 3) AS Variable_value, ''System Time'' AS Type, ''YES'' AS Enabled\\n)\\n ORDER BY Type, Variable_name;'\n            );\n        END IF;\n        CALL sys.execute_prepared_stmt(@sys.diagnostics.sql);\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        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            IF (v_has_metrics) THEN\n                SELECT 'SELECT * FROM sys.metrics' AS 'The following output is:';\n            ELSE\n                SELECT 'sys.metrics equivalent' AS 'The following output is:';\n            END IF;\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        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        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, sys.format_bytes(used) AS used, used_pages, sys.format_bytes(total) AS total, total_pages,\n                   ROUND(100*(used/total), 2) AS 'Used %'\n            FROM ndbinfo.memoryusage;\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            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            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    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    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     Schema Information\\n============================\\n' AS '';\n    SELECT COUNT(*) AS 'Total Number of Tables' FROM information_schema.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                sys.format_bytes(SUM(DATA_LENGTH)) AS DATA_LENGTH,\n                sys.format_bytes(SUM(INDEX_LENGTH)) AS INDEX_LENGTH,\n                sys.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     Overall Status\\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            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                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 = 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 IF;\n        END LOOP;\n        CLOSE c_sysviews_w_delta;\n        DEALLOCATE PREPARE stmt_gen_query;\n        SELECT '\\n======================\\n     Delta Status\\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        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            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 = 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    IF (v_has_metrics) THEN\n        SELECT 'SELECT * FROM sys.metrics' AS 'The following output is:';\n    ELSE\n        SELECT 'sys.metrics equivalent' AS 'The following output is:';\n    END IF;\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    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        SET sql_log_bin = @log_bin;\n    END IF;\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    IF (v_this_thread_enabled = 'YES') THEN\n        CALL sys.ps_setup_enable_thread(CONNECTION_ID());\n    END IF;\n    IF (@log_bin = 1) THEN\n        SET sql_log_bin = @log_bin;\n    END IF;\nEND","NULL","NULL","SQL","NO","READS SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Create a report of the current status of the server for diagnostics purposes. Data collected includes (some items depends on versions and settings):\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             Some of the sys schema views are calculated as initial (optional), overall, delta:\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             Requires the SUPER privilege for "SET sql_log_bin = 0;".\n             Versions supported:\n                * MySQL 5.6: 5.6.10 and later\n                * MySQL 5.7: 5.7.9 and later\n             Parameters\n             in_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.\n             in_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.\n             in_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.\n                  * full - enables all settings. This will have a big impact on the\n                           performance - be careful using this option.\n               If another setting the 'current' is chosen, the current settings\n               are restored at the end of the procedure.\n             Configuration Options\n             sys.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             sys.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             sys.statement_truncate_len\n               How much of queries in the process list output to include.\n               Default is 64.\n             sys.debug\n               Whether to provide debugging output.\n               Default is 'OFF'. Set to 'ON' to include.\n             Example\n             To create a report and append it to the file diag.out:\n             mysql> TEE diag.out;\n             mysql> CALL sys.diagnostics(120, 30, 'current');\n             ...\n             mysql> NOTEE;\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_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","NULL","SQL","YES","READS SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Shows all currently disabled instruments.\n             Parameters\n             None\n             Example\n             mysql> CALL sys.ps_setup_show_disabled_instruments();\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_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","NULL","SQL","YES","READS SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Shows all currently enabled instruments.\n             Parameters\n             None\n             Example\n             mysql> CALL sys.ps_setup_show_enabled_instruments();\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_ci""execute_prepared_stmt","def","sys","execute_prepared_stmt","PROCEDURE","","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","SQL","BEGIN\n    IF (@sys.debug IS NULL) THEN\n        SET @sys.debug = sys.sys_get_config('debug', 'OFF');\n    END IF;\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","NULL","SQL","NO","READS SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Takes the query in the argument and executes it using a prepared statement. The prepared statement is deallocated,\n             so the procedure is mainly useful for executing one off dynamically created queries.\n             The sys_execute_prepared_stmt prepared statement name is used for the query and is required not to exist.\n             Parameters\n             in_query (longtext CHARACTER SET UTF8):\n               The query to execute.\n             Configuration Options\n             sys.debug\n               Whether to provide debugging output.\n               Default is 'OFF'. Set to 'ON' to include.\n             Example\n             mysql> 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             +------------------------+-------+---------------------+--------+\n             1 row in set (0.00 sec)\n             Query OK, 0 rows affected (0.00 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_ci""extract_schema_from_file_name","def","sys","extract_schema_from_file_name","FUNCTION","varchar","64","192","NULL","NULL","NULL","utf8mb3","utf8mb3_general_ci","varchar(64)","SQL","BEGIN\n    RETURN LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(REPLACE(path, '\\', '/'), '/', -2), '/', 1), 64);\nEND","NULL","NULL","SQL","YES","NO SQL","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Takes a raw file path, and attempts to extract the schema name from it.\n             Useful for when interacting with Performance Schema data\n             concerning IO statistics, for example.\n             Currently relies on the fact that a table data file will be within a\n             specified database directory (will not work with partitions or tables\n             that specify an individual DATA_DIRECTORY).\n             Parameters\n             path (VARCHAR(512)):\n               The full file path to a data file to extract the schema name from.\n             Returns\n             VARCHAR(64)\n             Example\n             mysql> 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             +----------------------------------------------------------------------------+\n             1 row in set (0.00 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_ci""extract_table_from_file_name","def","sys","extract_table_from_file_name","FUNCTION","varchar","64","192","NULL","NULL","NULL","utf8mb3","utf8mb3_general_ci","varchar(64)","SQL","BEGIN\n    RETURN LEFT(SUBSTRING_INDEX(REPLACE(SUBSTRING_INDEX(REPLACE(path, '\\', '/'), '/', -1), '@0024', '$'), '.', 1), 64);\nEND","NULL","NULL","SQL","YES","NO SQL","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Takes a raw file path, and extracts the table name from it.\n             Useful for when interacting with Performance Schema data\n             concerning IO statistics, for example.\n             Parameters\n             path (VARCHAR(512)):\n               The full file path to a data file to extract the table name from.\n             Returns\n             VARCHAR(64)\n             Example\n             mysql> 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             +---------------------------------------------------------------------------+\n             1 row in set (0.02 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_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","NULL","SQL","NO","READS SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Outputs a textual histogram graph of the average latency values\n             across all normalized queries tracked within the Performance Schema\n             events_statements_summary_by_digest table.\n             Can be used to show a very high level picture of what kind of\n             latency distribution statements running within this instance have.\n             Parameters\n             None.\n             Example\n             mysql> CALL sys.ps_statement_avg_latency_histogram()\\G\n             *************************** 1. row ***************************\n             Performance Schema Statement Digest Average Latency Histogram:\n               . = 1 unit\n               * = 2 units\n               # = 3 units\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               Total Statements: 350; Buckets: 16; Bucket Size: 38 ms;\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_ci""ps_thread_trx_info","def","sys","ps_thread_trx_info","FUNCTION","longtext","2147483647","2147483647","NULL","NULL","NULL","utf8mb3","utf8mb3_general_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    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    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        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(sys.format_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(sys.format_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","NULL","SQL","NO","READS SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Returns a JSON object with info on the given threads current transaction,\n             and the statements it has already executed, derived from the\n             performance_schema.events_transactions_current and\n             performance_schema.events_statements_history tables (so the consumers\n             for these also have to be enabled within Performance Schema to get full\n             data in the object).\n             When the output exceeds the default truncation length (65535), a JSON error\n             object is returned, such as:\n             { "error": "Trx info truncated: Row 6 was cut by GROUP_CONCAT()" }\n             Similar error objects are returned for other warnings/and exceptions raised\n             when calling the function.\n             The max length of the output of this function can be controlled with the\n             ps_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             Parameters\n             in_thread_id (BIGINT UNSIGNED):\n               The id of the thread to return the transaction info for.\n             Example\n             SELECT sys.ps_thread_trx_info(48)\\G\n             *************************** 1. row ***************************\n             sys.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             ]\n             1 row in set (0.03 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_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    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        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           sys.format_time(SUM(timer_wait)) AS exec_time,\n           sys.format_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           sys.format_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           sys.format_time(timer_wait) AS exec_time,\n           sys.format_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               sys.format_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            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    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","NULL","SQL","NO","MODIFIES SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Traces all instrumentation within Performance Schema for a specific\n             Statement Digest.\n             When finding a statement of interest within the\n             performance_schema.events_statements_summary_by_digest table, feed\n             the DIGEST MD5 value in to this procedure, set how long to poll for,\n             and at what interval to poll, and it will generate a report of all\n             statistics tracked within Performance Schema for that digest for the\n             interval.\n             It will also attempt to generate an EXPLAIN for the longest running\n             example of the digest during the interval. Note this may fail, as:\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             When the EXPLAIN fails, the error will be ignored and no EXPLAIN\n             output generated.\n             Requires the SUPER privilege for "SET sql_log_bin = 0;".\n             Parameters\n             in_digest (VARCHAR(32)):\n               The statement digest identifier you would like to analyze\n             in_runtime (INT):\n               The number of seconds to run analysis for\n             in_interval (DECIMAL(2,2)):\n               The interval (in seconds, may be fractional) at which to try\n               and take snapshots\n             in_start_fresh (BOOLEAN):\n               Whether to TRUNCATE the events_statements_history_long and\n               events_stages_history_long tables before starting\n             in_auto_enable (BOOLEAN):\n               Whether to automatically turn on required consumers\n             Example\n             mysql> call ps_trace_statement_digest('891ec6860f98ba46d89dd20b0c03652c', 10, 0.1, true, true);\n             +--------------------+\n             | SUMMARY STATISTICS |\n             +--------------------+\n             | SUMMARY STATISTICS |\n             +--------------------+\n             1 row in set (9.11 sec)\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             +------------+-----------+-----------+-----------+---------------+------------+------------+\n             1 row in set (9.11 sec)\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             +------------------------------------------+-------+-----------+\n             17 rows in set (9.12 sec)\n             +---------------------------+\n             | LONGEST RUNNING STATEMENT |\n             +---------------------------+\n             | LONGEST RUNNING STATEMENT |\n             +---------------------------+\n             1 row in set (9.16 sec)\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             +-----------+-----------+-----------+-----------+---------------+------------+-----------+\n             1 row in set (9.16 sec)\n             // Truncated for clarity...\n             +-----------------------------------------------------------------+\n             | sql_text                                                        |\n             +-----------------------------------------------------------------+\n             | select hibeventhe0_.id as id1382_, hibeventhe0_.createdTime ... |\n             +-----------------------------------------------------------------+\n             1 row in set (9.17 sec)\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             +------------------------------------------+-----------+\n             18 rows in set (9.23 sec)\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             +----+-------------+--------------+-------+---------------+-----------+---------+-------------+------+-------+\n             1 row in set (9.27 sec)\n             Query OK, 0 rows affected (9.28 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_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                    '(', sys.format_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                    IF (event_name LIKE 'statement/%', IFNULL(CONCAT('\\n', wait_info), ''), ''),\n                    IF (in_debug AND event_name LIKE 'wait%', wait_info, ''),\n                    '", ',\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/lock%' THEN\n                           'shape=box, style=filled, color=tan'\n                         WHEN event_name LIKE 'statement/%' THEN\n                           CONCAT('shape=box, style=bold',\n                                  CASE WHEN event_name LIKE 'statement/com/%' THEN\n                                         ' style=filled, color=darkseagreen'\n                                       ELSE\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 'stage/%' THEN\n                           'style=filled, color=slategray3'\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 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: ', sys.format_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 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 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                                   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    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        DELETE FROM performance_schema.setup_actors;\n        UPDATE performance_schema.threads\n           SET INSTRUMENTED = IF(THREAD_ID = in_thread_id, 'YES', 'NO');\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_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    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    IF (in_auto_setup) THEN\n        CALL sys.ps_setup_reload_saved();\n    END IF;\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","NULL","SQL","NO","MODIFIES SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Dumps all data within Performance Schema for an instrumented thread,\n             to create a DOT formatted graph file.\n             Each resultset returned from the procedure should be used for a complete graph\n             Requires the SUPER privilege for "SET sql_log_bin = 0;".\n             Parameters\n             in_thread_id (BIGINT UNSIGNED):\n               The thread that you would like a stack trace for\n             in_outfile  (VARCHAR(255)):\n               The filename the dot file will be written to\n             in_max_runtime (DECIMAL(20,2)):\n               The maximum time to keep collecting data.\n               Use NULL to get the default which is 60 seconds.\n             in_interval (DECIMAL(20,2)):\n               How long to sleep between data collections.\n               Use NULL to get the default which is 1 second.\n             in_start_fresh (BOOLEAN):\n               Whether to reset all Performance Schema data before tracing.\n             in_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.\n             in_debug (BOOLEAN):\n               Whether you would like to include file:lineno in the graph\n             Example\n             mysql> 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             +-------------------+\n             1 row in set (0.00 sec)\n             +---------------------------------------------+\n             | Info                                        |\n             +---------------------------------------------+\n             | Data collection starting for THREAD_ID = 25 |\n             +---------------------------------------------+\n             1 row in set (0.03 sec)\n             +-----------------------------------------------------------+\n             | Info                                                      |\n             +-----------------------------------------------------------+\n             | Stack trace written to /tmp/stack-2014-02-16-21:18:41.dot |\n             +-----------------------------------------------------------+\n             1 row in set (60.07 sec)\n             +-------------------------------------------------------------------+\n             | Convert to PDF                                                    |\n             +-------------------------------------------------------------------+\n             | dot -Tpdf -o /tmp/stack_25.pdf /tmp/stack-2014-02-16-21:18:41.dot |\n             +-------------------------------------------------------------------+\n             1 row in set (60.07 sec)\n             +-------------------------------------------------------------------+\n             | Convert to PNG                                                    |\n             +-------------------------------------------------------------------+\n             | dot -Tpng -o /tmp/stack_25.png /tmp/stack-2014-02-16-21:18:41.dot |\n             +-------------------------------------------------------------------+\n             1 row in set (60.07 sec)\n             +------------------+\n             | summary          |\n             +------------------+\n             | Enabled 1 thread |\n             +------------------+\n             1 row in set (60.32 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_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    DECLARE v_error_msg VARCHAR(128);\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    SET @log_bin := @@sql_log_bin;\n    IF (@log_bin = 1) THEN\n        SET sql_log_bin = 0;\n    END IF;\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 = '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            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_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            IF (v_checksum_ref <> v_checksum_table) THEN\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 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    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            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            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            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            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            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(32) DEFAULT NULL,\\n  `DIGEST_TEXT` longtext,\\n  `COUNT_STAR` bigint(20) unsigned NOT NULL,\\n  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,\\n  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,\\n  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,\\n  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL,\\n  `SUM_LOCK_TIME` bigint(20) unsigned NOT NULL,\\n  `SUM_ERRORS` bigint(20) unsigned NOT NULL,\\n  `SUM_WARNINGS` bigint(20) unsigned NOT NULL,\\n  `SUM_ROWS_AFFECTED` bigint(20) unsigned NOT NULL,\\n  `SUM_ROWS_SENT` bigint(20) unsigned NOT NULL,\\n  `SUM_ROWS_EXAMINED` bigint(20) unsigned NOT NULL,\\n  `SUM_CREATED_TMP_DISK_TABLES` bigint(20) unsigned NOT NULL,\\n  `SUM_CREATED_TMP_TABLES` bigint(20) unsigned NOT NULL,\\n  `SUM_SELECT_FULL_JOIN` bigint(20) unsigned NOT NULL,\\n  `SUM_SELECT_FULL_RANGE_JOIN` bigint(20) unsigned NOT NULL,\\n  `SUM_SELECT_RANGE` bigint(20) unsigned NOT NULL,\\n  `SUM_SELECT_RANGE_CHECK` bigint(20) unsigned NOT NULL,\\n  `SUM_SELECT_SCAN` bigint(20) unsigned NOT NULL,\\n  `SUM_SORT_MERGE_PASSES` bigint(20) unsigned NOT NULL,\\n  `SUM_SORT_RANGE` bigint(20) unsigned NOT NULL,\\n  `SUM_SORT_ROWS` bigint(20) unsigned NOT NULL,\\n  `SUM_SORT_SCAN` bigint(20) unsigned NOT NULL,\\n  `SUM_NO_INDEX_USED` bigint(20) unsigned NOT NULL,\\n  `SUM_NO_GOOD_INDEX_USED` bigint(20) unsigned NOT NULL,\\n  `FIRST_SEEN` timestamp NULL DEFAULT NULL,\\n  `LAST_SEEN` timestamp NULL DEFAULT NULL,\\n  INDEX (SCHEMA_NAME, DIGEST)\\n) DEFAULT CHARSET=utf8';\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    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        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`.`FIRST_SEEN`,\\n       `d_end`.`LAST_SEEN`\\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                IF (NOT INSTR(@sys.statement_performance_analyzer.view, '.')) THEN\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    IF (v_this_thread_enabled = 'YES') THEN\n        CALL sys.ps_setup_enable_thread(CONNECTION_ID());\n    END IF;\n    IF (@log_bin = 1) THEN\n        SET sql_log_bin = @log_bin;\n    END IF;\nEND","NULL","NULL","SQL","NO","CONTAINS SQL","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Create a report of the statements running on the server.\n             The views are calculated based on the overall and/or delta activity.\n             Requires the SUPER privilege for "SET sql_log_bin = 0;".\n             Parameters\n             in_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             in_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               The meaning of the table for each action supporting the argument is:\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             in_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                 * 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             Default is to include all except 'custom'.\n             Configuration Options\n             sys.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             sys.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             sys.debug\n               Whether to provide debugging output.\n               Default is 'OFF'. Set to 'ON' to include.\n             Example\n             To create a report with the queries in the 95th percentile since last truncate of performance_schema.events_statements_summary_by_digest\n             and the delta for a 1 minute period:\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             mysql> CALL sys.statement_performance_analyzer('create_tmp', 'mydb.tmp_digests_ini', NULL);\n             Query OK, 0 rows affected (0.08 sec)\n             mysql> CALL sys.statement_performance_analyzer('snapshot', NULL, NULL);\n             Query OK, 0 rows affected (0.02 sec)\n             mysql> CALL sys.statement_performance_analyzer('save', 'mydb.tmp_digests_ini', NULL);\n             Query OK, 0 rows affected (0.00 sec)\n             mysql> DO SLEEP(60);\n             Query OK, 0 rows affected (1 min 0.00 sec)\n             mysql> CALL sys.statement_performance_analyzer('snapshot', NULL, NULL);\n             Query OK, 0 rows affected (0.02 sec)\n             mysql> 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             +-----------------------------------------+\n             1 row in set (0.05 sec)\n             ...\n             mysql> 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             +-----------------------------------------+\n             1 row in set (0.03 sec)\n             ...\n             To create an overall report of the 95th percentile queries and the top 10 queries with full table scans:\n             mysql> CALL sys.statement_performance_analyzer('snapshot', NULL, NULL);\n             Query OK, 0 rows affected (0.01 sec)\n             mysql> SET @sys.statement_performance_analyzer.limit = 10;\n             Query OK, 0 rows affected (0.00 sec)\n             mysql> 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             +-----------------------------------------+\n             1 row in set (0.01 sec)\n             ...\n             +-------------------------------------+\n             | Next Output                         |\n             +-------------------------------------+\n             | Top 10 Queries with Full Table Scan |\n             +-------------------------------------+\n             1 row in set (0.09 sec)\n             ...\n             Use a custom view showing the top 10 query sorted by total execution time refreshing the view every minute using\n             the watch command in Linux.\n             mysql> 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                 ->        sys.format_time(SUM_TIMER_WAIT) AS total_latency,\n                 ->        sys.format_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;\n             Query OK, 0 rows affected (0.01 sec)\n             mysql> CALL sys.statement_performance_analyzer('create_table', 'mydb.digests_prev', NULL);\n             Query OK, 0 rows affected (0.10 sec)\n             shell$ 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             Every 60.0s: mysql sys --table -e "                                                                                                   ...  Mon Dec 22 10:58:51 2014\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            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_ci""format_bytes","def","sys","format_bytes","FUNCTION","text","65535","65535","NULL","NULL","NULL","utf8mb3","utf8mb3_general_ci","text","SQL","BEGIN\n  IF bytes IS NULL THEN RETURN NULL;\n  ELSEIF bytes >= 1125899906842624 THEN RETURN CONCAT(ROUND(bytes / 1125899906842624, 2), ' PiB');\n  ELSEIF bytes >= 1099511627776 THEN RETURN CONCAT(ROUND(bytes / 1099511627776, 2), ' TiB');\n  ELSEIF bytes >= 1073741824 THEN RETURN CONCAT(ROUND(bytes / 1073741824, 2), ' GiB');\n  ELSEIF bytes >= 1048576 THEN RETURN CONCAT(ROUND(bytes / 1048576, 2), ' MiB');\n  ELSEIF bytes >= 1024 THEN RETURN CONCAT(ROUND(bytes / 1024, 2), ' KiB');\n  ELSE RETURN CONCAT(ROUND(bytes, 0), ' bytes');\n  END IF;\nEND","NULL","NULL","SQL","YES","NO SQL","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Takes a raw bytes value, and converts it to a human readable format.\n             Parameters\n             bytes (TEXT):\n               A raw bytes value.\n             Returns\n             TEXT\n             Example\n             mysql> SELECT sys.format_bytes(2348723492723746) AS size;\n             +----------+\n             | size     |\n             +----------+\n             | 2.09 PiB |\n             +----------+\n             1 row in set (0.00 sec)\n             mysql> SELECT sys.format_bytes(2348723492723) AS size;\n             +----------+\n             | size     |\n             +----------+\n             | 2.14 TiB |\n             +----------+\n             1 row in set (0.00 sec)\n             mysql> SELECT sys.format_bytes(23487234) AS size;\n             +-----------+\n             | size      |\n             +-----------+\n             | 22.40 MiB |\n             +-----------+\n             1 row in set (0.00 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_ci""format_path","def","sys","format_path","FUNCTION","varchar","512","1536","NULL","NULL","NULL","utf8mb3","utf8mb3_general_ci","varchar(512)","SQL","BEGIN\n  DECLARE v_dir VARCHAR(1024);\n  DECLARE v_path VARCHAR(512);\n  DECLARE path_separator CHAR(1) DEFAULT '/';\n  IF @@global.version_compile_os LIKE 'win%' THEN\n    SET path_separator = '\\';\n  END IF;\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  SET v_dir= IFNULL((SELECT VARIABLE_VALUE FROM information_schema.global_variables WHERE VARIABLE_NAME = 'innodb_data_home_dir'), '');\n  IF v_path IS NULL THEN\n    RETURN NULL;\n  END IF;\n  IF 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    RETURN v_path;\n  END IF;\n  IF 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    RETURN v_path;\n  END IF;\n  SET v_dir= IFNULL((SELECT VARIABLE_VALUE FROM information_schema.global_variables WHERE VARIABLE_NAME = 'innodb_data_home_dir'), '');\n  IF v_path LIKE CONCAT(v_dir, IF(SUBSTRING(v_dir, -1) = path_separator, '%', CONCAT(path_separator, '%'))) ESCAPE '|' THEN\n    SET v_path = REPLACE(v_path, v_dir, CONCAT('@@innodb_data_home_dir', IF(SUBSTRING(v_dir, -1) = path_separator, path_separator, '')));\n    RETURN v_path;\n  END IF;\n  SET v_dir= IFNULL((SELECT VARIABLE_VALUE FROM information_schema.global_variables WHERE VARIABLE_NAME = 'innodb_log_group_home_dir'), '');\n  IF v_path LIKE CONCAT(v_dir, IF(SUBSTRING(v_dir, -1) = path_separator, '%', CONCAT(path_separator, '%'))) ESCAPE '|' THEN\n    SET v_path = REPLACE(v_path, v_dir, CONCAT('@@innodb_log_group_home_dir', IF(SUBSTRING(v_dir, -1) = path_separator, path_separator, '')));\n    RETURN v_path;\n  END IF;\n  SET v_dir= IFNULL((SELECT VARIABLE_VALUE FROM information_schema.global_variables WHERE VARIABLE_NAME = 'slave_load_tmpdir'), '');\n  IF v_path LIKE CONCAT(v_dir, IF(SUBSTRING(v_dir, -1) = path_separator, '%', CONCAT(path_separator, '%'))) ESCAPE '|' THEN\n    SET v_path = REPLACE(v_path, v_dir, CONCAT('@@slave_load_tmpdir', IF(SUBSTRING(v_dir, -1) = path_separator, path_separator, '')));\n    RETURN v_path;\n  END IF;\n  SET v_dir = IFNULL((SELECT VARIABLE_VALUE FROM information_schema.global_variables WHERE VARIABLE_NAME = 'innodb_undo_directory'), '');\n  IF v_path LIKE CONCAT(v_dir, IF(SUBSTRING(v_dir, -1) = path_separator, '%', CONCAT(path_separator, '%'))) ESCAPE '|' THEN\n    SET v_path = REPLACE(v_path, v_dir, CONCAT('@@innodb_undo_directory', IF(SUBSTRING(v_dir, -1) = path_separator, path_separator, '')));\n    RETURN v_path;\n  END IF;\n  IF 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    RETURN v_path;\n  END IF;\n  RETURN v_path;\nEND","NULL","NULL","SQL","YES","NO SQL","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Takes a raw path value, and strips out the datadir or tmpdir\n             replacing with @@datadir and @@tmpdir respectively.\n             Also normalizes the paths across operating systems, so backslashes\n             on Windows are converted to forward slashes\n             Parameters\n             path (VARCHAR(512)):\n               The raw file path value to format.\n             Returns\n             VARCHAR(512) CHARSET UTF8\n             Example\n             mysql> select @@datadir;\n             +-----------------------------------------------+\n             | @@datadir                                     |\n             +-----------------------------------------------+\n             | /Users/mark/sandboxes/SmallTree/AMaster/data/ |\n             +-----------------------------------------------+\n             1 row in set (0.06 sec)\n             mysql> select format_path('/Users/mark/sandboxes/SmallTree/AMaster/data/mysql/proc.MYD') AS path;\n             +--------------------------+\n             | path                     |\n             +--------------------------+\n             | @@datadir/mysql/proc.MYD |\n             +--------------------------+\n             1 row in set (0.03 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_ci""format_statement","def","sys","format_statement","FUNCTION","longtext","2147483647","2147483647","NULL","NULL","NULL","utf8mb3","utf8mb3_general_ci","longtext","SQL","BEGIN\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","NULL","SQL","YES","NO SQL","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Formats a normalized statement, truncating it if it is > 64 characters long by default.\n             To configure the length to truncate the statement to by default, update the `statement_truncate_len`\n             variable with `sys_config` table to a different value. Alternatively, to change it just for just\n             your particular session, use `SET @sys.statement_truncate_len := <some new value>`.\n             Useful for printing statement related data from Performance Schema from\n             the command line.\n             Parameters\n             statement (LONGTEXT):\n               The statement to format.\n             Returns\n             LONGTEXT\n             Example\n             mysql> 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             +-------------------------------------------------------------------+\n             5 rows in set (0.00 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_ci""format_time","def","sys","format_time","FUNCTION","text","65535","65535","NULL","NULL","NULL","utf8mb3","utf8mb3_general_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","NULL","SQL","YES","NO SQL","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Takes a raw picoseconds value, and converts it to a human readable form.\n             Picoseconds are the precision that all latency values are printed in\n             within Performance Schema, however are not user friendly when wanting\n             to scan output from the command line.\n             Parameters\n             picoseconds (TEXT):\n               The raw picoseconds value to convert.\n             Returns\n             TEXT\n             Example\n             mysql> select format_time(342342342342345);\n             +------------------------------+\n             | format_time(342342342342345) |\n             +------------------------------+\n             | 00:05:42                     |\n             +------------------------------+\n             1 row in set (0.00 sec)\n             mysql> select format_time(342342342);\n             +------------------------+\n             | format_time(342342342) |\n             +------------------------+\n             | 342.34 us              |\n             +------------------------+\n             1 row in set (0.00 sec)\n             mysql> select format_time(34234);\n              +--------------------+\n             | format_time(34234) |\n             +--------------------+\n             | 34.23 ns           |\n             +--------------------+\n             1 row in set (0.00 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_ci""list_add","def","sys","list_add","FUNCTION","text","65535","65535","NULL","NULL","NULL","utf8mb3","utf8mb3_general_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 in_add_value;\n    END IF;\n    RETURN (SELECT CONCAT(TRIM(BOTH ',' FROM TRIM(in_list)), ',', in_add_value));\nEND","NULL","NULL","SQL","YES","CONTAINS SQL","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Takes a list, and a value to add to the list, and returns the resulting list.\n             Useful for altering certain session variables, like sql_mode or optimizer_switch for instance.\n             Parameters\n             in_list (TEXT):\n               The comma separated list to add a value to\n             in_add_value (TEXT):\n               The value to add to the input list\n             Returns\n             TEXT\n             Example\n             mysql> select @@sql_mode;\n             +-----------------------------------------------------------------------------------+\n             | @@sql_mode                                                                        |\n             +-----------------------------------------------------------------------------------+\n             | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |\n             +-----------------------------------------------------------------------------------+\n             1 row in set (0.00 sec)\n             mysql> set sql_mode = sys.list_add(@@sql_mode, 'ANSI_QUOTES');\n             Query OK, 0 rows affected (0.06 sec)\n             mysql> 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             +-----------------------------------------------------------------------------------------------+\n             1 row in set (0.00 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_ci""list_drop","def","sys","list_drop","FUNCTION","text","65535","65535","NULL","NULL","NULL","utf8mb3","utf8mb3_general_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 in_list;\n    END IF;\n    RETURN (SELECT TRIM(BOTH ',' FROM REPLACE(REPLACE(CONCAT(',', in_list), CONCAT(',', in_drop_value), ''), CONCAT(', ', in_drop_value), '')));\nEND","NULL","NULL","SQL","YES","CONTAINS SQL","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Takes a list, and a value to attempt to remove from the list, and returns the resulting list.\n             Useful for altering certain session variables, like sql_mode or optimizer_switch for instance.\n             Parameters\n             in_list (TEXT):\n               The comma separated list to drop a value from\n             in_drop_value (TEXT):\n               The value to drop from the input list\n             Returns\n             TEXT\n             Example\n             mysql> 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             +-----------------------------------------------------------------------------------------------+\n             1 row in set (0.00 sec)\n             mysql> set sql_mode = sys.list_drop(@@sql_mode, 'ONLY_FULL_GROUP_BY');\n             Query OK, 0 rows affected (0.03 sec)\n             mysql> select @@sql_mode;\n             +----------------------------------------------------------------------------+\n             | @@sql_mode                                                                 |\n             +----------------------------------------------------------------------------+\n             | ANSI_QUOTES,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |\n             +----------------------------------------------------------------------------+\n             1 row in set (0.00 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_ci""ps_is_account_enabled","def","sys","ps_is_account_enabled","FUNCTION","enum","3","9","NULL","NULL","NULL","utf8mb3","utf8mb3_general_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                    ),\n              'YES', 'NO'\n           );\nEND","NULL","NULL","SQL","YES","READS SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Determines whether instrumentation of an account is enabled\n             within Performance Schema.\n             Parameters\n             in_host VARCHAR(60):\n               The hostname of the account to check.\n             in_user (VARCHAR(16)):\n               The username of the account to check.\n             Returns\n             ENUM('YES', 'NO', 'PARTIAL')\n             Example\n             mysql> SELECT sys.ps_is_account_enabled('localhost', 'root');\n             +------------------------------------------------+\n             | sys.ps_is_account_enabled('localhost', 'root') |\n             +------------------------------------------------+\n             | YES                                            |\n             +------------------------------------------------+\n             1 row in set (0.01 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_ci""ps_is_consumer_enabled","def","sys","ps_is_consumer_enabled","FUNCTION","enum","3","9","NULL","NULL","NULL","utf8mb3","utf8mb3_general_ci","enum('YES','NO')","SQL","BEGIN\n    RETURN (\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       );\nEND","NULL","NULL","SQL","YES","READS SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Determines whether a consumer is enabled (taking the consumer hierarchy into consideration)\n             within the Performance Schema.\n             Parameters\n             in_consumer VARCHAR(64):\n               The name of the consumer to check.\n             Returns\n             ENUM('YES', 'NO')\n             Example\n             mysql> SELECT sys.ps_is_consumer_enabled('events_stages_history');\n             +-----------------------------------------------------+\n             | sys.ps_is_consumer_enabled('events_stages_history') |\n             +-----------------------------------------------------+\n             | NO                                                  |\n             +-----------------------------------------------------+\n             1 row in set (0.00 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_ci""ps_is_instrument_default_enabled","def","sys","ps_is_instrument_default_enabled","FUNCTION","enum","3","9","NULL","NULL","NULL","utf8mb3","utf8mb3_general_ci","enum('YES','NO')","SQL","BEGIN\n    DECLARE v_enabled ENUM('YES', 'NO');\n    SET v_enabled = IF(in_instrument LIKE 'wait/io/file/%'\n                        OR in_instrument LIKE 'wait/io/table/%'\n                        OR in_instrument LIKE 'statement/%'\n                        OR in_instrument LIKE 'memory/performance_schema/%'\n                        OR in_instrument IN ('wait/lock/table/sql/handler', 'idle')\n               \n                      ,\n                       'YES',\n                       'NO'\n                    );\n    RETURN v_enabled;\nEND","NULL","NULL","SQL","YES","READS SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Returns whether an instrument is enabled by default in this version of MySQL.\n             Parameters\n             in_instrument VARCHAR(128):\n               The instrument to check.\n             Returns\n             ENUM('YES', 'NO')\n             Example\n             mysql> 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             +--------------------------------------------------------------+\n             1 row in set (0.00 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_ci""ps_is_instrument_default_timed","def","sys","ps_is_instrument_default_timed","FUNCTION","enum","3","9","NULL","NULL","NULL","utf8mb3","utf8mb3_general_ci","enum('YES','NO')","SQL","BEGIN\n    DECLARE v_timed ENUM('YES', 'NO');\n    SET v_timed = IF(in_instrument LIKE 'wait/io/file/%'\n                        OR in_instrument LIKE 'wait/io/table/%'\n                        OR in_instrument LIKE 'statement/%'\n                        OR in_instrument IN ('wait/lock/table/sql/handler', 'idle')\n               \n                      ,\n                       'YES',\n                       'NO'\n                    );\n    RETURN v_timed;\nEND","NULL","NULL","SQL","YES","READS SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Returns whether an instrument is timed by default in this version of MySQL.\n             Parameters\n             in_instrument VARCHAR(128):\n               The instrument to check.\n             Returns\n             ENUM('YES', 'NO')\n             Example\n             mysql> 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             +------------------------------------------------------------+\n             1 row in set (0.00 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_ci""ps_is_thread_instrumented","def","sys","ps_is_thread_instrumented","FUNCTION","enum","7","21","NULL","NULL","NULL","utf8mb3","utf8mb3_general_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","NULL","SQL","NO","READS SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Checks whether the provided connection id is instrumented within Performance Schema.\n             Parameters\n             in_connection_id (BIGINT UNSIGNED):\n               The id of the connection to check.\n             Returns\n             ENUM('YES', 'NO', 'UNKNOWN')\n             Example\n             mysql> SELECT sys.ps_is_thread_instrumented(CONNECTION_ID());\n             +------------------------------------------------+\n             | sys.ps_is_thread_instrumented(CONNECTION_ID()) |\n             +------------------------------------------------+\n             | YES                                            |\n             +------------------------------------------------+\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_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","NULL","SQL","NO","MODIFIES SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Disable all background thread instrumentation within Performance Schema.\n             Parameters\n             None.\n             Example\n             mysql> CALL sys.ps_setup_disable_background_threads();\n             +--------------------------------+\n             | summary                        |\n             +--------------------------------+\n             | Disabled 18 background threads |\n             +--------------------------------+\n             1 row in set (0.00 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_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","NULL","SQL","NO","MODIFIES SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Disables consumers within Performance Schema\n             matching the input pattern.\n             Parameters\n             consumer (VARCHAR(128)):\n               A LIKE pattern match (using "%consumer%") of consumers to disable\n             Example\n             To disable all consumers:\n             mysql> CALL sys.ps_setup_disable_consumer('');\n             +--------------------------+\n             | summary                  |\n             +--------------------------+\n             | Disabled 15 consumers    |\n             +--------------------------+\n             1 row in set (0.02 sec)\n             To disable just the event_stage consumers:\n             mysql> CALL sys.ps_setup_disable_comsumers('stage');\n             +------------------------+\n             | summary                |\n             +------------------------+\n             | Disabled 3 consumers   |\n             +------------------------+\n             1 row in set (0.00 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_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","NULL","SQL","NO","MODIFIES SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Disables instruments within Performance Schema\n             matching the input pattern.\n             Parameters\n             in_pattern (VARCHAR(128)):\n               A LIKE pattern match (using "%in_pattern%") of events to disable\n             Example\n             To disable all mutex instruments:\n             mysql> CALL sys.ps_setup_disable_instrument('wait/synch/mutex');\n             +--------------------------+\n             | summary                  |\n             +--------------------------+\n             | Disabled 155 instruments |\n             +--------------------------+\n             1 row in set (0.02 sec)\n             To disable just a specific TCP/IP based network IO instrument:\n             mysql> CALL sys.ps_setup_disable_instrument('wait/io/socket/sql/server_tcpip_socket');\n             +------------------------+\n             | summary                |\n             +------------------------+\n             | Disabled 1 instruments |\n             +------------------------+\n             1 row in set (0.00 sec)\n             To disable all instruments:\n             mysql> CALL sys.ps_setup_disable_instrument('');\n             +--------------------------+\n             | summary                  |\n             +--------------------------+\n             | Disabled 547 instruments |\n             +--------------------------+\n             1 row in set (0.01 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_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","NULL","SQL","NO","MODIFIES SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Disable the given connection/thread in Performance Schema.\n             Parameters\n             in_connection_id (BIGINT):\n               The connection ID (PROCESSLIST_ID from performance_schema.threads\n               or the ID shown within SHOW PROCESSLIST)\n             Example\n             mysql> CALL sys.ps_setup_disable_thread(3);\n             +-------------------+\n             | summary           |\n             +-------------------+\n             | Disabled 1 thread |\n             +-------------------+\n             1 row in set (0.01 sec)\n             To disable the current connection:\n             mysql> CALL sys.ps_setup_disable_thread(CONNECTION_ID());\n             +-------------------+\n             | summary           |\n             +-------------------+\n             | Disabled 1 thread |\n             +-------------------+\n             1 row in set (0.00 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_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","NULL","SQL","NO","MODIFIES SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Enable all background thread instrumentation within Performance Schema.\n             Parameters\n             None.\n             Example\n             mysql> CALL sys.ps_setup_enable_background_threads();\n             +-------------------------------+\n             | summary                       |\n             +-------------------------------+\n             | Enabled 18 background threads |\n             +-------------------------------+\n             1 row in set (0.00 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_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","NULL","SQL","NO","MODIFIES SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Enables consumers within Performance Schema\n             matching the input pattern.\n             Parameters\n             consumer (VARCHAR(128)):\n               A LIKE pattern match (using "%consumer%") of consumers to enable\n             Example\n             To enable all consumers:\n             mysql> CALL sys.ps_setup_enable_consumer('');\n             +-------------------------+\n             | summary                 |\n             +-------------------------+\n             | Enabled 10 consumers    |\n             +-------------------------+\n             1 row in set (0.02 sec)\n             Query OK, 0 rows affected (0.02 sec)\n             To enable just "waits" consumers:\n             mysql> CALL sys.ps_setup_enable_consumer('waits');\n             +-----------------------+\n             | summary               |\n             +-----------------------+\n             | Enabled 3 consumers   |\n             +-----------------------+\n             1 row in set (0.00 sec)\n             Query OK, 0 rows affected (0.00 sec)\n             ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_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","NULL","SQL","NO","MODIFIES SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Enables instruments within Performance Schema\n             matching the input pattern.\n             Parameters\n             in_pattern (VARCHAR(128)):\n               A LIKE pattern match (using "%in_pattern%") of events to enable\n             Example\n             To enable all mutex instruments:\n             mysql> CALL sys.ps_setup_enable_instrument('wait/synch/mutex');\n             +-------------------------+\n             | summary                 |\n             +-------------------------+\n             | Enabled 155 instruments |\n             +-------------------------+\n             1 row in set (0.02 sec)\n             Query OK, 0 rows affected (0.02 sec)\n             To enable just a specific TCP/IP based network IO instrument:\n             mysql> CALL sys.ps_setup_enable_instrument('wait/io/socket/sql/server_tcpip_socket');\n             +-----------------------+\n             | summary               |\n             +-----------------------+\n             | Enabled 1 instruments |\n             +-----------------------+\n             1 row in set (0.00 sec)\n             Query OK, 0 rows affected (0.00 sec)\n             To enable all instruments:\n             mysql> CALL sys.ps_setup_enable_instrument('');\n             +-------------------------+\n             | summary                 |\n             +-------------------------+\n             | Enabled 547 instruments |\n             +-------------------------+\n             1 row in set (0.01 sec)\n             Query OK, 0 rows affected (0.01 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_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","NULL","SQL","NO","MODIFIES SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Enable the given connection/thread in Performance Schema.\n             Parameters\n             in_connection_id (BIGINT):\n               The connection ID (PROCESSLIST_ID from performance_schema.threads\n               or the ID shown within SHOW PROCESSLIST)\n             Example\n             mysql> CALL sys.ps_setup_enable_thread(3);\n             +------------------+\n             | summary          |\n             +------------------+\n             | Enabled 1 thread |\n             +------------------+\n             1 row in set (0.01 sec)\n             To enable the current connection:\n             mysql> CALL sys.ps_setup_enable_thread(CONNECTION_ID());\n             +------------------+\n             | summary          |\n             +------------------+\n             | Enabled 1 thread |\n             +------------------+\n             1 row in set (0.00 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_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 LIKE performance_schema.setup_actors;\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","NULL","SQL","NO","MODIFIES SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Saves the current configuration of Performance Schema,\n             so that you can alter the setup for debugging purposes,\n             but restore it to a previous state.\n             Use the companion procedure - ps_setup_reload_saved(), to\n             restore the saved config.\n             The named lock "sys.ps_setup_save" is taken before the\n             current configuration is saved. If the attempt to get the named\n             lock times out, an error occurs.\n             The lock is released after the settings have been restored by\n             calling ps_setup_reload_saved().\n             Requires the SUPER privilege for "SET sql_log_bin = 0;".\n             Parameters\n             in_timeout INT\n               The timeout in seconds used when trying to obtain the lock.\n               A negative timeout means infinite timeout.\n             Example\n             mysql> CALL sys.ps_setup_save(-1);\n             Query OK, 0 rows affected (0.08 sec)\n             mysql> UPDATE performance_schema.setup_instruments\n                 ->    SET enabled = 'YES', timed = 'YES';\n             Query OK, 547 rows affected (0.40 sec)\n             Rows matched: 784  Changed: 547  Warnings: 0\n             /* Run some tests that need more detailed instrumentation here */\n             mysql> CALL sys.ps_setup_reload_saved();\n             Query OK, 0 rows affected (0.32 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_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        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        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","NULL","SQL","NO","MODIFIES SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Reloads a saved Performance Schema configuration,\n             so that you can alter the setup for debugging purposes,\n             but restore it to a previous state.\n             Use the companion procedure - ps_setup_save(), to\n             save a configuration.\n             Requires the SUPER privilege for "SET sql_log_bin = 0;".\n             Parameters\n             None.\n             Example\n             mysql> CALL sys.ps_setup_save();\n             Query OK, 0 rows affected (0.08 sec)\n             mysql> UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES';\n             Query OK, 547 rows affected (0.40 sec)\n             Rows matched: 784  Changed: 547  Warnings: 0\n             /* Run some tests that need more detailed instrumentation here */\n             mysql> CALL sys.ps_setup_reload_saved();\n             Query OK, 0 rows affected (0.32 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_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","NULL","SQL","YES","READS SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Shows all currently disabled consumers.\n             Parameters\n             None\n             Example\n             mysql> CALL sys.ps_setup_show_disabled_consumers();\n             +---------------------------+\n             | disabled_consumers        |\n             +---------------------------+\n             | events_statements_current |\n             | global_instrumentation    |\n             | thread_instrumentation    |\n             | statements_digest         |\n             +---------------------------+\n             4 rows in set (0.05 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_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","NULL","SQL","NO","MODIFIES SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Resets the Performance Schema setup to the default settings.\n             Parameters\n             in_verbose (BOOLEAN):\n               Whether to print each setup stage (including the SQL) whilst running.\n             Example\n             mysql> CALL sys.ps_setup_reset_to_default(true)\\G\n             *************************** 1. row ***************************\n             status: Resetting: setup_actors\n             DELETE\n             FROM performance_schema.setup_actors\n              WHERE NOT (HOST = '%' AND USER = '%' AND ROLE = '%')\n             1 row in set (0.00 sec)\n             *************************** 1. row ***************************\n             status: Resetting: setup_actors\n             INSERT IGNORE INTO performance_schema.setup_actors\n             VALUES ('%', '%', '%')\n             1 row in set (0.00 sec)\n             ...\n             mysql> CALL sys.ps_setup_reset_to_default(false)\\G\n             Query OK, 0 rows affected (0.00 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_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    \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","NULL","SQL","NO","READS SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Shows all currently disable Performance Schema configuration.\n             Disabled users is only available for MySQL 5.7.6 and later.\n             In earlier versions it was only possible to enable users.\n             Parameters\n             in_show_instruments (BOOLEAN):\n               Whether to print disabled instruments (can print many items)\n             in_show_threads (BOOLEAN):\n               Whether to print disabled threads\n             Example\n             mysql> CALL sys.ps_setup_show_disabled(TRUE, TRUE);\n             +----------------------------+\n             | performance_schema_enabled |\n             +----------------------------+\n             |                          1 |\n             +----------------------------+\n             1 row in set (0.00 sec)\n             +--------------------+\n             | disabled_users     |\n             +--------------------+\n             | 'mark'@'localhost' |\n             +--------------------+\n             1 row in set (0.00 sec)\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             +-------------+----------------------+---------+-------+\n             15 rows in set (0.00 sec)\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             +----------------------------------+\n             10 rows in set (0.00 sec)\n             Empty set (0.00 sec)\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             +---------------------------------------------------------------------------------------+-------+\n             547 rows in set (0.00 sec)\n             Query OK, 0 rows affected (0.01 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_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' AND name <> 'thread/innodb/thread_pool_thread'\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","NULL","SQL","YES","READS SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Shows all currently enabled Performance Schema configuration.\n             Parameters\n             in_show_instruments (BOOLEAN):\n               Whether to print enabled instruments (can print many items)\n             in_show_threads (BOOLEAN):\n               Whether to print enabled threads\n             Example\n             mysql> CALL sys.ps_setup_show_enabled(TRUE, TRUE);\n             +----------------------------+\n             | performance_schema_enabled |\n             +----------------------------+\n             |                          1 |\n             +----------------------------+\n             1 row in set (0.00 sec)\n             +---------------+\n             | enabled_users |\n             +---------------+\n             | '%'@'%'       |\n             +---------------+\n             1 row in set (0.01 sec)\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             +-------------+---------+---------+-------+\n             5 rows in set (0.01 sec)\n             +---------------------------+\n             | enabled_consumers         |\n             +---------------------------+\n             | events_statements_current |\n             | global_instrumentation    |\n             | thread_instrumentation    |\n             | statements_digest         |\n             +---------------------------+\n             4 rows in set (0.05 sec)\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             +---------------------------------+-------------+\n             22 rows in set (0.01 sec)\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             +-------------------------------------+-------+\n             210 rows in set (0.08 sec)\n             Query OK, 0 rows affected (0.89 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_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","NULL","SQL","YES","READS SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Shows all currently enabled consumers.\n             Parameters\n             None\n             Example\n             mysql> CALL sys.ps_setup_show_enabled_consumers();\n             +---------------------------+\n             | enabled_consumers         |\n             +---------------------------+\n             | events_statements_current |\n             | global_instrumentation    |\n             | thread_instrumentation    |\n             | statements_digest         |\n             +---------------------------+\n             4 rows in set (0.05 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_ci""ps_thread_account","def","sys","ps_thread_account","FUNCTION","text","65535","65535","NULL","NULL","NULL","utf8mb3","utf8mb3_general_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","NULL","SQL","NO","READS SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Return the user@host account for the given Performance Schema thread id.\n             Parameters\n             in_thread_id (BIGINT UNSIGNED):\n               The id of the thread to return the account for.\n             Example\n             mysql> 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              +-----------+------------------+------------------+\n              4 rows in set (0.00 sec)\n              mysql> select sys.ps_thread_account(31);\n              +---------------------------+\n              | sys.ps_thread_account(31) |\n              +---------------------------+\n              | msandbox@localhost        |\n              +---------------------------+\n              1 row in set (0.00 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_ci""ps_thread_id","def","sys","ps_thread_id","FUNCTION","bigint","NULL","NULL","20","0","NULL","NULL","NULL","bigint(20) unsigned","SQL","BEGIN\n    RETURN (SELECT THREAD_ID\n              FROM `performance_schema`.`threads`\n             WHERE PROCESSLIST_ID = IFNULL(in_connection_id, CONNECTION_ID())\n           );\nEND","NULL","NULL","SQL","NO","READS SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Return the Performance Schema THREAD_ID for the specified connection ID.\n             Parameters\n             in_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             Example\n             mysql> SELECT sys.ps_thread_id(79);\n             +----------------------+\n             | sys.ps_thread_id(79) |\n             +----------------------+\n             |                   98 |\n             +----------------------+\n             1 row in set (0.00 sec)\n             mysql> SELECT sys.ps_thread_id(CONNECTION_ID());\n             +-----------------------------------+\n             | sys.ps_thread_id(CONNECTION_ID()) |\n             +-----------------------------------+\n             |                                98 |\n             +-----------------------------------+\n             1 row in set (0.00 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_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","NULL","SQL","YES","MODIFIES SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Truncates all summary tables within Performance Schema,\n             resetting all aggregated instrumentation as a snapshot.\n             Parameters\n             in_verbose (BOOLEAN):\n               Whether to print each TRUNCATE statement before running\n             Example\n             mysql> CALL sys.ps_truncate_all_tables(false);\n             +---------------------+\n             | summary             |\n             +---------------------+\n             | Truncated 44 tables |\n             +---------------------+\n             1 row in set (0.10 sec)\n             Query OK, 0 rows affected (0.10 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_ci""ps_thread_stack","def","sys","ps_thread_stack","FUNCTION","longtext","2147483647","2147483647","NULL","NULL","NULL","latin1","latin1_swedish_ci","longtext","SQL","BEGIN\n    DECLARE json_objects LONGTEXT;\n    \n    UPDATE performance_schema.threads\n       SET instrumented = 'NO'\n     WHERE processlist_id = CONNECTION_ID();\n    \n    SET SESSION group_concat_max_len=@@global.max_allowed_packet;\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              , 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              , CONCAT( '"wait_info": "', IFNULL(wait_info, ''), '"')\n              , CONCAT( '"source": "', IF(true AND event_name LIKE 'wait%', IFNULL(wait_info, ''), ''), '"')\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          \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 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 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                                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","NULL","SQL","NO","READS SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Outputs a JSON formatted stack of all statements, stages and events\n             within Performance Schema for the specified thread.\n             Parameters\n             thd_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.\n             in_verbose (BOOLEAN):\n               Include file:lineno information in the events.\n             Example\n             (line separation added for output)\n             mysql> SELECT sys.ps_thread_stack(37, FALSE) AS thread_stack\\G\n             *************************** 1. row ***************************\n             thread_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            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_ci""quote_identifier","def","sys","quote_identifier","FUNCTION","text","65535","65535","NULL","NULL","NULL","utf8mb3","utf8mb3_general_ci","text","SQL","BEGIN\n    RETURN CONCAT('`', REPLACE(in_identifier, '`', '``'), '`');\nEND","NULL","NULL","SQL","YES","NO SQL","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Takes an unquoted identifier (schema name, table name, etc.) and\n             returns the identifier quoted with backticks.\n             Parameters\n             in_identifier (TEXT):\n               The identifier to quote.\n             Returns\n             TEXT\n             Example\n             mysql> SELECT sys.quote_identifier('my_identifier') AS Identifier;\n             +-----------------+\n             | Identifier      |\n             +-----------------+\n             | `my_identifier` |\n             +-----------------+\n             1 row in set (0.00 sec)\n             mysql> SELECT sys.quote_identifier('my`idenfier') AS Identifier;\n             +----------------+\n             | Identifier     |\n             +----------------+\n             | `my``idenfier` |\n             +----------------+\n             1 row in set (0.00 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_ci""sys_get_config","def","sys","sys_get_config","FUNCTION","varchar","128","384","NULL","NULL","NULL","utf8mb3","utf8mb3_general_ci","varchar(128)","SQL","BEGIN\n    DECLARE v_value VARCHAR(128) DEFAULT NULL;\n    DECLARE old_val INTEGER DEFAULT NULL;\n    SET v_value = (SELECT value FROM sys.sys_config WHERE variable = in_variable_name);\n    IF (v_value IS NULL) THEN\n        SET v_value = in_default_value;\n    END IF;\n    RETURN v_value;\nEND","NULL","NULL","SQL","YES","READS SQL DATA","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Returns the value for the requested variable using the following logic:\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             Notes for using sys_get_config():\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             Parameters\n             in_variable_name (VARCHAR(128)):\n               The name of the config option to return the value for.\n             in_default_value (VARCHAR(128)):\n               The default value to return if the variable does not exist in sys.sys_config.\n             Returns\n             VARCHAR(128)\n             Example\n             mysql> SELECT sys.sys_get_config('statement_truncate_len', 128) AS Value;\n             +-------+\n             | Value |\n             +-------+\n             | 64    |\n             +-------+\n             1 row in set (0.00 sec)\n             mysql> SET @sys.statement_truncate_len = IFNULL(@sys.statement_truncate_len, sys.sys_get_config('statement_truncate_len', 64));\n             Query OK, 0 rows affected (0.00 sec)\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            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_ci""version_major","def","sys","version_major","FUNCTION","tinyint","NULL","NULL","3","0","NULL","NULL","NULL","tinyint(3) unsigned","SQL","BEGIN\n    RETURN SUBSTRING_INDEX(SUBSTRING_INDEX(VERSION(), '-', 1), '.', 1);\nEND","NULL","NULL","SQL","NO","NO SQL","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Returns the major version of MySQL Server.\n             Returns\n             TINYINT UNSIGNED\n             Example\n             mysql> SELECT VERSION(), sys.version_major();\n             +--------------------------------------+---------------------+\n             | VERSION()                            | sys.version_major() |\n             +--------------------------------------+---------------------+\n             | 5.7.9-enterprise-commercial-advanced | 5                   |\n             +--------------------------------------+---------------------+\n             1 row in set (0.00 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_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 db_quoted VARCHAR(64);\n    DECLARE table_quoted VARCHAR(64);\n    DECLARE v_table_type VARCHAR(16) DEFAULT '';\n    DECLARE v_system_db BOOLEAN\n        DEFAULT LOWER(in_db) IN ('information_schema', 'performance_schema');\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    SET db_quoted = sys.quote_identifier(in_db);\n    SET table_quoted = sys.quote_identifier(in_table);\n    IF (EXISTS(SELECT 1 FROM information_schema.TABLES WHERE TABLE_SCHEMA = in_db AND TABLE_NAME = in_table)) THEN\n        IF v_system_db = FALSE THEN\n            SET @sys.tmp.table_exists.SQL = CONCAT('CREATE TEMPORARY TABLE ',\n                                                    db_quoted,\n                                                    '.',\n                                                    table_quoted,\n                                                    '(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            SET @sys.tmp.table_exists.SQL = CONCAT('DROP TEMPORARY TABLE ',\n                                                                db_quoted,\n                                                                '.',\n                                                                table_quoted);\n            PREPARE stmt_drop_table FROM @sys.tmp.table_exists.SQL;\n            EXECUTE stmt_drop_table;\n            DEALLOCATE PREPARE stmt_drop_table;\n        END IF;\n        IF (v_error) THEN\n            SET out_exists = 'TEMPORARY';\n        ELSE\n            SET v_table_type = (SELECT TABLE_TYPE FROM information_schema.TABLES WHERE TABLE_SCHEMA = in_db AND TABLE_NAME = in_table);\n            IF v_table_type = 'SYSTEM VERSIONED' THEN\n                SET out_exists = 'BASE TABLE';\n            ELSE\n                SET out_exists = v_table_type;\n            END IF;\n        END IF;\n    ELSE\n        IF v_system_db = FALSE THEN\n            SET @sys.tmp.table_exists.SQL = CONCAT('SELECT COUNT(*) FROM ',\n                                                            db_quoted,\n                                                            '.',\n                                                            table_quoted);\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;\n    END IF;\nEND","NULL","NULL","SQL","NO","CONTAINS SQL","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Tests whether the table specified in in_db and in_table exists either as a regular\n             table, or as a temporary table. The returned value corresponds to the table that\n             will be used, so if there's both a temporary and a permanent table with the given\n             name, then 'TEMPORARY' will be returned.\n             Parameters\n             in_db (VARCHAR(64)):\n               The database name to check for the existence of the table in.\n             in_table (VARCHAR(64)):\n               The name of the table to check the existence of.\n             out_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, sequence 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                 * 'SEQUENCE'     - the table name exists as a sequence.\n                 * 'SYSTEM VIEW'  - the table name exists as a system view.\n             Example\n             mysql> CREATE DATABASE db1;\n             Query OK, 1 row affected (0.07 sec)\n             mysql> use db1;\n             Database changed\n             mysql> CREATE TABLE t1 (id INT PRIMARY KEY);\n             Query OK, 0 rows affected (0.08 sec)\n             mysql> CREATE TABLE t2 (id INT PRIMARY KEY);\n             Query OK, 0 rows affected (0.08 sec)\n             mysql> CREATE view v_t1 AS SELECT * FROM t1;\n             Query OK, 0 rows affected (0.00 sec)\n             mysql> CREATE TEMPORARY TABLE t1 (id INT PRIMARY KEY);\n             Query OK, 0 rows affected (0.00 sec)\n             mysql> CALL sys.table_exists('db1', 't1', @exists); SELECT @exists;\n             Query OK, 0 rows affected (0.00 sec)\n             +------------+\n             | @exists    |\n             +------------+\n             | TEMPORARY  |\n             +------------+\n             1 row in set (0.00 sec)\n             mysql> CALL sys.table_exists('db1', 't2', @exists); SELECT @exists;\n             Query OK, 0 rows affected (0.00 sec)\n             +------------+\n             | @exists    |\n             +------------+\n             | BASE TABLE |\n             +------------+\n             1 row in set (0.01 sec)\n             mysql> CALL sys.table_exists('db1', 'v_t1', @exists); SELECT @exists;\n             Query OK, 0 rows affected (0.00 sec)\n             +---------+\n             | @exists |\n             +---------+\n             | VIEW    |\n             +---------+\n             1 row in set (0.00 sec)\n             MariaDB [sys]> CALL sys.table_exists('db1', 's', @exists); SELECT @exists;\n             Query OK, 0 rows affected (0.006 sec)\n             +----------+\n             | @exists  |\n             +----------+\n             | SEQUENCE |\n             +----------+\n             1 row in set (0.000 sec)\n             MariaDB [sys]> CALL table_exists('information_schema', 'user_variables', @exists); SELECT @exists;\n             Query OK, 0 rows affected (0.003 sec)\n             +-------------+\n             | @exists     |\n             +-------------+\n             | SYSTEM VIEW |\n             +-------------+\n             1 row in set (0.001 sec)\n             mysql> CALL sys.table_exists('db1', 't3', @exists); SELECT @exists;\n             Query OK, 0 rows affected (0.01 sec)\n             +---------+\n             | @exists |\n             +---------+\n             |         |\n             +---------+\n             1 row in set (0.00 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_ci""version_minor","def","sys","version_minor","FUNCTION","tinyint","NULL","NULL","3","0","NULL","NULL","NULL","tinyint(3) unsigned","SQL","BEGIN\n    RETURN SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING_INDEX(VERSION(), '-', 1), '.', 2), '.', -1);\nEND","NULL","NULL","SQL","NO","NO SQL","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Returns the minor (release series) version of MySQL Server.\n             Returns\n             TINYINT UNSIGNED\n             Example\n             mysql> SELECT VERSION(), sys.server_minor();\n             +--------------------------------------+---------------------+\n             | VERSION()                            | sys.version_minor() |\n             +--------------------------------------+---------------------+\n             | 5.7.9-enterprise-commercial-advanced | 7                   |\n             +--------------------------------------+---------------------+\n             1 row in set (0.00 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_ci""version_patch","def","sys","version_patch","FUNCTION","tinyint","NULL","NULL","3","0","NULL","NULL","NULL","tinyint(3) unsigned","SQL","BEGIN\n    RETURN SUBSTRING_INDEX(SUBSTRING_INDEX(VERSION(), '-', 1), '.', -1);\nEND","NULL","NULL","SQL","NO","NO SQL","NULL","INVOKER","2023-03-23 16:38:03","2023-03-23 16:38:03","","\n             Description\n             Returns the patch release version of MySQL Server.\n             Returns\n             TINYINT UNSIGNED\n             Example\n             mysql> SELECT VERSION(), sys.version_patch();\n             +--------------------------------------+---------------------+\n             | VERSION()                            | sys.version_patch() |\n             +--------------------------------------+---------------------+\n             | 5.7.9-enterprise-commercial-advanced | 9                   |\n             +--------------------------------------+---------------------+\n             1 row in set (0.00 sec)\n            ","mariadb.sys@localhost","utf8mb3","utf8mb3_general_ci","utf8mb3_general_ci"