├── .gitignore ├── mysql-test └── suite │ └── sysschema │ ├── r │ ├── v_version.result │ ├── v_schema_object_overview.result │ ├── v_metrics.result │ ├── v_ps_check_lost_instrumentation.result │ ├── v_schema_unused_indexes.result │ ├── version_functions.result │ ├── v_session_ssl_status.result │ ├── fn_extract_table_from_file_name.result │ ├── fn_extract_schema_from_file_name.result │ ├── fn_ps_thread_id.result │ ├── v_memory_global_total.result │ ├── fn_sys_get_config.result │ ├── fn_ps_thread_account.result │ ├── v_host_summary_by_file_io.result │ ├── v_user_summary_by_file_io.result │ ├── v_latest_file_io.result │ ├── fn_ps_is_account_enabled.result │ ├── fn_ps_is_thread_instrumented.result │ ├── fn_quote_identifier.result │ ├── v_host_summary_by_stages.result │ ├── v_user_summary_by_stages.result │ ├── v_waits_global_by_latency.result │ ├── v_user_summary_by_file_io_type.result │ ├── fn_format_statement.result │ ├── v_host_summary_by_file_io_type.result │ ├── pr_ps_setup_show_disabled_consumers.result │ ├── v_waits_by_host_by_latency.result │ ├── v_waits_by_user_by_latency.result │ ├── v_ps_digest_avg_latency_distribution.result │ ├── v_innodb_buffer_stats_by_schema.result │ ├── v_wait_classes_global_by_latency.result │ ├── pr_execute_prepared_stmt.result │ ├── v_wait_classes_global_by_avg_latency.result │ ├── v_memory_by_host_by_current_bytes.result │ ├── v_memory_by_user_by_current_bytes.result │ ├── v_ps_digest_95th_percentile_by_avg_us.result │ ├── v_innodb_buffer_stats_by_table.result │ ├── v_memory_global_by_current_bytes.result │ ├── pr_ps_setup_show_enabled_consumers.result │ ├── v_io_by_thread_by_latency.result │ ├── v_memory_by_thread_by_current_bytes.result │ ├── v_io_global_by_file_by_bytes.result │ ├── pr_table_exists.result │ ├── pr_diagnostics.result │ ├── v_user_summary_by_statement_latency.result │ ├── v_host_summary_by_statement_latency.result │ ├── v_io_global_by_file_by_latency.result │ ├── v_host_summary_by_statement_type.result │ ├── v_user_summary_by_statement_type.result │ ├── v_statements_with_errors_or_warnings.result │ ├── fn_list_add.result │ ├── fn_format_bytes.result │ ├── fn_format_path.result │ ├── v_host_summary.result │ ├── v_schema_index_statistics.result │ ├── v_user_summary.result │ ├── v_statements_with_temp_tables.result │ ├── v_io_global_by_wait_by_bytes.result │ ├── v_statements_with_sorting.result │ ├── v_io_global_by_wait_by_latency.result │ ├── fn_list_drop.result │ ├── pr_ps_trace_statement_digest.result │ ├── v_schema_redundant_indexes.result │ ├── v_statements_with_runtimes_in_95th_percentile.result │ ├── fn_format_time.result │ ├── v_schema_table_statistics.result │ ├── t_sys_config.result │ ├── pr_create_synonym_db.result │ ├── pr_ps_setup_show_disabled_instruments.result │ ├── fn_ps_is_consumer_enabled.result │ ├── v_statement_analysis.result │ └── v_ps_schema_table_statistics_io.result │ ├── include │ ├── ps_threads_cleanup.inc │ ├── ps_setup_consumers_cleanup.inc │ ├── ps_setup_instruments_cleanup.inc │ ├── ps_truncate_all_tables.inc │ ├── ps_setup_actors_cleanup.inc │ ├── ps_setup_reset_to_default_cleanup.inc │ └── sys_config_cleanup.inc │ └── t │ ├── fn_format_path-master.opt │ ├── pr_ps_setup_show_disabled_consumers.test │ ├── pr_ps_setup_show_enabled_consumers.test │ ├── fn_format_path-master.sh │ ├── v_metrics.test │ ├── fn_extract_table_from_file_name.test │ ├── v_version.test │ ├── fn_extract_schema_from_file_name.test │ ├── v_session_ssl_status.test │ ├── pr_ps_setup_show_disabled_instruments.test │ ├── v_schema_unused_indexes.test │ ├── v_schema_object_overview.test │ ├── fn_ps_thread_account.test │ ├── v_ps_check_lost_instrumentation.test │ ├── fn_sys_get_config.test │ ├── v_session.test │ ├── pr_ps_setup_show_enabled_instruments.test │ ├── v_processlist.test │ ├── v_host_summary.test │ ├── v_user_summary.test │ ├── v_latest_file_io.test │ ├── v_innodb_lock_waits.test │ ├── pr_execute_prepared_stmt.test │ ├── v_statement_analysis.test │ ├── v_memory_global_total.test │ ├── v_host_summary_by_stages.test │ ├── v_user_summary_by_stages.test │ ├── v_host_summary_by_file_io.test │ ├── v_io_by_thread_by_latency.test │ ├── v_schema_index_statistics.test │ ├── v_schema_table_statistics.test │ ├── v_statements_with_sorting.test │ ├── v_user_summary_by_file_io.test │ ├── v_waits_global_by_latency.test │ ├── all_sys_objects_exist.test │ ├── t_sys_config.test │ ├── fn_ps_thread_id.test │ ├── v_waits_by_host_by_latency.test │ ├── v_waits_by_user_by_latency.test │ ├── v_io_global_by_file_by_bytes.test │ ├── v_io_global_by_wait_by_bytes.test │ ├── v_innodb_buffer_stats_by_table.test │ ├── v_statements_with_temp_tables.test │ ├── v_host_summary_by_file_io_type.test │ ├── v_innodb_buffer_stats_by_schema.test │ ├── v_io_global_by_file_by_latency.test │ ├── v_io_global_by_wait_by_latency.test │ ├── v_user_summary_by_file_io_type.test │ ├── fn_format_statement.test │ ├── v_host_summary_by_statement_type.test │ ├── v_memory_global_by_current_bytes.test │ ├── v_user_summary_by_statement_type.test │ ├── v_wait_classes_global_by_latency.test │ ├── v_memory_by_host_by_current_bytes.test │ ├── v_memory_by_user_by_current_bytes.test │ ├── fn_ps_is_thread_instrumented.test │ ├── v_host_summary_by_statement_latency.test │ ├── v_memory_by_thread_by_current_bytes.test │ ├── v_user_summary_by_statement_latency.test │ ├── v_ps_schema_table_statistics_io.test │ ├── fn_ps_is_account_enabled.test │ ├── v_statements_with_errors_or_warnings.test │ ├── v_wait_classes_global_by_avg_latency.test │ ├── v_schema_table_statistics_with_buffer.test │ ├── v_ps_digest_avg_latency_distribution.test │ ├── v_ps_digest_95th_percentile_by_avg_us.test │ ├── v_statements_with_runtimes_in_95th_percentile.test │ ├── pr_ps_setup_reset_to_default.test │ ├── fn_format_bytes.test │ ├── fn_list_drop.test │ ├── v_schema_redundant_indexes.test │ ├── fn_list_add.test │ ├── mysqldump.test │ ├── pr_table_exists.test │ ├── fn_quote_identifier.test │ ├── fn_format_time.test │ ├── pr_ps_setup_show_disabled.test │ ├── fn_format_path.test │ ├── fn_ps_is_instrument_default_timed.test │ ├── version_functions.test │ ├── fn_ps_is_instrument_default_enabled.test │ ├── pr_ps_setup_show_enabled.test │ ├── v_schema_table_lock_waits.test │ ├── fn_ps_is_consumer_enabled.test │ └── pr_diagnostics.test ├── LICENSE ├── after_setup.sql ├── procedures ├── ps_setup_reset_to_default_57_after.sql ├── ps_setup_reset_to_default_57_before.sql ├── ps_setup_show_enabled_instruments.sql ├── ps_setup_show_disabled_instruments.sql ├── ps_setup_enable_background_threads.sql ├── ps_setup_show_enabled_consumers.sql ├── ps_setup_show_disabled_consumers.sql └── ps_setup_disable_background_threads.sql ├── before_setup.sql ├── tables ├── sys_config.sql ├── sys_config_data.sql ├── sys_config_data_10.sql └── sys_config_data_57.sql ├── triggers ├── sys_config_insert_set_user.sql └── sys_config_update_set_user.sql ├── views ├── p_s │ ├── x_ps_digest_avg_latency_distribution.sql │ ├── x_memory_global_total.sql │ ├── memory_global_total.sql │ ├── session_ssl_status.sql │ ├── ps_check_lost_instrumentation.sql │ ├── ps_check_lost_instrumentation_57.sql │ ├── host_summary_by_file_io.sql │ ├── user_summary_by_file_io.sql │ ├── x_host_summary_by_file_io.sql │ ├── x_user_summary_by_file_io.sql │ ├── x_ps_digest_95th_percentile_by_avg_us.sql │ ├── statements_with_errors_or_warnings.sql │ ├── x_statements_with_errors_or_warnings.sql │ └── schema_unused_indexes.sql ├── version.sql └── i_s │ └── x_schema_flattened_keys.sql ├── templates ├── procedure.sql └── function.sql └── functions ├── version_major.sql ├── version_patch.sql └── version_minor.sql /.gitignore: -------------------------------------------------------------------------------- 1 | gen/ 2 | mariadb-sys.kdev4 3 | kdev4 4 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_version.result: -------------------------------------------------------------------------------- 1 | SELECT sys_version FROM sys.version; 2 | sys_version 3 | 1.5.2 4 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/include/ps_threads_cleanup.inc: -------------------------------------------------------------------------------- 1 | # Reset the performance_schema.setup_consumers table 2 | 3 | UPDATE performance_schema.threads SET instrumented = 'YES'; 4 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/include/ps_setup_consumers_cleanup.inc: -------------------------------------------------------------------------------- 1 | # Reset the performance_schema.setup_consumers table 2 | 3 | UPDATE performance_schema.setup_consumers SET enabled = 'YES'; 4 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/include/ps_setup_instruments_cleanup.inc: -------------------------------------------------------------------------------- 1 | # Reset the performance_schema.setup_instruments table 2 | 3 | UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES'; 4 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/fn_format_path-master.opt: -------------------------------------------------------------------------------- 1 | --innodb_data_home_dir=$MYSQLTEST_VARDIR/tmp/innodb --innodb_log_group_home_dir=$MYSQLTEST_VARDIR/tmp/innodb_logs --innodb_undo_directory=$MYSQLTEST_VARDIR/tmp/innodb_undo 2 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/include/ps_truncate_all_tables.inc: -------------------------------------------------------------------------------- 1 | # Reset all underlying Performance Schema data 2 | 3 | --disable_result_log 4 | --disable_query_log ONCE 5 | CALL sys.ps_truncate_all_tables(FALSE); 6 | --enable_result_log 7 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/include/ps_setup_actors_cleanup.inc: -------------------------------------------------------------------------------- 1 | # Reset the performance_schema.setup_actors table 2 | 3 | TRUNCATE TABLE performance_schema.setup_actors; 4 | 5 | INSERT INTO performance_schema.setup_actors VALUES ('%', '%', '%', 'YES', 'YES'); 6 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_schema_object_overview.result: -------------------------------------------------------------------------------- 1 | DESC sys.schema_object_overview; 2 | Field Type Null Key Default Extra 3 | db varchar(64) NO 4 | object_type varchar(64) YES NULL 5 | count bigint(21) NO 0 6 | SELECT * FROM sys.schema_object_overview; 7 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_metrics.result: -------------------------------------------------------------------------------- 1 | DESC sys.metrics; 2 | Field Type Null Key Default Extra 3 | Variable_name varchar(193) YES NULL 4 | Variable_value text YES NULL 5 | Type varchar(210) YES NULL 6 | Enabled varchar(7) NO 7 | SELECT * FROM sys.metrics; 8 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_ps_check_lost_instrumentation.result: -------------------------------------------------------------------------------- 1 | DESC sys.ps_check_lost_instrumentation; 2 | Field Type Null Key Default Extra 3 | variable_name varchar(64) NO NULL 4 | variable_value varchar(1024) YES NULL 5 | SELECT * FROM sys.ps_check_lost_instrumentation; 6 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_schema_unused_indexes.result: -------------------------------------------------------------------------------- 1 | DESC sys.schema_unused_indexes; 2 | Field Type Null Key Default Extra 3 | object_schema varchar(64) YES NULL 4 | object_name varchar(64) YES NULL 5 | index_name varchar(64) YES NULL 6 | SELECT * FROM sys.schema_unused_indexes; 7 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/version_functions.result: -------------------------------------------------------------------------------- 1 | SELECT sys.version_major(); 2 | SELECT sys.version_minor(); 3 | SELECT sys.version_patch(); 4 | SELECT @my_version = SUBSTRING(VERSION(), 1, CHAR_LENGTH(@my_version)); 5 | @my_version = SUBSTRING(VERSION(), 1, CHAR_LENGTH(@my_version)) 6 | 1 7 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/include/ps_setup_reset_to_default_cleanup.inc: -------------------------------------------------------------------------------- 1 | # Reset all Performance Schema configuration 2 | 3 | --source ./ps_setup_instruments_cleanup.inc 4 | 5 | --source ./ps_setup_actors_cleanup.inc 6 | 7 | --source ./ps_setup_consumers_cleanup.inc 8 | 9 | --source ./ps_threads_cleanup.inc 10 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_session_ssl_status.result: -------------------------------------------------------------------------------- 1 | DESC sys.session_ssl_status; 2 | Field Type Null Key Default Extra 3 | thread_id bigint(20) unsigned NO NULL 4 | ssl_version varchar(1024) YES NULL 5 | ssl_cipher varchar(1024) YES NULL 6 | ssl_sessions_reused varchar(1024) YES NULL 7 | SELECT * FROM sys.session_ssl_status; 8 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/fn_extract_table_from_file_name.result: -------------------------------------------------------------------------------- 1 | SELECT sys.extract_table_from_file_name(NULL); 2 | sys.extract_table_from_file_name(NULL) 3 | NULL 4 | SELECT sys.extract_table_from_file_name('/var/lib/mysql/employees/employee.ibd'); 5 | sys.extract_table_from_file_name('/var/lib/mysql/employees/employee.ibd') 6 | employee 7 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/fn_extract_schema_from_file_name.result: -------------------------------------------------------------------------------- 1 | SELECT sys.extract_schema_from_file_name(NULL); 2 | sys.extract_schema_from_file_name(NULL) 3 | NULL 4 | SELECT sys.extract_schema_from_file_name('/var/lib/mysql/employees/employee.ibd'); 5 | sys.extract_schema_from_file_name('/var/lib/mysql/employees/employee.ibd') 6 | employees 7 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/fn_ps_thread_id.result: -------------------------------------------------------------------------------- 1 | SELECT sys.ps_thread_id(234623462376); 2 | sys.ps_thread_id(234623462376) 3 | NULL 4 | SELECT sys.ps_thread_id(CONNECTION_ID()) = @ps_thread_id; 5 | sys.ps_thread_id(CONNECTION_ID()) = @ps_thread_id 6 | 1 7 | SELECT sys.ps_thread_id(NULL) = @ps_thread_id; 8 | sys.ps_thread_id(NULL) = @ps_thread_id 9 | 1 10 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_memory_global_total.result: -------------------------------------------------------------------------------- 1 | DESC sys.memory_global_total; 2 | Field Type Null Key Default Extra 3 | total_allocated text YES NULL 4 | SELECT * FROM sys.memory_global_total; 5 | DESC sys.x$memory_global_total; 6 | Field Type Null Key Default Extra 7 | total_allocated decimal(41,0) YES NULL 8 | SELECT * FROM sys.x$memory_global_total; 9 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/fn_sys_get_config.result: -------------------------------------------------------------------------------- 1 | SET @sys.statement_truncate_len := IFNULL(@sys.statement_truncate_len, sys.sys_get_config('statement_truncate_len', 128)); 2 | SELECT @sys.statement_truncate_len; 3 | @sys.statement_truncate_len 4 | 64 5 | SET @sys.foo := IFNULL(@sys.foo, sys.sys_get_config('foo', 'foobar')); 6 | SELECT @sys.foo; 7 | @sys.foo 8 | foobar 9 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/pr_ps_setup_show_disabled_consumers.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | 3 | # Disable the history_long consumers: 4 | UPDATE performance_schema.setup_consumers 5 | SET ENABLED = 'NO' 6 | WHERE NAME LIKE '%\_history\_long'; 7 | 8 | CALL sys.ps_setup_show_disabled_consumers(); 9 | 10 | # Clean up 11 | -- source ../include/ps_setup_reset_to_default_cleanup.inc 12 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/pr_ps_setup_show_enabled_consumers.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | 3 | # Disable the history_long consumers: 4 | UPDATE performance_schema.setup_consumers 5 | SET ENABLED = 'NO' 6 | WHERE NAME LIKE '%\_history\_long'; 7 | 8 | CALL sys.ps_setup_show_enabled_consumers(); 9 | 10 | # Clean up 11 | -- source ../include/ps_setup_reset_to_default_cleanup.inc 12 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/fn_format_path-master.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | mkdir $MYSQLTEST_VARDIR/tmp/innodb 4 | cp $MYSQLTEST_VARDIR/install.db/ibdata1 $MYSQLTEST_VARDIR/tmp/innodb 5 | cp $MYSQLTEST_VARDIR/install.db/ib_buffer_pool $MYSQLTEST_VARDIR/tmp/innodb 6 | mkdir $MYSQLTEST_VARDIR/tmp/innodb_logs 7 | cp $MYSQLTEST_VARDIR/install.db/ib_logfile* $MYSQLTEST_VARDIR/tmp/innodb_logs 8 | mkdir $MYSQLTEST_VARDIR/tmp/innodb_undo -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_metrics.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.metrics and sys.metrics_56 views 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.metrics; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.metrics; 12 | --enable_result_log 13 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/fn_extract_table_from_file_name.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | # Tests for sys schema 3 | # Verify the sys.extract_table_from_file_name() function perfoms as expected 4 | 5 | # Passing NULL should return NULL 6 | SELECT sys.extract_table_from_file_name(NULL); 7 | 8 | # Ensure the right part of the path is extracted 9 | SELECT sys.extract_table_from_file_name('/var/lib/mysql/employees/employee.ibd'); 10 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_version.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.version view 5 | 6 | # We do not do a DESC of this view, as the size of the version field 7 | # can change depending on the build. 8 | # Instead, we just select the sys_version, to ensure no errors/unwanted updates 9 | 10 | SELECT sys_version FROM sys.version; 11 | 12 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/fn_extract_schema_from_file_name.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | # Tests for sys schema 3 | # Verify the sys.extract_schema_from_file_name() function perfoms as expected 4 | 5 | # Passing NULL should return NULL 6 | SELECT sys.extract_schema_from_file_name(NULL); 7 | 8 | # Ensure the right part of the path is extracted 9 | SELECT sys.extract_schema_from_file_name('/var/lib/mysql/employees/employee.ibd'); 10 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_session_ssl_status.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.session_ssl_status view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.session_ssl_status; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.session_ssl_status; 12 | --enable_result_log 13 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/fn_ps_thread_account.result: -------------------------------------------------------------------------------- 1 | SELECT sys.ps_thread_account(NULL); 2 | sys.ps_thread_account(NULL) 3 | NULL 4 | SELECT sys.ps_thread_account(234623462376); 5 | sys.ps_thread_account(234623462376) 6 | NULL 7 | SELECT sys.ps_thread_account(-1); 8 | ERROR 22003: Out of range value for column 'in_thread_id' at row 1 9 | SELECT sys.ps_thread_account(sys.ps_thread_id(NULL)); 10 | sys.ps_thread_account(sys.ps_thread_id(NULL)) 11 | root@localhost 12 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/pr_ps_setup_show_disabled_instruments.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | 3 | # Disable a few instruments 4 | UPDATE performance_schema.setup_instruments 5 | SET ENABLED = 'NO' 6 | WHERE NAME LIKE 'stage/innodb/%' 7 | OR NAME LIKE 'statement/com/%' 8 | OR NAME = 'idle'; 9 | 10 | CALL sys.ps_setup_show_disabled_instruments(); 11 | 12 | # Clean up 13 | -- source ../include/ps_setup_reset_to_default_cleanup.inc 14 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_schema_unused_indexes.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.schema_unused_indexes view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.schema_unused_indexes; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.schema_unused_indexes; 12 | --enable_result_log 13 | 14 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_schema_object_overview.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.schema_object_overview view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.schema_object_overview; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.schema_object_overview; 12 | --enable_result_log 13 | 14 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/fn_ps_thread_account.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | # Tests for sys schema 3 | # Verify the sys.ps_thread_account() function perfoms as expected 4 | 5 | # Passing NULL, or an unknown connection id, should return NULL 6 | SELECT sys.ps_thread_account(NULL); 7 | SELECT sys.ps_thread_account(234623462376); 8 | 9 | -- error 1264 10 | SELECT sys.ps_thread_account(-1); 11 | 12 | # Check result 13 | SELECT sys.ps_thread_account(sys.ps_thread_id(NULL)); 14 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_ps_check_lost_instrumentation.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.ps_check_lost_instrumentation view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.ps_check_lost_instrumentation; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.ps_check_lost_instrumentation; 12 | --enable_result_log 13 | 14 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_host_summary_by_file_io.result: -------------------------------------------------------------------------------- 1 | DESC sys.host_summary_by_file_io; 2 | Field Type Null Key Default Extra 3 | host varchar(60) YES NULL 4 | ios decimal(42,0) YES NULL 5 | io_latency text YES NULL 6 | SELECT * FROM sys.host_summary_by_file_io; 7 | DESC sys.x$host_summary_by_file_io; 8 | Field Type Null Key Default Extra 9 | host varchar(60) YES NULL 10 | ios decimal(42,0) YES NULL 11 | io_latency decimal(42,0) YES NULL 12 | SELECT * FROM sys.x$host_summary_by_file_io; 13 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_user_summary_by_file_io.result: -------------------------------------------------------------------------------- 1 | DESC sys.user_summary_by_file_io; 2 | Field Type Null Key Default Extra 3 | user varchar(32) YES NULL 4 | ios decimal(42,0) YES NULL 5 | io_latency text YES NULL 6 | SELECT * FROM sys.user_summary_by_file_io; 7 | DESC sys.x$user_summary_by_file_io; 8 | Field Type Null Key Default Extra 9 | user varchar(32) YES NULL 10 | ios decimal(42,0) YES NULL 11 | io_latency decimal(42,0) YES NULL 12 | SELECT * FROM sys.x$user_summary_by_file_io; 13 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/fn_sys_get_config.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | # Tests for sys schema 3 | # Verify the sys.sys_get_config() function perfoms as expected 4 | 5 | # Check a known parameter 6 | SET @sys.statement_truncate_len := IFNULL(@sys.statement_truncate_len, sys.sys_get_config('statement_truncate_len', 128)); 7 | 8 | SELECT @sys.statement_truncate_len; 9 | 10 | # Check an unknown parameter 11 | SET @sys.foo := IFNULL(@sys.foo, sys.sys_get_config('foo', 'foobar')); 12 | 13 | SELECT @sys.foo; 14 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_latest_file_io.result: -------------------------------------------------------------------------------- 1 | DESC sys.latest_file_io; 2 | Field Type Null Key Default Extra 3 | thread varchar(149) YES NULL 4 | file varchar(512) YES NULL 5 | latency text YES NULL 6 | operation varchar(32) NO NULL 7 | requested text YES NULL 8 | SELECT * FROM sys.latest_file_io; 9 | DESC sys.x$latest_file_io; 10 | Field Type Null Key Default Extra 11 | thread varchar(149) YES NULL 12 | file varchar(512) YES NULL 13 | latency bigint(20) unsigned YES NULL 14 | operation varchar(32) NO NULL 15 | requested bigint(20) YES NULL 16 | SELECT * FROM sys.x$latest_file_io; 17 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/fn_ps_is_account_enabled.result: -------------------------------------------------------------------------------- 1 | SELECT sys.ps_is_account_enabled('foo', 'bar'); 2 | sys.ps_is_account_enabled('foo', 'bar') 3 | YES 4 | DELETE FROM performance_schema.setup_actors; 5 | INSERT INTO performance_schema.setup_actors VALUES 6 | ('test', 'test', '%', 'YES', 'NO'); 7 | SELECT sys.ps_is_account_enabled('foo', 'bar'); 8 | sys.ps_is_account_enabled('foo', 'bar') 9 | NO 10 | SELECT sys.ps_is_account_enabled('test', 'test'); 11 | sys.ps_is_account_enabled('test', 'test') 12 | YES 13 | TRUNCATE TABLE performance_schema.setup_actors; 14 | INSERT INTO performance_schema.setup_actors VALUES ('%', '%', '%', 'YES', 'YES'); 15 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_session.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.session view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.session; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.session; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$session; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$session; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/pr_ps_setup_show_enabled_instruments.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | 3 | # Disable all but a few instruments (reduces output as well) 4 | # It is not possible to disable memory/performance_schema/% 5 | # so don't even try. 6 | UPDATE performance_schema.setup_instruments 7 | SET ENABLED = 'NO' 8 | WHERE NAME NOT LIKE 'memory/performance_schema/%' 9 | AND NAME NOT LIKE 'stage/innodb/%' 10 | AND NAME NOT LIKE 'statement/com/%' 11 | AND NAME <> 'idle'; 12 | 13 | CALL sys.ps_setup_show_enabled_instruments(); 14 | 15 | # Clean up 16 | -- source ../include/ps_setup_reset_to_default_cleanup.inc 17 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/fn_ps_is_thread_instrumented.result: -------------------------------------------------------------------------------- 1 | SELECT sys.ps_is_thread_instrumented(NULL); 2 | sys.ps_is_thread_instrumented(NULL) 3 | NULL 4 | SELECT sys.ps_is_thread_instrumented(CONNECTION_ID()); 5 | sys.ps_is_thread_instrumented(CONNECTION_ID()) 6 | YES 7 | UPDATE performance_schema.threads SET instrumented = 'NO' WHERE processlist_id = CONNECTION_ID(); 8 | SELECT sys.ps_is_thread_instrumented(CONNECTION_ID()); 9 | sys.ps_is_thread_instrumented(CONNECTION_ID()) 10 | NO 11 | SELECT sys.ps_is_thread_instrumented(234623462376); 12 | sys.ps_is_thread_instrumented(234623462376) 13 | UNKNOWN 14 | UPDATE performance_schema.threads SET instrumented = 'YES'; 15 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/fn_quote_identifier.result: -------------------------------------------------------------------------------- 1 | SELECT sys.quote_identifier(NULL); 2 | sys.quote_identifier(NULL) 3 | NULL 4 | SELECT sys.quote_identifier('abc'); 5 | sys.quote_identifier('abc') 6 | `abc` 7 | SELECT sys.quote_identifier('ab`c'); 8 | sys.quote_identifier('ab`c') 9 | `ab``c` 10 | SELECT sys.quote_identifier('ab``c'); 11 | sys.quote_identifier('ab``c') 12 | `ab````c` 13 | SELECT sys.quote_identifier('ab```c'); 14 | sys.quote_identifier('ab```c') 15 | `ab``````c` 16 | SELECT sys.quote_identifier('a`b`c'); 17 | sys.quote_identifier('a`b`c') 18 | `a``b``c` 19 | SELECT sys.quote_identifier('a`b``c'); 20 | sys.quote_identifier('a`b``c') 21 | `a``b````c` 22 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_processlist.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.processlist view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.processlist; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.processlist; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$processlist; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$processlist; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_host_summary_by_stages.result: -------------------------------------------------------------------------------- 1 | DESC sys.host_summary_by_stages; 2 | Field Type Null Key Default Extra 3 | host varchar(60) YES NULL 4 | event_name varchar(128) NO NULL 5 | total bigint(20) unsigned NO NULL 6 | total_latency text YES NULL 7 | avg_latency text YES NULL 8 | SELECT * FROM sys.host_summary_by_stages; 9 | DESC sys.x$host_summary_by_stages; 10 | Field Type Null Key Default Extra 11 | host varchar(60) YES NULL 12 | event_name varchar(128) NO NULL 13 | total bigint(20) unsigned NO NULL 14 | total_latency bigint(20) unsigned NO NULL 15 | avg_latency bigint(20) unsigned NO NULL 16 | SELECT * FROM sys.x$host_summary_by_stages; 17 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_user_summary_by_stages.result: -------------------------------------------------------------------------------- 1 | DESC sys.user_summary_by_stages; 2 | Field Type Null Key Default Extra 3 | user varchar(32) YES NULL 4 | event_name varchar(128) NO NULL 5 | total bigint(20) unsigned NO NULL 6 | total_latency text YES NULL 7 | avg_latency text YES NULL 8 | SELECT * FROM sys.user_summary_by_stages; 9 | DESC sys.x$user_summary_by_stages; 10 | Field Type Null Key Default Extra 11 | user varchar(32) YES NULL 12 | event_name varchar(128) NO NULL 13 | total bigint(20) unsigned NO NULL 14 | total_latency bigint(20) unsigned NO NULL 15 | avg_latency bigint(20) unsigned NO NULL 16 | SELECT * FROM sys.x$user_summary_by_stages; 17 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_host_summary.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.host_summary view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.host_summary; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.host_summary; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$host_summary; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$host_summary; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_user_summary.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.user_summary view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.user_summary; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.user_summary; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$user_summary; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$user_summary; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_waits_global_by_latency.result: -------------------------------------------------------------------------------- 1 | DESC sys.waits_global_by_latency; 2 | Field Type Null Key Default Extra 3 | events varchar(128) NO NULL 4 | total bigint(20) unsigned NO NULL 5 | total_latency text YES NULL 6 | avg_latency text YES NULL 7 | max_latency text YES NULL 8 | SELECT * FROM sys.waits_global_by_latency; 9 | DESC sys.x$waits_global_by_latency; 10 | Field Type Null Key Default Extra 11 | events varchar(128) NO NULL 12 | total bigint(20) unsigned NO NULL 13 | total_latency bigint(20) unsigned NO NULL 14 | avg_latency bigint(20) unsigned NO NULL 15 | max_latency bigint(20) unsigned NO NULL 16 | SELECT * FROM sys.x$waits_global_by_latency; 17 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_latest_file_io.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.latest_file_io view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.latest_file_io; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.latest_file_io; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$latest_file_io; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$latest_file_io; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_user_summary_by_file_io_type.result: -------------------------------------------------------------------------------- 1 | DESC sys.user_summary_by_file_io_type; 2 | Field Type Null Key Default Extra 3 | user varchar(32) YES NULL 4 | event_name varchar(128) NO NULL 5 | total bigint(20) unsigned NO NULL 6 | latency text YES NULL 7 | max_latency text YES NULL 8 | SELECT * FROM sys.user_summary_by_file_io_type; 9 | DESC sys.x$user_summary_by_file_io_type; 10 | Field Type Null Key Default Extra 11 | user varchar(32) YES NULL 12 | event_name varchar(128) NO NULL 13 | total bigint(20) unsigned NO NULL 14 | latency bigint(20) unsigned NO NULL 15 | max_latency bigint(20) unsigned NO NULL 16 | SELECT * FROM sys.x$user_summary_by_file_io_type; 17 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/fn_format_statement.result: -------------------------------------------------------------------------------- 1 | SELECT sys.format_statement(NULL); 2 | sys.format_statement(NULL) 3 | NULL 4 | SELECT sys.format_statement('SELECT foo, bar, baz, foobar, foobaz FROM foo JOIN bar USING (foobar) JOIN baz USING (foobar) WHERE foo = \'foo\' AND bar = \'bar\'') AS statement; 5 | statement 6 | SELECT foo, bar, baz, foobar, ... RE foo = 'foo' AND bar = 'bar' 7 | SET @sys.statement_truncate_len = 80; 8 | SELECT sys.format_statement('SELECT foo, bar, baz, foobar, foobaz FROM foo JOIN bar USING (foobar) JOIN baz USING (foobar) WHERE foo = \'foo\' AND bar = \'bar\'') AS statement; 9 | statement 10 | SELECT foo, bar, baz, foobar, foobaz F ... bar) WHERE foo = 'foo' AND bar = 'bar' 11 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_host_summary_by_file_io_type.result: -------------------------------------------------------------------------------- 1 | DESC sys.host_summary_by_file_io_type; 2 | Field Type Null Key Default Extra 3 | host varchar(60) YES NULL 4 | event_name varchar(128) NO NULL 5 | total bigint(20) unsigned NO NULL 6 | total_latency text YES NULL 7 | max_latency text YES NULL 8 | SELECT * FROM sys.host_summary_by_file_io_type; 9 | DESC sys.x$host_summary_by_file_io_type; 10 | Field Type Null Key Default Extra 11 | host varchar(60) YES NULL 12 | event_name varchar(128) NO NULL 13 | total bigint(20) unsigned NO NULL 14 | total_latency bigint(20) unsigned NO NULL 15 | max_latency bigint(20) unsigned NO NULL 16 | SELECT * FROM sys.x$host_summary_by_file_io_type; 17 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_innodb_lock_waits.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.innodb_lock_waits view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.innodb_lock_waits; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.innodb_lock_waits; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$innodb_lock_waits; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$innodb_lock_waits; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/pr_execute_prepared_stmt.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | 3 | # Do some valid changes, ensure they are successful 4 | SET @sql := "CREATE TABLE test.t1 (i INT)"; 5 | CALL sys.execute_prepared_stmt(@sql); 6 | 7 | SHOW CREATE TABLE test.t1; 8 | 9 | SET @sql := CONCAT('INSERT INTO test.t1 VALUES (', 1, ')'); 10 | CALL sys.execute_prepared_stmt(@sql); 11 | 12 | SELECT * FROM test.t1; 13 | 14 | SET @sql := "DROP TABLE test.t1"; 15 | CALL sys.execute_prepared_stmt(@sql); 16 | 17 | SHOW TABLES; 18 | 19 | SET @sql = NULL; 20 | 21 | # Invalid inputs 22 | -- error S45000 23 | CALL sys.execute_prepared_stmt(NULL); 24 | -- error S45000 25 | CALL sys.execute_prepared_stmt('foo'); 26 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_statement_analysis.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.statement_analysis view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.statement_analysis; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.statement_analysis; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$statement_analysis; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$statement_analysis; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_memory_global_total.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.memory_global_total view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.memory_global_total; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.memory_global_total; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$memory_global_total; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$memory_global_total; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/pr_ps_setup_show_disabled_consumers.result: -------------------------------------------------------------------------------- 1 | UPDATE performance_schema.setup_consumers 2 | SET ENABLED = 'NO' 3 | WHERE NAME LIKE '%\_history\_long'; 4 | CALL sys.ps_setup_show_disabled_consumers(); 5 | disabled_consumers 6 | events_stages_history_long 7 | events_statements_history_long 8 | events_transactions_history_long 9 | events_waits_history_long 10 | UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES'; 11 | TRUNCATE TABLE performance_schema.setup_actors; 12 | INSERT INTO performance_schema.setup_actors VALUES ('%', '%', '%', 'YES', 'YES'); 13 | UPDATE performance_schema.setup_consumers SET enabled = 'YES'; 14 | UPDATE performance_schema.threads SET instrumented = 'YES'; 15 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_host_summary_by_stages.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.host_summary_by_stages view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.host_summary_by_stages; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.host_summary_by_stages; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$host_summary_by_stages; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$host_summary_by_stages; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_user_summary_by_stages.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.user_summary_by_stages view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.user_summary_by_stages; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.user_summary_by_stages; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$user_summary_by_stages; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$user_summary_by_stages; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_host_summary_by_file_io.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.host_summary_by_file_io view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.host_summary_by_file_io; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.host_summary_by_file_io; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$host_summary_by_file_io; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$host_summary_by_file_io; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_io_by_thread_by_latency.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.io_by_thread_by_latency view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.io_by_thread_by_latency; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.io_by_thread_by_latency; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$io_by_thread_by_latency; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$io_by_thread_by_latency; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_schema_index_statistics.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.schema_index_statistics view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.schema_index_statistics; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.schema_index_statistics; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$schema_index_statistics; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$schema_index_statistics; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_schema_table_statistics.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.schema_table_statistics view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.schema_table_statistics; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.schema_table_statistics; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$schema_table_statistics; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$schema_table_statistics; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_statements_with_sorting.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.statements_with_sorting view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.statements_with_sorting; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.statements_with_sorting; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$statements_with_sorting; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$statements_with_sorting; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_user_summary_by_file_io.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.user_summary_by_file_io view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.user_summary_by_file_io; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.user_summary_by_file_io; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$user_summary_by_file_io; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$user_summary_by_file_io; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_waits_global_by_latency.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.waits_global_by_latency view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.waits_global_by_latency; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.waits_global_by_latency; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$waits_global_by_latency; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$waits_global_by_latency; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/all_sys_objects_exist.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | # Ensure database exists 3 | USE sys; 4 | 5 | # Ensure all views are created 6 | SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'sys' ORDER BY TABLE_NAME; 7 | 8 | # Ensure all functions and routines are created 9 | SELECT ROUTINE_NAME, ROUTINE_TYPE FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA = 'sys' ORDER BY ROUTINE_TYPE, ROUTINE_NAME; 10 | 11 | # Ensure all triggers are created 12 | SELECT TRIGGER_NAME FROM INFORMATION_SCHEMA.TRIGGERS WHERE TRIGGER_SCHEMA = 'sys' ORDER BY TRIGGER_NAME; 13 | 14 | # Check the version of the schema (and ensure no updates slip in undetected) 15 | SELECT sys_version FROM sys.version; 16 | 17 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/t_sys_config.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | # Tests for sys schema 3 | # Verify the sys.sys_config table is as expected 4 | 5 | DESC sys.sys_config; 6 | 7 | SELECT variable, value, set_by FROM sys.sys_config; 8 | 9 | # Ensure the sys.sys_config_update_set_user trigger functions correctly 10 | UPDATE sys.sys_config SET value = 128 WHERE variable = 'statement_truncate_len'; 11 | 12 | SELECT variable, value, set_by FROM sys.sys_config; 13 | 14 | # Ensure the sys.sys_config_insert_set_user trigger functions correctly 15 | INSERT INTO sys.sys_config (variable, value) VALUES ('foo', 'bar'); 16 | 17 | SELECT variable, value, set_by FROM sys.sys_config; 18 | 19 | --source ../include/sys_config_cleanup.inc 20 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/fn_ps_thread_id.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | # Tests for sys schema 3 | # Verify the sys.ps_thread_id() function perfoms as expected 4 | 5 | # Passing unknown connection id should return NULL 6 | SELECT sys.ps_thread_id(234623462376); 7 | 8 | # Grab the thread_id for this connection directly from Performance Schema 9 | let $MY_THREAD_ID=`SELECT thread_id FROM performance_schema.threads 10 | WHERE PROCESSLIST_ID = connection_id()`; 11 | 12 | --disable_query_log ONCE 13 | eval SET @ps_thread_id = $MY_THREAD_ID; 14 | 15 | SELECT sys.ps_thread_id(CONNECTION_ID()) = @ps_thread_id; 16 | 17 | # Passing NULL should also return the current connection thread id 18 | SELECT sys.ps_thread_id(NULL) = @ps_thread_id; 19 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_waits_by_host_by_latency.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.waits_by_host_by_latency view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.waits_by_host_by_latency; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.waits_by_host_by_latency; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$waits_by_host_by_latency; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$waits_by_host_by_latency; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_waits_by_user_by_latency.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.waits_by_user_by_latency view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.waits_by_user_by_latency; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.waits_by_user_by_latency; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$waits_by_user_by_latency; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$waits_by_user_by_latency; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_waits_by_host_by_latency.result: -------------------------------------------------------------------------------- 1 | DESC sys.waits_by_host_by_latency; 2 | Field Type Null Key Default Extra 3 | host varchar(60) YES NULL 4 | event varchar(128) NO NULL 5 | total bigint(20) unsigned NO NULL 6 | total_latency text YES NULL 7 | avg_latency text YES NULL 8 | max_latency text YES NULL 9 | SELECT * FROM sys.waits_by_host_by_latency; 10 | DESC sys.x$waits_by_host_by_latency; 11 | Field Type Null Key Default Extra 12 | host varchar(60) YES NULL 13 | event varchar(128) NO NULL 14 | total bigint(20) unsigned NO NULL 15 | total_latency bigint(20) unsigned NO NULL 16 | avg_latency bigint(20) unsigned NO NULL 17 | max_latency bigint(20) unsigned NO NULL 18 | SELECT * FROM sys.x$waits_by_host_by_latency; 19 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_waits_by_user_by_latency.result: -------------------------------------------------------------------------------- 1 | DESC sys.waits_by_user_by_latency; 2 | Field Type Null Key Default Extra 3 | user varchar(32) YES NULL 4 | event varchar(128) NO NULL 5 | total bigint(20) unsigned NO NULL 6 | total_latency text YES NULL 7 | avg_latency text YES NULL 8 | max_latency text YES NULL 9 | SELECT * FROM sys.waits_by_user_by_latency; 10 | DESC sys.x$waits_by_user_by_latency; 11 | Field Type Null Key Default Extra 12 | user varchar(32) YES NULL 13 | event varchar(128) NO NULL 14 | total bigint(20) unsigned NO NULL 15 | total_latency bigint(20) unsigned NO NULL 16 | avg_latency bigint(20) unsigned NO NULL 17 | max_latency bigint(20) unsigned NO NULL 18 | SELECT * FROM sys.x$waits_by_user_by_latency; 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_io_global_by_file_by_bytes.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.io_global_by_file_by_bytes view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.io_global_by_file_by_bytes; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.io_global_by_file_by_bytes; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$io_global_by_file_by_bytes; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$io_global_by_file_by_bytes; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_io_global_by_wait_by_bytes.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.io_global_by_wait_by_bytes view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.io_global_by_wait_by_bytes; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.io_global_by_wait_by_bytes; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$io_global_by_wait_by_bytes; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$io_global_by_wait_by_bytes; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/include/sys_config_cleanup.inc: -------------------------------------------------------------------------------- 1 | # Reset the sys.sys_config table 2 | 3 | # Note, we have to disable the triggers to reset the set_by column back to NULL 4 | # as the sys.sys_config_update_set_user trigger will overwrite it to the current user 5 | SET @sys.ignore_sys_config_triggers := true; 6 | 7 | DELETE FROM sys.sys_config; 8 | 9 | INSERT IGNORE INTO sys.sys_config (variable, value) VALUES 10 | ('statement_truncate_len', 64), 11 | ('statement_performance_analyzer.limit', 100), 12 | ('statement_performance_analyzer.view', NULL), 13 | ('diagnostics.allow_i_s_tables', 'OFF'), 14 | ('diagnostics.include_raw', 'OFF'), 15 | ('ps_thread_trx_info.max_length', 65535); 16 | 17 | SET @sys.ignore_sys_config_triggers := NULL; 18 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_innodb_buffer_stats_by_table.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.innodb_buffer_stats_by_table view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.innodb_buffer_stats_by_table; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.innodb_buffer_stats_by_table; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$innodb_buffer_stats_by_table; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$innodb_buffer_stats_by_table; 21 | --enable_result_log 22 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_statements_with_temp_tables.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.statements_with_temp_tables view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.statements_with_temp_tables; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.statements_with_temp_tables; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$statements_with_temp_tables; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$statements_with_temp_tables; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_host_summary_by_file_io_type.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.host_summary_by_file_io_type view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.host_summary_by_file_io_type; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.host_summary_by_file_io_type; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$host_summary_by_file_io_type; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$host_summary_by_file_io_type; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_innodb_buffer_stats_by_schema.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.innodb_buffer_stats_by_schema view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.innodb_buffer_stats_by_schema; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.innodb_buffer_stats_by_schema; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$innodb_buffer_stats_by_schema; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$innodb_buffer_stats_by_schema; 21 | --enable_result_log 22 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_io_global_by_file_by_latency.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.io_global_by_file_by_latency view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.io_global_by_file_by_latency; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.io_global_by_file_by_latency; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$io_global_by_file_by_latency; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$io_global_by_file_by_latency; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_io_global_by_wait_by_latency.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.io_global_by_wait_by_latency view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.io_global_by_wait_by_latency; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.io_global_by_wait_by_latency; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$io_global_by_wait_by_latency; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$io_global_by_wait_by_latency; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_user_summary_by_file_io_type.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.user_summary_by_file_io_type view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.user_summary_by_file_io_type; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.user_summary_by_file_io_type; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$user_summary_by_file_io_type; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$user_summary_by_file_io_type; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/fn_format_statement.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | # Tests for sys schema 3 | # Verify the sys.format_statement() function perfoms as expected 4 | 5 | # Passing NULL should return NULL 6 | SELECT sys.format_statement(NULL); 7 | 8 | # Ensure long statements are truncated correctly 9 | SELECT sys.format_statement('SELECT foo, bar, baz, foobar, foobaz FROM foo JOIN bar USING (foobar) JOIN baz USING (foobar) WHERE foo = \'foo\' AND bar = \'bar\'') AS statement; 10 | 11 | # Increase truncation limit and test that it takes effect 12 | SET @sys.statement_truncate_len = 80; 13 | SELECT sys.format_statement('SELECT foo, bar, baz, foobar, foobaz FROM foo JOIN bar USING (foobar) JOIN baz USING (foobar) WHERE foo = \'foo\' AND bar = \'bar\'') AS statement; 14 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_host_summary_by_statement_type.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.host_summary_by_statement_type view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.host_summary_by_statement_type; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.host_summary_by_statement_type; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$host_summary_by_statement_type; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$host_summary_by_statement_type; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_memory_global_by_current_bytes.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.memory_global_by_current_bytes view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.memory_global_by_current_bytes; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.memory_global_by_current_bytes; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$memory_global_by_current_bytes; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$memory_global_by_current_bytes; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_user_summary_by_statement_type.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.user_summary_by_statement_type view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.user_summary_by_statement_type; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.user_summary_by_statement_type; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$user_summary_by_statement_type; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$user_summary_by_statement_type; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_wait_classes_global_by_latency.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.wait_classes_global_by_latency view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.wait_classes_global_by_latency; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.wait_classes_global_by_latency; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$wait_classes_global_by_latency; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$wait_classes_global_by_latency; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_ps_digest_avg_latency_distribution.result: -------------------------------------------------------------------------------- 1 | DESC sys.x$ps_digest_avg_latency_distribution; 2 | Field Type Null Key Default Extra 3 | cnt bigint(21) NO 0 4 | avg_us decimal(21,0) YES NULL 5 | DESC sys.x$ps_digest_avg_latency_distribution; 6 | Field Type Null Key Default Extra 7 | cnt bigint(21) NO 0 8 | avg_us decimal(21,0) YES NULL 9 | DESC sys.x$ps_digest_avg_latency_distribution; 10 | Field Type Null Key Default Extra 11 | cnt bigint(21) NO 0 12 | avg_us decimal(21,0) YES NULL 13 | SELECT * FROM sys.x$ps_digest_avg_latency_distribution; 14 | DESC sys.x$ps_digest_avg_latency_distribution; 15 | Field Type Null Key Default Extra 16 | cnt bigint(21) NO 0 17 | avg_us decimal(21,0) YES NULL 18 | SELECT * FROM sys.x$ps_digest_avg_latency_distribution; 19 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_memory_by_host_by_current_bytes.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.memory_by_host_by_current_bytes view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.memory_by_host_by_current_bytes; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.memory_by_host_by_current_bytes; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$memory_by_host_by_current_bytes; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$memory_by_host_by_current_bytes; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_memory_by_user_by_current_bytes.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.memory_by_user_by_current_bytes view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.memory_by_user_by_current_bytes; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.memory_by_user_by_current_bytes; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$memory_by_user_by_current_bytes; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$memory_by_user_by_current_bytes; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_innodb_buffer_stats_by_schema.result: -------------------------------------------------------------------------------- 1 | DESC sys.innodb_buffer_stats_by_schema; 2 | Field Type Null Key Default Extra 3 | object_schema text YES NULL 4 | allocated text YES NULL 5 | data text YES NULL 6 | pages bigint(21) NO 0 7 | pages_hashed bigint(21) NO 0 8 | pages_old bigint(21) NO 0 9 | rows_cached decimal(44,0) YES NULL 10 | SELECT * FROM sys.innodb_buffer_stats_by_schema; 11 | DESC sys.x$innodb_buffer_stats_by_schema; 12 | Field Type Null Key Default Extra 13 | object_schema text YES NULL 14 | allocated decimal(43,0) YES NULL 15 | data decimal(43,0) YES NULL 16 | pages bigint(21) NO 0 17 | pages_hashed bigint(21) NO 0 18 | pages_old bigint(21) NO 0 19 | rows_cached decimal(44,0) NO 0 20 | SELECT * FROM sys.x$innodb_buffer_stats_by_schema; 21 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_wait_classes_global_by_latency.result: -------------------------------------------------------------------------------- 1 | DESC sys.wait_classes_global_by_latency; 2 | Field Type Null Key Default Extra 3 | event_class varchar(128) YES NULL 4 | total decimal(42,0) YES NULL 5 | total_latency text YES NULL 6 | min_latency text YES NULL 7 | avg_latency text YES NULL 8 | max_latency text YES NULL 9 | SELECT * FROM sys.wait_classes_global_by_latency; 10 | DESC sys.x$wait_classes_global_by_latency; 11 | Field Type Null Key Default Extra 12 | event_class varchar(128) YES NULL 13 | total decimal(42,0) YES NULL 14 | total_latency decimal(42,0) YES NULL 15 | min_latency bigint(20) unsigned YES NULL 16 | avg_latency decimal(46,4) NO 0.0000 17 | max_latency bigint(20) unsigned YES NULL 18 | SELECT * FROM sys.x$wait_classes_global_by_latency; 19 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/fn_ps_is_thread_instrumented.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | # Tests for sys schema 3 | # Verify the sys.ps_is_thread_instrumented() function perfoms as expected 4 | 5 | # Passing NULL/nothing should return NULL 6 | SELECT sys.ps_is_thread_instrumented(NULL); 7 | 8 | # By default current thread should be instrumented 9 | SELECT sys.ps_is_thread_instrumented(CONNECTION_ID()); 10 | 11 | # Now toggle our thread to off and re-check 12 | UPDATE performance_schema.threads SET instrumented = 'NO' WHERE processlist_id = CONNECTION_ID(); 13 | SELECT sys.ps_is_thread_instrumented(CONNECTION_ID()); 14 | 15 | # Try some huge number to check unknown connections 16 | SELECT sys.ps_is_thread_instrumented(234623462376); 17 | 18 | --source ../include/ps_threads_cleanup.inc 19 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_host_summary_by_statement_latency.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.host_summary_by_statement_latency view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.host_summary_by_statement_latency; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.host_summary_by_statement_latency; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$host_summary_by_statement_latency; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$host_summary_by_statement_latency; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_memory_by_thread_by_current_bytes.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.memory_by_thread_by_current_bytes view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.memory_by_thread_by_current_bytes; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.memory_by_thread_by_current_bytes; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$memory_by_thread_by_current_bytes; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$memory_by_thread_by_current_bytes; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_user_summary_by_statement_latency.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.user_summary_by_statement_latency view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.user_summary_by_statement_latency; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.user_summary_by_statement_latency; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$user_summary_by_statement_latency; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$user_summary_by_statement_latency; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_ps_schema_table_statistics_io.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | 4 | DESC sys.x$ps_schema_table_statistics_io; 5 | 6 | DESC sys.x$ps_schema_table_statistics_io; 7 | 8 | # Ensure structure changes don't slip in 9 | DESC sys.x$ps_schema_table_statistics_io; 10 | 11 | # Make sure view select does not error, but ignore results 12 | --disable_result_log 13 | SELECT * FROM sys.x$ps_schema_table_statistics_io; 14 | --enable_result_log 15 | 16 | 17 | # Ensure structure changes don't slip in 18 | DESC sys.x$ps_schema_table_statistics_io; 19 | 20 | # Make sure view select does not error, but ignore results 21 | --disable_result_log 22 | SELECT * FROM sys.x$ps_schema_table_statistics_io; 23 | --enable_result_log 24 | 25 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/fn_ps_is_account_enabled.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | # Tests for sys schema 3 | # Verify the sys.ps_is_account_enabled() function perfoms as expected 4 | 5 | # First test with the default "all enabled" for any random user 6 | SELECT sys.ps_is_account_enabled('foo', 'bar'); 7 | 8 | # Now remove the wild card entry, and add some specific users to testx 9 | DELETE FROM performance_schema.setup_actors; 10 | 11 | INSERT INTO performance_schema.setup_actors VALUES 12 | ('test', 'test', '%', 'YES', 'NO'); 13 | 14 | # Now the random account should not be enabled 15 | SELECT sys.ps_is_account_enabled('foo', 'bar'); 16 | 17 | # But the specified one should 18 | SELECT sys.ps_is_account_enabled('test', 'test'); 19 | 20 | --source ../include/ps_setup_actors_cleanup.inc 21 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_statements_with_errors_or_warnings.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.statements_with_errors_or_warnings view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.statements_with_errors_or_warnings; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.statements_with_errors_or_warnings; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$statements_with_errors_or_warnings; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$statements_with_errors_or_warnings; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_wait_classes_global_by_avg_latency.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.wait_classes_global_by_avg_latency view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.wait_classes_global_by_avg_latency; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.wait_classes_global_by_avg_latency; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$wait_classes_global_by_avg_latency; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$wait_classes_global_by_avg_latency; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/pr_execute_prepared_stmt.result: -------------------------------------------------------------------------------- 1 | SET @sql := "CREATE TABLE test.t1 (i INT)"; 2 | CALL sys.execute_prepared_stmt(@sql); 3 | SHOW CREATE TABLE test.t1; 4 | Table Create Table 5 | t1 CREATE TABLE `t1` ( 6 | `i` int(11) DEFAULT NULL 7 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1 8 | SET @sql := CONCAT('INSERT INTO test.t1 VALUES (', 1, ')'); 9 | CALL sys.execute_prepared_stmt(@sql); 10 | SELECT * FROM test.t1; 11 | i 12 | 1 13 | SET @sql := "DROP TABLE test.t1"; 14 | CALL sys.execute_prepared_stmt(@sql); 15 | SHOW TABLES; 16 | Tables_in_test 17 | SET @sql = NULL; 18 | CALL sys.execute_prepared_stmt(NULL); 19 | ERROR 45000: The @sys.execute_prepared_stmt.sql must contain a query 20 | CALL sys.execute_prepared_stmt('foo'); 21 | ERROR 45000: The @sys.execute_prepared_stmt.sql must contain a query 22 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_schema_table_statistics_with_buffer.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.schema_table_statistics_with_buffer view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.schema_table_statistics_with_buffer; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.schema_table_statistics_with_buffer; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$schema_table_statistics_with_buffer; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$schema_table_statistics_with_buffer; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_wait_classes_global_by_avg_latency.result: -------------------------------------------------------------------------------- 1 | DESC sys.wait_classes_global_by_avg_latency; 2 | Field Type Null Key Default Extra 3 | event_class varchar(128) YES NULL 4 | total decimal(42,0) YES NULL 5 | total_latency text YES NULL 6 | min_latency text YES NULL 7 | avg_latency text YES NULL 8 | max_latency text YES NULL 9 | SELECT * FROM sys.wait_classes_global_by_avg_latency; 10 | DESC sys.x$wait_classes_global_by_avg_latency; 11 | Field Type Null Key Default Extra 12 | event_class varchar(128) YES NULL 13 | total decimal(42,0) YES NULL 14 | total_latency decimal(42,0) YES NULL 15 | min_latency bigint(20) unsigned YES NULL 16 | avg_latency decimal(46,4) NO 0.0000 17 | max_latency bigint(20) unsigned YES NULL 18 | SELECT * FROM sys.x$wait_classes_global_by_avg_latency; 19 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_memory_by_host_by_current_bytes.result: -------------------------------------------------------------------------------- 1 | DESC sys.memory_by_host_by_current_bytes; 2 | Field Type Null Key Default Extra 3 | host varchar(60) YES NULL 4 | current_count_used decimal(41,0) YES NULL 5 | current_allocated text YES NULL 6 | current_avg_alloc text YES NULL 7 | current_max_alloc text YES NULL 8 | total_allocated text YES NULL 9 | SELECT * FROM sys.memory_by_host_by_current_bytes; 10 | DESC sys.x$memory_by_host_by_current_bytes; 11 | Field Type Null Key Default Extra 12 | host varchar(60) YES NULL 13 | current_count_used decimal(41,0) YES NULL 14 | current_allocated decimal(41,0) YES NULL 15 | current_avg_alloc decimal(45,4) NO 0.0000 16 | current_max_alloc bigint(20) YES NULL 17 | total_allocated decimal(42,0) YES NULL 18 | SELECT * FROM sys.x$memory_by_host_by_current_bytes; 19 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_memory_by_user_by_current_bytes.result: -------------------------------------------------------------------------------- 1 | DESC sys.memory_by_user_by_current_bytes; 2 | Field Type Null Key Default Extra 3 | user varchar(32) YES NULL 4 | current_count_used decimal(41,0) YES NULL 5 | current_allocated text YES NULL 6 | current_avg_alloc text YES NULL 7 | current_max_alloc text YES NULL 8 | total_allocated text YES NULL 9 | SELECT * FROM sys.memory_by_user_by_current_bytes; 10 | DESC sys.x$memory_by_user_by_current_bytes; 11 | Field Type Null Key Default Extra 12 | user varchar(32) YES NULL 13 | current_count_used decimal(41,0) YES NULL 14 | current_allocated decimal(41,0) YES NULL 15 | current_avg_alloc decimal(45,4) NO 0.0000 16 | current_max_alloc bigint(20) YES NULL 17 | total_allocated decimal(42,0) YES NULL 18 | SELECT * FROM sys.x$memory_by_user_by_current_bytes; 19 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_ps_digest_avg_latency_distribution.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | 4 | DESC sys.x$ps_digest_avg_latency_distribution; 5 | 6 | DESC sys.x$ps_digest_avg_latency_distribution; 7 | 8 | # Ensure structure changes don't slip in 9 | DESC sys.x$ps_digest_avg_latency_distribution; 10 | 11 | # Make sure view select does not error, but ignore results 12 | --disable_result_log 13 | SELECT * FROM sys.x$ps_digest_avg_latency_distribution; 14 | --enable_result_log 15 | 16 | 17 | # Ensure structure changes don't slip in 18 | DESC sys.x$ps_digest_avg_latency_distribution; 19 | 20 | # Make sure view select does not error, but ignore results 21 | --disable_result_log 22 | SELECT * FROM sys.x$ps_digest_avg_latency_distribution; 23 | --enable_result_log 24 | 25 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_ps_digest_95th_percentile_by_avg_us.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | 4 | DESC sys.x$ps_digest_95th_percentile_by_avg_us; 5 | 6 | DESC sys.x$ps_digest_95th_percentile_by_avg_us; 7 | 8 | # Ensure structure changes don't slip in 9 | DESC sys.x$ps_digest_95th_percentile_by_avg_us; 10 | 11 | # Make sure view select does not error, but ignore results 12 | --disable_result_log 13 | SELECT * FROM sys.x$ps_digest_95th_percentile_by_avg_us; 14 | --enable_result_log 15 | 16 | 17 | # Ensure structure changes don't slip in 18 | DESC sys.x$ps_digest_95th_percentile_by_avg_us; 19 | 20 | # Make sure view select does not error, but ignore results 21 | --disable_result_log 22 | SELECT * FROM sys.x$ps_digest_95th_percentile_by_avg_us; 23 | --enable_result_log 24 | 25 | -------------------------------------------------------------------------------- /after_setup.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | SET @@sql_log_bin = @sql_log_bin; 17 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_ps_digest_95th_percentile_by_avg_us.result: -------------------------------------------------------------------------------- 1 | DESC sys.x$ps_digest_95th_percentile_by_avg_us; 2 | Field Type Null Key Default Extra 3 | avg_us decimal(21,0) YES NULL 4 | percentile decimal(46,4) NO 0.0000 5 | DESC sys.x$ps_digest_95th_percentile_by_avg_us; 6 | Field Type Null Key Default Extra 7 | avg_us decimal(21,0) YES NULL 8 | percentile decimal(46,4) NO 0.0000 9 | DESC sys.x$ps_digest_95th_percentile_by_avg_us; 10 | Field Type Null Key Default Extra 11 | avg_us decimal(21,0) YES NULL 12 | percentile decimal(46,4) NO 0.0000 13 | SELECT * FROM sys.x$ps_digest_95th_percentile_by_avg_us; 14 | DESC sys.x$ps_digest_95th_percentile_by_avg_us; 15 | Field Type Null Key Default Extra 16 | avg_us decimal(21,0) YES NULL 17 | percentile decimal(46,4) NO 0.0000 18 | SELECT * FROM sys.x$ps_digest_95th_percentile_by_avg_us; 19 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_innodb_buffer_stats_by_table.result: -------------------------------------------------------------------------------- 1 | DESC sys.innodb_buffer_stats_by_table; 2 | Field Type Null Key Default Extra 3 | object_schema text YES NULL 4 | object_name text YES NULL 5 | allocated text YES NULL 6 | data text YES NULL 7 | pages bigint(21) NO 0 8 | pages_hashed bigint(21) NO 0 9 | pages_old bigint(21) NO 0 10 | rows_cached decimal(44,0) YES NULL 11 | SELECT * FROM sys.innodb_buffer_stats_by_table; 12 | DESC sys.x$innodb_buffer_stats_by_table; 13 | Field Type Null Key Default Extra 14 | object_schema text YES NULL 15 | object_name text YES NULL 16 | allocated decimal(43,0) YES NULL 17 | data decimal(43,0) YES NULL 18 | pages bigint(21) NO 0 19 | pages_hashed bigint(21) NO 0 20 | pages_old bigint(21) NO 0 21 | rows_cached decimal(44,0) NO 0 22 | SELECT * FROM sys.x$innodb_buffer_stats_by_table; 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_statements_with_runtimes_in_95th_percentile.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.statements_with_runtimes_in_95th_percentile view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.statements_with_runtimes_in_95th_percentile; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.statements_with_runtimes_in_95th_percentile; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$statements_with_runtimes_in_95th_percentile; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$statements_with_runtimes_in_95th_percentile; 21 | --enable_result_log 22 | 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_memory_global_by_current_bytes.result: -------------------------------------------------------------------------------- 1 | DESC sys.memory_global_by_current_bytes; 2 | Field Type Null Key Default Extra 3 | event_name varchar(128) NO NULL 4 | current_count bigint(20) NO NULL 5 | current_alloc text YES NULL 6 | current_avg_alloc text YES NULL 7 | high_count bigint(20) NO NULL 8 | high_alloc text YES NULL 9 | high_avg_alloc text YES NULL 10 | SELECT * FROM sys.memory_global_by_current_bytes; 11 | DESC sys.x$memory_global_by_current_bytes; 12 | Field Type Null Key Default Extra 13 | event_name varchar(128) NO NULL 14 | current_count bigint(20) NO NULL 15 | current_alloc bigint(20) NO NULL 16 | current_avg_alloc decimal(23,4) NO 0.0000 17 | high_count bigint(20) NO NULL 18 | high_alloc bigint(20) NO NULL 19 | high_avg_alloc decimal(23,4) NO 0.0000 20 | SELECT * FROM sys.x$memory_global_by_current_bytes; 21 | -------------------------------------------------------------------------------- /procedures/ps_setup_reset_to_default_57_after.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | SET @@session.sql_mode = @old_sql_mode; 17 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/pr_ps_setup_show_enabled_consumers.result: -------------------------------------------------------------------------------- 1 | UPDATE performance_schema.setup_consumers 2 | SET ENABLED = 'NO' 3 | WHERE NAME LIKE '%\_history\_long'; 4 | CALL sys.ps_setup_show_enabled_consumers(); 5 | enabled_consumers 6 | events_stages_current 7 | events_stages_history 8 | events_statements_current 9 | events_statements_history 10 | events_transactions_current 11 | events_transactions_history 12 | events_waits_current 13 | events_waits_history 14 | global_instrumentation 15 | statements_digest 16 | thread_instrumentation 17 | UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES'; 18 | TRUNCATE TABLE performance_schema.setup_actors; 19 | INSERT INTO performance_schema.setup_actors VALUES ('%', '%', '%', 'YES', 'YES'); 20 | UPDATE performance_schema.setup_consumers SET enabled = 'YES'; 21 | UPDATE performance_schema.threads SET instrumented = 'YES'; 22 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/pr_ps_setup_reset_to_default.test: -------------------------------------------------------------------------------- 1 | ########### suite/sysschema/t/pr_ps_setup_reset_to_default.test ############# 2 | # # 3 | # Testing of of the sys.ps_setup_reset_to_default() procedure # 4 | # # 5 | # Creation: # 6 | # 2015-08-14 jkrogh Implement this test as part of Bug 21550271/Bug77927 # 7 | # # 8 | ############################################################################# 9 | 10 | -- source include/not_embedded.inc 11 | 12 | # Currently just a sanity check 13 | CALL sys.ps_setup_reset_to_default(TRUE); 14 | 15 | -- source ../include/ps_setup_reset_to_default_cleanup.inc 16 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/fn_format_bytes.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | # Tests for sys schema 3 | # Verify the sys.format_bytes() function perfoms as expected 4 | 5 | # Passing NULL/nothing should return NULL 6 | SELECT sys.format_bytes(NULL); 7 | 8 | # Format bytes 9 | SELECT sys.format_bytes(1); 10 | SELECT sys.format_bytes(1023); 11 | 12 | # Format kilobytes 13 | SELECT sys.format_bytes(1024); 14 | SELECT sys.format_bytes(1048575); 15 | 16 | # Format megabytes 17 | SELECT sys.format_bytes(1048576); 18 | SELECT sys.format_bytes(1073741823); 19 | 20 | # Format gigabytes 21 | SELECT sys.format_bytes(1073741824); 22 | SELECT sys.format_bytes(1099511627775); 23 | 24 | # Format terabytes 25 | SELECT sys.format_bytes(1099511627776); 26 | SELECT sys.format_bytes(1125899906842623); 27 | 28 | # Formate petabytes 29 | SELECT sys.format_bytes(1125899906842624); 30 | SELECT sys.format_bytes(1125899906842624238947293); 31 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_io_by_thread_by_latency.result: -------------------------------------------------------------------------------- 1 | DESC sys.io_by_thread_by_latency; 2 | Field Type Null Key Default Extra 3 | user varchar(128) YES NULL 4 | total decimal(42,0) YES NULL 5 | total_latency text YES NULL 6 | min_latency text YES NULL 7 | avg_latency text YES NULL 8 | max_latency text YES NULL 9 | thread_id bigint(20) unsigned NO NULL 10 | processlist_id bigint(20) unsigned YES NULL 11 | SELECT * FROM sys.io_by_thread_by_latency; 12 | DESC sys.x$io_by_thread_by_latency; 13 | Field Type Null Key Default Extra 14 | user varchar(128) YES NULL 15 | total decimal(42,0) YES NULL 16 | total_latency decimal(42,0) YES NULL 17 | min_latency bigint(20) unsigned YES NULL 18 | avg_latency decimal(24,4) YES NULL 19 | max_latency bigint(20) unsigned YES NULL 20 | thread_id bigint(20) unsigned NO NULL 21 | processlist_id bigint(20) unsigned YES NULL 22 | SELECT * FROM sys.x$io_by_thread_by_latency; 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_memory_by_thread_by_current_bytes.result: -------------------------------------------------------------------------------- 1 | DESC sys.memory_by_thread_by_current_bytes; 2 | Field Type Null Key Default Extra 3 | thread_id bigint(20) unsigned NO NULL 4 | user varchar(128) YES NULL 5 | current_count_used decimal(41,0) YES NULL 6 | current_allocated text YES NULL 7 | current_avg_alloc text YES NULL 8 | current_max_alloc text YES NULL 9 | total_allocated text YES NULL 10 | SELECT * FROM sys.memory_by_thread_by_current_bytes; 11 | DESC sys.x$memory_by_thread_by_current_bytes; 12 | Field Type Null Key Default Extra 13 | thread_id bigint(20) unsigned NO NULL 14 | user varchar(128) YES NULL 15 | current_count_used decimal(41,0) YES NULL 16 | current_allocated decimal(41,0) YES NULL 17 | current_avg_alloc decimal(45,4) NO 0.0000 18 | current_max_alloc bigint(20) YES NULL 19 | total_allocated decimal(42,0) YES NULL 20 | SELECT * FROM sys.x$memory_by_thread_by_current_bytes; 21 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_io_global_by_file_by_bytes.result: -------------------------------------------------------------------------------- 1 | DESC sys.io_global_by_file_by_bytes; 2 | Field Type Null Key Default Extra 3 | file varchar(512) YES NULL 4 | count_read bigint(20) unsigned NO NULL 5 | total_read text YES NULL 6 | avg_read text YES NULL 7 | count_write bigint(20) unsigned NO NULL 8 | total_written text YES NULL 9 | avg_write text YES NULL 10 | total text YES NULL 11 | write_pct decimal(26,2) NO 0.00 12 | SELECT * FROM sys.io_global_by_file_by_bytes; 13 | DESC sys.x$io_global_by_file_by_bytes; 14 | Field Type Null Key Default Extra 15 | file varchar(512) NO NULL 16 | count_read bigint(20) unsigned NO NULL 17 | total_read bigint(20) NO NULL 18 | avg_read decimal(23,4) NO 0.0000 19 | count_write bigint(20) unsigned NO NULL 20 | total_written bigint(20) NO NULL 21 | avg_write decimal(23,4) NO 0.0000 22 | total bigint(21) NO 0 23 | write_pct decimal(26,2) NO 0.00 24 | SELECT * FROM sys.x$io_global_by_file_by_bytes; 25 | -------------------------------------------------------------------------------- /procedures/ps_setup_reset_to_default_57_before.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | -- Because of bug 11750980/bug 41686, set the sql_mode to '' 17 | SET @old_sql_mode = @@session.sql_mode, @@session.sql_mode = ''; 18 | -------------------------------------------------------------------------------- /before_setup.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | SET NAMES utf8; 17 | SET @sql_log_bin = @@sql_log_bin; 18 | SET sql_log_bin = 0; 19 | 20 | CREATE DATABASE IF NOT EXISTS sys DEFAULT CHARACTER SET utf8; 21 | 22 | USE sys; 23 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/pr_table_exists.result: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS t1, t2; 2 | DROP VIEW IF EXISTS v_t1; 3 | CREATE TABLE t1 (id INT PRIMARY KEY); 4 | CREATE view v_t1 AS SELECT * FROM t1; 5 | CALL sys.table_exists('test', 't1', @exists); 6 | SELECT @exists; 7 | @exists 8 | BASE TABLE 9 | CALL sys.table_exists('test', 'v_t1', @exists); 10 | SELECT @exists; 11 | @exists 12 | VIEW 13 | CREATE TEMPORARY TABLE t1 (id INT PRIMARY KEY); 14 | CALL sys.table_exists('test', 't1', @exists); 15 | SELECT @exists; 16 | @exists 17 | TEMPORARY 18 | CALL sys.table_exists('test', 't2', @exists); 19 | SELECT @exists; 20 | @exists 21 | 22 | SET @identifier := REPEAT('a', 65); 23 | CALL sys.table_exists(@identifier, 't1', @exists); 24 | ERROR 22001: Data too long for column 'in_db' at row 1 25 | CALL sys.table_exists('test', @identifier, @exists); 26 | ERROR 22001: Data too long for column 'in_table' at row 1 27 | DROP TEMPORARY TABLE t1; 28 | DROP TABLE t1; 29 | DROP VIEW v_t1; 30 | SET @identifier := NULL; 31 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/pr_diagnostics.result: -------------------------------------------------------------------------------- 1 | SET @sys.debug = 'ON', 2 | @sys.diagnostics.allow_i_s_tables = 'ON', 3 | @sys.diagnostics.include_raw = 'ON'; 4 | SET @tmp_show_compatibility_56 = @@global.show_compatibility_56, 5 | GLOBAL show_compatibility_56 = ON; 6 | CALL sys.diagnostics(4, 2, 'full'); 7 | SET GLOBAL show_compatibility_56 = OFF; 8 | CALL sys.diagnostics(4, 2, 'full'); 9 | SET GLOBAL show_compatibility_56 = @tmp_show_compatibility_56, 10 | @tmp_show_compatibility_56 = NULL; 11 | SET @sys.debug = 'OFF', 12 | @sys.diagnostics.allow_i_s_tables = 'OFF', 13 | @sys.diagnostics.include_raw = 'OFF'; 14 | CALL sys.diagnostics(0, 0, 'full'); 15 | summary 16 | Disabled 1 thread 17 | ERROR 45000: in_max_runtime must be greater than 0 18 | CALL sys.diagnostics(2, 0, 'full'); 19 | ERROR 45000: in_interval must be greater than 0 20 | CALL sys.diagnostics(1, 2, 'full'); 21 | ERROR 45000: in_max_runtime must be greater than or equal to in_interval 22 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_user_summary_by_statement_latency.result: -------------------------------------------------------------------------------- 1 | DESC sys.user_summary_by_statement_latency; 2 | Field Type Null Key Default Extra 3 | user varchar(32) YES NULL 4 | total decimal(42,0) YES NULL 5 | total_latency text YES NULL 6 | max_latency text YES NULL 7 | lock_latency text YES NULL 8 | rows_sent decimal(42,0) YES NULL 9 | rows_examined decimal(42,0) YES NULL 10 | rows_affected decimal(42,0) YES NULL 11 | full_scans decimal(43,0) YES NULL 12 | SELECT * FROM sys.user_summary_by_statement_latency; 13 | DESC sys.x$user_summary_by_statement_latency; 14 | Field Type Null Key Default Extra 15 | user varchar(32) YES NULL 16 | total decimal(42,0) YES NULL 17 | total_latency decimal(42,0) YES NULL 18 | max_latency decimal(42,0) YES NULL 19 | lock_latency decimal(42,0) YES NULL 20 | rows_sent decimal(42,0) YES NULL 21 | rows_examined decimal(42,0) YES NULL 22 | rows_affected decimal(42,0) YES NULL 23 | full_scans decimal(43,0) YES NULL 24 | SELECT * FROM sys.x$user_summary_by_statement_latency; 25 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_host_summary_by_statement_latency.result: -------------------------------------------------------------------------------- 1 | DESC sys.host_summary_by_statement_latency; 2 | Field Type Null Key Default Extra 3 | host varchar(60) YES NULL 4 | total decimal(42,0) YES NULL 5 | total_latency text YES NULL 6 | max_latency text YES NULL 7 | lock_latency text YES NULL 8 | rows_sent decimal(42,0) YES NULL 9 | rows_examined decimal(42,0) YES NULL 10 | rows_affected decimal(42,0) YES NULL 11 | full_scans decimal(43,0) YES NULL 12 | SELECT * FROM sys.host_summary_by_statement_latency; 13 | DESC sys.x$host_summary_by_statement_latency; 14 | Field Type Null Key Default Extra 15 | host varchar(60) YES NULL 16 | total decimal(42,0) YES NULL 17 | total_latency decimal(42,0) YES NULL 18 | max_latency bigint(20) unsigned YES NULL 19 | lock_latency decimal(42,0) YES NULL 20 | rows_sent decimal(42,0) YES NULL 21 | rows_examined decimal(42,0) YES NULL 22 | rows_affected decimal(42,0) YES NULL 23 | full_scans decimal(43,0) YES NULL 24 | SELECT * FROM sys.x$host_summary_by_statement_latency; 25 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_io_global_by_file_by_latency.result: -------------------------------------------------------------------------------- 1 | DESC sys.io_global_by_file_by_latency; 2 | Field Type Null Key Default Extra 3 | file varchar(512) YES NULL 4 | total bigint(20) unsigned NO NULL 5 | total_latency text YES NULL 6 | count_read bigint(20) unsigned NO NULL 7 | read_latency text YES NULL 8 | count_write bigint(20) unsigned NO NULL 9 | write_latency text YES NULL 10 | count_misc bigint(20) unsigned NO NULL 11 | misc_latency text YES NULL 12 | SELECT * FROM sys.io_global_by_file_by_latency; 13 | DESC sys.x$io_global_by_file_by_latency; 14 | Field Type Null Key Default Extra 15 | file varchar(512) NO NULL 16 | total bigint(20) unsigned NO NULL 17 | total_latency bigint(20) unsigned NO NULL 18 | count_read bigint(20) unsigned NO NULL 19 | read_latency bigint(20) unsigned NO NULL 20 | count_write bigint(20) unsigned NO NULL 21 | write_latency bigint(20) unsigned NO NULL 22 | count_misc bigint(20) unsigned NO NULL 23 | misc_latency bigint(20) unsigned NO NULL 24 | SELECT * FROM sys.x$io_global_by_file_by_latency; 25 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/fn_list_drop.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | # Tests for sys schema 3 | # Verify the sys.sql_mode_drop() function perfoms as expected 4 | 5 | # Remove from front of list 6 | SELECT sys.list_drop('1,2,3,4,5', '1'); 7 | 8 | # Remove from middle of list 9 | SELECT sys.list_drop('1,2,3,4,5', '3'); 10 | 11 | # Remove from end of list 12 | SELECT sys.list_drop('1,2,3,4,5', '5'); 13 | 14 | # Make sure spaces are appropriately dealt with 15 | SELECT sys.list_drop('1, 2, 3, 4, 5', '1'); 16 | SELECT sys.list_drop('1, 2, 3, 4, 5', '3'); 17 | SELECT sys.list_drop('1, 2, 3, 4, 5', '5'); 18 | 19 | # Should return an error with a NULL value to drop 20 | --error 1138 21 | SELECT sys.list_drop('1,2,3,4,5', NULL); 22 | 23 | # Test the sql mode update use case 24 | # save old mode to restore 25 | SET @sqlmode := @@sql_mode; 26 | 27 | SELECT @@sql_mode; 28 | 29 | SET SESSION sql_mode = sys.list_drop(@@sql_mode, 'STRICT_TRANS_TABLES'); 30 | 31 | SELECT @@sql_mode; 32 | 33 | # restore old mode 34 | SET SESSION sql_mode = @sqlmode; 35 | SET @sqlmode := NULL; 36 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_schema_redundant_indexes.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.schema_redundant_indexes / x$schema_flattened_keys views 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.schema_redundant_indexes; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.schema_redundant_indexes; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$schema_flattened_keys; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$schema_flattened_keys; 21 | --enable_result_log 22 | 23 | # Test correctly identifies keys 24 | 25 | CREATE DATABASE rkey; 26 | 27 | CREATE TABLE rkey.rkey ( 28 | i INT, 29 | j INT, 30 | k INT, 31 | PRIMARY KEY (i), 32 | KEY (j), 33 | KEY (j, k), 34 | KEY (i, j, k) 35 | ); 36 | 37 | SELECT * FROM sys.schema_redundant_indexes; 38 | 39 | DROP DATABASE rkey; 40 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/fn_list_add.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | # Tests for sys schema 3 | # Verify the sys.list_add() function perfoms as expected 4 | 5 | # Should init with a single value 6 | SELECT sys.list_add(NULL, 'foo'); 7 | 8 | # Should init with a single value 9 | SELECT sys.list_add('', 'foo'); 10 | 11 | # Should add to the list with a comma 12 | SELECT sys.list_add('bar', 'foo'); 13 | 14 | # Should add to the list with a single comma 15 | SELECT sys.list_add('bar, ', 'foo'); 16 | 17 | # Should return an error with a NULL value to add 18 | --error 1138 19 | SELECT sys.list_add('foo', NULL); 20 | 21 | # Test the sql mode update use case 22 | # save old mode to restore 23 | SET @sqlmode := @@sql_mode; 24 | 25 | SELECT @@sql_mode; 26 | 27 | SET SESSION sql_mode = sys.list_add(@@sql_mode, 'ANSI_QUOTES'); 28 | 29 | SELECT @@sql_mode; 30 | 31 | # restore old mode 32 | SET SESSION sql_mode = @sqlmode; 33 | SET @sqlmode := NULL; 34 | 35 | # Check too large a value 36 | SET @input := REPEAT('a', 4194304); 37 | -- error 1406 38 | SELECT sys.list_add(@input, 'foo'); 39 | SET @input := NULL; 40 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/mysqldump.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | 3 | # Dump all databases 4 | --exec $MYSQL_DUMP -uroot --all-databases > $MYSQLTEST_VARDIR/tmp/bug20902791.sql 5 | 6 | # Save a copy of the user/tables_priv, to restore later 7 | # Otherwise the final mysql_upgrade will REPLACE and update timestamps etc. 8 | CREATE TEMPORARY TABLE tmp_user AS SELECT * FROM mysql.user; 9 | CREATE TEMPORARY TABLE tmp_tables_priv AS SELECT * FROM mysql.tables_priv; 10 | 11 | # Remove the sys schema 12 | DROP DATABASE sys; 13 | 14 | # Reload the dump 15 | --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20902791.sql 16 | 17 | # The sys schema should not exist 18 | SHOW DATABASES; 19 | 20 | # Finally reload the sys schema to return to normal 21 | --exec $MYSQL_UPGRADE --skip-verbose --force 22 | SHOW DATABASES; 23 | 24 | # Restore the saved privileges 25 | TRUNCATE TABLE mysql.user; 26 | INSERT INTO mysql.user (SELECT * FROM tmp_user); 27 | DROP TEMPORARY TABLE tmp_user; 28 | 29 | TRUNCATE TABLE mysql.tables_priv; 30 | INSERT INTO mysql.tables_priv (SELECT * FROM tmp_tables_priv); 31 | DROP TEMPORARY TABLE tmp_tables_priv; 32 | 33 | FLUSH PRIVILEGES; 34 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_host_summary_by_statement_type.result: -------------------------------------------------------------------------------- 1 | DESC sys.host_summary_by_statement_type; 2 | Field Type Null Key Default Extra 3 | host varchar(60) YES NULL 4 | statement varchar(128) YES NULL 5 | total bigint(20) unsigned NO NULL 6 | total_latency text YES NULL 7 | max_latency text YES NULL 8 | lock_latency text YES NULL 9 | rows_sent bigint(20) unsigned NO NULL 10 | rows_examined bigint(20) unsigned NO NULL 11 | rows_affected bigint(20) unsigned NO NULL 12 | full_scans bigint(21) unsigned NO 0 13 | SELECT * FROM sys.host_summary_by_statement_type; 14 | DESC sys.x$host_summary_by_statement_type; 15 | Field Type Null Key Default Extra 16 | host varchar(60) YES NULL 17 | statement varchar(128) YES NULL 18 | total bigint(20) unsigned NO NULL 19 | total_latency bigint(20) unsigned NO NULL 20 | max_latency bigint(20) unsigned NO NULL 21 | lock_latency bigint(20) unsigned NO NULL 22 | rows_sent bigint(20) unsigned NO NULL 23 | rows_examined bigint(20) unsigned NO NULL 24 | rows_affected bigint(20) unsigned NO NULL 25 | full_scans bigint(21) unsigned NO 0 26 | SELECT * FROM sys.x$host_summary_by_statement_type; 27 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_user_summary_by_statement_type.result: -------------------------------------------------------------------------------- 1 | DESC sys.user_summary_by_statement_type; 2 | Field Type Null Key Default Extra 3 | user varchar(32) YES NULL 4 | statement varchar(128) YES NULL 5 | total bigint(20) unsigned NO NULL 6 | total_latency text YES NULL 7 | max_latency text YES NULL 8 | lock_latency text YES NULL 9 | rows_sent bigint(20) unsigned NO NULL 10 | rows_examined bigint(20) unsigned NO NULL 11 | rows_affected bigint(20) unsigned NO NULL 12 | full_scans bigint(21) unsigned NO 0 13 | SELECT * FROM sys.user_summary_by_statement_type; 14 | DESC sys.x$user_summary_by_statement_type; 15 | Field Type Null Key Default Extra 16 | user varchar(32) YES NULL 17 | statement varchar(128) YES NULL 18 | total bigint(20) unsigned NO NULL 19 | total_latency bigint(20) unsigned NO NULL 20 | max_latency bigint(20) unsigned NO NULL 21 | lock_latency bigint(20) unsigned NO NULL 22 | rows_sent bigint(20) unsigned NO NULL 23 | rows_examined bigint(20) unsigned NO NULL 24 | rows_affected bigint(20) unsigned NO NULL 25 | full_scans bigint(21) unsigned NO 0 26 | SELECT * FROM sys.x$user_summary_by_statement_type; 27 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_statements_with_errors_or_warnings.result: -------------------------------------------------------------------------------- 1 | DESC sys.statements_with_errors_or_warnings; 2 | Field Type Null Key Default Extra 3 | query longtext YES NULL 4 | db varchar(64) YES NULL 5 | exec_count bigint(20) unsigned NO NULL 6 | errors bigint(20) unsigned NO NULL 7 | error_pct decimal(27,4) NO 0.0000 8 | warnings bigint(20) unsigned NO NULL 9 | warning_pct decimal(27,4) NO 0.0000 10 | first_seen timestamp NO 0000-00-00 00:00:00 11 | last_seen timestamp NO 0000-00-00 00:00:00 12 | digest varchar(32) YES NULL 13 | SELECT * FROM sys.statements_with_errors_or_warnings; 14 | DESC sys.x$statements_with_errors_or_warnings; 15 | Field Type Null Key Default Extra 16 | query longtext YES NULL 17 | db varchar(64) YES NULL 18 | exec_count bigint(20) unsigned NO NULL 19 | errors bigint(20) unsigned NO NULL 20 | error_pct decimal(27,4) NO 0.0000 21 | warnings bigint(20) unsigned NO NULL 22 | warning_pct decimal(27,4) NO 0.0000 23 | first_seen timestamp NO 0000-00-00 00:00:00 24 | last_seen timestamp NO 0000-00-00 00:00:00 25 | digest varchar(32) YES NULL 26 | SELECT * FROM sys.x$statements_with_errors_or_warnings; 27 | -------------------------------------------------------------------------------- /tables/sys_config.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | -- 17 | -- Table: sys_config 18 | -- 19 | -- Stores configuration options for sys objects 20 | -- 21 | 22 | CREATE TABLE IF NOT EXISTS sys_config ( 23 | variable VARCHAR(128) PRIMARY KEY, 24 | value VARCHAR(128), 25 | set_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 26 | set_by VARCHAR(128) 27 | ) ENGINE = InnoDB; 28 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/fn_list_add.result: -------------------------------------------------------------------------------- 1 | SELECT sys.list_add(NULL, 'foo'); 2 | sys.list_add(NULL, 'foo') 3 | foo 4 | SELECT sys.list_add('', 'foo'); 5 | sys.list_add('', 'foo') 6 | foo 7 | SELECT sys.list_add('bar', 'foo'); 8 | sys.list_add('bar', 'foo') 9 | bar,foo 10 | SELECT sys.list_add('bar, ', 'foo'); 11 | sys.list_add('bar, ', 'foo') 12 | bar,foo 13 | SELECT sys.list_add('foo', NULL); 14 | ERROR 02200: Function sys.list_add: in_add_value input variable should not be NULL 15 | SET @sqlmode := @@sql_mode; 16 | SELECT @@sql_mode; 17 | @@sql_mode 18 | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION 19 | SET SESSION sql_mode = sys.list_add(@@sql_mode, 'ANSI_QUOTES'); 20 | SELECT @@sql_mode; 21 | @@sql_mode 22 | ANSI_QUOTES,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION 23 | SET SESSION sql_mode = @sqlmode; 24 | SET @sqlmode := NULL; 25 | SET @input := REPEAT('a', 4194304); 26 | SELECT sys.list_add(@input, 'foo'); 27 | ERROR 22001: Data too long for column 'in_list' at row 1 28 | SET @input := NULL; 29 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/pr_table_exists.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | 3 | --disable_warnings 4 | DROP TABLE IF EXISTS t1, t2; 5 | DROP VIEW IF EXISTS v_t1; 6 | --enable_warnings 7 | 8 | # Create a base table and a view 9 | CREATE TABLE t1 (id INT PRIMARY KEY); 10 | CREATE view v_t1 AS SELECT * FROM t1; 11 | 12 | # Verify the base table and view is supported 13 | CALL sys.table_exists('test', 't1', @exists); 14 | SELECT @exists; 15 | 16 | CALL sys.table_exists('test', 'v_t1', @exists); 17 | SELECT @exists; 18 | 19 | # Replace the base table with a temporary table 20 | CREATE TEMPORARY TABLE t1 (id INT PRIMARY KEY); 21 | CALL sys.table_exists('test', 't1', @exists); 22 | SELECT @exists; 23 | 24 | # Try a non-existing table 25 | CALL sys.table_exists('test', 't2', @exists); 26 | SELECT @exists; 27 | 28 | # Try variables longer than expected 29 | SET @identifier := REPEAT('a', 65); 30 | 31 | -- error 1406 32 | CALL sys.table_exists(@identifier, 't1', @exists); 33 | 34 | -- error 1406 35 | CALL sys.table_exists('test', @identifier, @exists); 36 | 37 | # Clean up 38 | DROP TEMPORARY TABLE t1; 39 | DROP TABLE t1; 40 | DROP VIEW v_t1; 41 | SET @identifier := NULL; 42 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/fn_quote_identifier.test: -------------------------------------------------------------------------------- 1 | ########### suite/sysschema/t/fn_quote_identifier.test ############# 2 | # # 3 | # Testing of of the sys.quote_identifier() function # 4 | # # 5 | # Creation: # 6 | # 2016-05-23 jkrogh Implement this test as part of bug 22011361 # 7 | # # 8 | #################################################################### 9 | 10 | -- source include/not_embedded.inc 11 | # Tests for sys schema 12 | # Verify the sys.quote_identifer() function perfoms as expected 13 | 14 | # Passing NULL should return NULL 15 | SELECT sys.quote_identifier(NULL); 16 | 17 | # Passing a simple string 18 | SELECT sys.quote_identifier('abc'); 19 | 20 | # Passing a string containing backticks (`) 21 | SELECT sys.quote_identifier('ab`c'); 22 | SELECT sys.quote_identifier('ab``c'); 23 | SELECT sys.quote_identifier('ab```c'); 24 | SELECT sys.quote_identifier('a`b`c'); 25 | SELECT sys.quote_identifier('a`b``c'); 26 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/fn_format_bytes.result: -------------------------------------------------------------------------------- 1 | SELECT sys.format_bytes(NULL); 2 | sys.format_bytes(NULL) 3 | NULL 4 | SELECT sys.format_bytes(1); 5 | sys.format_bytes(1) 6 | 1 bytes 7 | SELECT sys.format_bytes(1023); 8 | sys.format_bytes(1023) 9 | 1023 bytes 10 | SELECT sys.format_bytes(1024); 11 | sys.format_bytes(1024) 12 | 1.00 KiB 13 | SELECT sys.format_bytes(1048575); 14 | sys.format_bytes(1048575) 15 | 1024.00 KiB 16 | SELECT sys.format_bytes(1048576); 17 | sys.format_bytes(1048576) 18 | 1.00 MiB 19 | SELECT sys.format_bytes(1073741823); 20 | sys.format_bytes(1073741823) 21 | 1024.00 MiB 22 | SELECT sys.format_bytes(1073741824); 23 | sys.format_bytes(1073741824) 24 | 1.00 GiB 25 | SELECT sys.format_bytes(1099511627775); 26 | sys.format_bytes(1099511627775) 27 | 1024.00 GiB 28 | SELECT sys.format_bytes(1099511627776); 29 | sys.format_bytes(1099511627776) 30 | 1.00 TiB 31 | SELECT sys.format_bytes(1125899906842623); 32 | sys.format_bytes(1125899906842623) 33 | 1024.00 TiB 34 | SELECT sys.format_bytes(1125899906842624); 35 | sys.format_bytes(1125899906842624) 36 | 1.00 PiB 37 | SELECT sys.format_bytes(1125899906842624238947293); 38 | sys.format_bytes(1125899906842624238947293) 39 | 1000000000.00 PiB 40 | -------------------------------------------------------------------------------- /tables/sys_config_data.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | -- NOTE: This needs to be replicated within the sys_config_clean.inc file 17 | 18 | INSERT IGNORE INTO sys.sys_config (variable, value) VALUES 19 | ('statement_truncate_len', 64), 20 | ('statement_performance_analyzer.limit', 100), 21 | ('statement_performance_analyzer.view', NULL), 22 | ('diagnostics.allow_i_s_tables', 'OFF'), 23 | ('diagnostics.include_raw', 'OFF'); 24 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/fn_format_path.result: -------------------------------------------------------------------------------- 1 | SELECT sys.format_path(NULL); 2 | sys.format_path(NULL) 3 | NULL 4 | SET @mypath := CONCAT(@@global.basedir, '/logs/binlog.000001'); 5 | SELECT sys.format_path(@mypath); 6 | sys.format_path(@mypath) 7 | @@basedir/logs/binlog.000001 8 | SET @mypath := CONCAT(@@global.datadir, 'foo/bar.foo'); 9 | SELECT sys.format_path(@mypath); 10 | sys.format_path(@mypath) 11 | @@datadir/foo/bar.foo 12 | SET @mypath := CONCAT(@@global.tmpdir, '/foo/bar.foo'); 13 | SELECT sys.format_path(@mypath); 14 | sys.format_path(@mypath) 15 | @@tmpdir/foo/bar.foo 16 | SET @mypath := CONCAT(@@global.innodb_data_home_dir, '/foo/bar.ibd'); 17 | SELECT sys.format_path(@mypath); 18 | sys.format_path(@mypath) 19 | @@innodb_data_home_dir/foo/bar.ibd 20 | SET @mypath := CONCAT(@@global.innodb_log_group_home_dir, '/ib_logfile0'); 21 | SELECT sys.format_path(@mypath); 22 | sys.format_path(@mypath) 23 | @@innodb_log_group_home_dir/ib_logfile0 24 | SET @mypath := CONCAT(@@global.innodb_undo_directory, '/undo0'); 25 | SELECT sys.format_path(@mypath); 26 | sys.format_path(@mypath) 27 | @@innodb_undo_directory/undo0 28 | SELECT sys.format_path('/foo/bar/baz.foo'); 29 | sys.format_path('/foo/bar/baz.foo') 30 | /foo/bar/baz.foo 31 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_host_summary.result: -------------------------------------------------------------------------------- 1 | DESC sys.host_summary; 2 | Field Type Null Key Default Extra 3 | host varchar(60) YES NULL 4 | statements decimal(64,0) YES NULL 5 | statement_latency text YES NULL 6 | statement_avg_latency text YES NULL 7 | table_scans decimal(65,0) YES NULL 8 | file_ios decimal(64,0) YES NULL 9 | file_io_latency text YES NULL 10 | current_connections decimal(41,0) YES NULL 11 | total_connections decimal(41,0) YES NULL 12 | unique_users bigint(21) NO 0 13 | current_memory text YES NULL 14 | total_memory_allocated text YES NULL 15 | SELECT * FROM sys.host_summary; 16 | DESC sys.x$host_summary; 17 | Field Type Null Key Default Extra 18 | host varchar(60) YES NULL 19 | statements decimal(64,0) YES NULL 20 | statement_latency decimal(64,0) YES NULL 21 | statement_avg_latency decimal(65,4) YES NULL 22 | table_scans decimal(65,0) YES NULL 23 | file_ios decimal(64,0) YES NULL 24 | file_io_latency decimal(64,0) YES NULL 25 | current_connections decimal(41,0) YES NULL 26 | total_connections decimal(41,0) YES NULL 27 | unique_users bigint(21) NO 0 28 | current_memory decimal(63,0) YES NULL 29 | total_memory_allocated decimal(64,0) YES NULL 30 | SELECT * FROM sys.x$host_summary; 31 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_schema_index_statistics.result: -------------------------------------------------------------------------------- 1 | DESC sys.schema_index_statistics; 2 | Field Type Null Key Default Extra 3 | table_schema varchar(64) YES NULL 4 | table_name varchar(64) YES NULL 5 | index_name varchar(64) YES NULL 6 | rows_selected bigint(20) unsigned NO NULL 7 | select_latency text YES NULL 8 | rows_inserted bigint(20) unsigned NO NULL 9 | insert_latency text YES NULL 10 | rows_updated bigint(20) unsigned NO NULL 11 | update_latency text YES NULL 12 | rows_deleted bigint(20) unsigned NO NULL 13 | delete_latency text YES NULL 14 | SELECT * FROM sys.schema_index_statistics; 15 | DESC sys.x$schema_index_statistics; 16 | Field Type Null Key Default Extra 17 | table_schema varchar(64) YES NULL 18 | table_name varchar(64) YES NULL 19 | index_name varchar(64) YES NULL 20 | rows_selected bigint(20) unsigned NO NULL 21 | select_latency bigint(20) unsigned NO NULL 22 | rows_inserted bigint(20) unsigned NO NULL 23 | insert_latency bigint(20) unsigned NO NULL 24 | rows_updated bigint(20) unsigned NO NULL 25 | update_latency bigint(20) unsigned NO NULL 26 | rows_deleted bigint(20) unsigned NO NULL 27 | delete_latency bigint(20) unsigned NO NULL 28 | SELECT * FROM sys.x$schema_index_statistics; 29 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_user_summary.result: -------------------------------------------------------------------------------- 1 | DESC sys.user_summary; 2 | Field Type Null Key Default Extra 3 | user varchar(32) YES NULL 4 | statements decimal(64,0) YES NULL 5 | statement_latency text YES NULL 6 | statement_avg_latency text YES NULL 7 | table_scans decimal(65,0) YES NULL 8 | file_ios decimal(64,0) YES NULL 9 | file_io_latency text YES NULL 10 | current_connections decimal(41,0) YES NULL 11 | total_connections decimal(41,0) YES NULL 12 | unique_hosts bigint(21) NO 0 13 | current_memory text YES NULL 14 | total_memory_allocated text YES NULL 15 | SELECT * FROM sys.user_summary; 16 | DESC sys.x$user_summary; 17 | Field Type Null Key Default Extra 18 | user varchar(32) YES NULL 19 | statements decimal(64,0) YES NULL 20 | statement_latency decimal(64,0) YES NULL 21 | statement_avg_latency decimal(65,4) NO 0.0000 22 | table_scans decimal(65,0) YES NULL 23 | file_ios decimal(64,0) YES NULL 24 | file_io_latency decimal(64,0) YES NULL 25 | current_connections decimal(41,0) YES NULL 26 | total_connections decimal(41,0) YES NULL 27 | unique_hosts bigint(21) NO 0 28 | current_memory decimal(63,0) YES NULL 29 | total_memory_allocated decimal(64,0) YES NULL 30 | SELECT * FROM sys.x$user_summary; 31 | -------------------------------------------------------------------------------- /tables/sys_config_data_10.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | -- NOTE: This needs to be replicated within the sys_config_clean.inc file 17 | 18 | INSERT IGNORE INTO sys.sys_config (variable, value) VALUES 19 | ('statement_truncate_len', 64), 20 | ('statement_performance_analyzer.limit', 100), 21 | ('statement_performance_analyzer.view', NULL), 22 | ('diagnostics.allow_i_s_tables', 'OFF'), 23 | ('diagnostics.include_raw', 'OFF'), 24 | ('ps_thread_trx_info.max_length', 65535); 25 | -------------------------------------------------------------------------------- /tables/sys_config_data_57.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | -- NOTE: This needs to be replicated within the sys_config_clean.inc file 17 | 18 | INSERT IGNORE INTO sys.sys_config (variable, value) VALUES 19 | ('statement_truncate_len', 64), 20 | ('statement_performance_analyzer.limit', 100), 21 | ('statement_performance_analyzer.view', NULL), 22 | ('diagnostics.allow_i_s_tables', 'OFF'), 23 | ('diagnostics.include_raw', 'OFF'), 24 | ('ps_thread_trx_info.max_length', 65535); 25 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_statements_with_temp_tables.result: -------------------------------------------------------------------------------- 1 | DESC sys.statements_with_temp_tables; 2 | Field Type Null Key Default Extra 3 | query longtext YES NULL 4 | db varchar(64) YES NULL 5 | exec_count bigint(20) unsigned NO NULL 6 | total_latency text YES NULL 7 | memory_tmp_tables bigint(20) unsigned NO NULL 8 | disk_tmp_tables bigint(20) unsigned NO NULL 9 | avg_tmp_tables_per_query decimal(21,0) NO 0 10 | tmp_tables_to_disk_pct decimal(24,0) NO 0 11 | first_seen timestamp NO 0000-00-00 00:00:00 12 | last_seen timestamp NO 0000-00-00 00:00:00 13 | digest varchar(32) YES NULL 14 | SELECT * FROM sys.statements_with_temp_tables; 15 | DESC sys.x$statements_with_temp_tables; 16 | Field Type Null Key Default Extra 17 | query longtext YES NULL 18 | db varchar(64) YES NULL 19 | exec_count bigint(20) unsigned NO NULL 20 | total_latency bigint(20) unsigned NO NULL 21 | memory_tmp_tables bigint(20) unsigned NO NULL 22 | disk_tmp_tables bigint(20) unsigned NO NULL 23 | avg_tmp_tables_per_query decimal(21,0) NO 0 24 | tmp_tables_to_disk_pct decimal(24,0) NO 0 25 | first_seen timestamp NO 0000-00-00 00:00:00 26 | last_seen timestamp NO 0000-00-00 00:00:00 27 | digest varchar(32) YES NULL 28 | SELECT * FROM sys.x$statements_with_temp_tables; 29 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/fn_format_time.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | # Tests for sys schema 3 | # Verify the sys.format_time() function perfoms as expected 4 | 5 | # Passing NULL should return NULL 6 | SELECT sys.format_time(NULL); 7 | 8 | # Format picoseconds 9 | SELECT sys.format_time(1); 10 | SELECT sys.format_time(999); 11 | 12 | # Format nanoseconds 13 | SELECT sys.format_time(1000); 14 | SELECT sys.format_time(999999); 15 | 16 | # Format microseconds 17 | SELECT sys.format_time(1000000); 18 | SELECT sys.format_time(999999999); 19 | 20 | # Format milliseconds 21 | SELECT sys.format_time(1000000000); 22 | SELECT sys.format_time(999999999999); 23 | 24 | # Format seconds 25 | SELECT sys.format_time(1000000000000); 26 | SELECT sys.format_time(59999999999999); 27 | 28 | # Format minutes 29 | SELECT sys.format_time(60000000000000); 30 | SELECT sys.format_time(3599999999999999); 31 | 32 | # Format hours 33 | SELECT sys.format_time(3600000000000000); 34 | SELECT sys.format_time(86399999999999988); 35 | 36 | # Format days 37 | SELECT sys.format_time(86400000000000000); 38 | SELECT sys.format_time(604799999999999888); 39 | 40 | # Format weeks 41 | SELECT sys.format_time(604800000000000000); 42 | SELECT sys.format_time(2389472398472389748237429837423984728374); 43 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_io_global_by_wait_by_bytes.result: -------------------------------------------------------------------------------- 1 | DESC sys.io_global_by_wait_by_bytes; 2 | Field Type Null Key Default Extra 3 | event_name varchar(128) YES NULL 4 | total bigint(20) unsigned NO NULL 5 | total_latency text YES NULL 6 | min_latency text YES NULL 7 | avg_latency text YES NULL 8 | max_latency text YES NULL 9 | count_read bigint(20) unsigned NO NULL 10 | total_read text YES NULL 11 | avg_read text YES NULL 12 | count_write bigint(20) unsigned NO NULL 13 | total_written text YES NULL 14 | avg_written text YES NULL 15 | total_requested text YES NULL 16 | SELECT * FROM sys.io_global_by_wait_by_bytes; 17 | DESC sys.x$io_global_by_wait_by_bytes; 18 | Field Type Null Key Default Extra 19 | event_name varchar(128) YES NULL 20 | total bigint(20) unsigned NO NULL 21 | total_latency bigint(20) unsigned NO NULL 22 | min_latency bigint(20) unsigned NO NULL 23 | avg_latency bigint(20) unsigned NO NULL 24 | max_latency bigint(20) unsigned NO NULL 25 | count_read bigint(20) unsigned NO NULL 26 | total_read bigint(20) NO NULL 27 | avg_read decimal(23,4) NO 0.0000 28 | count_write bigint(20) unsigned NO NULL 29 | total_written bigint(20) NO NULL 30 | avg_written decimal(23,4) NO 0.0000 31 | total_requested bigint(21) NO 0 32 | SELECT * FROM sys.x$io_global_by_wait_by_bytes; 33 | -------------------------------------------------------------------------------- /triggers/sys_config_insert_set_user.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | -- 17 | -- Trigger: sys_config_insert_set_user 18 | -- 19 | -- Sets the user that inserts configuration 20 | -- 21 | -- 22 | 23 | DROP TRIGGER IF EXISTS sys_config_insert_set_user; 24 | 25 | DELIMITER $$ 26 | 27 | CREATE DEFINER='root'@'localhost' TRIGGER sys_config_insert_set_user BEFORE INSERT on sys_config 28 | FOR EACH ROW 29 | BEGIN 30 | IF @sys.ignore_sys_config_triggers != true AND NEW.set_by IS NULL THEN 31 | SET NEW.set_by = USER(); 32 | END IF; 33 | END$$ 34 | 35 | DELIMITER ; 36 | -------------------------------------------------------------------------------- /triggers/sys_config_update_set_user.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | -- 17 | -- Trigger: sys_config_update_set_user 18 | -- 19 | -- Sets the user that updates configuration 20 | -- 21 | -- 22 | 23 | 24 | DROP TRIGGER IF EXISTS sys_config_update_set_user; 25 | 26 | DELIMITER $$ 27 | 28 | CREATE DEFINER='root'@'localhost' TRIGGER sys_config_update_set_user BEFORE UPDATE on sys_config 29 | FOR EACH ROW 30 | BEGIN 31 | IF @sys.ignore_sys_config_triggers != true AND NEW.set_by IS NULL THEN 32 | SET NEW.set_by = USER(); 33 | END IF; 34 | END$$ 35 | 36 | DELIMITER ; 37 | -------------------------------------------------------------------------------- /views/p_s/x_ps_digest_avg_latency_distribution.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | -- 17 | -- View: x$ps_digest_avg_latency_distribution 18 | -- 19 | -- Helper view for x$ps_digest_95th_percentile_by_avg_us 20 | -- 21 | 22 | CREATE OR REPLACE 23 | ALGORITHM = TEMPTABLE 24 | DEFINER = 'root'@'localhost' 25 | SQL SECURITY INVOKER 26 | VIEW x$ps_digest_avg_latency_distribution ( 27 | cnt, 28 | avg_us 29 | ) AS 30 | SELECT COUNT(*) cnt, 31 | ROUND(avg_timer_wait/1000000) AS avg_us 32 | FROM performance_schema.events_statements_summary_by_digest 33 | GROUP BY avg_us; 34 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/pr_ps_setup_show_disabled.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | 3 | # Add to users to the setup_actors table: one enabled, and one disabled 4 | INSERT INTO performance_schema.setup_actors 5 | VALUES ('localhost', 'foo', '%', 'YES', 'YES'), 6 | ('localhost', 'bar', '%', 'NO', 'NO'); 7 | 8 | # Disable a few instruments 9 | UPDATE performance_schema.setup_instruments 10 | SET ENABLED = 'NO' 11 | WHERE NAME LIKE 'stage/innodb/%' 12 | OR NAME LIKE 'statement/com/%' 13 | OR NAME = 'idle'; 14 | 15 | # Disable the history_long consumers: 16 | UPDATE performance_schema.setup_consumers 17 | SET ENABLED = 'NO' 18 | WHERE NAME LIKE '%\_history\_long'; 19 | 20 | # Disable some of the background threads: 21 | UPDATE performance_schema.threads SET INSTRUMENTED = 'NO' WHERE NAME LIKE 'thread/innodb/srv\_%'; 22 | 23 | # Show limited info (no thread or instrument info) 24 | CALL sys.ps_setup_show_disabled(FALSE, FALSE); 25 | 26 | # Should show instrument data, but not thread info 27 | CALL sys.ps_setup_show_disabled(TRUE, FALSE); 28 | 29 | # Should show thread info, but no instrument data 30 | CALL sys.ps_setup_show_disabled(FALSE, TRUE); 31 | 32 | # Should show all info 33 | CALL sys.ps_setup_show_disabled(TRUE, TRUE); 34 | 35 | # Clean up 36 | -- source ../include/ps_setup_reset_to_default_cleanup.inc 37 | -------------------------------------------------------------------------------- /views/version.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | -- 17 | -- View: version 18 | -- 19 | -- Shows the sys schema and mysql versions 20 | -- 21 | -- mysql> select * from sys.version; 22 | -- +-------------+---------------+ 23 | -- | sys_version | mysql_version | 24 | -- +-------------+---------------+ 25 | -- | 1.5.0 | 5.7.8-rc | 26 | -- +-------------+---------------+ 27 | -- 28 | 29 | CREATE OR REPLACE 30 | DEFINER = 'root'@'localhost' 31 | SQL SECURITY INVOKER 32 | VIEW version ( 33 | sys_version, 34 | mysql_version 35 | ) AS 36 | SELECT '1.5.2' AS sys_version, 37 | version() AS mysql_version; -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_statements_with_sorting.result: -------------------------------------------------------------------------------- 1 | DESC sys.statements_with_sorting; 2 | Field Type Null Key Default Extra 3 | query longtext YES NULL 4 | db varchar(64) YES NULL 5 | exec_count bigint(20) unsigned NO NULL 6 | total_latency text YES NULL 7 | sort_merge_passes bigint(20) unsigned NO NULL 8 | avg_sort_merges decimal(21,0) NO 0 9 | sorts_using_scans bigint(20) unsigned NO NULL 10 | sort_using_range bigint(20) unsigned NO NULL 11 | rows_sorted bigint(20) unsigned NO NULL 12 | avg_rows_sorted decimal(21,0) NO 0 13 | first_seen timestamp NO 0000-00-00 00:00:00 14 | last_seen timestamp NO 0000-00-00 00:00:00 15 | digest varchar(32) YES NULL 16 | SELECT * FROM sys.statements_with_sorting; 17 | DESC sys.x$statements_with_sorting; 18 | Field Type Null Key Default Extra 19 | query longtext YES NULL 20 | db varchar(64) YES NULL 21 | exec_count bigint(20) unsigned NO NULL 22 | total_latency bigint(20) unsigned NO NULL 23 | sort_merge_passes bigint(20) unsigned NO NULL 24 | avg_sort_merges decimal(21,0) NO 0 25 | sorts_using_scans bigint(20) unsigned NO NULL 26 | sort_using_range bigint(20) unsigned NO NULL 27 | rows_sorted bigint(20) unsigned NO NULL 28 | avg_rows_sorted decimal(21,0) NO 0 29 | first_seen timestamp NO 0000-00-00 00:00:00 30 | last_seen timestamp NO 0000-00-00 00:00:00 31 | digest varchar(32) YES NULL 32 | SELECT * FROM sys.x$statements_with_sorting; 33 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_io_global_by_wait_by_latency.result: -------------------------------------------------------------------------------- 1 | DESC sys.io_global_by_wait_by_latency; 2 | Field Type Null Key Default Extra 3 | event_name varchar(128) YES NULL 4 | total bigint(20) unsigned NO NULL 5 | total_latency text YES NULL 6 | avg_latency text YES NULL 7 | max_latency text YES NULL 8 | read_latency text YES NULL 9 | write_latency text YES NULL 10 | misc_latency text YES NULL 11 | count_read bigint(20) unsigned NO NULL 12 | total_read text YES NULL 13 | avg_read text YES NULL 14 | count_write bigint(20) unsigned NO NULL 15 | total_written text YES NULL 16 | avg_written text YES NULL 17 | SELECT * FROM sys.io_global_by_wait_by_latency; 18 | DESC sys.x$io_global_by_wait_by_latency; 19 | Field Type Null Key Default Extra 20 | event_name varchar(128) YES NULL 21 | total bigint(20) unsigned NO NULL 22 | total_latency bigint(20) unsigned NO NULL 23 | avg_latency bigint(20) unsigned NO NULL 24 | max_latency bigint(20) unsigned NO NULL 25 | read_latency bigint(20) unsigned NO NULL 26 | write_latency bigint(20) unsigned NO NULL 27 | misc_latency bigint(20) unsigned NO NULL 28 | count_read bigint(20) unsigned NO NULL 29 | total_read bigint(20) NO NULL 30 | avg_read decimal(23,4) NO 0.0000 31 | count_write bigint(20) unsigned NO NULL 32 | total_written bigint(20) NO NULL 33 | avg_written decimal(23,4) NO 0.0000 34 | SELECT * FROM sys.x$io_global_by_wait_by_latency; 35 | -------------------------------------------------------------------------------- /views/p_s/x_memory_global_total.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | -- 17 | -- View: x$memory_global_total 18 | -- 19 | -- Shows the total memory usage within the server globally 20 | -- 21 | -- mysql> select * from x$memory_global_total; 22 | -- +-----------------+ 23 | -- | total_allocated | 24 | -- +-----------------+ 25 | -- | 1420023 | 26 | -- +-----------------+ 27 | -- 28 | 29 | CREATE OR REPLACE 30 | ALGORITHM = TEMPTABLE 31 | DEFINER = 'root'@'localhost' 32 | SQL SECURITY INVOKER 33 | VIEW x$memory_global_total ( 34 | total_allocated 35 | ) AS 36 | SELECT SUM(CURRENT_NUMBER_OF_BYTES_USED) total_allocated 37 | FROM performance_schema.memory_summary_global_by_event_name; 38 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/fn_list_drop.result: -------------------------------------------------------------------------------- 1 | SELECT sys.list_drop('1,2,3,4,5', '1'); 2 | sys.list_drop('1,2,3,4,5', '1') 3 | 2,3,4,5 4 | SELECT sys.list_drop('1,2,3,4,5', '3'); 5 | sys.list_drop('1,2,3,4,5', '3') 6 | 1,2,4,5 7 | SELECT sys.list_drop('1,2,3,4,5', '5'); 8 | sys.list_drop('1,2,3,4,5', '5') 9 | 1,2,3,4 10 | SELECT sys.list_drop('1, 2, 3, 4, 5', '1'); 11 | sys.list_drop('1, 2, 3, 4, 5', '1') 12 | 2, 3, 4, 5 13 | SELECT sys.list_drop('1, 2, 3, 4, 5', '3'); 14 | sys.list_drop('1, 2, 3, 4, 5', '3') 15 | 1, 2, 4, 5 16 | SELECT sys.list_drop('1, 2, 3, 4, 5', '5'); 17 | sys.list_drop('1, 2, 3, 4, 5', '5') 18 | 1, 2, 3, 4 19 | SELECT sys.list_drop('1,2,3,4,5', NULL); 20 | ERROR 02200: Function sys.list_drop: in_drop_value input variable should not be NULL 21 | SET @sqlmode := @@sql_mode; 22 | SELECT @@sql_mode; 23 | @@sql_mode 24 | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION 25 | SET SESSION sql_mode = sys.list_drop(@@sql_mode, 'STRICT_TRANS_TABLES'); 26 | Warnings: 27 | Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. 28 | SELECT @@sql_mode; 29 | @@sql_mode 30 | ONLY_FULL_GROUP_BY,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION 31 | SET SESSION sql_mode = @sqlmode; 32 | SET @sqlmode := NULL; 33 | -------------------------------------------------------------------------------- /views/p_s/memory_global_total.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | -- 17 | -- View: memory_global_total 18 | -- 19 | -- Shows the total memory usage within the server globally. 20 | -- 21 | -- mysql> select * from memory_global_total; 22 | -- +-----------------+ 23 | -- | total_allocated | 24 | -- +-----------------+ 25 | -- | 123.35 MiB | 26 | -- +-----------------+ 27 | -- 28 | 29 | CREATE OR REPLACE 30 | ALGORITHM = TEMPTABLE 31 | DEFINER = 'root'@'localhost' 32 | SQL SECURITY INVOKER 33 | VIEW memory_global_total ( 34 | total_allocated 35 | ) AS 36 | SELECT sys.format_bytes(SUM(CURRENT_NUMBER_OF_BYTES_USED)) total_allocated 37 | FROM performance_schema.memory_summary_global_by_event_name; 38 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/fn_format_path.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | # Windows paths are \ not /, so ignore here 3 | -- source include/not_windows.inc 4 | # Tests for sys schema 5 | # Verify the sys.format_path() function perfoms as expected 6 | # 7 | 8 | # Passing NULL should return NULL 9 | SELECT sys.format_path(NULL); 10 | 11 | # Ensure basedir is recognized and stripped 12 | SET @mypath := CONCAT(@@global.basedir, '/logs/binlog.000001'); 13 | 14 | SELECT sys.format_path(@mypath); 15 | 16 | # Ensure datadir is recognized and stripped 17 | SET @mypath := CONCAT(@@global.datadir, 'foo/bar.foo'); 18 | 19 | SELECT sys.format_path(@mypath); 20 | 21 | # Ensure tmpdir is recognized and stripped 22 | SET @mypath := CONCAT(@@global.tmpdir, '/foo/bar.foo'); 23 | 24 | SELECT sys.format_path(@mypath); 25 | 26 | # Ensure innodb_data_home_dir is recognized and stripped 27 | SET @mypath := CONCAT(@@global.innodb_data_home_dir, '/foo/bar.ibd'); 28 | 29 | SELECT sys.format_path(@mypath); 30 | 31 | # Ensure innodb_log_group_home_dir is recognized and stripped 32 | SET @mypath := CONCAT(@@global.innodb_log_group_home_dir, '/ib_logfile0'); 33 | 34 | SELECT sys.format_path(@mypath); 35 | 36 | # Ensure innodb_undo_directory is recognized and stripped 37 | SET @mypath := CONCAT(@@global.innodb_undo_directory, '/undo0'); 38 | 39 | SELECT sys.format_path(@mypath); 40 | 41 | # Unrecognized paths should return the full path 42 | SELECT sys.format_path('/foo/bar/baz.foo'); 43 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/pr_ps_trace_statement_digest.result: -------------------------------------------------------------------------------- 1 | use test; 2 | SET @threadid = sys.ps_thread_id(NULL); 3 | CREATE TABLE t1 (id INT PRIMARY KEY, val int); 4 | INSERT INTO test.t1 VALUES (1, 9); 5 | SET @digest.insert = (SELECT DIGEST FROM performance_schema.events_statements_history WHERE THREAD_ID = @threadid AND SQL_TEXT LIKE 'INSERT INTO test.t1 VALUES (1, 9)'); 6 | SELECT * FROM t1; 7 | id val 8 | 1 9 9 | SET @digest.select = (SELECT DIGEST FROM performance_schema.events_statements_history WHERE THREAD_ID = @threadid AND SQL_TEXT LIKE 'SELECT * FROM t1'); 10 | SHOW CREATE TABLE test.t1; 11 | Table Create Table 12 | t1 CREATE TABLE `t1` ( 13 | `id` int(11) NOT NULL, 14 | `val` int(11) DEFAULT NULL, 15 | PRIMARY KEY (`id`) 16 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1 17 | SET @digest.show = (SELECT DIGEST FROM performance_schema.events_statements_history WHERE THREAD_ID = @threadid AND SQL_TEXT LIKE 'SHOW CREATE TABLE test.t1'); 18 | CREATE SCHEMA test_sys; 19 | use test_sys; 20 | CALL sys.ps_trace_statement_digest(@digest.insert, 0.5, 0.1, FALSE, FALSE); 21 | CALL sys.ps_trace_statement_digest(@digest.select, 0.5, 0.1, FALSE, FALSE); 22 | CALL sys.ps_trace_statement_digest(@digest.show , 0.5, 0.1, FALSE, FALSE); 23 | CALL sys.ps_trace_statement_digest(@digest.insert, 0.5, 0.1, TRUE , FALSE); 24 | use test; 25 | DROP SCHEMA test_sys; 26 | DROP TABLE t1; 27 | SET @threadid = NULL, 28 | @digest.insert = NULL, 29 | @digest.select = NULL, 30 | @digest.show = NULL; 31 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/fn_ps_is_instrument_default_timed.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | # Tests for sys schema 3 | # Verify the sys.ps_is_instrument_default_timed() function perfoms as expected 4 | 5 | # Should all be enabled 6 | SELECT sys.ps_is_instrument_default_timed('wait/io/file/sql/binlog'); 7 | SELECT sys.ps_is_instrument_default_timed('statement/sql/select'); 8 | SELECT sys.ps_is_instrument_default_timed('statement/sp/error'); 9 | SELECT sys.ps_is_instrument_default_timed('statement/com/Prepare'); 10 | SELECT sys.ps_is_instrument_default_timed('wait/io/table/sql/handler'); 11 | SELECT sys.ps_is_instrument_default_timed('wait/lock/table/sql/handler'); 12 | SELECT sys.ps_is_instrument_default_timed('idle'); 13 | 14 | # Should all be disabled 15 | SELECT sys.ps_is_instrument_default_timed('wait/synch/mutex/sql/LOCK_plugin'); 16 | SELECT sys.ps_is_instrument_default_timed('wait/synch/rwlock/sql/LOCK_grant'); 17 | SELECT sys.ps_is_instrument_default_timed('wait/synch/sxlock/innodb/btr_search_latch'); 18 | SELECT sys.ps_is_instrument_default_timed('wait/synch/cond/sql/MYSQL_BIN_LOG::update_cond'); 19 | SELECT sys.ps_is_instrument_default_timed('stage/sql/end'); 20 | SELECT sys.ps_is_instrument_default_timed('transaction'); 21 | SELECT sys.ps_is_instrument_default_timed('wait/io/socket/sql/server_tcpip_socket'); 22 | SELECT sys.ps_is_instrument_default_timed('memory/performance_schema/internal_buffers'); 23 | SELECT sys.ps_is_instrument_default_timed('wait/lock/metadata/sql/mdl'); 24 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/version_functions.test: -------------------------------------------------------------------------------- 1 | ########### suite/sysschema/t/version_functions.test ############# 2 | # # 3 | # Testing of the sys.version_major(), sys.version_minor(), # 4 | # and sys.version_patch() functions # 5 | # # 6 | # Creation: # 7 | # 2015-08-14 jkrogh Implement this test # 8 | # # 9 | ################################################################## 10 | 11 | -- source include/not_embedded.inc 12 | 13 | # Sanity check - the functions should not return any warnings or errors 14 | --disable_result_log 15 | SELECT sys.version_major(); 16 | SELECT sys.version_minor(); 17 | SELECT sys.version_patch(); 18 | --enable_result_log 19 | 20 | # Check that concatenating the three version parts gives the beginning of the output of VERSION() 21 | # This is not truly an independent test, but there isn't really anywhere else to get the actual version, 22 | # so it at least verifies that the three parts go back together in the right way. 23 | let $MY_VERSION=`SELECT CONCAT(sys.version_major(), '.', sys.version_minor(), '.', sys.version_patch())`; 24 | --disable_query_log ONCE 25 | eval SET @my_version = '$MY_VERSION'; 26 | 27 | SELECT @my_version = SUBSTRING(VERSION(), 1, CHAR_LENGTH(@my_version)); 28 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_schema_redundant_indexes.result: -------------------------------------------------------------------------------- 1 | DESC sys.schema_redundant_indexes; 2 | Field Type Null Key Default Extra 3 | table_schema varchar(64) NO 4 | table_name varchar(64) NO 5 | redundant_index_name varchar(64) NO 6 | redundant_index_columns text YES NULL 7 | redundant_index_non_unique bigint(1) YES NULL 8 | dominant_index_name varchar(64) NO 9 | dominant_index_columns text YES NULL 10 | dominant_index_non_unique bigint(1) YES NULL 11 | subpart_exists int(1) NO 0 12 | sql_drop_index varchar(223) YES NULL 13 | SELECT * FROM sys.schema_redundant_indexes; 14 | DESC sys.x$schema_flattened_keys; 15 | Field Type Null Key Default Extra 16 | table_schema varchar(64) NO 17 | table_name varchar(64) NO 18 | index_name varchar(64) NO 19 | non_unique bigint(1) YES NULL 20 | subpart_exists bigint(1) YES NULL 21 | index_columns text YES NULL 22 | SELECT * FROM sys.x$schema_flattened_keys; 23 | CREATE DATABASE rkey; 24 | CREATE TABLE rkey.rkey ( 25 | i INT, 26 | j INT, 27 | k INT, 28 | PRIMARY KEY (i), 29 | KEY (j), 30 | KEY (j, k), 31 | KEY (i, j, k) 32 | ); 33 | SELECT * FROM sys.schema_redundant_indexes; 34 | table_schema table_name redundant_index_name redundant_index_columns redundant_index_non_unique dominant_index_name dominant_index_columns dominant_index_non_unique subpart_exists sql_drop_index 35 | rkey rkey j j 1 j_2 j,k 1 0 ALTER TABLE `rkey`.`rkey` DROP INDEX `j` 36 | rkey rkey i i,j,k 1 PRIMARY i 0 0 ALTER TABLE `rkey`.`rkey` DROP INDEX `i` 37 | DROP DATABASE rkey; 38 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/fn_ps_is_instrument_default_enabled.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | # Tests for sys schema 3 | # Verify the sys.ps_is_instrument_default_enabled() function perfoms as expected 4 | 5 | # Should all be enabled 6 | SELECT sys.ps_is_instrument_default_enabled('memory/performance_schema/internal_buffers'); 7 | SELECT sys.ps_is_instrument_default_enabled('statement/sql/select'); 8 | SELECT sys.ps_is_instrument_default_enabled('statement/sp/error'); 9 | SELECT sys.ps_is_instrument_default_enabled('statement/com/Prepare'); 10 | SELECT sys.ps_is_instrument_default_enabled('wait/io/file/sql/binlog'); 11 | SELECT sys.ps_is_instrument_default_enabled('wait/io/table/sql/handler'); 12 | SELECT sys.ps_is_instrument_default_enabled('wait/lock/table/sql/handler'); 13 | SELECT sys.ps_is_instrument_default_enabled('idle'); 14 | 15 | # Should all be disabled 16 | SELECT sys.ps_is_instrument_default_enabled('wait/synch/mutex/sql/LOCK_plugin'); 17 | SELECT sys.ps_is_instrument_default_enabled('wait/synch/rwlock/sql/LOCK_grant'); 18 | SELECT sys.ps_is_instrument_default_enabled('wait/synch/sxlock/innodb/btr_search_latch'); 19 | SELECT sys.ps_is_instrument_default_enabled('wait/synch/cond/sql/MYSQL_BIN_LOG::update_cond'); 20 | SELECT sys.ps_is_instrument_default_enabled('stage/sql/end'); 21 | SELECT sys.ps_is_instrument_default_enabled('transaction'); 22 | SELECT sys.ps_is_instrument_default_enabled('wait/io/socket/sql/server_tcpip_socket'); 23 | SELECT sys.ps_is_instrument_default_enabled('wait/lock/metadata/sql/mdl'); 24 | -------------------------------------------------------------------------------- /views/p_s/session_ssl_status.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- View: session_ssl_status 3 | -- 4 | -- Shows SSL version, cipher and the count of re-used SSL sessions per connection 5 | -- 6 | -- mysql> select * from session_ssl_status; 7 | -- +-----------+-------------+--------------------+---------------------+ 8 | -- | thread_id | ssl_version | ssl_cipher | ssl_sessions_reused | 9 | -- +-----------+-------------+--------------------+---------------------+ 10 | -- | 26 | TLSv1 | DHE-RSA-AES256-SHA | 0 | 11 | -- | 27 | TLSv1 | DHE-RSA-AES256-SHA | 0 | 12 | -- | 28 | TLSv1 | DHE-RSA-AES256-SHA | 0 | 13 | -- +-----------+-------------+--------------------+---------------------+ 14 | -- 3 rows in set (0.00 sec) 15 | -- 16 | 17 | CREATE OR REPLACE 18 | ALGORITHM = MERGE 19 | DEFINER = 'root'@'localhost' 20 | SQL SECURITY INVOKER 21 | VIEW session_ssl_status ( 22 | thread_id, 23 | ssl_version, 24 | ssl_cipher, 25 | ssl_sessions_reused 26 | ) AS 27 | SELECT sslver.thread_id, 28 | sslver.variable_value ssl_version, 29 | sslcip.variable_value ssl_cipher, 30 | sslreuse.variable_value ssl_sessions_reused 31 | FROM performance_schema.status_by_thread sslver 32 | LEFT JOIN performance_schema.status_by_thread sslcip 33 | ON (sslcip.thread_id=sslver.thread_id and sslcip.variable_name='Ssl_cipher') 34 | LEFT JOIN performance_schema.status_by_thread sslreuse 35 | ON (sslreuse.thread_id=sslver.thread_id and sslreuse.variable_name='Ssl_sessions_reused') 36 | WHERE sslver.variable_name='Ssl_version'; 37 | -------------------------------------------------------------------------------- /templates/procedure.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | DROP PROCEDURE IF EXISTS ; 17 | 18 | DELIMITER $$ 19 | 20 | CREATE DEFINER='root'@'localhost' PROCEDURE ( 21 | /* Variables */ 22 | ) 23 | COMMENT ' 24 | Description 25 | ----------- 26 | 27 | ... 28 | 29 | Parameters 30 | ----------- 31 | 32 | ... 33 | 34 | 35 | Configuration Options 36 | ---------------------- 37 | 38 | ... 39 | 40 | 41 | Example 42 | -------- 43 | 44 | ... 45 | 46 | ' 47 | SQL SECURITY INVOKER 48 | { DETERMINISTIC | NOT DETERMINISTIC } 49 | { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA } 50 | BEGIN 51 | 52 | /* BODY */ 53 | 54 | END$$ 55 | 56 | DELIMITER ; 57 | -------------------------------------------------------------------------------- /templates/function.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | DROP FUNCTION IF EXISTS ; 17 | 18 | DELIMITER $$ 19 | 20 | CREATE DEFINER='root'@'localhost' FUNCTION ( 21 | /* Variables */ 22 | ) 23 | RETURNS 24 | COMMENT ' 25 | Description 26 | ----------- 27 | 28 | ... 29 | 30 | Parameters 31 | ----------- 32 | 33 | ... 34 | 35 | Returns 36 | ----------- 37 | 38 | 39 | 40 | Example 41 | ----------- 42 | 43 | ... 44 | 45 | ' 46 | SQL SECURITY INVOKER 47 | { DETERMINISTIC | NOT DETERMINISTIC } 48 | { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA } 49 | BEGIN 50 | 51 | /* BODY */ 52 | RETURN ; 53 | 54 | END$$ 55 | 56 | DELIMITER ; 57 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/pr_ps_setup_show_enabled.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | 3 | # Add to users to the setup_actors table: one enabled, and one disabled 4 | INSERT INTO performance_schema.setup_actors 5 | VALUES ('localhost', 'foo', '%', 'YES', 'YES'), 6 | ('localhost', 'bar', '%', 'NO', 'NO'); 7 | 8 | # Disable all but a few instruments (reduces output as well) 9 | # It is not possible to disable memory/performance_schema/% 10 | # so don't even try. 11 | UPDATE performance_schema.setup_instruments 12 | SET ENABLED = 'NO' 13 | WHERE NAME NOT LIKE 'memory/performance_schema/%' 14 | AND NAME NOT LIKE 'stage/innodb/%' 15 | AND NAME NOT LIKE 'statement/com/%' 16 | AND NAME <> 'idle'; 17 | 18 | # Disable the history_long consumers: 19 | UPDATE performance_schema.setup_consumers 20 | SET ENABLED = 'NO' 21 | WHERE NAME LIKE '%\_history\_long'; 22 | 23 | # Disable some of the background threads (including those that differ between unix like and Windows systems): 24 | UPDATE performance_schema.threads 25 | SET INSTRUMENTED = 'NO' 26 | WHERE NAME LIKE 'thread/innodb/srv\_%' 27 | OR NAME LIKE '%con\_%' 28 | OR NAME LIKE '%signal_handler%'; 29 | 30 | # Show limited info (no thread or instrument info) 31 | CALL sys.ps_setup_show_enabled(FALSE, FALSE); 32 | 33 | # Should show instrument data, but not thread info 34 | CALL sys.ps_setup_show_enabled(TRUE, FALSE); 35 | 36 | # Should show thread info, but no instrument data 37 | CALL sys.ps_setup_show_enabled(FALSE, TRUE); 38 | 39 | # Should show all info 40 | CALL sys.ps_setup_show_enabled(TRUE, TRUE); 41 | 42 | # Clean up 43 | -- source ../include/ps_setup_reset_to_default_cleanup.inc 44 | -------------------------------------------------------------------------------- /procedures/ps_setup_show_enabled_instruments.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | DROP PROCEDURE IF EXISTS ps_setup_show_enabled_instruments; 17 | 18 | DELIMITER $$ 19 | 20 | CREATE DEFINER='root'@'localhost' PROCEDURE ps_setup_show_enabled_instruments () 21 | COMMENT ' 22 | Description 23 | ----------- 24 | 25 | Shows all currently enabled instruments. 26 | 27 | Parameters 28 | ----------- 29 | 30 | None 31 | 32 | Example 33 | ----------- 34 | 35 | mysql> CALL sys.ps_setup_show_enabled_instruments(); 36 | ' 37 | SQL SECURITY INVOKER 38 | DETERMINISTIC 39 | READS SQL DATA 40 | BEGIN 41 | SELECT name AS enabled_instruments, timed 42 | FROM performance_schema.setup_instruments 43 | WHERE enabled = 'YES' 44 | ORDER BY enabled_instruments; 45 | END$$ 46 | 47 | DELIMITER ; 48 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_statements_with_runtimes_in_95th_percentile.result: -------------------------------------------------------------------------------- 1 | DESC sys.statements_with_runtimes_in_95th_percentile; 2 | Field Type Null Key Default Extra 3 | query longtext YES NULL 4 | db varchar(64) YES NULL 5 | full_scan varchar(1) NO 6 | exec_count bigint(20) unsigned NO NULL 7 | err_count bigint(20) unsigned NO NULL 8 | warn_count bigint(20) unsigned NO NULL 9 | total_latency text YES NULL 10 | max_latency text YES NULL 11 | avg_latency text YES NULL 12 | rows_sent bigint(20) unsigned NO NULL 13 | rows_sent_avg decimal(21,0) NO 0 14 | rows_examined bigint(20) unsigned NO NULL 15 | rows_examined_avg decimal(21,0) NO 0 16 | first_seen timestamp NO 0000-00-00 00:00:00 17 | last_seen timestamp NO 0000-00-00 00:00:00 18 | digest varchar(32) YES NULL 19 | SELECT * FROM sys.statements_with_runtimes_in_95th_percentile; 20 | DESC sys.x$statements_with_runtimes_in_95th_percentile; 21 | Field Type Null Key Default Extra 22 | query longtext YES NULL 23 | db varchar(64) YES NULL 24 | full_scan varchar(1) NO 25 | exec_count bigint(20) unsigned NO NULL 26 | err_count bigint(20) unsigned NO NULL 27 | warn_count bigint(20) unsigned NO NULL 28 | total_latency bigint(20) unsigned NO NULL 29 | max_latency bigint(20) unsigned NO NULL 30 | avg_latency bigint(20) unsigned NO NULL 31 | rows_sent bigint(20) unsigned NO NULL 32 | rows_sent_avg decimal(21,0) NO 0 33 | rows_examined bigint(20) unsigned NO NULL 34 | rows_examined_avg decimal(21,0) NO 0 35 | first_seen timestamp NO 0000-00-00 00:00:00 36 | last_seen timestamp NO 0000-00-00 00:00:00 37 | digest varchar(32) YES NULL 38 | SELECT * FROM sys.x$statements_with_runtimes_in_95th_percentile; 39 | -------------------------------------------------------------------------------- /procedures/ps_setup_show_disabled_instruments.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | DROP PROCEDURE IF EXISTS ps_setup_show_disabled_instruments; 17 | 18 | DELIMITER $$ 19 | 20 | CREATE DEFINER='root'@'localhost' PROCEDURE ps_setup_show_disabled_instruments () 21 | COMMENT ' 22 | Description 23 | ----------- 24 | 25 | Shows all currently disabled instruments. 26 | 27 | Parameters 28 | ----------- 29 | 30 | None 31 | 32 | Example 33 | ----------- 34 | 35 | mysql> CALL sys.ps_setup_show_disabled_instruments(); 36 | ' 37 | SQL SECURITY INVOKER 38 | DETERMINISTIC 39 | READS SQL DATA 40 | BEGIN 41 | SELECT name AS disabled_instruments, timed 42 | FROM performance_schema.setup_instruments 43 | WHERE enabled = 'NO' 44 | ORDER BY disabled_instruments; 45 | END$$ 46 | 47 | DELIMITER ; 48 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/v_schema_table_lock_waits.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | -- source ../include/ps_truncate_all_tables.inc 3 | # Tests for sys schema 4 | # Verify the sys.schema_table_lock_waits view 5 | 6 | # Ensure structure changes don't slip in 7 | DESC sys.schema_table_lock_waits; 8 | 9 | # Make sure view select does not error, but ignore results 10 | --disable_result_log 11 | SELECT * FROM sys.schema_table_lock_waits; 12 | --enable_result_log 13 | 14 | 15 | # Ensure structure changes don't slip in 16 | DESC sys.x$schema_table_lock_waits; 17 | 18 | # Make sure view select does not error, but ignore results 19 | --disable_result_log 20 | SELECT * FROM sys.x$schema_table_lock_waits; 21 | --enable_result_log 22 | 23 | # Ensure lock waits show up correctly 24 | --connect(con1,localhost,root,,) 25 | --connect(con2,localhost,root,,) 26 | 27 | connection con1; 28 | CREATE TABLE test.lock_waits (i INT PRIMARY KEY, j INT) ENGINE = InnoDB; 29 | LOCK TABLE lock_waits WRITE; 30 | 31 | connection con2; 32 | send ALTER TABLE test.lock_waits ADD k VARCHAR(20); 33 | 34 | connection default; 35 | SELECT SLEEP(1); 36 | SELECT object_schema, object_name, 37 | waiting_account, waiting_lock_type, waiting_query, 38 | blocking_account, blocking_lock_type, blocking_lock_duration 39 | FROM sys.schema_table_lock_waits; 40 | 41 | disconnect con1; 42 | 43 | connection default; 44 | SELECT SLEEP(1); 45 | SELECT object_schema, object_name, 46 | waiting_account, waiting_lock_type, waiting_query, 47 | blocking_account, blocking_lock_type, blocking_lock_duration 48 | FROM sys.schema_table_lock_waits; 49 | 50 | disconnect con2; 51 | connection default; 52 | 53 | DROP TABLE test.lock_waits; 54 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/fn_format_time.result: -------------------------------------------------------------------------------- 1 | SELECT sys.format_time(NULL); 2 | sys.format_time(NULL) 3 | NULL 4 | SELECT sys.format_time(1); 5 | sys.format_time(1) 6 | 1 ps 7 | SELECT sys.format_time(999); 8 | sys.format_time(999) 9 | 999 ps 10 | SELECT sys.format_time(1000); 11 | sys.format_time(1000) 12 | 1.00 ns 13 | SELECT sys.format_time(999999); 14 | sys.format_time(999999) 15 | 1000.00 ns 16 | SELECT sys.format_time(1000000); 17 | sys.format_time(1000000) 18 | 1.00 us 19 | SELECT sys.format_time(999999999); 20 | sys.format_time(999999999) 21 | 1000.00 us 22 | SELECT sys.format_time(1000000000); 23 | sys.format_time(1000000000) 24 | 1.00 ms 25 | SELECT sys.format_time(999999999999); 26 | sys.format_time(999999999999) 27 | 1000.00 ms 28 | SELECT sys.format_time(1000000000000); 29 | sys.format_time(1000000000000) 30 | 1.00 s 31 | SELECT sys.format_time(59999999999999); 32 | sys.format_time(59999999999999) 33 | 60.00 s 34 | SELECT sys.format_time(60000000000000); 35 | sys.format_time(60000000000000) 36 | 1.00 m 37 | SELECT sys.format_time(3599999999999999); 38 | sys.format_time(3599999999999999) 39 | 60.00 m 40 | SELECT sys.format_time(3600000000000000); 41 | sys.format_time(3600000000000000) 42 | 1.00 h 43 | SELECT sys.format_time(86399999999999988); 44 | sys.format_time(86399999999999988) 45 | 24.00 h 46 | SELECT sys.format_time(86400000000000000); 47 | sys.format_time(86400000000000000) 48 | 1.00 d 49 | SELECT sys.format_time(604799999999999888); 50 | sys.format_time(604799999999999888) 51 | 7.00 d 52 | SELECT sys.format_time(604800000000000000); 53 | sys.format_time(604800000000000000) 54 | 1.00 w 55 | SELECT sys.format_time(2389472398472389748237429837423984728374); 56 | sys.format_time(2389472398472389748237429837423984728374) 57 | 3950847219696411300000.00 w 58 | -------------------------------------------------------------------------------- /views/p_s/ps_check_lost_instrumentation.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | -- 17 | -- View: ps_check_lost_instrumentation 18 | -- 19 | -- Used to check whether Performance Schema is not able to monitor 20 | -- all runtime data - only returns variables that have lost instruments 21 | -- 22 | -- mysql> select * from ps_check_lost_instrumentation; 23 | -- +----------------------------------------+----------------+ 24 | -- | variable_name | variable_value | 25 | -- +----------------------------------------+----------------+ 26 | -- | Performance_schema_file_handles_lost | 101223 | 27 | -- | Performance_schema_file_instances_lost | 1231 | 28 | -- +----------------------------------------+----------------+ 29 | -- 30 | 31 | CREATE OR REPLACE 32 | ALGORITHM = MERGE 33 | DEFINER = 'root'@'localhost' 34 | SQL SECURITY INVOKER 35 | VIEW ps_check_lost_instrumentation ( 36 | variable_name, 37 | variable_value 38 | ) 39 | AS 40 | SELECT variable_name, variable_value 41 | FROM information_schema.global_status 42 | WHERE variable_name LIKE 'perf%lost' 43 | AND variable_value > 0; 44 | -------------------------------------------------------------------------------- /views/p_s/ps_check_lost_instrumentation_57.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | -- 17 | -- View: ps_check_lost_instrumentation 18 | -- 19 | -- Used to check whether Performance Schema is not able to monitor 20 | -- all runtime data - only returns variables that have lost instruments 21 | -- 22 | -- mysql> select * from ps_check_lost_instrumentation; 23 | -- +----------------------------------------+----------------+ 24 | -- | variable_name | variable_value | 25 | -- +----------------------------------------+----------------+ 26 | -- | Performance_schema_file_handles_lost | 101223 | 27 | -- | Performance_schema_file_instances_lost | 1231 | 28 | -- +----------------------------------------+----------------+ 29 | -- 30 | 31 | CREATE OR REPLACE 32 | ALGORITHM = MERGE 33 | DEFINER = 'root'@'localhost' 34 | SQL SECURITY INVOKER 35 | VIEW ps_check_lost_instrumentation ( 36 | variable_name, 37 | variable_value 38 | ) 39 | AS 40 | SELECT variable_name, variable_value 41 | FROM performance_schema.global_status 42 | WHERE variable_name LIKE 'perf%lost' 43 | AND variable_value > 0; 44 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/fn_ps_is_consumer_enabled.test: -------------------------------------------------------------------------------- 1 | -- source include/not_embedded.inc 2 | # Tests for sys schema 3 | # Verify the sys.ps_is_consumer_enabled() function perfoms as expected 4 | 5 | # Should be disabled by default 6 | UPDATE performance_schema.setup_consumers SET enabled = 'NO' WHERE name = 'events_stages_history'; 7 | SELECT sys.ps_is_consumer_enabled('events_stages_history'); 8 | 9 | # Should be enabled by default 10 | SELECT sys.ps_is_consumer_enabled('global_instrumentation'); 11 | 12 | # 13 | # Check that hierarchy is properly reflected 14 | # 15 | 16 | UPDATE performance_schema.setup_consumers SET enabled = 'NO' WHERE name = 'events_stages_current'; 17 | UPDATE performance_schema.setup_consumers SET enabled = 'YES' WHERE name = 'events_stages_history'; 18 | 19 | # Should still be disabled, as events_stages_current not enabled 20 | SELECT sys.ps_is_consumer_enabled('events_stages_history'); 21 | 22 | UPDATE performance_schema.setup_consumers SET enabled = 'YES' WHERE name = 'events_stages_current'; 23 | 24 | # Now it should be enabled 25 | SELECT sys.ps_is_consumer_enabled('events_stages_history'); 26 | 27 | # Toggling global_instrumentation should disable all other consumers 28 | UPDATE performance_schema.setup_consumers SET enabled = 'NO' WHERE name = 'global_instrumentation'; 29 | 30 | SELECT sys.ps_is_consumer_enabled('thread_instrumentation'); 31 | SELECT sys.ps_is_consumer_enabled('statements_digest'); 32 | SELECT sys.ps_is_consumer_enabled('events_stages_current'); 33 | SELECT sys.ps_is_consumer_enabled('events_stages_history'); 34 | SELECT sys.ps_is_consumer_enabled('events_stages_history_long'); 35 | SELECT sys.ps_is_consumer_enabled('events_statements_current'); 36 | SELECT sys.ps_is_consumer_enabled('events_statements_history'); 37 | SELECT sys.ps_is_consumer_enabled('events_statements_history_long'); 38 | 39 | --source ../include/ps_setup_consumers_cleanup.inc 40 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_schema_table_statistics.result: -------------------------------------------------------------------------------- 1 | DESC sys.schema_table_statistics; 2 | Field Type Null Key Default Extra 3 | table_schema varchar(64) YES NULL 4 | table_name varchar(64) YES NULL 5 | total_latency text YES NULL 6 | rows_fetched bigint(20) unsigned NO NULL 7 | fetch_latency text YES NULL 8 | rows_inserted bigint(20) unsigned NO NULL 9 | insert_latency text YES NULL 10 | rows_updated bigint(20) unsigned NO NULL 11 | update_latency text YES NULL 12 | rows_deleted bigint(20) unsigned NO NULL 13 | delete_latency text YES NULL 14 | io_read_requests decimal(42,0) YES NULL 15 | io_read text YES NULL 16 | io_read_latency text YES NULL 17 | io_write_requests decimal(42,0) YES NULL 18 | io_write text YES NULL 19 | io_write_latency text YES NULL 20 | io_misc_requests decimal(42,0) YES NULL 21 | io_misc_latency text YES NULL 22 | SELECT * FROM sys.schema_table_statistics; 23 | DESC sys.x$schema_table_statistics; 24 | Field Type Null Key Default Extra 25 | table_schema varchar(64) YES NULL 26 | table_name varchar(64) YES NULL 27 | total_latency bigint(20) unsigned NO NULL 28 | rows_fetched bigint(20) unsigned NO NULL 29 | fetch_latency bigint(20) unsigned NO NULL 30 | rows_inserted bigint(20) unsigned NO NULL 31 | insert_latency bigint(20) unsigned NO NULL 32 | rows_updated bigint(20) unsigned NO NULL 33 | update_latency bigint(20) unsigned NO NULL 34 | rows_deleted bigint(20) unsigned NO NULL 35 | delete_latency bigint(20) unsigned NO NULL 36 | io_read_requests decimal(42,0) YES NULL 37 | io_read decimal(41,0) YES NULL 38 | io_read_latency decimal(42,0) YES NULL 39 | io_write_requests decimal(42,0) YES NULL 40 | io_write decimal(41,0) YES NULL 41 | io_write_latency decimal(42,0) YES NULL 42 | io_misc_requests decimal(42,0) YES NULL 43 | io_misc_latency decimal(42,0) YES NULL 44 | SELECT * FROM sys.x$schema_table_statistics; 45 | -------------------------------------------------------------------------------- /views/p_s/host_summary_by_file_io.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | -- 17 | -- View: host_summary_by_file_io 18 | -- 19 | -- Summarizes file IO totals per host. 20 | -- 21 | -- When the host found is NULL, it is assumed to be a "background" thread. 22 | -- 23 | -- mysql> select * from host_summary_by_file_io; 24 | -- +------------+-------+------------+ 25 | -- | host | ios | io_latency | 26 | -- +------------+-------+------------+ 27 | -- | hal1 | 26457 | 21.58 s | 28 | -- | hal2 | 1189 | 394.21 ms | 29 | -- +------------+-------+------------+ 30 | -- 31 | 32 | CREATE OR REPLACE 33 | ALGORITHM = TEMPTABLE 34 | DEFINER = 'root'@'localhost' 35 | SQL SECURITY INVOKER 36 | VIEW host_summary_by_file_io ( 37 | host, 38 | ios, 39 | io_latency 40 | ) AS 41 | SELECT IF(host IS NULL, 'background', host) AS host, 42 | SUM(count_star) AS ios, 43 | sys.format_time(SUM(sum_timer_wait)) AS io_latency 44 | FROM performance_schema.events_waits_summary_by_host_by_event_name 45 | WHERE event_name LIKE 'wait/io/file/%' 46 | GROUP BY IF(host IS NULL, 'background', host) 47 | ORDER BY SUM(sum_timer_wait) DESC; 48 | -------------------------------------------------------------------------------- /views/p_s/user_summary_by_file_io.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | -- 17 | -- View: user_summary_by_file_io 18 | -- 19 | -- Summarizes file IO totals per user. 20 | -- 21 | -- When the user found is NULL, it is assumed to be a "background" thread. 22 | -- 23 | -- mysql> select * from user_summary_by_file_io; 24 | -- +------------+-------+------------+ 25 | -- | user | ios | io_latency | 26 | -- +------------+-------+------------+ 27 | -- | root | 26457 | 21.58 s | 28 | -- | background | 1189 | 394.21 ms | 29 | -- +------------+-------+------------+ 30 | -- 31 | 32 | CREATE OR REPLACE 33 | ALGORITHM = TEMPTABLE 34 | DEFINER = 'root'@'localhost' 35 | SQL SECURITY INVOKER 36 | VIEW user_summary_by_file_io ( 37 | user, 38 | ios, 39 | io_latency 40 | ) AS 41 | SELECT IF(user IS NULL, 'background', user) AS user, 42 | SUM(count_star) AS ios, 43 | sys.format_time(SUM(sum_timer_wait)) AS io_latency 44 | FROM performance_schema.events_waits_summary_by_user_by_event_name 45 | WHERE event_name LIKE 'wait/io/file/%' 46 | GROUP BY IF(user IS NULL, 'background', user) 47 | ORDER BY SUM(sum_timer_wait) DESC; 48 | -------------------------------------------------------------------------------- /views/p_s/x_host_summary_by_file_io.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | -- 17 | -- View: x$host_summary_by_file_io 18 | -- 19 | -- Summarizes file IO totals per host. 20 | -- 21 | -- When the host found is NULL, it is assumed to be a "background" thread. 22 | -- 23 | -- mysql> select * from x$host_summary_by_file_io; 24 | -- +------------+-------+----------------+ 25 | -- | host | ios | io_latency | 26 | -- +------------+-------+----------------+ 27 | -- | hal1 | 26457 | 21579585586390 | 28 | -- | hal2 | 1189 | 394212617370 | 29 | -- +------------+-------+----------------+ 30 | -- 31 | 32 | CREATE OR REPLACE 33 | ALGORITHM = TEMPTABLE 34 | DEFINER = 'root'@'localhost' 35 | SQL SECURITY INVOKER 36 | VIEW x$host_summary_by_file_io ( 37 | host, 38 | ios, 39 | io_latency 40 | ) AS 41 | SELECT IF(host IS NULL, 'background', host) AS host, 42 | SUM(count_star) AS ios, 43 | SUM(sum_timer_wait) AS io_latency 44 | FROM performance_schema.events_waits_summary_by_host_by_event_name 45 | WHERE event_name LIKE 'wait/io/file/%' 46 | GROUP BY IF(host IS NULL, 'background', host) 47 | ORDER BY SUM(sum_timer_wait) DESC; 48 | -------------------------------------------------------------------------------- /views/p_s/x_user_summary_by_file_io.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | -- 17 | -- View: x$user_summary_by_file_io 18 | -- 19 | -- Summarizes file IO totals per user. 20 | -- 21 | -- When the user found is NULL, it is assumed to be a "background" thread. 22 | -- 23 | -- mysql> select * from x$user_summary_by_file_io; 24 | -- +------------+-------+----------------+ 25 | -- | user | ios | io_latency | 26 | -- +------------+-------+----------------+ 27 | -- | root | 26457 | 21579585586390 | 28 | -- | background | 1189 | 394212617370 | 29 | -- +------------+-------+----------------+ 30 | -- 31 | 32 | CREATE OR REPLACE 33 | ALGORITHM = TEMPTABLE 34 | DEFINER = 'root'@'localhost' 35 | SQL SECURITY INVOKER 36 | VIEW x$user_summary_by_file_io ( 37 | user, 38 | ios, 39 | io_latency 40 | ) AS 41 | SELECT IF(user IS NULL, 'background', user) AS user, 42 | SUM(count_star) AS ios, 43 | SUM(sum_timer_wait) AS io_latency 44 | FROM performance_schema.events_waits_summary_by_user_by_event_name 45 | WHERE event_name LIKE 'wait/io/file/%' 46 | GROUP BY IF(user IS NULL, 'background', user) 47 | ORDER BY SUM(sum_timer_wait) DESC; 48 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/t/pr_diagnostics.test: -------------------------------------------------------------------------------- 1 | ########### suite/sysschema/t/pr_diagnostics.test ############# 2 | # # 3 | # Testing of of the sys.diagnostics()) procedure # 4 | # # 5 | # Creation: # 6 | # 2015-07-28 jkrogh Implement this test as part of # 7 | # WL#7804 REPORT FOR SUPPORT # 8 | # # 9 | ############################################################### 10 | 11 | -- source include/not_embedded.inc 12 | 13 | # Sanity check that the procedure completes two iterations with full debug, 14 | # raw output, and Information Schema table outputs without generating 15 | # any warnings. 16 | 17 | --disable_result_log 18 | SET @sys.debug = 'ON', 19 | @sys.diagnostics.allow_i_s_tables = 'ON', 20 | @sys.diagnostics.include_raw = 'ON'; 21 | 22 | # First use @@global.show_compatibility_56 = ON 23 | SET @tmp_show_compatibility_56 = @@global.show_compatibility_56, 24 | GLOBAL show_compatibility_56 = ON; 25 | CALL sys.diagnostics(4, 2, 'full'); 26 | 27 | # Then use @@global.show_compatibility_56 = OFF 28 | SET GLOBAL show_compatibility_56 = OFF; 29 | CALL sys.diagnostics(4, 2, 'full'); 30 | 31 | SET GLOBAL show_compatibility_56 = @tmp_show_compatibility_56, 32 | @tmp_show_compatibility_56 = NULL; 33 | 34 | SET @sys.debug = 'OFF', 35 | @sys.diagnostics.allow_i_s_tables = 'OFF', 36 | @sys.diagnostics.include_raw = 'OFF'; 37 | --enable_result_log 38 | 39 | # Check input variable validation 40 | -- error S45000 41 | CALL sys.diagnostics(0, 0, 'full'); 42 | -- error S45000 43 | CALL sys.diagnostics(2, 0, 'full'); 44 | -- error S45000 45 | CALL sys.diagnostics(1, 2, 'full'); 46 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/t_sys_config.result: -------------------------------------------------------------------------------- 1 | DESC sys.sys_config; 2 | Field Type Null Key Default Extra 3 | variable varchar(128) NO PRI NULL 4 | value varchar(128) YES NULL 5 | set_time timestamp NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP 6 | set_by varchar(128) YES NULL 7 | SELECT variable, value, set_by FROM sys.sys_config; 8 | variable value set_by 9 | diagnostics.allow_i_s_tables OFF NULL 10 | diagnostics.include_raw OFF NULL 11 | ps_thread_trx_info.max_length 65535 NULL 12 | statement_performance_analyzer.limit 100 NULL 13 | statement_performance_analyzer.view NULL NULL 14 | statement_truncate_len 64 NULL 15 | UPDATE sys.sys_config SET value = 128 WHERE variable = 'statement_truncate_len'; 16 | SELECT variable, value, set_by FROM sys.sys_config; 17 | variable value set_by 18 | diagnostics.allow_i_s_tables OFF NULL 19 | diagnostics.include_raw OFF NULL 20 | ps_thread_trx_info.max_length 65535 NULL 21 | statement_performance_analyzer.limit 100 NULL 22 | statement_performance_analyzer.view NULL NULL 23 | statement_truncate_len 128 NULL 24 | INSERT INTO sys.sys_config (variable, value) VALUES ('foo', 'bar'); 25 | SELECT variable, value, set_by FROM sys.sys_config; 26 | variable value set_by 27 | diagnostics.allow_i_s_tables OFF NULL 28 | diagnostics.include_raw OFF NULL 29 | foo bar NULL 30 | ps_thread_trx_info.max_length 65535 NULL 31 | statement_performance_analyzer.limit 100 NULL 32 | statement_performance_analyzer.view NULL NULL 33 | statement_truncate_len 128 NULL 34 | SET @sys.ignore_sys_config_triggers := true; 35 | DELETE FROM sys.sys_config; 36 | INSERT IGNORE INTO sys.sys_config (variable, value) VALUES 37 | ('statement_truncate_len', 64), 38 | ('statement_performance_analyzer.limit', 100), 39 | ('statement_performance_analyzer.view', NULL), 40 | ('diagnostics.allow_i_s_tables', 'OFF'), 41 | ('diagnostics.include_raw', 'OFF'), 42 | ('ps_thread_trx_info.max_length', 65535); 43 | SET @sys.ignore_sys_config_triggers := NULL; 44 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/pr_create_synonym_db.result: -------------------------------------------------------------------------------- 1 | CREATE TABLE t1 (t1_id int PRIMARY KEY, t1_val varchar(10)); 2 | CREATE TABLE t2 (t2_id int PRIMARY KEY, t1_id int, t2_val int, INDEX (t1_id)); 3 | CREATE TABLE `is` (t1_id int PRIMARY KEY, t1_val varchar(10)); 4 | CREATE TABLE `ab``c` (t1_id int PRIMARY KEY, t1_val varchar(10)); 5 | CREATE SQL SECURITY INVOKER VIEW myview AS SELECT * FROM t1 NATURAL JOIN t2; 6 | CALL sys.create_synonym_db('test', 'test1'); 7 | summary 8 | Created 5 views in the `test1` database 9 | SELECT TABLE_NAME, SECURITY_TYPE FROM information_schema.VIEWS WHERE TABLE_SCHEMA = 'test1' ORDER BY TABLE_NAME; 10 | TABLE_NAME SECURITY_TYPE 11 | ab`c INVOKER 12 | is INVOKER 13 | myview INVOKER 14 | t1 INVOKER 15 | t2 INVOKER 16 | CALL sys.create_synonym_db('test', 'test1'); 17 | ERROR HY000: Can't create database test1; database exists 18 | CREATE SCHEMA test2; 19 | CALL sys.create_synonym_db('test', 'test2'); 20 | ERROR HY000: Can't create database test2; database exists 21 | SELECT COUNT(*) FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'test2'; 22 | COUNT(*) 23 | 0 24 | CALL sys.create_synonym_db('test', 'is'); 25 | summary 26 | Created 5 views in the `is` database 27 | SELECT TABLE_NAME, SECURITY_TYPE FROM information_schema.VIEWS WHERE TABLE_SCHEMA = 'is' ORDER BY TABLE_NAME; 28 | TABLE_NAME SECURITY_TYPE 29 | ab`c INVOKER 30 | is INVOKER 31 | myview INVOKER 32 | t1 INVOKER 33 | t2 INVOKER 34 | CALL sys.create_synonym_db('is', 'i`s'); 35 | summary 36 | Created 5 views in the `i``s` database 37 | SELECT TABLE_NAME, SECURITY_TYPE FROM information_schema.VIEWS WHERE TABLE_SCHEMA = 'i`s' ORDER BY TABLE_NAME; 38 | TABLE_NAME SECURITY_TYPE 39 | ab`c INVOKER 40 | is INVOKER 41 | myview INVOKER 42 | t1 INVOKER 43 | t2 INVOKER 44 | DROP SCHEMA test1; 45 | DROP SCHEMA test2; 46 | DROP SCHEMA `is`; 47 | DROP SCHEMA `i``s`; 48 | DROP VIEW test.myview; 49 | DROP TABLE test.t1; 50 | DROP TABLE test.t2; 51 | DROP TABLE `is`; 52 | DROP TABLE `ab``c`; 53 | -------------------------------------------------------------------------------- /views/i_s/x_schema_flattened_keys.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- View: x$schema_flattened_keys 3 | -- 4 | -- Helper view for the schema_redundant_keys view. 5 | -- 6 | -- mysql> select * from sys.x$schema_flattened_keys; 7 | -- +---------------+---------------------+------------------------------+------------+----------------+-----------------+ 8 | -- | table_schema | table_name | index_name | non_unique | subpart_exists | index_columns | 9 | -- +---------------+---------------------+------------------------------+------------+----------------+-----------------+ 10 | -- | mem__advisors | advisor_initialized | PRIMARY | 0 | 0 | advisorClassId | 11 | -- | mem__advisors | advisor_schedules | advisorClassIdIdx | 1 | 0 | advisorClassId | 12 | -- | mem__advisors | advisor_schedules | PRIMARY | 0 | 0 | schedule_id | 13 | -- | mem__advisors | app_identity_path | FK_7xbq2i81hgo0xlvnb6rr77s21 | 1 | 0 | for_schedule_id | 14 | -- | mem__advisors | app_identity_path | PRIMARY | 0 | 0 | hib_id | 15 | -- ... 16 | -- 17 | 18 | CREATE OR REPLACE 19 | ALGORITHM = TEMPTABLE 20 | DEFINER = 'root'@'localhost' 21 | SQL SECURITY INVOKER 22 | VIEW x$schema_flattened_keys ( 23 | table_schema, 24 | table_name, 25 | index_name, 26 | non_unique, 27 | subpart_exists, 28 | index_columns 29 | ) AS 30 | SELECT 31 | TABLE_SCHEMA, 32 | TABLE_NAME, 33 | INDEX_NAME, 34 | MAX(NON_UNIQUE) AS non_unique, 35 | MAX(IF(SUB_PART IS NULL, 0, 1)) AS subpart_exists, 36 | GROUP_CONCAT(COLUMN_NAME ORDER BY SEQ_IN_INDEX) AS index_columns 37 | FROM INFORMATION_SCHEMA.STATISTICS 38 | WHERE 39 | INDEX_TYPE='BTREE' 40 | AND TABLE_SCHEMA NOT IN ('mysql', 'sys', 'INFORMATION_SCHEMA', 'PERFORMANCE_SCHEMA') 41 | GROUP BY 42 | TABLE_SCHEMA, TABLE_NAME, INDEX_NAME; 43 | -------------------------------------------------------------------------------- /views/p_s/x_ps_digest_95th_percentile_by_avg_us.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | -- 17 | -- View: x$ps_digest_95th_percentile_by_avg_us 18 | -- 19 | -- Helper view for statements_with_runtimes_in_95th_percentile. 20 | -- Lists the 95th percentile runtime, for all statements 21 | -- 22 | -- mysql> select * from x$ps_digest_95th_percentile_by_avg_us; 23 | -- +--------+------------+ 24 | -- | avg_us | percentile | 25 | -- +--------+------------+ 26 | -- | 964 | 0.9525 | 27 | -- +--------+------------+ 28 | -- 29 | 30 | CREATE OR REPLACE 31 | ALGORITHM = TEMPTABLE 32 | DEFINER = 'root'@'localhost' 33 | SQL SECURITY INVOKER 34 | VIEW x$ps_digest_95th_percentile_by_avg_us ( 35 | avg_us, 36 | percentile 37 | ) AS 38 | SELECT s2.avg_us avg_us, 39 | IFNULL(SUM(s1.cnt)/NULLIF((SELECT COUNT(*) FROM performance_schema.events_statements_summary_by_digest), 0), 0) percentile 40 | FROM sys.x$ps_digest_avg_latency_distribution AS s1 41 | JOIN sys.x$ps_digest_avg_latency_distribution AS s2 42 | ON s1.avg_us <= s2.avg_us 43 | GROUP BY s2.avg_us 44 | HAVING IFNULL(SUM(s1.cnt)/NULLIF((SELECT COUNT(*) FROM performance_schema.events_statements_summary_by_digest), 0), 0) > 0.95 45 | ORDER BY percentile 46 | LIMIT 1; 47 | -------------------------------------------------------------------------------- /functions/version_major.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | DROP FUNCTION IF EXISTS version_major; 17 | 18 | DELIMITER $$ 19 | 20 | CREATE DEFINER='root'@'localhost' FUNCTION version_major () 21 | RETURNS TINYINT UNSIGNED 22 | COMMENT ' 23 | Description 24 | ----------- 25 | 26 | Returns the major version of MySQL Server. 27 | 28 | Returns 29 | ----------- 30 | 31 | TINYINT UNSIGNED 32 | 33 | Example 34 | ----------- 35 | 36 | mysql> SELECT VERSION(), sys.version_major(); 37 | +--------------------------------------+---------------------+ 38 | | VERSION() | sys.version_major() | 39 | +--------------------------------------+---------------------+ 40 | | 5.7.9-enterprise-commercial-advanced | 5 | 41 | +--------------------------------------+---------------------+ 42 | 1 row in set (0.00 sec) 43 | ' 44 | SQL SECURITY INVOKER 45 | NOT DETERMINISTIC 46 | NO SQL 47 | BEGIN 48 | RETURN SUBSTRING_INDEX(SUBSTRING_INDEX(VERSION(), '-', 1), '.', 1); 49 | END$$ 50 | 51 | DELIMITER ; 52 | -------------------------------------------------------------------------------- /functions/version_patch.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | DROP FUNCTION IF EXISTS version_patch; 17 | 18 | DELIMITER $$ 19 | 20 | CREATE DEFINER='root'@'localhost' FUNCTION version_patch () 21 | RETURNS TINYINT UNSIGNED 22 | COMMENT ' 23 | Description 24 | ----------- 25 | 26 | Returns the patch release version of MySQL Server. 27 | 28 | Returns 29 | ----------- 30 | 31 | TINYINT UNSIGNED 32 | 33 | Example 34 | ----------- 35 | 36 | mysql> SELECT VERSION(), sys.version_patch(); 37 | +--------------------------------------+---------------------+ 38 | | VERSION() | sys.version_patch() | 39 | +--------------------------------------+---------------------+ 40 | | 5.7.9-enterprise-commercial-advanced | 9 | 41 | +--------------------------------------+---------------------+ 42 | 1 row in set (0.00 sec) 43 | ' 44 | SQL SECURITY INVOKER 45 | NOT DETERMINISTIC 46 | NO SQL 47 | BEGIN 48 | RETURN SUBSTRING_INDEX(SUBSTRING_INDEX(VERSION(), '-', 1), '.', -1); 49 | END$$ 50 | 51 | DELIMITER ; 52 | -------------------------------------------------------------------------------- /functions/version_minor.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | DROP FUNCTION IF EXISTS version_minor; 17 | 18 | DELIMITER $$ 19 | 20 | CREATE DEFINER='root'@'localhost' FUNCTION version_minor () 21 | RETURNS TINYINT UNSIGNED 22 | COMMENT ' 23 | Description 24 | ----------- 25 | 26 | Returns the minor (release series) version of MySQL Server. 27 | 28 | Returns 29 | ----------- 30 | 31 | TINYINT UNSIGNED 32 | 33 | Example 34 | ----------- 35 | 36 | mysql> SELECT VERSION(), sys.server_minor(); 37 | +--------------------------------------+---------------------+ 38 | | VERSION() | sys.version_minor() | 39 | +--------------------------------------+---------------------+ 40 | | 5.7.9-enterprise-commercial-advanced | 7 | 41 | +--------------------------------------+---------------------+ 42 | 1 row in set (0.00 sec) 43 | ' 44 | SQL SECURITY INVOKER 45 | NOT DETERMINISTIC 46 | NO SQL 47 | BEGIN 48 | RETURN SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING_INDEX(VERSION(), '-', 1), '.', 2), '.', -1); 49 | END$$ 50 | 51 | DELIMITER ; 52 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/pr_ps_setup_show_disabled_instruments.result: -------------------------------------------------------------------------------- 1 | UPDATE performance_schema.setup_instruments 2 | SET ENABLED = 'NO' 3 | WHERE NAME LIKE 'stage/innodb/%' 4 | OR NAME LIKE 'statement/com/%' 5 | OR NAME = 'idle'; 6 | CALL sys.ps_setup_show_disabled_instruments(); 7 | disabled_instruments timed 8 | idle YES 9 | stage/innodb/alter table (end) YES 10 | stage/innodb/alter table (flush) YES 11 | stage/innodb/alter table (insert) YES 12 | stage/innodb/alter table (log apply index) YES 13 | stage/innodb/alter table (log apply table) YES 14 | stage/innodb/alter table (merge sort) YES 15 | stage/innodb/alter table (read PK and internal sort) YES 16 | stage/innodb/buffer pool load YES 17 | statement/com/Binlog Dump YES 18 | statement/com/Binlog Dump GTID YES 19 | statement/com/Change user YES 20 | statement/com/Close stmt YES 21 | statement/com/Connect YES 22 | statement/com/Connect Out YES 23 | statement/com/Create DB YES 24 | statement/com/Daemon YES 25 | statement/com/Debug YES 26 | statement/com/Delayed insert YES 27 | statement/com/Drop DB YES 28 | statement/com/Error YES 29 | statement/com/Execute YES 30 | statement/com/Fetch YES 31 | statement/com/Field List YES 32 | statement/com/Init DB YES 33 | statement/com/Kill YES 34 | statement/com/Long Data YES 35 | statement/com/Ping YES 36 | statement/com/Prepare YES 37 | statement/com/Processlist YES 38 | statement/com/Quit YES 39 | statement/com/Refresh YES 40 | statement/com/Register Slave YES 41 | statement/com/Reset Connection YES 42 | statement/com/Reset stmt YES 43 | statement/com/Set option YES 44 | statement/com/Shutdown YES 45 | statement/com/Sleep YES 46 | statement/com/Statistics YES 47 | statement/com/Table Dump YES 48 | statement/com/Time YES 49 | UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES'; 50 | TRUNCATE TABLE performance_schema.setup_actors; 51 | INSERT INTO performance_schema.setup_actors VALUES ('%', '%', '%', 'YES', 'YES'); 52 | UPDATE performance_schema.setup_consumers SET enabled = 'YES'; 53 | UPDATE performance_schema.threads SET instrumented = 'YES'; 54 | -------------------------------------------------------------------------------- /procedures/ps_setup_enable_background_threads.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | DROP PROCEDURE IF EXISTS ps_setup_enable_background_threads; 17 | 18 | DELIMITER $$ 19 | 20 | CREATE DEFINER='root'@'localhost' PROCEDURE ps_setup_enable_background_threads () 21 | COMMENT ' 22 | Description 23 | ----------- 24 | 25 | Enable all background thread instrumentation within Performance Schema. 26 | 27 | Parameters 28 | ----------- 29 | 30 | None. 31 | 32 | Example 33 | ----------- 34 | 35 | mysql> CALL sys.ps_setup_enable_background_threads(); 36 | +-------------------------------+ 37 | | summary | 38 | +-------------------------------+ 39 | | Enabled 18 background threads | 40 | +-------------------------------+ 41 | 1 row in set (0.00 sec) 42 | ' 43 | SQL SECURITY INVOKER 44 | NOT DETERMINISTIC 45 | MODIFIES SQL DATA 46 | BEGIN 47 | UPDATE performance_schema.threads 48 | SET instrumented = 'YES' 49 | WHERE type = 'BACKGROUND'; 50 | 51 | SELECT CONCAT('Enabled ', @rows := ROW_COUNT(), ' background thread', IF(@rows != 1, 's', '')) AS summary; 52 | END$$ 53 | 54 | DELIMITER ; 55 | -------------------------------------------------------------------------------- /procedures/ps_setup_show_enabled_consumers.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | DROP PROCEDURE IF EXISTS ps_setup_show_enabled_consumers; 17 | 18 | DELIMITER $$ 19 | 20 | CREATE DEFINER='root'@'localhost' PROCEDURE ps_setup_show_enabled_consumers () 21 | COMMENT ' 22 | Description 23 | ----------- 24 | 25 | Shows all currently enabled consumers. 26 | 27 | Parameters 28 | ----------- 29 | 30 | None 31 | 32 | Example 33 | ----------- 34 | 35 | mysql> CALL sys.ps_setup_show_enabled_consumers(); 36 | 37 | +---------------------------+ 38 | | enabled_consumers | 39 | +---------------------------+ 40 | | events_statements_current | 41 | | global_instrumentation | 42 | | thread_instrumentation | 43 | | statements_digest | 44 | +---------------------------+ 45 | 4 rows in set (0.05 sec) 46 | ' 47 | SQL SECURITY INVOKER 48 | DETERMINISTIC 49 | READS SQL DATA 50 | BEGIN 51 | SELECT name AS enabled_consumers 52 | FROM performance_schema.setup_consumers 53 | WHERE enabled = 'YES' 54 | ORDER BY enabled_consumers; 55 | END$$ 56 | 57 | DELIMITER ; 58 | -------------------------------------------------------------------------------- /procedures/ps_setup_show_disabled_consumers.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | DROP PROCEDURE IF EXISTS ps_setup_show_disabled_consumers; 17 | 18 | DELIMITER $$ 19 | 20 | CREATE DEFINER='root'@'localhost' PROCEDURE ps_setup_show_disabled_consumers () 21 | COMMENT ' 22 | Description 23 | ----------- 24 | 25 | Shows all currently disabled consumers. 26 | 27 | Parameters 28 | ----------- 29 | 30 | None 31 | 32 | Example 33 | ----------- 34 | 35 | mysql> CALL sys.ps_setup_show_disabled_consumers(); 36 | 37 | +---------------------------+ 38 | | disabled_consumers | 39 | +---------------------------+ 40 | | events_statements_current | 41 | | global_instrumentation | 42 | | thread_instrumentation | 43 | | statements_digest | 44 | +---------------------------+ 45 | 4 rows in set (0.05 sec) 46 | ' 47 | SQL SECURITY INVOKER 48 | DETERMINISTIC 49 | READS SQL DATA 50 | BEGIN 51 | SELECT name AS disabled_consumers 52 | FROM performance_schema.setup_consumers 53 | WHERE enabled = 'NO' 54 | ORDER BY disabled_consumers; 55 | END$$ 56 | 57 | DELIMITER ; 58 | -------------------------------------------------------------------------------- /procedures/ps_setup_disable_background_threads.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | DROP PROCEDURE IF EXISTS ps_setup_disable_background_threads; 17 | 18 | DELIMITER $$ 19 | 20 | CREATE DEFINER='root'@'localhost' PROCEDURE ps_setup_disable_background_threads () 21 | COMMENT ' 22 | Description 23 | ----------- 24 | 25 | Disable all background thread instrumentation within Performance Schema. 26 | 27 | Parameters 28 | ----------- 29 | 30 | None. 31 | 32 | Example 33 | ----------- 34 | 35 | mysql> CALL sys.ps_setup_disable_background_threads(); 36 | +--------------------------------+ 37 | | summary | 38 | +--------------------------------+ 39 | | Disabled 18 background threads | 40 | +--------------------------------+ 41 | 1 row in set (0.00 sec) 42 | ' 43 | SQL SECURITY INVOKER 44 | NOT DETERMINISTIC 45 | MODIFIES SQL DATA 46 | BEGIN 47 | UPDATE performance_schema.threads 48 | SET instrumented = 'NO' 49 | WHERE type = 'BACKGROUND'; 50 | 51 | SELECT CONCAT('Disabled ', @rows := ROW_COUNT(), ' background thread', IF(@rows != 1, 's', '')) AS summary; 52 | END$$ 53 | 54 | DELIMITER ; 55 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/fn_ps_is_consumer_enabled.result: -------------------------------------------------------------------------------- 1 | UPDATE performance_schema.setup_consumers SET enabled = 'NO' WHERE name = 'events_stages_history'; 2 | SELECT sys.ps_is_consumer_enabled('events_stages_history'); 3 | sys.ps_is_consumer_enabled('events_stages_history') 4 | NO 5 | SELECT sys.ps_is_consumer_enabled('global_instrumentation'); 6 | sys.ps_is_consumer_enabled('global_instrumentation') 7 | YES 8 | UPDATE performance_schema.setup_consumers SET enabled = 'NO' WHERE name = 'events_stages_current'; 9 | UPDATE performance_schema.setup_consumers SET enabled = 'YES' WHERE name = 'events_stages_history'; 10 | SELECT sys.ps_is_consumer_enabled('events_stages_history'); 11 | sys.ps_is_consumer_enabled('events_stages_history') 12 | NO 13 | UPDATE performance_schema.setup_consumers SET enabled = 'YES' WHERE name = 'events_stages_current'; 14 | SELECT sys.ps_is_consumer_enabled('events_stages_history'); 15 | sys.ps_is_consumer_enabled('events_stages_history') 16 | YES 17 | UPDATE performance_schema.setup_consumers SET enabled = 'NO' WHERE name = 'global_instrumentation'; 18 | SELECT sys.ps_is_consumer_enabled('thread_instrumentation'); 19 | sys.ps_is_consumer_enabled('thread_instrumentation') 20 | NO 21 | SELECT sys.ps_is_consumer_enabled('statements_digest'); 22 | sys.ps_is_consumer_enabled('statements_digest') 23 | NO 24 | SELECT sys.ps_is_consumer_enabled('events_stages_current'); 25 | sys.ps_is_consumer_enabled('events_stages_current') 26 | NO 27 | SELECT sys.ps_is_consumer_enabled('events_stages_history'); 28 | sys.ps_is_consumer_enabled('events_stages_history') 29 | NO 30 | SELECT sys.ps_is_consumer_enabled('events_stages_history_long'); 31 | sys.ps_is_consumer_enabled('events_stages_history_long') 32 | NO 33 | SELECT sys.ps_is_consumer_enabled('events_statements_current'); 34 | sys.ps_is_consumer_enabled('events_statements_current') 35 | NO 36 | SELECT sys.ps_is_consumer_enabled('events_statements_history'); 37 | sys.ps_is_consumer_enabled('events_statements_history') 38 | NO 39 | SELECT sys.ps_is_consumer_enabled('events_statements_history_long'); 40 | sys.ps_is_consumer_enabled('events_statements_history_long') 41 | NO 42 | UPDATE performance_schema.setup_consumers SET enabled = 'YES'; 43 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_statement_analysis.result: -------------------------------------------------------------------------------- 1 | DESC sys.statement_analysis; 2 | Field Type Null Key Default Extra 3 | query longtext YES NULL 4 | db varchar(64) YES NULL 5 | full_scan varchar(1) NO 6 | exec_count bigint(20) unsigned NO NULL 7 | err_count bigint(20) unsigned NO NULL 8 | warn_count bigint(20) unsigned NO NULL 9 | total_latency text YES NULL 10 | max_latency text YES NULL 11 | avg_latency text YES NULL 12 | lock_latency text YES NULL 13 | rows_sent bigint(20) unsigned NO NULL 14 | rows_sent_avg decimal(21,0) NO 0 15 | rows_examined bigint(20) unsigned NO NULL 16 | rows_examined_avg decimal(21,0) NO 0 17 | rows_affected bigint(20) unsigned NO NULL 18 | rows_affected_avg decimal(21,0) NO 0 19 | tmp_tables bigint(20) unsigned NO NULL 20 | tmp_disk_tables bigint(20) unsigned NO NULL 21 | rows_sorted bigint(20) unsigned NO NULL 22 | sort_merge_passes bigint(20) unsigned NO NULL 23 | digest varchar(32) YES NULL 24 | first_seen timestamp NO 0000-00-00 00:00:00 25 | last_seen timestamp NO 0000-00-00 00:00:00 26 | SELECT * FROM sys.statement_analysis; 27 | DESC sys.x$statement_analysis; 28 | Field Type Null Key Default Extra 29 | query longtext YES NULL 30 | db varchar(64) YES NULL 31 | full_scan varchar(1) NO 32 | exec_count bigint(20) unsigned NO NULL 33 | err_count bigint(20) unsigned NO NULL 34 | warn_count bigint(20) unsigned NO NULL 35 | total_latency bigint(20) unsigned NO NULL 36 | max_latency bigint(20) unsigned NO NULL 37 | avg_latency bigint(20) unsigned NO NULL 38 | lock_latency bigint(20) unsigned NO NULL 39 | rows_sent bigint(20) unsigned NO NULL 40 | rows_sent_avg decimal(21,0) NO 0 41 | rows_examined bigint(20) unsigned NO NULL 42 | rows_examined_avg decimal(21,0) NO 0 43 | rows_affected bigint(20) unsigned NO NULL 44 | rows_affected_avg decimal(21,0) NO 0 45 | tmp_tables bigint(20) unsigned NO NULL 46 | tmp_disk_tables bigint(20) unsigned NO NULL 47 | rows_sorted bigint(20) unsigned NO NULL 48 | sort_merge_passes bigint(20) unsigned NO NULL 49 | digest varchar(32) YES NULL 50 | first_seen timestamp NO 0000-00-00 00:00:00 51 | last_seen timestamp NO 0000-00-00 00:00:00 52 | SELECT * FROM sys.x$statement_analysis; 53 | -------------------------------------------------------------------------------- /mysql-test/suite/sysschema/r/v_ps_schema_table_statistics_io.result: -------------------------------------------------------------------------------- 1 | DESC sys.x$ps_schema_table_statistics_io; 2 | Field Type Null Key Default Extra 3 | table_schema varchar(64) YES NULL 4 | table_name varchar(64) YES NULL 5 | count_read decimal(42,0) YES NULL 6 | sum_number_of_bytes_read decimal(41,0) YES NULL 7 | sum_timer_read decimal(42,0) YES NULL 8 | count_write decimal(42,0) YES NULL 9 | sum_number_of_bytes_write decimal(41,0) YES NULL 10 | sum_timer_write decimal(42,0) YES NULL 11 | count_misc decimal(42,0) YES NULL 12 | sum_timer_misc decimal(42,0) YES NULL 13 | DESC sys.x$ps_schema_table_statistics_io; 14 | Field Type Null Key Default Extra 15 | table_schema varchar(64) YES NULL 16 | table_name varchar(64) YES NULL 17 | count_read decimal(42,0) YES NULL 18 | sum_number_of_bytes_read decimal(41,0) YES NULL 19 | sum_timer_read decimal(42,0) YES NULL 20 | count_write decimal(42,0) YES NULL 21 | sum_number_of_bytes_write decimal(41,0) YES NULL 22 | sum_timer_write decimal(42,0) YES NULL 23 | count_misc decimal(42,0) YES NULL 24 | sum_timer_misc decimal(42,0) YES NULL 25 | DESC sys.x$ps_schema_table_statistics_io; 26 | Field Type Null Key Default Extra 27 | table_schema varchar(64) YES NULL 28 | table_name varchar(64) YES NULL 29 | count_read decimal(42,0) YES NULL 30 | sum_number_of_bytes_read decimal(41,0) YES NULL 31 | sum_timer_read decimal(42,0) YES NULL 32 | count_write decimal(42,0) YES NULL 33 | sum_number_of_bytes_write decimal(41,0) YES NULL 34 | sum_timer_write decimal(42,0) YES NULL 35 | count_misc decimal(42,0) YES NULL 36 | sum_timer_misc decimal(42,0) YES NULL 37 | SELECT * FROM sys.x$ps_schema_table_statistics_io; 38 | DESC sys.x$ps_schema_table_statistics_io; 39 | Field Type Null Key Default Extra 40 | table_schema varchar(64) YES NULL 41 | table_name varchar(64) YES NULL 42 | count_read decimal(42,0) YES NULL 43 | sum_number_of_bytes_read decimal(41,0) YES NULL 44 | sum_timer_read decimal(42,0) YES NULL 45 | count_write decimal(42,0) YES NULL 46 | sum_number_of_bytes_write decimal(41,0) YES NULL 47 | sum_timer_write decimal(42,0) YES NULL 48 | count_misc decimal(42,0) YES NULL 49 | sum_timer_misc decimal(42,0) YES NULL 50 | SELECT * FROM sys.x$ps_schema_table_statistics_io; 51 | -------------------------------------------------------------------------------- /views/p_s/statements_with_errors_or_warnings.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | -- 17 | -- View: statements_with_errors_or_warnings 18 | -- 19 | -- Lists all normalized statements that have raised errors or warnings. 20 | -- 21 | -- mysql> select * from statements_with_errors_or_warnings LIMIT 1\G 22 | -- *************************** 1. row *************************** 23 | -- query: CREATE OR REPLACE ALGORITHM = ... _delete` AS `rows_deleted` ... 24 | -- db: sys 25 | -- exec_count: 2 26 | -- errors: 1 27 | -- error_pct: 50.0000 28 | -- warnings: 0 29 | -- warning_pct: 0.0000 30 | -- first_seen: 2014-03-07 12:56:54 31 | -- last_seen: 2014-03-07 13:01:01 32 | -- digest: 943a788859e623d5f7798ba0ae0fd8a9 33 | -- 34 | 35 | CREATE OR REPLACE 36 | ALGORITHM = MERGE 37 | DEFINER = 'root'@'localhost' 38 | SQL SECURITY INVOKER 39 | VIEW statements_with_errors_or_warnings ( 40 | query, 41 | db, 42 | exec_count, 43 | errors, 44 | error_pct, 45 | warnings, 46 | warning_pct, 47 | first_seen, 48 | last_seen, 49 | digest 50 | ) AS 51 | SELECT sys.format_statement(DIGEST_TEXT) AS query, 52 | SCHEMA_NAME as db, 53 | COUNT_STAR AS exec_count, 54 | SUM_ERRORS AS errors, 55 | IFNULL(SUM_ERRORS / NULLIF(COUNT_STAR, 0), 0) * 100 as error_pct, 56 | SUM_WARNINGS AS warnings, 57 | IFNULL(SUM_WARNINGS / NULLIF(COUNT_STAR, 0), 0) * 100 as warning_pct, 58 | FIRST_SEEN as first_seen, 59 | LAST_SEEN as last_seen, 60 | DIGEST AS digest 61 | FROM performance_schema.events_statements_summary_by_digest 62 | WHERE SUM_ERRORS > 0 63 | OR SUM_WARNINGS > 0 64 | ORDER BY SUM_ERRORS DESC, SUM_WARNINGS DESC; 65 | -------------------------------------------------------------------------------- /views/p_s/x_statements_with_errors_or_warnings.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | -- 17 | -- View: x$statements_with_errors_or_warnings 18 | -- 19 | -- Lists all normalized statements that have raised errors or warnings. 20 | -- 21 | -- mysql> select * from x$statements_with_errors_or_warnings LIMIT 1\G 22 | -- *************************** 1. row *************************** 23 | -- query: CREATE OR REPLACE ALGORITHM = TEMPTABLE DEFINER = ? @ ? SQL SECURITY INVOKER VIEW ... truncated 24 | -- db: sys 25 | -- exec_count: 2 26 | -- errors: 1 27 | -- error_pct: 50.0000 28 | -- warnings: 0 29 | -- warning_pct: 0.0000 30 | -- first_seen: 2014-03-07 12:56:54 31 | -- last_seen: 2014-03-07 13:01:01 32 | -- digest: 943a788859e623d5f7798ba0ae0fd8a9 33 | -- 34 | 35 | CREATE OR REPLACE 36 | ALGORITHM = MERGE 37 | DEFINER = 'root'@'localhost' 38 | SQL SECURITY INVOKER 39 | VIEW x$statements_with_errors_or_warnings ( 40 | query, 41 | db, 42 | exec_count, 43 | errors, 44 | error_pct, 45 | warnings, 46 | warning_pct, 47 | first_seen, 48 | last_seen, 49 | digest 50 | ) AS 51 | SELECT DIGEST_TEXT AS query, 52 | SCHEMA_NAME as db, 53 | COUNT_STAR AS exec_count, 54 | SUM_ERRORS AS errors, 55 | IFNULL(SUM_ERRORS / NULLIF(COUNT_STAR, 0), 0) * 100 as error_pct, 56 | SUM_WARNINGS AS warnings, 57 | IFNULL(SUM_WARNINGS / NULLIF(COUNT_STAR, 0), 0) * 100 as warning_pct, 58 | FIRST_SEEN as first_seen, 59 | LAST_SEEN as last_seen, 60 | DIGEST AS digest 61 | FROM performance_schema.events_statements_summary_by_digest 62 | WHERE SUM_ERRORS > 0 63 | OR SUM_WARNINGS > 0 64 | ORDER BY SUM_ERRORS DESC, SUM_WARNINGS DESC; 65 | -------------------------------------------------------------------------------- /views/p_s/schema_unused_indexes.sql: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License 13 | -- along with this program; if not, write to the Free Software 14 | -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 | 16 | -- 17 | -- View: schema_unused_indexes 18 | -- 19 | -- Finds indexes that have had no events against them (and hence, no usage). 20 | -- 21 | -- To trust whether the data from this view is representative of your workload, 22 | -- you should ensure that the server has been up for a representative amount of 23 | -- time before using it. 24 | -- 25 | -- PRIMARY (key) indexes are ignored. 26 | -- 27 | -- mysql> select * from schema_unused_indexes limit 5; 28 | -- +--------------------+---------------------+--------------------+ 29 | -- | object_schema | object_name | index_name | 30 | -- +--------------------+---------------------+--------------------+ 31 | -- | mem30__bean_config | plists | path | 32 | -- | mem30__config | group_selections | name | 33 | -- | mem30__config | notification_groups | name | 34 | -- | mem30__config | user_form_defaults | FKC1AEF1F9E7EE2CFB | 35 | -- | mem30__enterprise | whats_new_entries | entryId | 36 | -- +--------------------+---------------------+--------------------+ 37 | -- 38 | 39 | CREATE OR REPLACE 40 | ALGORITHM = MERGE 41 | DEFINER = 'root'@'localhost' 42 | SQL SECURITY INVOKER 43 | VIEW schema_unused_indexes ( 44 | object_schema, 45 | object_name, 46 | index_name 47 | ) AS 48 | SELECT object_schema, 49 | object_name, 50 | index_name 51 | FROM performance_schema.table_io_waits_summary_by_index_usage 52 | WHERE index_name IS NOT NULL 53 | AND count_star = 0 54 | AND object_schema != 'mysql' 55 | AND index_name != 'PRIMARY' 56 | ORDER BY object_schema, object_name; 57 | --------------------------------------------------------------------------------