summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/perfschema/t
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--mysql-test/suite/perfschema/t/all_tests.test67
-rw-r--r--mysql-test/suite/perfschema/t/alter_table_progress.test147
-rw-r--r--mysql-test/suite/perfschema/t/bad_option.test75
-rw-r--r--mysql-test/suite/perfschema/t/batch_table_io_func.test152
-rw-r--r--mysql-test/suite/perfschema/t/binlog_edge_mix-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/binlog_edge_mix.test10
-rw-r--r--mysql-test/suite/perfschema/t/binlog_edge_row-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/binlog_edge_row.test10
-rw-r--r--mysql-test/suite/perfschema/t/binlog_edge_stmt-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/binlog_edge_stmt.test10
-rw-r--r--mysql-test/suite/perfschema/t/binlog_mix.test10
-rw-r--r--mysql-test/suite/perfschema/t/binlog_ok_mix-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/binlog_ok_mix.test10
-rw-r--r--mysql-test/suite/perfschema/t/binlog_ok_row-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/binlog_ok_row.test10
-rw-r--r--mysql-test/suite/perfschema/t/binlog_ok_stmt-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/binlog_ok_stmt.test10
-rw-r--r--mysql-test/suite/perfschema/t/binlog_row.test10
-rw-r--r--mysql-test/suite/perfschema/t/binlog_stmt.test11
-rw-r--r--mysql-test/suite/perfschema/t/checksum.test121
-rw-r--r--mysql-test/suite/perfschema/t/cnf_option.cnf10
-rw-r--r--mysql-test/suite/perfschema/t/cnf_option.test9
-rw-r--r--mysql-test/suite/perfschema/t/column_privilege.test62
-rw-r--r--mysql-test/suite/perfschema/t/connect_attrs.test83
-rw-r--r--mysql-test/suite/perfschema/t/connection.test7
-rw-r--r--mysql-test/suite/perfschema/t/connection_3a-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/connection_3a.test7
-rw-r--r--mysql-test/suite/perfschema/t/connection_3a_3u-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/connection_3a_3u.test7
-rw-r--r--mysql-test/suite/perfschema/t/connection_3u-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/connection_3u.test7
-rw-r--r--mysql-test/suite/perfschema/t/connection_type_notwin.test92
-rw-r--r--mysql-test/suite/perfschema/t/connection_type_win.test90
-rw-r--r--mysql-test/suite/perfschema/t/csv_table_io.test28
-rw-r--r--mysql-test/suite/perfschema/t/ddl_accounts.test17
-rw-r--r--mysql-test/suite/perfschema/t/ddl_cond_instances.test17
-rw-r--r--mysql-test/suite/perfschema/t/ddl_esgs_by_account_by_event_name.test19
-rw-r--r--mysql-test/suite/perfschema/t/ddl_esgs_by_host_by_event_name.test19
-rw-r--r--mysql-test/suite/perfschema/t/ddl_esgs_by_thread_by_event_name.test18
-rw-r--r--mysql-test/suite/perfschema/t/ddl_esgs_by_user_by_event_name.test19
-rw-r--r--mysql-test/suite/perfschema/t/ddl_esgs_global_by_event_name.test19
-rw-r--r--mysql-test/suite/perfschema/t/ddl_esms_by_account_by_event_name.test19
-rw-r--r--mysql-test/suite/perfschema/t/ddl_esms_by_digest.test40
-rw-r--r--mysql-test/suite/perfschema/t/ddl_esms_by_host_by_event_name.test19
-rw-r--r--mysql-test/suite/perfschema/t/ddl_esms_by_program.test21
-rw-r--r--mysql-test/suite/perfschema/t/ddl_esms_by_thread_by_event_name.test18
-rw-r--r--mysql-test/suite/perfschema/t/ddl_esms_by_user_by_event_name.test19
-rw-r--r--mysql-test/suite/perfschema/t/ddl_esms_global_by_event_name.test19
-rw-r--r--mysql-test/suite/perfschema/t/ddl_ets_by_account_by_event_name.test19
-rw-r--r--mysql-test/suite/perfschema/t/ddl_ets_by_host_by_event_name.test19
-rw-r--r--mysql-test/suite/perfschema/t/ddl_ets_by_thread_by_event_name.test18
-rw-r--r--mysql-test/suite/perfschema/t/ddl_ets_by_user_by_event_name.test19
-rw-r--r--mysql-test/suite/perfschema/t/ddl_ets_global_by_event_name.test19
-rw-r--r--mysql-test/suite/perfschema/t/ddl_events_stages_current.test21
-rw-r--r--mysql-test/suite/perfschema/t/ddl_events_stages_history.test21
-rw-r--r--mysql-test/suite/perfschema/t/ddl_events_stages_history_long.test21
-rw-r--r--mysql-test/suite/perfschema/t/ddl_events_statements_current.test16
-rw-r--r--mysql-test/suite/perfschema/t/ddl_events_statements_history.test16
-rw-r--r--mysql-test/suite/perfschema/t/ddl_events_statements_history_long.test16
-rw-r--r--mysql-test/suite/perfschema/t/ddl_events_transactions_current.test16
-rw-r--r--mysql-test/suite/perfschema/t/ddl_events_transactions_history.test16
-rw-r--r--mysql-test/suite/perfschema/t/ddl_events_transactions_history_long.test16
-rw-r--r--mysql-test/suite/perfschema/t/ddl_events_waits_current.test16
-rw-r--r--mysql-test/suite/perfschema/t/ddl_events_waits_history.test16
-rw-r--r--mysql-test/suite/perfschema/t/ddl_events_waits_history_long.test16
-rw-r--r--mysql-test/suite/perfschema/t/ddl_ews_by_account_by_event_name.test19
-rw-r--r--mysql-test/suite/perfschema/t/ddl_ews_by_host_by_event_name.test19
-rw-r--r--mysql-test/suite/perfschema/t/ddl_ews_by_instance.test16
-rw-r--r--mysql-test/suite/perfschema/t/ddl_ews_by_thread_by_event_name.test18
-rw-r--r--mysql-test/suite/perfschema/t/ddl_ews_by_user_by_event_name.test19
-rw-r--r--mysql-test/suite/perfschema/t/ddl_ews_global_by_event_name.test19
-rw-r--r--mysql-test/suite/perfschema/t/ddl_file_instances.test17
-rw-r--r--mysql-test/suite/perfschema/t/ddl_fs_by_event_name.test16
-rw-r--r--mysql-test/suite/perfschema/t/ddl_fs_by_instance.test16
-rw-r--r--mysql-test/suite/perfschema/t/ddl_global_status.test19
-rw-r--r--mysql-test/suite/perfschema/t/ddl_global_variables.test20
-rw-r--r--mysql-test/suite/perfschema/t/ddl_host_cache.test16
-rw-r--r--mysql-test/suite/perfschema/t/ddl_hosts.test17
-rw-r--r--mysql-test/suite/perfschema/t/ddl_mems_by_account_by_event_name.test19
-rw-r--r--mysql-test/suite/perfschema/t/ddl_mems_by_host_by_event_name.test19
-rw-r--r--mysql-test/suite/perfschema/t/ddl_mems_by_thread_by_event_name.test19
-rw-r--r--mysql-test/suite/perfschema/t/ddl_mems_by_user_by_event_name.test19
-rw-r--r--mysql-test/suite/perfschema/t/ddl_mems_global_by_event_name.test19
-rw-r--r--mysql-test/suite/perfschema/t/ddl_metadata_locks.test17
-rw-r--r--mysql-test/suite/perfschema/t/ddl_mutex_instances.test17
-rw-r--r--mysql-test/suite/perfschema/t/ddl_os_global_by_type.test19
-rw-r--r--mysql-test/suite/perfschema/t/ddl_performance_timers.test17
-rw-r--r--mysql-test/suite/perfschema/t/ddl_prepared_statements_instances.test21
-rw-r--r--mysql-test/suite/perfschema/t/ddl_processlist.test32
-rw-r--r--mysql-test/suite/perfschema/t/ddl_replication_applier_configuration.test22
-rw-r--r--mysql-test/suite/perfschema/t/ddl_replication_applier_status.test22
-rw-r--r--mysql-test/suite/perfschema/t/ddl_replication_applier_status_by_coordinator.test22
-rw-r--r--mysql-test/suite/perfschema/t/ddl_replication_applier_status_by_worker.test22
-rw-r--r--mysql-test/suite/perfschema/t/ddl_replication_connection_configuration.test22
-rw-r--r--mysql-test/suite/perfschema/t/ddl_replication_connection_status.test22
-rw-r--r--mysql-test/suite/perfschema/t/ddl_replication_group_member_stats.test21
-rw-r--r--mysql-test/suite/perfschema/t/ddl_replication_group_members.test22
-rw-r--r--mysql-test/suite/perfschema/t/ddl_rwlock_instances.test17
-rw-r--r--mysql-test/suite/perfschema/t/ddl_session_account_connect_attrs.test15
-rw-r--r--mysql-test/suite/perfschema/t/ddl_session_connect_attrs.test15
-rw-r--r--mysql-test/suite/perfschema/t/ddl_session_status.test20
-rw-r--r--mysql-test/suite/perfschema/t/ddl_session_variables.test20
-rw-r--r--mysql-test/suite/perfschema/t/ddl_setup_actors.test31
-rw-r--r--mysql-test/suite/perfschema/t/ddl_setup_consumers.test17
-rw-r--r--mysql-test/suite/perfschema/t/ddl_setup_instruments.test17
-rw-r--r--mysql-test/suite/perfschema/t/ddl_setup_objects.test29
-rw-r--r--mysql-test/suite/perfschema/t/ddl_setup_timers.test17
-rw-r--r--mysql-test/suite/perfschema/t/ddl_socket_instances.test17
-rw-r--r--mysql-test/suite/perfschema/t/ddl_socket_summary_by_event_name.test16
-rw-r--r--mysql-test/suite/perfschema/t/ddl_socket_summary_by_instance.test16
-rw-r--r--mysql-test/suite/perfschema/t/ddl_status_by_account.test19
-rw-r--r--mysql-test/suite/perfschema/t/ddl_status_by_host.test19
-rw-r--r--mysql-test/suite/perfschema/t/ddl_status_by_thread.test19
-rw-r--r--mysql-test/suite/perfschema/t/ddl_status_by_user.test19
-rw-r--r--mysql-test/suite/perfschema/t/ddl_table_handles.test17
-rw-r--r--mysql-test/suite/perfschema/t/ddl_threads.test17
-rw-r--r--mysql-test/suite/perfschema/t/ddl_tiws_by_index_usage.test17
-rw-r--r--mysql-test/suite/perfschema/t/ddl_tiws_by_table.test17
-rw-r--r--mysql-test/suite/perfschema/t/ddl_tlws_by_table.test17
-rw-r--r--mysql-test/suite/perfschema/t/ddl_users.test17
-rw-r--r--mysql-test/suite/perfschema/t/ddl_uvar_by_thread.test20
-rw-r--r--mysql-test/suite/perfschema/t/ddl_variables_by_thread.test20
-rw-r--r--mysql-test/suite/perfschema/t/digest_null_literal.test32
-rw-r--r--mysql-test/suite/perfschema/t/digest_table_full-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/digest_table_full.test32
-rw-r--r--mysql-test/suite/perfschema/t/digest_view.test153
-rw-r--r--mysql-test/suite/perfschema/t/disabled.def12
-rw-r--r--mysql-test/suite/perfschema/t/discovery.test15
-rw-r--r--mysql-test/suite/perfschema/t/dml_accounts.test47
-rw-r--r--mysql-test/suite/perfschema/t/dml_cond_instances.test41
-rw-r--r--mysql-test/suite/perfschema/t/dml_esgs_by_account_by_event_name.test48
-rw-r--r--mysql-test/suite/perfschema/t/dml_esgs_by_host_by_event_name.test48
-rw-r--r--mysql-test/suite/perfschema/t/dml_esgs_by_thread_by_event_name.test48
-rw-r--r--mysql-test/suite/perfschema/t/dml_esgs_by_user_by_event_name.test48
-rw-r--r--mysql-test/suite/perfschema/t/dml_esgs_global_by_event_name.test47
-rw-r--r--mysql-test/suite/perfschema/t/dml_esms_by_account_by_event_name.test48
-rw-r--r--mysql-test/suite/perfschema/t/dml_esms_by_digest.test69
-rw-r--r--mysql-test/suite/perfschema/t/dml_esms_by_host_by_event_name.test48
-rw-r--r--mysql-test/suite/perfschema/t/dml_esms_by_program.test44
-rw-r--r--mysql-test/suite/perfschema/t/dml_esms_by_thread_by_event_name.test48
-rw-r--r--mysql-test/suite/perfschema/t/dml_esms_by_user_by_event_name.test48
-rw-r--r--mysql-test/suite/perfschema/t/dml_esms_global_by_event_name.test47
-rw-r--r--mysql-test/suite/perfschema/t/dml_ets_by_account_by_event_name.test42
-rw-r--r--mysql-test/suite/perfschema/t/dml_ets_by_host_by_event_name.test42
-rw-r--r--mysql-test/suite/perfschema/t/dml_ets_by_thread_by_event_name.test42
-rw-r--r--mysql-test/suite/perfschema/t/dml_ets_by_user_by_event_name.test42
-rw-r--r--mysql-test/suite/perfschema/t/dml_ets_global_by_event_name.test41
-rw-r--r--mysql-test/suite/perfschema/t/dml_events_stages_current.test47
-rw-r--r--mysql-test/suite/perfschema/t/dml_events_stages_history.test53
-rw-r--r--mysql-test/suite/perfschema/t/dml_events_stages_history_long.test53
-rw-r--r--mysql-test/suite/perfschema/t/dml_events_statements_current.test47
-rw-r--r--mysql-test/suite/perfschema/t/dml_events_statements_history.test53
-rw-r--r--mysql-test/suite/perfschema/t/dml_events_statements_history_long.test53
-rw-r--r--mysql-test/suite/perfschema/t/dml_events_transactions_current.test41
-rw-r--r--mysql-test/suite/perfschema/t/dml_events_transactions_history.test47
-rw-r--r--mysql-test/suite/perfschema/t/dml_events_transactions_history_long.test47
-rw-r--r--mysql-test/suite/perfschema/t/dml_events_waits_current.test47
-rw-r--r--mysql-test/suite/perfschema/t/dml_events_waits_history.test53
-rw-r--r--mysql-test/suite/perfschema/t/dml_events_waits_history_long.test53
-rw-r--r--mysql-test/suite/perfschema/t/dml_ews_by_account_by_event_name.test47
-rw-r--r--mysql-test/suite/perfschema/t/dml_ews_by_host_by_event_name.test47
-rw-r--r--mysql-test/suite/perfschema/t/dml_ews_by_instance.test60
-rw-r--r--mysql-test/suite/perfschema/t/dml_ews_by_thread_by_event_name.test48
-rw-r--r--mysql-test/suite/perfschema/t/dml_ews_by_user_by_event_name.test47
-rw-r--r--mysql-test/suite/perfschema/t/dml_ews_global_by_event_name.test47
-rw-r--r--mysql-test/suite/perfschema/t/dml_file_instances.test113
-rw-r--r--mysql-test/suite/perfschema/t/dml_fs_by_event_name.test47
-rw-r--r--mysql-test/suite/perfschema/t/dml_fs_by_instance.test47
-rw-r--r--mysql-test/suite/perfschema/t/dml_global_status.test36
-rw-r--r--mysql-test/suite/perfschema/t/dml_global_variables.test36
-rw-r--r--mysql-test/suite/perfschema/t/dml_handler.test46
-rw-r--r--mysql-test/suite/perfschema/t/dml_host_cache.test49
-rw-r--r--mysql-test/suite/perfschema/t/dml_hosts.test47
-rw-r--r--mysql-test/suite/perfschema/t/dml_mems_by_account_by_event_name.test48
-rw-r--r--mysql-test/suite/perfschema/t/dml_mems_by_host_by_event_name.test48
-rw-r--r--mysql-test/suite/perfschema/t/dml_mems_by_thread_by_event_name.test42
-rw-r--r--mysql-test/suite/perfschema/t/dml_mems_by_user_by_event_name.test48
-rw-r--r--mysql-test/suite/perfschema/t/dml_mems_global_by_event_name.test48
-rw-r--r--mysql-test/suite/perfschema/t/dml_metadata_locks.test41
-rw-r--r--mysql-test/suite/perfschema/t/dml_mutex_instances.test41
-rw-r--r--mysql-test/suite/perfschema/t/dml_os_global_by_type.test63
-rw-r--r--mysql-test/suite/perfschema/t/dml_performance_timers.test43
-rw-r--r--mysql-test/suite/perfschema/t/dml_prepared_statements_instances.test43
-rw-r--r--mysql-test/suite/perfschema/t/dml_processlist.test39
-rw-r--r--mysql-test/suite/perfschema/t/dml_replication_applier_configuration.test38
-rw-r--r--mysql-test/suite/perfschema/t/dml_replication_applier_status.test42
-rw-r--r--mysql-test/suite/perfschema/t/dml_replication_applier_status_by_coordinator.test43
-rw-r--r--mysql-test/suite/perfschema/t/dml_replication_applier_status_by_worker.test50
-rw-r--r--mysql-test/suite/perfschema/t/dml_replication_connection_configuration.test43
-rw-r--r--mysql-test/suite/perfschema/t/dml_replication_connection_status.test43
-rw-r--r--mysql-test/suite/perfschema/t/dml_replication_group_member_stats.test38
-rw-r--r--mysql-test/suite/perfschema/t/dml_replication_group_members.test40
-rw-r--r--mysql-test/suite/perfschema/t/dml_rwlock_instances.test41
-rw-r--r--mysql-test/suite/perfschema/t/dml_session_account_connect_attrs.test47
-rw-r--r--mysql-test/suite/perfschema/t/dml_session_connect_attrs.test47
-rw-r--r--mysql-test/suite/perfschema/t/dml_session_status.test36
-rw-r--r--mysql-test/suite/perfschema/t/dml_session_variables.test36
-rw-r--r--mysql-test/suite/perfschema/t/dml_setup_actors.test147
-rw-r--r--mysql-test/suite/perfschema/t/dml_setup_consumers.test46
-rw-r--r--mysql-test/suite/perfschema/t/dml_setup_instruments.test110
-rw-r--r--mysql-test/suite/perfschema/t/dml_setup_objects.test102
-rw-r--r--mysql-test/suite/perfschema/t/dml_setup_timers.test76
-rw-r--r--mysql-test/suite/perfschema/t/dml_socket_instances.test41
-rw-r--r--mysql-test/suite/perfschema/t/dml_socket_summary_by_event_name.test48
-rw-r--r--mysql-test/suite/perfschema/t/dml_socket_summary_by_instance.test48
-rw-r--r--mysql-test/suite/perfschema/t/dml_status_by_account.test40
-rw-r--r--mysql-test/suite/perfschema/t/dml_status_by_host.test40
-rw-r--r--mysql-test/suite/perfschema/t/dml_status_by_thread.test40
-rw-r--r--mysql-test/suite/perfschema/t/dml_status_by_user.test40
-rw-r--r--mysql-test/suite/perfschema/t/dml_table_handles.test35
-rw-r--r--mysql-test/suite/perfschema/t/dml_threads.test56
-rw-r--r--mysql-test/suite/perfschema/t/dml_tiws_by_index_usage.test48
-rw-r--r--mysql-test/suite/perfschema/t/dml_tiws_by_table.test48
-rw-r--r--mysql-test/suite/perfschema/t/dml_tlws_by_table.test48
-rw-r--r--mysql-test/suite/perfschema/t/dml_users.test47
-rw-r--r--mysql-test/suite/perfschema/t/dml_uvar_by_thread.test48
-rw-r--r--mysql-test/suite/perfschema/t/dml_variables_by_thread.test40
-rw-r--r--mysql-test/suite/perfschema/t/event_aggregate-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/event_aggregate.test5
-rw-r--r--mysql-test/suite/perfschema/t/event_aggregate_no_a-master.opt3
-rw-r--r--mysql-test/suite/perfschema/t/event_aggregate_no_a.test5
-rw-r--r--mysql-test/suite/perfschema/t/event_aggregate_no_a_no_h-master.opt4
-rw-r--r--mysql-test/suite/perfschema/t/event_aggregate_no_a_no_h.test5
-rw-r--r--mysql-test/suite/perfschema/t/event_aggregate_no_a_no_u-master.opt4
-rw-r--r--mysql-test/suite/perfschema/t/event_aggregate_no_a_no_u.test5
-rw-r--r--mysql-test/suite/perfschema/t/event_aggregate_no_a_no_u_no_h-master.opt5
-rw-r--r--mysql-test/suite/perfschema/t/event_aggregate_no_a_no_u_no_h.test5
-rw-r--r--mysql-test/suite/perfschema/t/event_aggregate_no_h-master.opt3
-rw-r--r--mysql-test/suite/perfschema/t/event_aggregate_no_h.test5
-rw-r--r--mysql-test/suite/perfschema/t/event_aggregate_no_u-master.opt3
-rw-r--r--mysql-test/suite/perfschema/t/event_aggregate_no_u.test5
-rw-r--r--mysql-test/suite/perfschema/t/event_aggregate_no_u_no_h-master.opt4
-rw-r--r--mysql-test/suite/perfschema/t/event_aggregate_no_u_no_h.test5
-rw-r--r--mysql-test/suite/perfschema/t/file_misc-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/file_misc.test11
-rw-r--r--mysql-test/suite/perfschema/t/func_file_io.test193
-rw-r--r--mysql-test/suite/perfschema/t/func_mutex.test134
-rw-r--r--mysql-test/suite/perfschema/t/global_objects-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/global_objects.test29
-rw-r--r--mysql-test/suite/perfschema/t/global_read_lock.test78
-rw-r--r--mysql-test/suite/perfschema/t/grant.test12
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_again_allow.test53
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_again_deny.test48
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_bad_allow.test56
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_bad_deny.test50
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_good_allow.test54
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_good_deny.test48
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_noname_allow.test58
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_noname_deny.test48
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv4_auth_ed25519.test56
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv4_auth_plugin.test92
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv4_blocked.test161
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv4_format.test47
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv4_max_con-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv4_max_con.test264
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_again_allow.test76
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_again_deny.test66
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_noname_allow.test54
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_noname_deny.test48
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv4_passwd.test87
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv4_ssl.test72
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_again_allow-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_again_allow.test55
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_again_deny-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_again_deny.test49
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_bad_allow-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_bad_allow.test57
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_bad_deny-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_bad_deny.test51
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_good_allow-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_good_allow.test55
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_good_deny-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_good_deny.test45
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_noname_allow-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_noname_allow.test58
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_noname_deny-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_noname_deny.test48
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_auth_plugin-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_auth_plugin.test93
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_blocked-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_blocked.test161
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_max_con-master.opt3
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_max_con.test246
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_again_allow-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_again_allow.test77
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_again_deny-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_again_deny.test67
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_noname_allow-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_noname_allow.test55
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_noname_deny-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_noname_deny.test49
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_passwd-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_passwd.test85
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_ssl-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_ipv6_ssl.test73
-rw-r--r--mysql-test/suite/perfschema/t/hostcache_peer_addr.test50
-rw-r--r--mysql-test/suite/perfschema/t/indexed_table_io.test114
-rw-r--r--mysql-test/suite/perfschema/t/information_schema.test73
-rw-r--r--mysql-test/suite/perfschema/t/innodb_events_transactions_history_long.test19
-rw-r--r--mysql-test/suite/perfschema/t/innodb_table_io.test29
-rw-r--r--mysql-test/suite/perfschema/t/io_cache-master.opt3
-rw-r--r--mysql-test/suite/perfschema/t/io_cache.test121
-rw-r--r--mysql-test/suite/perfschema/t/max_program_zero-master.opt3
-rw-r--r--mysql-test/suite/perfschema/t/max_program_zero.test48
-rw-r--r--mysql-test/suite/perfschema/t/mdl_func.test487
-rw-r--r--mysql-test/suite/perfschema/t/memory_aggregate-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/memory_aggregate.test7
-rw-r--r--mysql-test/suite/perfschema/t/memory_aggregate_32bit-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/memory_aggregate_32bit.test7
-rw-r--r--mysql-test/suite/perfschema/t/memory_aggregate_no_a-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/memory_aggregate_no_a.test7
-rw-r--r--mysql-test/suite/perfschema/t/memory_aggregate_no_a_no_h-master.opt3
-rw-r--r--mysql-test/suite/perfschema/t/memory_aggregate_no_a_no_h.test7
-rw-r--r--mysql-test/suite/perfschema/t/memory_aggregate_no_a_no_u-master.opt3
-rw-r--r--mysql-test/suite/perfschema/t/memory_aggregate_no_a_no_u.test7
-rw-r--r--mysql-test/suite/perfschema/t/memory_aggregate_no_a_no_u_no_h-master.opt4
-rw-r--r--mysql-test/suite/perfschema/t/memory_aggregate_no_a_no_u_no_h.test7
-rw-r--r--mysql-test/suite/perfschema/t/memory_aggregate_no_h-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/memory_aggregate_no_h.test7
-rw-r--r--mysql-test/suite/perfschema/t/memory_aggregate_no_u-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/memory_aggregate_no_u.test7
-rw-r--r--mysql-test/suite/perfschema/t/memory_aggregate_no_u_no_h-master.opt3
-rw-r--r--mysql-test/suite/perfschema/t/memory_aggregate_no_u_no_h.test7
-rw-r--r--mysql-test/suite/perfschema/t/memory_table_io.test28
-rw-r--r--mysql-test/suite/perfschema/t/merge_table_io.test46
-rw-r--r--mysql-test/suite/perfschema/t/misc.test320
-rw-r--r--mysql-test/suite/perfschema/t/misc_global_status-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/misc_global_status.test142
-rw-r--r--mysql-test/suite/perfschema/t/mks_timer-6258.test6
-rw-r--r--mysql-test/suite/perfschema/t/multi_table_io.test55
-rw-r--r--mysql-test/suite/perfschema/t/myisam_file_io.opt1
-rw-r--r--mysql-test/suite/perfschema/t/myisam_file_io.test61
-rw-r--r--mysql-test/suite/perfschema/t/myisam_table_io.test28
-rw-r--r--mysql-test/suite/perfschema/t/nesting.test191
-rw-r--r--mysql-test/suite/perfschema/t/no_threads-master.opt5
-rw-r--r--mysql-test/suite/perfschema/t/no_threads.test59
-rw-r--r--mysql-test/suite/perfschema/t/one_thread_per_con-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/one_thread_per_con.test70
-rw-r--r--mysql-test/suite/perfschema/t/ortho_iter.test307
-rw-r--r--mysql-test/suite/perfschema/t/part_table_io.test30
-rw-r--r--mysql-test/suite/perfschema/t/partition.test16
-rw-r--r--mysql-test/suite/perfschema/t/pfs_upgrade_event-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/pfs_upgrade_event.test24
-rw-r--r--mysql-test/suite/perfschema/t/pfs_upgrade_func-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/pfs_upgrade_func.test24
-rw-r--r--mysql-test/suite/perfschema/t/pfs_upgrade_proc-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/pfs_upgrade_proc.test24
-rw-r--r--mysql-test/suite/perfschema/t/pfs_upgrade_table-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/pfs_upgrade_table.test30
-rw-r--r--mysql-test/suite/perfschema/t/pfs_upgrade_view-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/pfs_upgrade_view.test30
-rw-r--r--mysql-test/suite/perfschema/t/prepared_statements.test210
-rw-r--r--mysql-test/suite/perfschema/t/prepared_stmts_by_stored_programs.test151
-rw-r--r--mysql-test/suite/perfschema/t/privilege.test353
-rw-r--r--mysql-test/suite/perfschema/t/privilege_table_io.test53
-rw-r--r--mysql-test/suite/perfschema/t/processlist-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/processlist.test197
-rw-r--r--mysql-test/suite/perfschema/t/processlist_57.test349
-rw-r--r--mysql-test/suite/perfschema/t/processlist_acl-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/processlist_acl.test196
-rw-r--r--mysql-test/suite/perfschema/t/processlist_anonymous.test111
-rw-r--r--mysql-test/suite/perfschema/t/processlist_no_pfs-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/processlist_no_pfs.test29
-rw-r--r--mysql-test/suite/perfschema/t/processlist_port-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/processlist_port.test162
-rw-r--r--mysql-test/suite/perfschema/t/processlist_reg_user.test134
-rw-r--r--mysql-test/suite/perfschema/t/query_cache-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/query_cache.test61
-rw-r--r--mysql-test/suite/perfschema/t/read_only.test77
-rw-r--r--mysql-test/suite/perfschema/t/relaylog.test180
-rw-r--r--mysql-test/suite/perfschema/t/rollback_table_io.test48
-rw-r--r--mysql-test/suite/perfschema/t/rpl_group_member_stats.test48
-rw-r--r--mysql-test/suite/perfschema/t/rpl_group_members.test33
-rw-r--r--mysql-test/suite/perfschema/t/rpl_gtid_func.test86
-rw-r--r--mysql-test/suite/perfschema/t/rpl_statements.test313
-rw-r--r--mysql-test/suite/perfschema/t/rpl_threads.test85
-rw-r--r--mysql-test/suite/perfschema/t/schema.test7
-rw-r--r--mysql-test/suite/perfschema/t/selects-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/selects.test181
-rw-r--r--mysql-test/suite/perfschema/t/server_init.test144
-rw-r--r--mysql-test/suite/perfschema/t/setup_actors.test230
-rw-r--r--mysql-test/suite/perfschema/t/setup_actors_enabled.test219
-rw-r--r--mysql-test/suite/perfschema/t/setup_actors_history.test177
-rw-r--r--mysql-test/suite/perfschema/t/setup_consumers_defaults-master.opt18
-rw-r--r--mysql-test/suite/perfschema/t/setup_consumers_defaults.test18
-rw-r--r--mysql-test/suite/perfschema/t/setup_instruments_defaults-master.opt28
-rw-r--r--mysql-test/suite/perfschema/t/setup_instruments_defaults.test100
-rw-r--r--mysql-test/suite/perfschema/t/setup_object_table_lock_io.test107
-rw-r--r--mysql-test/suite/perfschema/t/setup_objects.test197
-rw-r--r--mysql-test/suite/perfschema/t/short_option_1-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/short_option_1.test16
-rw-r--r--mysql-test/suite/perfschema/t/short_option_2-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/short_option_2.test14
-rw-r--r--mysql-test/suite/perfschema/t/show_aggregate.test301
-rw-r--r--mysql-test/suite/perfschema/t/show_coverage.test186
-rw-r--r--mysql-test/suite/perfschema/t/show_misc.test64
-rw-r--r--mysql-test/suite/perfschema/t/show_plugin.test321
-rw-r--r--mysql-test/suite/perfschema/t/show_sanity.test1831
-rw-r--r--mysql-test/suite/perfschema/t/socket_connect.test293
-rw-r--r--mysql-test/suite/perfschema/t/socket_instances_func-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/socket_instances_func.test443
-rw-r--r--mysql-test/suite/perfschema/t/socket_instances_func_win-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/socket_instances_func_win.test339
-rw-r--r--mysql-test/suite/perfschema/t/socket_summary_by_event_name_func.test337
-rw-r--r--mysql-test/suite/perfschema/t/socket_summary_by_instance_func.test1713
-rw-r--r--mysql-test/suite/perfschema/t/socket_summary_by_instance_func_win.test1730
-rw-r--r--mysql-test/suite/perfschema/t/stage_mdl_function.test63
-rw-r--r--mysql-test/suite/perfschema/t/stage_mdl_global.opt2
-rw-r--r--mysql-test/suite/perfschema/t/stage_mdl_global.test54
-rw-r--r--mysql-test/suite/perfschema/t/stage_mdl_procedure.test79
-rw-r--r--mysql-test/suite/perfschema/t/stage_mdl_table.test59
-rw-r--r--mysql-test/suite/perfschema/t/start_server_1_digest-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/start_server_1_digest.test15
-rw-r--r--mysql-test/suite/perfschema/t/start_server_disable_idle-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/start_server_disable_idle.test28
-rw-r--r--mysql-test/suite/perfschema/t/start_server_disable_stages-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/start_server_disable_stages.test28
-rw-r--r--mysql-test/suite/perfschema/t/start_server_disable_statements-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/start_server_disable_statements.test28
-rw-r--r--mysql-test/suite/perfschema/t/start_server_disable_transactions-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/start_server_disable_transactions.test28
-rw-r--r--mysql-test/suite/perfschema/t/start_server_disable_waits-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/start_server_disable_waits.test28
-rw-r--r--mysql-test/suite/perfschema/t/start_server_innodb-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/start_server_innodb.test11
-rw-r--r--mysql-test/suite/perfschema/t/start_server_low_digest-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/start_server_low_digest.test21
-rw-r--r--mysql-test/suite/perfschema/t/start_server_low_digest_sql_length-master.opt3
-rw-r--r--mysql-test/suite/perfschema/t/start_server_low_digest_sql_length.test23
-rw-r--r--mysql-test/suite/perfschema/t/start_server_low_index-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_low_index.test187
-rw-r--r--mysql-test/suite/perfschema/t/start_server_low_table_lock-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_low_table_lock.test136
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_account-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_account.test18
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_cond_class-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_cond_class.test25
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_cond_inst-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_cond_inst.test28
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_digests-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_digests.test32
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_file_class-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_file_class.test25
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_file_inst-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_file_inst.test28
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_host-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_host.test18
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_index-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_index.test66
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_mdl-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_mdl.test23
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_memory_class-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_memory_class.test26
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_mutex_class-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_mutex_class.test25
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_mutex_inst-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_mutex_inst.test28
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_prepared_stmts_instances-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_prepared_stmts_instances.test43
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_rwlock_class-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_rwlock_class.test25
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_rwlock_inst-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_rwlock_inst.test28
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_setup_actors-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_setup_actors.test13
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_setup_objects-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_setup_objects.test13
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_socket_class-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_socket_class.test25
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_socket_inst-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_socket_inst.test28
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_stage_class-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_stage_class.test28
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_stages_history-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_stages_history.test14
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_stages_history_long-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_stages_history_long.test14
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_statement_class-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_statement_class.test28
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_statements_history-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_statements_history.test14
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_statements_history_long-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_statements_history_long.test14
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_table_hdl-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_table_hdl.test32
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_table_inst-master.opt4
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_table_inst.test32
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_table_lock-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_table_lock.test56
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_thread_class-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_thread_class.test25
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_thread_inst-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_thread_inst.test29
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_transactions_history-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_transactions_history.test14
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_transactions_history_long-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_transactions_history_long.test14
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_user-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_user.test18
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_waits_history-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_waits_history.test14
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_waits_history_long-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/start_server_no_waits_history_long.test14
-rw-r--r--mysql-test/suite/perfschema/t/start_server_nothing-master.opt47
-rw-r--r--mysql-test/suite/perfschema/t/start_server_nothing.test62
-rw-r--r--mysql-test/suite/perfschema/t/start_server_off-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/start_server_off.test56
-rw-r--r--mysql-test/suite/perfschema/t/start_server_on-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/start_server_on.test10
-rw-r--r--mysql-test/suite/perfschema/t/start_server_variables.test11
-rw-r--r--mysql-test/suite/perfschema/t/start_server_zero_digest_sql_length-master.opt3
-rw-r--r--mysql-test/suite/perfschema/t/start_server_zero_digest_sql_length.test20
-rw-r--r--mysql-test/suite/perfschema/t/statement_digest.test25
-rw-r--r--mysql-test/suite/perfschema/t/statement_digest_charset.test36
-rw-r--r--mysql-test/suite/perfschema/t/statement_digest_consumers-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/statement_digest_consumers.test35
-rw-r--r--mysql-test/suite/perfschema/t/statement_digest_consumers2-master.opt2
-rw-r--r--mysql-test/suite/perfschema/t/statement_digest_consumers2.test37
-rw-r--r--mysql-test/suite/perfschema/t/statement_digest_long_query-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/statement_digest_long_query.test31
-rw-r--r--mysql-test/suite/perfschema/t/statement_program_concurrency-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/statement_program_concurrency.test132
-rw-r--r--mysql-test/suite/perfschema/t/statement_program_lost_inst-master.opt3
-rw-r--r--mysql-test/suite/perfschema/t/statement_program_lost_inst.test72
-rw-r--r--mysql-test/suite/perfschema/t/statement_program_nested-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/statement_program_nested.test75
-rw-r--r--mysql-test/suite/perfschema/t/statement_program_nesting_event_check-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/statement_program_nesting_event_check.test47
-rw-r--r--mysql-test/suite/perfschema/t/statement_program_non_nested-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/statement_program_non_nested.test144
-rw-r--r--mysql-test/suite/perfschema/t/status_reprepare.test61
-rw-r--r--mysql-test/suite/perfschema/t/sxlock_func.test70
-rw-r--r--mysql-test/suite/perfschema/t/table_aggregate_global_2u_2t.test21
-rw-r--r--mysql-test/suite/perfschema/t/table_aggregate_global_2u_3t.test19
-rw-r--r--mysql-test/suite/perfschema/t/table_aggregate_global_4u_2t.test19
-rw-r--r--mysql-test/suite/perfschema/t/table_aggregate_global_4u_3t.test17
-rw-r--r--mysql-test/suite/perfschema/t/table_aggregate_hist_2u_2t.test19
-rw-r--r--mysql-test/suite/perfschema/t/table_aggregate_hist_2u_3t.test17
-rw-r--r--mysql-test/suite/perfschema/t/table_aggregate_hist_4u_2t.test17
-rw-r--r--mysql-test/suite/perfschema/t/table_aggregate_hist_4u_3t.test15
-rw-r--r--mysql-test/suite/perfschema/t/table_aggregate_off.test13
-rw-r--r--mysql-test/suite/perfschema/t/table_aggregate_thread_2u_2t.test21
-rw-r--r--mysql-test/suite/perfschema/t/table_aggregate_thread_2u_3t.test19
-rw-r--r--mysql-test/suite/perfschema/t/table_aggregate_thread_4u_2t.test19
-rw-r--r--mysql-test/suite/perfschema/t/table_aggregate_thread_4u_3t.test17
-rw-r--r--mysql-test/suite/perfschema/t/table_io_aggregate_global_2u_2t.test23
-rw-r--r--mysql-test/suite/perfschema/t/table_io_aggregate_global_2u_3t.test21
-rw-r--r--mysql-test/suite/perfschema/t/table_io_aggregate_global_4u_2t.test21
-rw-r--r--mysql-test/suite/perfschema/t/table_io_aggregate_global_4u_3t.test19
-rw-r--r--mysql-test/suite/perfschema/t/table_io_aggregate_hist_2u_2t.test21
-rw-r--r--mysql-test/suite/perfschema/t/table_io_aggregate_hist_2u_3t.test19
-rw-r--r--mysql-test/suite/perfschema/t/table_io_aggregate_hist_4u_2t.test19
-rw-r--r--mysql-test/suite/perfschema/t/table_io_aggregate_hist_4u_3t.test17
-rw-r--r--mysql-test/suite/perfschema/t/table_io_aggregate_thread_2u_2t.test23
-rw-r--r--mysql-test/suite/perfschema/t/table_io_aggregate_thread_2u_3t.test21
-rw-r--r--mysql-test/suite/perfschema/t/table_io_aggregate_thread_4u_2t.test21
-rw-r--r--mysql-test/suite/perfschema/t/table_io_aggregate_thread_4u_3t.test19
-rw-r--r--mysql-test/suite/perfschema/t/table_lock_aggregate_global_2u_2t.test26
-rw-r--r--mysql-test/suite/perfschema/t/table_lock_aggregate_global_2u_3t.test24
-rw-r--r--mysql-test/suite/perfschema/t/table_lock_aggregate_global_4u_2t.test24
-rw-r--r--mysql-test/suite/perfschema/t/table_lock_aggregate_global_4u_3t.test22
-rw-r--r--mysql-test/suite/perfschema/t/table_lock_aggregate_hist_2u_2t.test24
-rw-r--r--mysql-test/suite/perfschema/t/table_lock_aggregate_hist_2u_3t.test22
-rw-r--r--mysql-test/suite/perfschema/t/table_lock_aggregate_hist_4u_2t.test22
-rw-r--r--mysql-test/suite/perfschema/t/table_lock_aggregate_hist_4u_3t.test20
-rw-r--r--mysql-test/suite/perfschema/t/table_lock_aggregate_thread_2u_2t.test26
-rw-r--r--mysql-test/suite/perfschema/t/table_lock_aggregate_thread_2u_3t.test24
-rw-r--r--mysql-test/suite/perfschema/t/table_lock_aggregate_thread_4u_2t.test24
-rw-r--r--mysql-test/suite/perfschema/t/table_lock_aggregate_thread_4u_3t.test22
-rw-r--r--mysql-test/suite/perfschema/t/table_name.test177
-rw-r--r--mysql-test/suite/perfschema/t/table_schema.test62
-rw-r--r--mysql-test/suite/perfschema/t/temp_table_io.test28
-rw-r--r--mysql-test/suite/perfschema/t/thread_cache-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/thread_cache.test173
-rw-r--r--mysql-test/suite/perfschema/t/thread_misc-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/thread_misc.test11
-rw-r--r--mysql-test/suite/perfschema/t/threads_history.test727
-rw-r--r--mysql-test/suite/perfschema/t/threads_innodb.test23
-rw-r--r--mysql-test/suite/perfschema/t/threads_mysql-master.opt1
-rw-r--r--mysql-test/suite/perfschema/t/threads_mysql.test116
-rw-r--r--mysql-test/suite/perfschema/t/threads_mysql_freebsd.test22
-rw-r--r--mysql-test/suite/perfschema/t/threads_mysql_linux.test22
-rw-r--r--mysql-test/suite/perfschema/t/threads_mysql_windows.test22
-rw-r--r--mysql-test/suite/perfschema/t/transaction-master.opt4
-rw-r--r--mysql-test/suite/perfschema/t/transaction.test734
-rw-r--r--mysql-test/suite/perfschema/t/transaction_gtid.test194
-rw-r--r--mysql-test/suite/perfschema/t/transaction_nested_events-master.opt19
-rw-r--r--mysql-test/suite/perfschema/t/transaction_nested_events.test387
-rw-r--r--mysql-test/suite/perfschema/t/trigger_table_io.test76
-rw-r--r--mysql-test/suite/perfschema/t/unary_digest.test98
-rw-r--r--mysql-test/suite/perfschema/t/update_order-3837.test8
-rw-r--r--mysql-test/suite/perfschema/t/user_var_func.test101
-rw-r--r--mysql-test/suite/perfschema/t/view_table_io.test42
593 files changed, 31697 insertions, 0 deletions
diff --git a/mysql-test/suite/perfschema/t/all_tests.test b/mysql-test/suite/perfschema/t/all_tests.test
new file mode 100644
index 00000000..b16364ba
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/all_tests.test
@@ -0,0 +1,67 @@
+--source include/not_embedded.inc
+
+#
+# Test based on mysql-test/suite/sys_vars/t/all_vars.test
+# and adapted for the performance schema tables.
+#
+# This test verifies that *all* performance schema tables are tested
+# by the perfschema test suite.
+# In particular, every table there must be covered by:
+# - a ddl_<table_name>.test file.
+# - a dml_<table_name>.test file.
+#
+
+#
+# we can diff in perl or in sql, as it's my_SQL_test suite, do it in sql
+#
+
+perl;
+ use File::Basename;
+ my $dirname=dirname($ENV{MYSQLTEST_FILE});
+ my @all_tests=<$dirname/*.test>;
+ open(F, '>', "$ENV{MYSQLTEST_VARDIR}/tmp/perfschema-all_tests.txt") or die;
+ binmode F;
+ print F join "\n", sort map { basename $_ } @all_tests;
+EOF
+
+--disable_warnings
+drop table if exists t1;
+drop table if exists t2;
+--enable_warnings
+
+create table t1 (test_name text);
+create table t2 (test_name text);
+--replace_result $MYSQLTEST_VARDIR <MYSQLTEST_VARDIR>
+eval load data infile "$MYSQLTEST_VARDIR/tmp/perfschema-all_tests.txt" into table t1;
+
+insert into t2 select concat('ddl_', table_name, '.test') from information_schema.tables
+ where table_schema='performance_schema';
+insert into t2 select concat('dml_', table_name, '.test') from information_schema.tables
+ where table_schema='performance_schema';
+
+# Abbreviations used for naming test files:
+update t2 set test_name= replace(test_name, "events_waits_summary_", "ews_");
+update t2 set test_name= replace(test_name, "events_stages_summary_", "esgs_");
+update t2 set test_name= replace(test_name, "events_statements_summary_", "esms_");
+update t2 set test_name= replace(test_name, "events_transactions_summary_", "ets_");
+update t2 set test_name= replace(test_name, "file_summary_", "fs_");
+update t2 set test_name= replace(test_name, "objects_summary_", "os_");
+update t2 set test_name= replace(test_name, "table_io_waits_summary_", "tiws_");
+update t2 set test_name= replace(test_name, "table_lock_waits_summary_", "tlws_");
+update t2 set test_name= replace(test_name, "memory_summary_", "mems_");
+update t2 set test_name= replace(test_name, "user_variables_", "uvar_");
+
+# Debug
+# select test_name as 'FOUND' from t1;
+# select test_name as 'EXPECTED' from t2;
+
+delete from t2 where t2.test_name in (select t1.test_name from t1);
+
+# If this fails, the test listed in the output is missing from the test suite.
+# The way to fix the failure is to implement the missing test, not silence this select.
+select test_name as `MISSING DDL/DML TESTS` from t2;
+
+drop table t1;
+drop table t2;
+
+--remove_file $MYSQLTEST_VARDIR/tmp/perfschema-all_tests.txt
diff --git a/mysql-test/suite/perfschema/t/alter_table_progress.test b/mysql-test/suite/perfschema/t/alter_table_progress.test
new file mode 100644
index 00000000..d4933ac9
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/alter_table_progress.test
@@ -0,0 +1,147 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_innodb.inc
+--source include/have_perfschema.inc
+--source include/have_debug.inc
+--source include/have_debug_sync.inc
+
+# Presence of the query cache changes query stages,
+# causing noise in the test output
+#--source include/have_query_cache_disabled.inc
+
+# Setup
+
+connect (con1, localhost, root, , );
+
+let $con1_THREAD_ID=`select thread_id from performance_schema.threads
+ where PROCESSLIST_ID = connection_id()`;
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1(a int) engine = myisam;
+
+insert into t1 values (1), (2), (3), (4), (5);
+
+--connection default
+
+update performance_schema.threads
+ set instrumented = 'NO'
+ where processlist_id = connection_id();
+
+truncate table performance_schema.events_statements_history_long;
+truncate table performance_schema.events_stages_history_long;
+
+--disable_query_log
+eval select $con1_THREAD_ID into @con1_thread_id;
+--enable_query_log
+
+--connection con1
+
+# ALTER TABLE statement to inspect,
+# execution should instrument progress
+
+SET DEBUG_SYNC='RESET';
+SET DEBUG_SYNC='copy_data_between_tables_before SIGNAL found_row WAIT_FOR wait_row EXECUTE 5';
+--send ALTER TABLE t1 engine = innodb;
+
+--connection default
+
+SET DEBUG_SYNC='now WAIT_FOR found_row';
+
+# Find the statement id of the ALTER TABLE
+--enable_prepare_warnings
+select event_id from performance_schema.events_statements_current
+ where thread_id = @con1_thread_id into @con1_stmt_id;
+--disable_prepare_warnings
+
+# completed 0
+select EVENT_NAME, WORK_COMPLETED, WORK_ESTIMATED
+ from performance_schema.events_stages_current
+ where (thread_id = @con1_thread_id);
+
+SET DEBUG_SYNC='now SIGNAL wait_row';
+
+#======
+
+SET DEBUG_SYNC='now WAIT_FOR found_row';
+
+# completed 1
+select EVENT_NAME, WORK_COMPLETED, WORK_ESTIMATED
+ from performance_schema.events_stages_current
+ where (thread_id = @con1_thread_id);
+
+SET DEBUG_SYNC='now SIGNAL wait_row';
+
+#======
+
+SET DEBUG_SYNC='now WAIT_FOR found_row';
+
+# completed 2
+select EVENT_NAME, WORK_COMPLETED, WORK_ESTIMATED
+ from performance_schema.events_stages_current
+ where (thread_id = @con1_thread_id);
+
+SET DEBUG_SYNC='now SIGNAL wait_row';
+
+#======
+
+SET DEBUG_SYNC='now WAIT_FOR found_row';
+
+# completed 3
+select EVENT_NAME, WORK_COMPLETED, WORK_ESTIMATED
+ from performance_schema.events_stages_current
+ where (thread_id = @con1_thread_id);
+
+SET DEBUG_SYNC='now SIGNAL wait_row';
+
+#======
+
+SET DEBUG_SYNC='now WAIT_FOR found_row';
+
+# completed 4
+select EVENT_NAME, WORK_COMPLETED, WORK_ESTIMATED
+ from performance_schema.events_stages_current
+ where (thread_id = @con1_thread_id);
+
+SET DEBUG_SYNC='now SIGNAL wait_row';
+
+#======
+
+--connection con1
+
+# Complete the ALTER TABLE statement.
+--reap
+
+# Make sure the ALTER TABLE cleanup is executed,
+# as the last stages are after writing back to the client,
+# and done asynchronously from the last 'reap'.
+select "After payload";
+
+--connection default
+
+--echo # Dumping ALTER TABLE stages
+
+# Print all stages for this ALTER TABLE statement
+select EVENT_NAME, WORK_COMPLETED, WORK_ESTIMATED
+ from performance_schema.events_stages_history_long
+ where (thread_id = @con1_thread_id)
+ and (nesting_event_id = @con1_stmt_id)
+ order by thread_id, event_id;
+
+SET DEBUG_SYNC='RESET';
+
+--connection con1
+
+drop table t1;
+
+--disconnect con1
+
+--connection default
+
+update performance_schema.threads
+ set instrumented = 'YES'
+ where processlist_id = connection_id();
+
diff --git a/mysql-test/suite/perfschema/t/bad_option.test b/mysql-test/suite/perfschema/t/bad_option.test
new file mode 100644
index 00000000..4feb0468
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/bad_option.test
@@ -0,0 +1,75 @@
+# Tests for PERFORMANCE_SCHEMA
+# Check error handling for invalid server start options and values
+
+# The current test unites and replaces all suite/perfschema/t/bad_option_*.test
+# which were developed by Marc.
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/not_as_root.inc
+
+let $error_log= $MYSQLTEST_VARDIR/log/my_restart.err;
+--error 0,1
+--remove_file $error_log
+let SEARCH_FILE= $error_log;
+# Stop the server
+let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
+--exec echo "wait" > $restart_file
+--shutdown_server
+--source include/wait_until_disconnected.inc
+--error 7
+--exec $MYSQLD_CMD --loose-console --skip-log-error --performance-schema-enabled=maybe > $error_log 2>&1
+# The server restart aborts
+# [ERROR] unknown variable 'performance-schema-enabled=maybe'
+let SEARCH_PATTERN= \[ERROR\].*unknown variable 'performance-schema-enabled=maybe';
+--source include/search_pattern_in_file.inc
+--echo # Server start with invalid startup option value 'performance-schema-enabled=maybe' : pass
+
+--remove_file $error_log
+--error 7
+--exec $MYSQLD_CMD --loose-console --skip-log-error --performance-schema-max_=12 > $error_log 2>&1
+# The server restart aborts
+# [ERROR] unknown variable 'performance-schema-max_=12'
+let SEARCH_PATTERN= \[ERROR\].*unknown variable 'performance-schema-max_=12';
+--source include/search_pattern_in_file.inc
+--echo # Server start with ambigous startup option 'performance-schema-max_=12' : pass
+# The important points is here:
+# 1. There is no option 'performance-schema-max_' or 'performance-schema-max-' at all.
+# 2. But we have many options where the name starts exact with this pattern.
+# 3. There is a value assigned.
+# 4. The server criticizes "variable" and not "option"!
+# This seems to be caused by 3. because "--performance-schema-unknown=ON" gets
+# a similar reaction.
+
+--remove_file $error_log
+--error 2
+--exec $MYSQLD_CMD --loose-console --skip-log-error --performance-schema-unknown_99 > $error_log 2>&1
+# The server restart aborts
+let SEARCH_PATTERN= \[ERROR\].*unknown option '--performance-schema-unknown_99';
+--source include/search_pattern_in_file.inc
+--echo # Server start with invalid startup option '--performance-schema-unknown_99' : pass
+
+--remove_file $error_log
+--error 1
+--exec $MYSQLD_CMD --loose-console --skip-log-error --datadir=bad_option_h_param > $error_log 2>&1
+# The server restart aborts
+# [ERROR] failed to set datadir to /work/repo1/mysql-trunk2/bad_option_h_param
+let SEARCH_PATTERN= Can.t change dir to .*bad_option_h_param;
+--source include/search_pattern_in_file.inc
+--echo # Server start with invalid startup option value '--datadir=bad_option_h_param' : pass
+# The important point is here:
+# There is no directory "bad_option_h_param".
+
+--remove_file $error_log
+# Write file to make mysql-test-run.pl start up the server again
+--exec echo "restart" > $restart_file
+
+# Turn on reconnect
+--enable_reconnect
+
+# Call script that will poll the server waiting for it to be back online again
+--source include/wait_until_connected_again.inc
+
+# Turn off reconnect again
+--disable_reconnect
+
diff --git a/mysql-test/suite/perfschema/t/batch_table_io_func.test b/mysql-test/suite/perfschema/t/batch_table_io_func.test
new file mode 100644
index 00000000..dcdf61b0
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/batch_table_io_func.test
@@ -0,0 +1,152 @@
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+UPDATE performance_schema.setup_instruments SET enabled = 'NO', timed = 'YES';
+
+UPDATE performance_schema.setup_instruments SET enabled = 'YES'
+WHERE name in ('wait/io/table/sql/handler',
+ 'wait/lock/table/sql/handler');
+
+--disable_warnings
+drop procedure if exists before_payload;
+drop procedure if exists after_payload;
+--enable_warnings
+
+delimiter $$;
+
+create procedure before_payload()
+begin
+ TRUNCATE TABLE performance_schema.table_io_waits_summary_by_index_usage;
+ TRUNCATE TABLE performance_schema.table_io_waits_summary_by_table;
+ TRUNCATE TABLE performance_schema.events_waits_history_long;
+ TRUNCATE TABLE performance_schema.events_waits_history;
+ TRUNCATE TABLE performance_schema.events_waits_current;
+end
+$$
+
+create procedure after_payload()
+begin
+ select count(1) as number_seen,
+ OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME,
+ OPERATION, NUMBER_OF_BYTES
+ from performance_schema.events_waits_history_long
+ where OBJECT_SCHEMA = "test"
+ group by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME, OPERATION, NUMBER_OF_BYTES;
+
+ select OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME,
+ COUNT_STAR, COUNT_READ, COUNT_WRITE
+ from performance_schema.table_io_waits_summary_by_index_usage
+ where OBJECT_SCHEMA = "test"
+ order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME;
+
+ select OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME,
+ COUNT_STAR, COUNT_READ, COUNT_WRITE
+ from performance_schema.table_io_waits_summary_by_table
+ where OBJECT_SCHEMA = "test"
+ order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME;
+end
+$$
+
+delimiter ;$$
+
+
+--disable_warnings
+drop table if exists t1;
+drop table if exists t2;
+drop table if exists t3;
+--enable_warnings
+
+create table t0(v int);
+create table t1(id1 int, a int);
+create table t2(id1 int, id2 int, b int);
+create table t3(id2 int, id3 int, c int);
+
+insert into t0 values
+ (0), (1), (2), (3), (4),
+ (5), (6), (7), (8), (9);
+
+insert into t1(id1, a)
+ select v, 100*v from t0;
+
+insert into t2(id1, id2, b)
+ select X.v, 10*X.v + Y.v, 100*X.v + 10*Y.v
+ from t0 X, t0 Y;
+
+insert into t3(id2, id3, c)
+ select 10*X.v + Y.v, 100*X.v + 10*Y.v + Z.v, 100*X.v + 10*Y.v + Z.v
+ from t0 X, t0 Y, t0 Z;
+
+analyze table t1;
+analyze table t2;
+analyze table t3;
+
+select * from t1 order by a;
+
+# Only dump a small part
+select * from t2
+ where (b >= 180) and (b <= 220)
+ order by b;
+
+# Only dump a small part
+select * from t3
+ where (c >= 587) and (c <= 612)
+ order by c;
+
+#
+# TEST 1 (join, no index)
+#
+
+explain extended select t1.*, t2.*, t3.*
+ from t1 join t2 using (id1) join t3 using (id2);
+
+call before_payload();
+
+# Payload query to analyse: should do batch io on t3
+
+--disable_ps2_protocol
+--disable_result_log
+select t1.*, t2.*, t3.*
+ from t1 join t2 using (id1) join t3 using (id2);
+--enable_result_log
+--enable_ps2_protocol
+
+call after_payload();
+
+#
+# TEST 2 (join, with index)
+#
+
+alter table t1 add unique index(id1);
+alter table t2 add unique index(id2);
+alter table t2 add index(id1);
+alter table t3 add unique index(id3);
+alter table t3 add index(id2);
+
+explain extended select t1.*, t2.*, t3.*
+ from t1 join t2 using (id1) join t3 using (id2);
+
+call before_payload();
+
+# Payload query to analyse: should do batch io on t3
+
+--disable_ps2_protocol
+--disable_result_log
+select t1.*, t2.*, t3.*
+ from t1 join t2 using (id1) join t3 using (id2);
+--enable_result_log
+--enable_ps2_protocol
+
+call after_payload();
+
+# Cleanup
+
+drop table t0;
+drop table t1;
+drop table t2;
+drop table t3;
+
+drop procedure before_payload;
+drop procedure after_payload;
+
+UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES';
+
diff --git a/mysql-test/suite/perfschema/t/binlog_edge_mix-master.opt b/mysql-test/suite/perfschema/t/binlog_edge_mix-master.opt
new file mode 100644
index 00000000..824b8885
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/binlog_edge_mix-master.opt
@@ -0,0 +1,2 @@
+--log-bin
+--binlog-ignore-db=my_local_db
diff --git a/mysql-test/suite/perfschema/t/binlog_edge_mix.test b/mysql-test/suite/perfschema/t/binlog_edge_mix.test
new file mode 100644
index 00000000..da6a6290
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/binlog_edge_mix.test
@@ -0,0 +1,10 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/have_log_bin.inc
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+set binlog_format=mixed;
+
+--source ../include/binlog_edge_common.inc
+
diff --git a/mysql-test/suite/perfschema/t/binlog_edge_row-master.opt b/mysql-test/suite/perfschema/t/binlog_edge_row-master.opt
new file mode 100644
index 00000000..824b8885
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/binlog_edge_row-master.opt
@@ -0,0 +1,2 @@
+--log-bin
+--binlog-ignore-db=my_local_db
diff --git a/mysql-test/suite/perfschema/t/binlog_edge_row.test b/mysql-test/suite/perfschema/t/binlog_edge_row.test
new file mode 100644
index 00000000..2931aa83
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/binlog_edge_row.test
@@ -0,0 +1,10 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/have_log_bin.inc
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+set binlog_format=row;
+
+--source ../include/binlog_edge_common.inc
+
diff --git a/mysql-test/suite/perfschema/t/binlog_edge_stmt-master.opt b/mysql-test/suite/perfschema/t/binlog_edge_stmt-master.opt
new file mode 100644
index 00000000..824b8885
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/binlog_edge_stmt-master.opt
@@ -0,0 +1,2 @@
+--log-bin
+--binlog-ignore-db=my_local_db
diff --git a/mysql-test/suite/perfschema/t/binlog_edge_stmt.test b/mysql-test/suite/perfschema/t/binlog_edge_stmt.test
new file mode 100644
index 00000000..33bf2447
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/binlog_edge_stmt.test
@@ -0,0 +1,10 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/have_log_bin.inc
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+set binlog_format=statement;
+
+--source ../include/binlog_edge_common.inc
+
diff --git a/mysql-test/suite/perfschema/t/binlog_mix.test b/mysql-test/suite/perfschema/t/binlog_mix.test
new file mode 100644
index 00000000..ec2a6847
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/binlog_mix.test
@@ -0,0 +1,10 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/have_log_bin.inc
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+set binlog_format=mixed;
+
+--source ../include/binlog_common.inc
+
diff --git a/mysql-test/suite/perfschema/t/binlog_ok_mix-master.opt b/mysql-test/suite/perfschema/t/binlog_ok_mix-master.opt
new file mode 100644
index 00000000..824b8885
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/binlog_ok_mix-master.opt
@@ -0,0 +1,2 @@
+--log-bin
+--binlog-ignore-db=my_local_db
diff --git a/mysql-test/suite/perfschema/t/binlog_ok_mix.test b/mysql-test/suite/perfschema/t/binlog_ok_mix.test
new file mode 100644
index 00000000..8020814a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/binlog_ok_mix.test
@@ -0,0 +1,10 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/have_log_bin.inc
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+set binlog_format=mixed;
+
+--source ../include/binlog_ok_common.inc
+
diff --git a/mysql-test/suite/perfschema/t/binlog_ok_row-master.opt b/mysql-test/suite/perfschema/t/binlog_ok_row-master.opt
new file mode 100644
index 00000000..824b8885
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/binlog_ok_row-master.opt
@@ -0,0 +1,2 @@
+--log-bin
+--binlog-ignore-db=my_local_db
diff --git a/mysql-test/suite/perfschema/t/binlog_ok_row.test b/mysql-test/suite/perfschema/t/binlog_ok_row.test
new file mode 100644
index 00000000..ad95cc8f
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/binlog_ok_row.test
@@ -0,0 +1,10 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/have_log_bin.inc
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+set binlog_format=row;
+
+--source ../include/binlog_ok_common.inc
+
diff --git a/mysql-test/suite/perfschema/t/binlog_ok_stmt-master.opt b/mysql-test/suite/perfschema/t/binlog_ok_stmt-master.opt
new file mode 100644
index 00000000..824b8885
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/binlog_ok_stmt-master.opt
@@ -0,0 +1,2 @@
+--log-bin
+--binlog-ignore-db=my_local_db
diff --git a/mysql-test/suite/perfschema/t/binlog_ok_stmt.test b/mysql-test/suite/perfschema/t/binlog_ok_stmt.test
new file mode 100644
index 00000000..d6f4d452
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/binlog_ok_stmt.test
@@ -0,0 +1,10 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/have_log_bin.inc
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+set binlog_format=statement;
+
+--source ../include/binlog_ok_common.inc
+
diff --git a/mysql-test/suite/perfschema/t/binlog_row.test b/mysql-test/suite/perfschema/t/binlog_row.test
new file mode 100644
index 00000000..825da373
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/binlog_row.test
@@ -0,0 +1,10 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/have_log_bin.inc
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+set binlog_format=row;
+
+--source ../include/binlog_common.inc
+
diff --git a/mysql-test/suite/perfschema/t/binlog_stmt.test b/mysql-test/suite/perfschema/t/binlog_stmt.test
new file mode 100644
index 00000000..463bba0e
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/binlog_stmt.test
@@ -0,0 +1,11 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/have_log_bin.inc
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+set binlog_format=statement;
+call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
+
+--source ../include/binlog_common.inc
+
diff --git a/mysql-test/suite/perfschema/t/checksum.test b/mysql-test/suite/perfschema/t/checksum.test
new file mode 100644
index 00000000..a2d43b27
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/checksum.test
@@ -0,0 +1,121 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+#
+# The checksum value itself is random (data is volatile),
+# just testing that this does not crash
+#
+--disable_result_log
+
+checksum table performance_schema.accounts;
+checksum table performance_schema.cond_instances;
+checksum table performance_schema.events_stages_current;
+checksum table performance_schema.events_stages_history;
+checksum table performance_schema.events_stages_history_long;
+checksum table performance_schema.events_stages_summary_by_account_by_event_name;
+checksum table performance_schema.events_stages_summary_by_host_by_event_name;
+checksum table performance_schema.events_stages_summary_by_thread_by_event_name;
+checksum table performance_schema.events_stages_summary_by_user_by_event_name;
+checksum table performance_schema.events_stages_summary_global_by_event_name;
+checksum table performance_schema.events_statements_current;
+checksum table performance_schema.events_statements_history;
+checksum table performance_schema.events_statements_history_long;
+checksum table performance_schema.events_statements_summary_by_account_by_event_name;
+checksum table performance_schema.events_statements_summary_by_host_by_event_name;
+checksum table performance_schema.events_statements_summary_by_thread_by_event_name;
+checksum table performance_schema.events_statements_summary_by_user_by_event_name;
+checksum table performance_schema.events_statements_summary_global_by_event_name;
+checksum table performance_schema.events_transactions_current;
+checksum table performance_schema.events_transactions_history;
+checksum table performance_schema.events_transactions_history_long;
+checksum table performance_schema.events_transactions_summary_by_account_by_event_name;
+checksum table performance_schema.events_transactions_summary_by_host_by_event_name;
+checksum table performance_schema.events_transactions_summary_by_thread_by_event_name;
+checksum table performance_schema.events_transactions_summary_by_user_by_event_name;
+checksum table performance_schema.events_transactions_summary_global_by_event_name;
+checksum table performance_schema.events_waits_current;
+checksum table performance_schema.events_waits_history;
+checksum table performance_schema.events_waits_history_long;
+checksum table performance_schema.events_waits_summary_by_account_by_event_name;
+checksum table performance_schema.events_waits_summary_by_host_by_event_name;
+checksum table performance_schema.events_waits_summary_by_instance;
+checksum table performance_schema.events_waits_summary_by_thread_by_event_name;
+checksum table performance_schema.events_waits_summary_by_user_by_event_name;
+checksum table performance_schema.events_waits_summary_global_by_event_name;
+checksum table performance_schema.file_instances;
+checksum table performance_schema.file_summary_by_event_name;
+checksum table performance_schema.file_summary_by_instance;
+checksum table performance_schema.hosts;
+checksum table performance_schema.mutex_instances;
+checksum table performance_schema.objects_summary_global_by_type;
+checksum table performance_schema.performance_timers;
+checksum table performance_schema.rwlock_instances;
+checksum table performance_schema.setup_actors;
+checksum table performance_schema.setup_consumers;
+checksum table performance_schema.setup_instruments;
+checksum table performance_schema.setup_objects;
+checksum table performance_schema.setup_timers;
+checksum table performance_schema.table_io_waits_summary_by_index_usage;
+checksum table performance_schema.table_io_waits_summary_by_table;
+checksum table performance_schema.table_lock_waits_summary_by_table;
+checksum table performance_schema.threads;
+checksum table performance_schema.users;
+
+checksum table performance_schema.accounts extended;
+checksum table performance_schema.cond_instances extended;
+checksum table performance_schema.events_stages_current extended;
+checksum table performance_schema.events_stages_history extended;
+checksum table performance_schema.events_stages_history_long extended;
+checksum table performance_schema.events_stages_summary_by_account_by_event_name extended;
+checksum table performance_schema.events_stages_summary_by_host_by_event_name extended;
+checksum table performance_schema.events_stages_summary_by_thread_by_event_name extended;
+checksum table performance_schema.events_stages_summary_by_user_by_event_name extended;
+checksum table performance_schema.events_stages_summary_global_by_event_name extended;
+checksum table performance_schema.events_statements_current extended;
+checksum table performance_schema.events_statements_history extended;
+checksum table performance_schema.events_statements_history_long extended;
+checksum table performance_schema.events_statements_summary_by_account_by_event_name extended;
+checksum table performance_schema.events_statements_summary_by_host_by_event_name extended;
+checksum table performance_schema.events_statements_summary_by_thread_by_event_name extended;
+checksum table performance_schema.events_statements_summary_by_user_by_event_name extended;
+checksum table performance_schema.events_statements_summary_global_by_event_name extended;
+checksum table performance_schema.events_transactions_current extended;
+checksum table performance_schema.events_transactions_history extended;
+checksum table performance_schema.events_transactions_history_long extended;
+checksum table performance_schema.events_transactions_summary_by_account_by_event_name extended;
+checksum table performance_schema.events_transactions_summary_by_host_by_event_name extended;
+checksum table performance_schema.events_transactions_summary_by_thread_by_event_name extended;
+checksum table performance_schema.events_transactions_summary_by_user_by_event_name extended;
+checksum table performance_schema.events_transactions_summary_global_by_event_name extended;
+checksum table performance_schema.events_waits_current extended;
+checksum table performance_schema.events_waits_history extended;
+checksum table performance_schema.events_waits_history_long extended;
+checksum table performance_schema.events_waits_summary_by_account_by_event_name extended;
+checksum table performance_schema.events_waits_summary_by_host_by_event_name extended;
+checksum table performance_schema.events_waits_summary_by_instance extended;
+checksum table performance_schema.events_waits_summary_by_thread_by_event_name extended;
+checksum table performance_schema.events_waits_summary_by_user_by_event_name extended;
+checksum table performance_schema.events_waits_summary_global_by_event_name extended;
+checksum table performance_schema.file_instances extended;
+checksum table performance_schema.file_summary_by_event_name extended;
+checksum table performance_schema.file_summary_by_instance extended;
+checksum table performance_schema.hosts extended;
+checksum table performance_schema.mutex_instances extended;
+checksum table performance_schema.objects_summary_global_by_type extended;
+checksum table performance_schema.performance_timers extended;
+checksum table performance_schema.rwlock_instances extended;
+checksum table performance_schema.setup_actors extended;
+checksum table performance_schema.setup_consumers extended;
+checksum table performance_schema.setup_instruments extended;
+checksum table performance_schema.setup_objects extended;
+checksum table performance_schema.setup_timers extended;
+checksum table performance_schema.table_io_waits_summary_by_index_usage extended;
+checksum table performance_schema.table_io_waits_summary_by_table extended;
+checksum table performance_schema.table_lock_waits_summary_by_table extended;
+checksum table performance_schema.threads extended;
+checksum table performance_schema.users extended;
+
+--enable_result_log
+
diff --git a/mysql-test/suite/perfschema/t/cnf_option.cnf b/mysql-test/suite/perfschema/t/cnf_option.cnf
new file mode 100644
index 00000000..d2459323
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/cnf_option.cnf
@@ -0,0 +1,10 @@
+# Tests for PERFORMANCE_SCHEMA
+# Check server start options, read from a .cnf file
+
+# Use default setting for mysqld processes
+!include include/default_mysqld.cnf
+
+[mysqld.1]
+loose-performance-schema-max-thread_instances=318
+loose-performance-schema-max-thread_classes=12
+
diff --git a/mysql-test/suite/perfschema/t/cnf_option.test b/mysql-test/suite/perfschema/t/cnf_option.test
new file mode 100644
index 00000000..04140310
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/cnf_option.test
@@ -0,0 +1,9 @@
+# Tests for PERFORMANCE_SCHEMA
+# Check server start options, read from a .cnf file
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+show global variables like 'performance_schema_max_thread_classes';
+show global variables like 'performance_schema_max_thread_instances';
+
diff --git a/mysql-test/suite/perfschema/t/column_privilege.test b/mysql-test/suite/perfschema/t/column_privilege.test
new file mode 100644
index 00000000..004492c6
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/column_privilege.test
@@ -0,0 +1,62 @@
+# Tests for PERFORMANCE_SCHEMA
+# Test how columns privileges can be used on performance schema tables,
+# for very fine control.
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+show grants;
+
+create user 'pfs_user_5'@localhost;
+grant usage on *.* to 'pfs_user_5'@localhost with GRANT OPTION;
+
+# Test per column privileges on performance_schema
+
+grant SELECT(thread_id, event_id) on performance_schema.events_waits_current
+ to 'pfs_user_5'@localhost;
+
+grant UPDATE(enabled) on performance_schema.setup_instruments
+ to 'pfs_user_5'@localhost;
+
+flush privileges;
+
+connect (con1, localhost, pfs_user_5, , );
+
+# Commented because the result is not consistent (uppercase/lowercase)
+# show grants;
+
+# For statements that works, we do not look at the output
+--disable_result_log
+
+select thread_id from performance_schema.events_waits_current;
+
+select thread_id, event_id from performance_schema.events_waits_current;
+
+update performance_schema.setup_instruments set enabled='YES';
+
+--enable_result_log
+
+# For statements that are denied, check the error number and error text.
+
+--error ER_COLUMNACCESS_DENIED_ERROR
+select event_name from performance_schema.events_waits_current;
+
+--error ER_COLUMNACCESS_DENIED_ERROR
+select thread_id, event_id, event_name
+ from performance_schema.events_waits_current;
+
+--error ER_COLUMNACCESS_DENIED_ERROR
+update performance_schema.setup_instruments set name='illegal';
+
+--error ER_COLUMNACCESS_DENIED_ERROR
+update performance_schema.setup_instruments set timed='NO';
+
+# Cleanup
+
+--connection default
+--disconnect con1
+REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'pfs_user_5'@localhost;
+DROP USER 'pfs_user_5'@localhost;
+flush privileges;
+UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES';
+
diff --git a/mysql-test/suite/perfschema/t/connect_attrs.test b/mysql-test/suite/perfschema/t/connect_attrs.test
new file mode 100644
index 00000000..2d2c2ce2
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/connect_attrs.test
@@ -0,0 +1,83 @@
+# Session connect attributes test
+--source include/have_perfschema.inc
+
+# although the connection attributes transfer code works
+# with embedded P_S is not active, so the test won't run.
+# TODO: remove this when P_S works with embedded.
+--source include/not_embedded.inc
+
+# make sure we're alone
+let $count_sessions= 1;
+--source include/wait_until_count_sessions.inc
+
+# basic performance_schema.session_connect_attrs tests
+
+# check the presense of the pre-defined attributes
+--echo # must return 0, 6
+SELECT SUM(ISNULL(ATTR_VALUE)), COUNT(*)
+ FROM performance_schema.session_connect_attrs
+ WHERE ATTR_NAME IN ('_os', '_client_name', '_pid',
+ '_client_version', '_platform', 'program_name')
+ AND PROCESSLIST_ID = CONNECTION_ID();
+
+# check the presense of the pre-defined attributes
+--echo # must return 1
+SELECT COUNT(DISTINCT PROCESSLIST_ID)
+ FROM performance_schema.session_connect_attrs;
+
+
+# basic performance_schema.session_account_connect_attrs tests
+
+# check the presense of the pre-defined attributes
+--echo # must return 0, 6
+SELECT SUM(ISNULL(ATTR_VALUE)), COUNT(*)
+ FROM performance_schema.session_account_connect_attrs
+ WHERE ATTR_NAME IN ('_os', '_client_name', '_pid',
+ '_client_version', '_platform', 'program_name')
+ AND PROCESSLIST_ID = CONNECTION_ID();
+
+# check the presense of the pre-defined attributes
+--echo # must return 1
+SELECT COUNT(DISTINCT PROCESSLIST_ID)
+ FROM performance_schema.session_account_connect_attrs;
+
+
+
+CREATE USER wl5924@localhost;
+
+connect(non_privileged_user,localhost,wl5924,,"*NO-ONE*");
+connection default;
+
+--echo # must return 1
+SELECT COUNT(DISTINCT PROCESSLIST_ID)
+ FROM performance_schema.session_account_connect_attrs;
+
+--echo # must return 2
+SELECT COUNT(DISTINCT PROCESSLIST_ID)
+ FROM performance_schema.session_connect_attrs;
+
+connection non_privileged_user;
+--echo # must return 1
+SELECT COUNT(DISTINCT PROCESSLIST_ID)
+ FROM performance_schema.session_account_connect_attrs;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+SELECT COUNT(DISTINCT PROCESSLIST_ID)
+ FROM performance_schema.session_connect_attrs;
+
+connection default;
+disconnect non_privileged_user;
+
+grant select on performance_schema.* to wl5924@localhost;
+change_user wl5924;
+SELECT SUM(ISNULL(ATTR_VALUE)), COUNT(*)
+ FROM performance_schema.session_account_connect_attrs
+ WHERE ATTR_NAME IN ('_os', '_client_name', '_pid',
+ '_client_version', '_platform', 'program_name')
+ AND PROCESSLIST_ID = CONNECTION_ID();
+change_user root,,test;
+
+DROP USER wl5924@localhost;
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/suite/perfschema/t/connection.test b/mysql-test/suite/perfschema/t/connection.test
new file mode 100644
index 00000000..1ca0ce2f
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/connection.test
@@ -0,0 +1,7 @@
+# Tests for the performance schema
+#
+
+--source ../include/connection_setup.inc
+--source ../include/connection_load.inc
+--source ../include/connection_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/connection_3a-master.opt b/mysql-test/suite/perfschema/t/connection_3a-master.opt
new file mode 100644
index 00000000..315f0f27
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/connection_3a-master.opt
@@ -0,0 +1 @@
+--loose-performance_schema_accounts_size=3
diff --git a/mysql-test/suite/perfschema/t/connection_3a.test b/mysql-test/suite/perfschema/t/connection_3a.test
new file mode 100644
index 00000000..1ca0ce2f
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/connection_3a.test
@@ -0,0 +1,7 @@
+# Tests for the performance schema
+#
+
+--source ../include/connection_setup.inc
+--source ../include/connection_load.inc
+--source ../include/connection_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/connection_3a_3u-master.opt b/mysql-test/suite/perfschema/t/connection_3a_3u-master.opt
new file mode 100644
index 00000000..945dc5a0
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/connection_3a_3u-master.opt
@@ -0,0 +1,2 @@
+--loose-performance_schema_accounts_size=3
+--loose-performance_schema_users_size=3
diff --git a/mysql-test/suite/perfschema/t/connection_3a_3u.test b/mysql-test/suite/perfschema/t/connection_3a_3u.test
new file mode 100644
index 00000000..1ca0ce2f
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/connection_3a_3u.test
@@ -0,0 +1,7 @@
+# Tests for the performance schema
+#
+
+--source ../include/connection_setup.inc
+--source ../include/connection_load.inc
+--source ../include/connection_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/connection_3u-master.opt b/mysql-test/suite/perfschema/t/connection_3u-master.opt
new file mode 100644
index 00000000..ac3ef727
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/connection_3u-master.opt
@@ -0,0 +1 @@
+--loose-performance_schema_users_size=3
diff --git a/mysql-test/suite/perfschema/t/connection_3u.test b/mysql-test/suite/perfschema/t/connection_3u.test
new file mode 100644
index 00000000..1ca0ce2f
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/connection_3u.test
@@ -0,0 +1,7 @@
+# Tests for the performance schema
+#
+
+--source ../include/connection_setup.inc
+--source ../include/connection_load.inc
+--source ../include/connection_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/connection_type_notwin.test b/mysql-test/suite/perfschema/t/connection_type_notwin.test
new file mode 100644
index 00000000..bb96d690
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/connection_type_notwin.test
@@ -0,0 +1,92 @@
+
+--source include/not_windows.inc
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/have_perfschema.inc
+
+--echo # Default connection
+
+--vertical_results
+select NAME, PROCESSLIST_USER, PROCESSLIST_HOST, CONNECTION_TYPE
+ from performance_schema.threads
+ where PROCESSLIST_ID = connection_id();
+
+create user 'root'@'santa.claus.ipv4.example.com';
+grant select on *.* to 'root'@'santa.claus.ipv4.example.com';
+create user 'rootssl'@'santa.claus.ipv4.example.com'
+ require SSL;
+grant select on *.* to 'rootssl'@'santa.claus.ipv4.example.com';
+
+set @old_dbug=@@global.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_fake_good_ipv4";
+
+# Setup
+# make sure we start with a clean slate. log_tables.test says this is OK.
+TRUNCATE TABLE mysql.general_log;
+
+SET @old_log_output= @@global.log_output;
+SET @old_general_log= @@global.general_log;
+SET @old_general_log_file= @@global.general_log_file;
+
+--replace_result $MYSQLTEST_VARDIR ...
+eval SET GLOBAL general_log_file = '$MYSQLTEST_VARDIR/log/rewrite_general_con.log';
+SET GLOBAL log_output = 'FILE,TABLE';
+SET GLOBAL general_log= 'ON';
+
+connect(con1, localhost, root,,test);
+
+select NAME, PROCESSLIST_USER, PROCESSLIST_HOST, CONNECTION_TYPE
+ from performance_schema.threads
+ where PROCESSLIST_ID = connection_id();
+
+--disconnect con1
+
+connect(con2, "127.0.0.1", root,,test,$MASTER_MYPORT,);
+
+select NAME, PROCESSLIST_USER, PROCESSLIST_HOST, CONNECTION_TYPE
+ from performance_schema.threads
+ where PROCESSLIST_ID = connection_id();
+
+--disconnect con2
+
+connect(con3, "127.0.0.1", rootssl,,test,$MASTER_MYPORT,,SSL);
+
+select NAME, PROCESSLIST_USER, PROCESSLIST_HOST, CONNECTION_TYPE
+ from performance_schema.threads
+ where PROCESSLIST_ID = connection_id();
+
+--disconnect con3
+
+--connection default
+
+SET GLOBAL general_log= 'OFF';
+
+# show general-logging to file is correct
+CREATE TABLE test_log (argument TEXT);
+--replace_result $MYSQLTEST_VARDIR ...
+eval LOAD DATA LOCAL INFILE '$MYSQLTEST_VARDIR/log/rewrite_general_con.log'
+ INTO TABLE test_log FIELDS TERMINATED BY '\n' LINES TERMINATED BY '\n';
+
+select user_host, command_type, argument from mysql.general_log
+ where command_type = "Connect";
+
+select substring(argument, locate("Connect", argument)) from test_log
+ where argument like "%Connect%on test%";
+
+
+DROP TABLE test_log;
+
+--remove_file $MYSQLTEST_VARDIR/log/rewrite_general_con.log
+
+SET GLOBAL general_log_file= @old_general_log_file;
+SET GLOBAL general_log= @old_general_log;
+SET GLOBAL log_output= @old_log_output;
+
+--horizontal_results
+
+set global debug_dbug= @old_dbug;
+revoke select on *.* from 'root'@'santa.claus.ipv4.example.com';
+drop user 'root'@'santa.claus.ipv4.example.com';
+revoke select on *.* from 'rootssl'@'santa.claus.ipv4.example.com';
+drop user 'rootssl'@'santa.claus.ipv4.example.com';
+
diff --git a/mysql-test/suite/perfschema/t/connection_type_win.test b/mysql-test/suite/perfschema/t/connection_type_win.test
new file mode 100644
index 00000000..2beccdbc
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/connection_type_win.test
@@ -0,0 +1,90 @@
+
+--source include/windows.inc
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/have_perfschema.inc
+
+--echo # Default connection
+
+--vertical_results
+select NAME, PROCESSLIST_USER, PROCESSLIST_HOST, CONNECTION_TYPE
+ from performance_schema.threads
+ where PROCESSLIST_ID = connection_id();
+
+create user 'root'@'santa.claus.ipv4.example.com';
+grant select on *.* to 'root'@'santa.claus.ipv4.example.com';
+create user 'rootssl'@'santa.claus.ipv4.example.com'
+ require SSL;
+grant select on *.* to 'rootssl'@'santa.claus.ipv4.example.com';
+
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_fake_good_ipv4";
+
+# Setup
+# make sure we start with a clean slate. log_tables.test says this is OK.
+TRUNCATE TABLE mysql.general_log;
+
+SET @old_log_output= @@global.log_output;
+SET @old_general_log= @@global.general_log;
+SET @old_general_log_file= @@global.general_log_file;
+
+--replace_result $MYSQLTEST_VARDIR ...
+eval SET GLOBAL general_log_file = '$MYSQLTEST_VARDIR/log/rewrite_general_con.log';
+SET GLOBAL log_output = 'FILE,TABLE';
+SET GLOBAL general_log= 'ON';
+
+connect(con1, localhost, root,,);
+
+select NAME, PROCESSLIST_USER, PROCESSLIST_HOST, CONNECTION_TYPE
+ from performance_schema.threads
+ where PROCESSLIST_ID = connection_id();
+
+--disconnect con1
+
+connect(con2, "127.0.0.1", root,,test,$MASTER_MYPORT,);
+
+select NAME, PROCESSLIST_USER, PROCESSLIST_HOST, CONNECTION_TYPE
+ from performance_schema.threads
+ where PROCESSLIST_ID = connection_id();
+
+--disconnect con2
+
+connect(con3, "127.0.0.1", rootssl,,test,$MASTER_MYPORT,,SSL);
+
+select NAME, PROCESSLIST_USER, PROCESSLIST_HOST, CONNECTION_TYPE
+ from performance_schema.threads
+ where PROCESSLIST_ID = connection_id();
+
+--disconnect con3
+
+--connection default
+
+SET GLOBAL general_log= 'OFF';
+
+# show general-logging to file is correct
+CREATE TABLE test_log (argument TEXT);
+--replace_result $MYSQLTEST_VARDIR ...
+eval LOAD DATA LOCAL INFILE '$MYSQLTEST_VARDIR/log/rewrite_general_con.log'
+ INTO TABLE test_log FIELDS TERMINATED BY '\n' LINES TERMINATED BY '\n';
+
+select user_host, command_type, argument from mysql.general_log
+ where command_type = "Connect";
+
+select substring(argument, locate("Connect", argument)) from test_log
+ where argument like "%Connect%on test%";
+
+
+DROP TABLE test_log;
+
+--remove_file $MYSQLTEST_VARDIR/log/rewrite_general_con.log
+
+SET GLOBAL general_log_file= @old_general_log_file;
+SET GLOBAL general_log= @old_general_log;
+SET GLOBAL log_output= @old_log_output;
+
+--horizontal_results
+
+set global debug_dbug= default;
+revoke select on *.* from 'root'@'santa.claus.ipv4.example.com';
+drop user 'root'@'santa.claus.ipv4.example.com';
+revoke select on *.* from 'rootssl'@'santa.claus.ipv4.example.com';
+drop user 'rootssl'@'santa.claus.ipv4.example.com';
diff --git a/mysql-test/suite/perfschema/t/csv_table_io.test b/mysql-test/suite/perfschema/t/csv_table_io.test
new file mode 100644
index 00000000..862b488c
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/csv_table_io.test
@@ -0,0 +1,28 @@
+# Tests for PERFORMANCE_SCHEMA table io
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source ../include/table_io_setup_helper.inc
+
+let $engine_type= CSV;
+let $table_item= test.no_index_tab;
+--disable_warnings
+eval drop table if exists $table_item;
+--enable_warnings
+
+# Start recording events
+update performance_schema.setup_consumers set enabled='YES';
+insert into marker set a = 1;
+eval create table $table_item
+( a varchar(255) not null, b int not null) engine = $engine_type;
+insert into marker set a = 1;
+eval show create table $table_item;
+--source ../include/table_io_basic_dml.inc
+eval drop table $table_item;
+
+# Stop recording events + pull result
+--source ../include/table_io_result_helper.inc
+
+# Cleanup
+--source ../include/table_io_cleanup_helper.inc
+
diff --git a/mysql-test/suite/perfschema/t/ddl_accounts.test b/mysql-test/suite/perfschema/t/ddl_accounts.test
new file mode 100644
index 00000000..c29553b2
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_accounts.test
@@ -0,0 +1,17 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.accounts
+ add column foo integer;
+
+truncate table performance_schema.accounts;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.accounts ADD INDEX test_index(CURRENT_CONNECTIONS);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.accounts(CURRENT_CONNECTIONS);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_cond_instances.test b/mysql-test/suite/perfschema/t/ddl_cond_instances.test
new file mode 100644
index 00000000..11c86a0b
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_cond_instances.test
@@ -0,0 +1,17 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.cond_instances add column foo integer;
+
+-- error ER_WRONG_PERFSCHEMA_USAGE
+truncate table performance_schema.cond_instances;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.cond_instances ADD INDEX test_index(NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.cond_instances(NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_esgs_by_account_by_event_name.test b/mysql-test/suite/perfschema/t/ddl_esgs_by_account_by_event_name.test
new file mode 100644
index 00000000..da15335d
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_esgs_by_account_by_event_name.test
@@ -0,0 +1,19 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_stages_summary_by_account_by_event_name
+ add column foo integer;
+
+truncate table performance_schema.events_stages_summary_by_account_by_event_name;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_stages_summary_by_account_by_event_name
+ ADD INDEX test_index(USERNAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.events_stages_summary_by_account_by_event_name(USERNAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_esgs_by_host_by_event_name.test b/mysql-test/suite/perfschema/t/ddl_esgs_by_host_by_event_name.test
new file mode 100644
index 00000000..b6c90ab4
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_esgs_by_host_by_event_name.test
@@ -0,0 +1,19 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_stages_summary_by_host_by_event_name
+ add column foo integer;
+
+truncate table performance_schema.events_stages_summary_by_host_by_event_name;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_stages_summary_by_host_by_event_name
+ ADD INDEX test_index(HOSTNAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.events_stages_summary_by_host_by_event_name(HOSTNAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_esgs_by_thread_by_event_name.test b/mysql-test/suite/perfschema/t/ddl_esgs_by_thread_by_event_name.test
new file mode 100644
index 00000000..87d90d5e
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_esgs_by_thread_by_event_name.test
@@ -0,0 +1,18 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_stages_summary_by_thread_by_event_name
+ add column foo integer;
+
+truncate table performance_schema.events_stages_summary_by_thread_by_event_name;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_stages_summary_by_thread_by_event_name ADD INDEX test_index(THREAD_ID);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.events_stages_summary_by_thread_by_event_name(THREAD_ID);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_esgs_by_user_by_event_name.test b/mysql-test/suite/perfschema/t/ddl_esgs_by_user_by_event_name.test
new file mode 100644
index 00000000..81503c5a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_esgs_by_user_by_event_name.test
@@ -0,0 +1,19 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_stages_summary_by_user_by_event_name
+ add column foo integer;
+
+truncate table performance_schema.events_stages_summary_by_user_by_event_name;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_stages_summary_by_user_by_event_name
+ ADD INDEX test_index(USERNAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.events_stages_summary_by_user_by_event_name(USERNAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_esgs_global_by_event_name.test b/mysql-test/suite/perfschema/t/ddl_esgs_global_by_event_name.test
new file mode 100644
index 00000000..60a74064
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_esgs_global_by_event_name.test
@@ -0,0 +1,19 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_stages_summary_global_by_event_name
+ add column foo integer;
+
+truncate table performance_schema.events_stages_summary_global_by_event_name;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_stages_summary_global_by_event_name
+ ADD INDEX test_index(EVENT_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.events_stages_summary_global_by_event_name(EVENT_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_esms_by_account_by_event_name.test b/mysql-test/suite/perfschema/t/ddl_esms_by_account_by_event_name.test
new file mode 100644
index 00000000..02c508e9
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_esms_by_account_by_event_name.test
@@ -0,0 +1,19 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_statements_summary_by_account_by_event_name
+ add column foo integer;
+
+truncate table performance_schema.events_statements_summary_by_account_by_event_name;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_statements_summary_by_account_by_event_name
+ ADD INDEX test_index(USERNAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.events_statements_summary_by_account_by_event_name(USERNAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_esms_by_digest.test b/mysql-test/suite/perfschema/t/ddl_esms_by_digest.test
new file mode 100644
index 00000000..9cf1775c
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_esms_by_digest.test
@@ -0,0 +1,40 @@
+# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License, version 2.0,
+# as published by the Free Software Foundation.
+#
+# This program is also distributed with certain software (including
+# but not limited to OpenSSL) that is licensed under separate terms,
+# as designated in a particular file or component or in included license
+# documentation. The authors of MySQL hereby grant you an additional
+# permission to link the program and your derivative works with the
+# separately licensed software that they have included with MySQL.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License, version 2.0, for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
+
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_statements_summary_by_digest
+ add column foo integer;
+
+truncate table performance_schema.events_statements_summary_by_digest;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_statements_summary_by_digest ADD INDEX test_index(DIGEST);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.events_statements_summary_by_digest(DIGEST);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_esms_by_host_by_event_name.test b/mysql-test/suite/perfschema/t/ddl_esms_by_host_by_event_name.test
new file mode 100644
index 00000000..9ff84018
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_esms_by_host_by_event_name.test
@@ -0,0 +1,19 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_statements_summary_by_host_by_event_name
+ add column foo integer;
+
+truncate table performance_schema.events_statements_summary_by_host_by_event_name;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_statements_summary_by_host_by_event_name
+ ADD INDEX test_index(HOSTNAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.events_statements_summary_by_host_by_event_name(HOSTNAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_esms_by_program.test b/mysql-test/suite/perfschema/t/ddl_esms_by_program.test
new file mode 100644
index 00000000..ba24da5e
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_esms_by_program.test
@@ -0,0 +1,21 @@
+# This line and the line below is a temporary line for tests that do not need MyISAM in future, but need to be kept for tests that need it.
+#--source include/have_myisam.inc
+
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_statements_summary_by_program
+ add column foo integer;
+
+truncate table performance_schema.events_statements_summary_by_program;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_statements_summary_by_program ADD INDEX test_index(OBJECT_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.events_statements_summary_by_program(OBJECT_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_esms_by_thread_by_event_name.test b/mysql-test/suite/perfschema/t/ddl_esms_by_thread_by_event_name.test
new file mode 100644
index 00000000..53775a88
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_esms_by_thread_by_event_name.test
@@ -0,0 +1,18 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_statements_summary_by_thread_by_event_name
+ add column foo integer;
+
+truncate table performance_schema.events_statements_summary_by_thread_by_event_name;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_statements_summary_by_thread_by_event_name ADD INDEX test_index(THREAD_ID);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.events_statements_summary_by_thread_by_event_name(THREAD_ID);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_esms_by_user_by_event_name.test b/mysql-test/suite/perfschema/t/ddl_esms_by_user_by_event_name.test
new file mode 100644
index 00000000..4af93537
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_esms_by_user_by_event_name.test
@@ -0,0 +1,19 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_statements_summary_by_user_by_event_name
+ add column foo integer;
+
+truncate table performance_schema.events_statements_summary_by_user_by_event_name;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_statements_summary_by_user_by_event_name
+ ADD INDEX test_index(USERNAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.events_statements_summary_by_user_by_event_name(USERNAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_esms_global_by_event_name.test b/mysql-test/suite/perfschema/t/ddl_esms_global_by_event_name.test
new file mode 100644
index 00000000..7f8e5484
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_esms_global_by_event_name.test
@@ -0,0 +1,19 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_statements_summary_global_by_event_name
+ add column foo integer;
+
+truncate table performance_schema.events_statements_summary_global_by_event_name;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_statements_summary_global_by_event_name
+ ADD INDEX test_index(EVENT_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.events_statements_summary_global_by_event_name(EVENT_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_ets_by_account_by_event_name.test b/mysql-test/suite/perfschema/t/ddl_ets_by_account_by_event_name.test
new file mode 100644
index 00000000..2ec1ddf7
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_ets_by_account_by_event_name.test
@@ -0,0 +1,19 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_transactions_summary_by_account_by_event_name
+ add column foo integer;
+
+truncate table performance_schema.events_transactions_summary_by_account_by_event_name;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_transactions_summary_by_account_by_event_name
+ ADD INDEX test_index(USERNAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.events_transactions_summary_by_account_by_event_name(USERNAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_ets_by_host_by_event_name.test b/mysql-test/suite/perfschema/t/ddl_ets_by_host_by_event_name.test
new file mode 100644
index 00000000..47ae1d19
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_ets_by_host_by_event_name.test
@@ -0,0 +1,19 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_transactions_summary_by_host_by_event_name
+ add column foo integer;
+
+truncate table performance_schema.events_transactions_summary_by_host_by_event_name;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_transactions_summary_by_host_by_event_name
+ ADD INDEX test_index(HOSTNAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.events_transactions_summary_by_host_by_event_name(HOSTNAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_ets_by_thread_by_event_name.test b/mysql-test/suite/perfschema/t/ddl_ets_by_thread_by_event_name.test
new file mode 100644
index 00000000..63cdfd89
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_ets_by_thread_by_event_name.test
@@ -0,0 +1,18 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_transactions_summary_by_thread_by_event_name
+ add column foo integer;
+
+truncate table performance_schema.events_transactions_summary_by_thread_by_event_name;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_transactions_summary_by_thread_by_event_name ADD INDEX test_index(THREAD_ID);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.events_transactions_summary_by_thread_by_event_name(THREAD_ID);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_ets_by_user_by_event_name.test b/mysql-test/suite/perfschema/t/ddl_ets_by_user_by_event_name.test
new file mode 100644
index 00000000..9a70075b
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_ets_by_user_by_event_name.test
@@ -0,0 +1,19 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_transactions_summary_by_user_by_event_name
+ add column foo integer;
+
+truncate table performance_schema.events_transactions_summary_by_user_by_event_name;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_transactions_summary_by_user_by_event_name
+ ADD INDEX test_index(USERNAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.events_transactions_summary_by_user_by_event_name(USERNAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_ets_global_by_event_name.test b/mysql-test/suite/perfschema/t/ddl_ets_global_by_event_name.test
new file mode 100644
index 00000000..5bb70245
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_ets_global_by_event_name.test
@@ -0,0 +1,19 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_transactions_summary_global_by_event_name
+ add column foo integer;
+
+truncate table performance_schema.events_transactions_summary_global_by_event_name;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_transactions_summary_global_by_event_name
+ ADD INDEX test_index(EVENT_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.events_transactions_summary_global_by_event_name(EVENT_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_events_stages_current.test b/mysql-test/suite/perfschema/t/ddl_events_stages_current.test
new file mode 100644
index 00000000..822600ce
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_events_stages_current.test
@@ -0,0 +1,21 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_stages_current add column foo integer;
+
+truncate table performance_schema.events_stages_current;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_stages_current ADD INDEX test_index(EVENT_ID);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.events_stages_current(EVENT_ID);
+
+--disable_query_log
+# Checking if the column WORK_COMPLETED and WORK_ESTIMATED exists
+select * from information_schema.columns where TABLE_NAME = 'events_stages_current' and column_name in ('WORK_COMPLETED','WORK_ESTIMATED')
+and table_schema='performance_schema';
+--enable_query_log
diff --git a/mysql-test/suite/perfschema/t/ddl_events_stages_history.test b/mysql-test/suite/perfschema/t/ddl_events_stages_history.test
new file mode 100644
index 00000000..eac2889e
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_events_stages_history.test
@@ -0,0 +1,21 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_stages_history add column foo integer;
+
+truncate table performance_schema.events_stages_history;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_stages_history ADD INDEX test_index(EVENT_ID);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.events_stages_history(EVENT_ID);
+
+--disable_query_log
+# Checking if the column WORK_COMPLETED and WORK_ESTIMATED exists
+select * from information_schema.columns where TABLE_NAME ='events_stages_history' and column_name in ('WORK_COMPLETED','WORK_ESTIMATED')
+and table_schema='performance_schema';
+--enable_query_log
diff --git a/mysql-test/suite/perfschema/t/ddl_events_stages_history_long.test b/mysql-test/suite/perfschema/t/ddl_events_stages_history_long.test
new file mode 100644
index 00000000..2bc78b12
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_events_stages_history_long.test
@@ -0,0 +1,21 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_stages_history_long add column foo integer;
+
+truncate table performance_schema.events_stages_history_long;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_stages_history_long ADD INDEX test_index(EVENT_ID);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.events_stages_history_long(EVENT_ID);
+
+--disable_query_log
+# Checking if the column WORK_COMPLETED and WORK_ESTIMATED exists
+select * from information_schema.columns where TABLE_NAME ='events_stages_history_long' and column_name in ('WORK_COMPLETED','WORK_ESTIMATED')
+and table_schema='performance_schema';
+--enable_query_log
diff --git a/mysql-test/suite/perfschema/t/ddl_events_statements_current.test b/mysql-test/suite/perfschema/t/ddl_events_statements_current.test
new file mode 100644
index 00000000..1bff6258
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_events_statements_current.test
@@ -0,0 +1,16 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_statements_current add column foo integer;
+
+truncate table performance_schema.events_statements_current;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_statements_current ADD INDEX test_index(EVENT_ID);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.events_statements_current(EVENT_ID);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_events_statements_history.test b/mysql-test/suite/perfschema/t/ddl_events_statements_history.test
new file mode 100644
index 00000000..2113fc7f
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_events_statements_history.test
@@ -0,0 +1,16 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_statements_history add column foo integer;
+
+truncate table performance_schema.events_statements_history;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_statements_history ADD INDEX test_index(EVENT_ID);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.events_statements_history(EVENT_ID);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_events_statements_history_long.test b/mysql-test/suite/perfschema/t/ddl_events_statements_history_long.test
new file mode 100644
index 00000000..6a42c957
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_events_statements_history_long.test
@@ -0,0 +1,16 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_statements_history_long add column foo integer;
+
+truncate table performance_schema.events_statements_history_long;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_statements_history_long ADD INDEX test_index(EVENT_ID);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.events_statements_history_long(EVENT_ID);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_events_transactions_current.test b/mysql-test/suite/perfschema/t/ddl_events_transactions_current.test
new file mode 100644
index 00000000..5f64e65c
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_events_transactions_current.test
@@ -0,0 +1,16 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_transactions_current add column foo integer;
+
+truncate table performance_schema.events_transactions_current;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_transactions_current ADD INDEX test_index(EVENT_ID);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.events_transactions_current(EVENT_ID);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_events_transactions_history.test b/mysql-test/suite/perfschema/t/ddl_events_transactions_history.test
new file mode 100644
index 00000000..a3b0cdde
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_events_transactions_history.test
@@ -0,0 +1,16 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_transactions_history add column foo integer;
+
+truncate table performance_schema.events_transactions_history;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_transactions_history ADD INDEX test_index(EVENT_ID);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.events_transactions_history(EVENT_ID);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_events_transactions_history_long.test b/mysql-test/suite/perfschema/t/ddl_events_transactions_history_long.test
new file mode 100644
index 00000000..1c8d6076
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_events_transactions_history_long.test
@@ -0,0 +1,16 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_transactions_history_long add column foo integer;
+
+truncate table performance_schema.events_transactions_history_long;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_transactions_history_long ADD INDEX test_index(EVENT_ID);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.events_transactions_history_long(EVENT_ID);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_events_waits_current.test b/mysql-test/suite/perfschema/t/ddl_events_waits_current.test
new file mode 100644
index 00000000..6a7a6412
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_events_waits_current.test
@@ -0,0 +1,16 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_waits_current add column foo integer;
+
+truncate table performance_schema.events_waits_current;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_waits_current ADD INDEX test_index(EVENT_ID);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.events_waits_current(EVENT_ID);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_events_waits_history.test b/mysql-test/suite/perfschema/t/ddl_events_waits_history.test
new file mode 100644
index 00000000..a731d462
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_events_waits_history.test
@@ -0,0 +1,16 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_waits_history add column foo integer;
+
+truncate table performance_schema.events_waits_history;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_waits_history ADD INDEX test_index(EVENT_ID);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.events_waits_history(EVENT_ID);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_events_waits_history_long.test b/mysql-test/suite/perfschema/t/ddl_events_waits_history_long.test
new file mode 100644
index 00000000..686f20bc
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_events_waits_history_long.test
@@ -0,0 +1,16 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_waits_history_long add column foo integer;
+
+truncate table performance_schema.events_waits_history_long;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_waits_history_long ADD INDEX test_index(EVENT_ID);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.events_waits_history_long(EVENT_ID);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_ews_by_account_by_event_name.test b/mysql-test/suite/perfschema/t/ddl_ews_by_account_by_event_name.test
new file mode 100644
index 00000000..cbca37ff
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_ews_by_account_by_event_name.test
@@ -0,0 +1,19 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_waits_summary_by_account_by_event_name
+ add column foo integer;
+
+truncate table performance_schema.events_waits_summary_by_account_by_event_name;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_waits_summary_by_account_by_event_name
+ ADD INDEX test_index(USERNAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.events_waits_summary_by_account_by_event_name(USERNAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_ews_by_host_by_event_name.test b/mysql-test/suite/perfschema/t/ddl_ews_by_host_by_event_name.test
new file mode 100644
index 00000000..5957d193
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_ews_by_host_by_event_name.test
@@ -0,0 +1,19 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_waits_summary_by_host_by_event_name
+ add column foo integer;
+
+truncate table performance_schema.events_waits_summary_by_host_by_event_name;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_waits_summary_by_host_by_event_name
+ ADD INDEX test_index(HOSTNAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.events_waits_summary_by_host_by_event_name(HOSTNAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_ews_by_instance.test b/mysql-test/suite/perfschema/t/ddl_ews_by_instance.test
new file mode 100644
index 00000000..999b1283
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_ews_by_instance.test
@@ -0,0 +1,16 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_waits_summary_by_instance add column foo integer;
+
+truncate table performance_schema.events_waits_summary_by_instance;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_waits_summary_by_instance ADD INDEX test_index(EVENT_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.events_waits_summary_by_instance(EVENT_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_ews_by_thread_by_event_name.test b/mysql-test/suite/perfschema/t/ddl_ews_by_thread_by_event_name.test
new file mode 100644
index 00000000..30782794
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_ews_by_thread_by_event_name.test
@@ -0,0 +1,18 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_waits_summary_by_thread_by_event_name
+ add column foo integer;
+
+truncate table performance_schema.events_waits_summary_by_thread_by_event_name;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_waits_summary_by_thread_by_event_name ADD INDEX test_index(THREAD_ID);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.events_waits_summary_by_thread_by_event_name(THREAD_ID);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_ews_by_user_by_event_name.test b/mysql-test/suite/perfschema/t/ddl_ews_by_user_by_event_name.test
new file mode 100644
index 00000000..47f09752
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_ews_by_user_by_event_name.test
@@ -0,0 +1,19 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_waits_summary_by_user_by_event_name
+ add column foo integer;
+
+truncate table performance_schema.events_waits_summary_by_user_by_event_name;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_waits_summary_by_user_by_event_name
+ ADD INDEX test_index(USERNAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.events_waits_summary_by_user_by_event_name(USERNAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_ews_global_by_event_name.test b/mysql-test/suite/perfschema/t/ddl_ews_global_by_event_name.test
new file mode 100644
index 00000000..09d6f34e
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_ews_global_by_event_name.test
@@ -0,0 +1,19 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.events_waits_summary_global_by_event_name
+ add column foo integer;
+
+truncate table performance_schema.events_waits_summary_global_by_event_name;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.events_waits_summary_global_by_event_name
+ ADD INDEX test_index(EVENT_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.events_waits_summary_global_by_event_name(EVENT_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_file_instances.test b/mysql-test/suite/perfschema/t/ddl_file_instances.test
new file mode 100644
index 00000000..818aeae4
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_file_instances.test
@@ -0,0 +1,17 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.file_instances add column foo integer;
+
+-- error ER_WRONG_PERFSCHEMA_USAGE
+truncate table performance_schema.file_instances;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.file_instances ADD INDEX test_index(FILE_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.file_instances(FILE_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_fs_by_event_name.test b/mysql-test/suite/perfschema/t/ddl_fs_by_event_name.test
new file mode 100644
index 00000000..d3090196
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_fs_by_event_name.test
@@ -0,0 +1,16 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.file_summary_by_event_name add column foo integer;
+
+truncate table performance_schema.file_summary_by_event_name;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.file_summary_by_event_name ADD INDEX test_index(NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.file_summary_by_event_name(NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_fs_by_instance.test b/mysql-test/suite/perfschema/t/ddl_fs_by_instance.test
new file mode 100644
index 00000000..894122aa
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_fs_by_instance.test
@@ -0,0 +1,16 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.file_summary_by_instance add column foo integer;
+
+truncate table performance_schema.file_summary_by_instance;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.file_summary_by_instance ADD INDEX test_index(NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.file_summary_by_instance(NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_global_status.test b/mysql-test/suite/perfschema/t/ddl_global_status.test
new file mode 100644
index 00000000..fe65b79a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_global_status.test
@@ -0,0 +1,19 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.global_status
+ add column foo integer;
+
+truncate table performance_schema.global_status;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.global_status
+ ADD INDEX test_index(VARIABLE_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.global_status(VARIABLE_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_global_variables.test b/mysql-test/suite/perfschema/t/ddl_global_variables.test
new file mode 100644
index 00000000..f9b66a7d
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_global_variables.test
@@ -0,0 +1,20 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.global_variables
+ add column foo integer;
+
+-- error ER_WRONG_PERFSCHEMA_USAGE
+truncate table performance_schema.global_variables;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.global_variables
+ ADD INDEX test_index(VARIABLE_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.global_variables(VARIABLE_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_host_cache.test b/mysql-test/suite/perfschema/t/ddl_host_cache.test
new file mode 100644
index 00000000..0e8d153d
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_host_cache.test
@@ -0,0 +1,16 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.host_cache add column foo integer;
+
+truncate table performance_schema.host_cache;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.host_cache ADD INDEX test_index(IP);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.host_cache(IP);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_hosts.test b/mysql-test/suite/perfschema/t/ddl_hosts.test
new file mode 100644
index 00000000..9651196c
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_hosts.test
@@ -0,0 +1,17 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.hosts
+ add column foo integer;
+
+truncate table performance_schema.hosts;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.hosts ADD INDEX test_index(CURRENT_CONNECTIONS);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.hosts(CURRENT_CONNECTIONS);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_mems_by_account_by_event_name.test b/mysql-test/suite/perfschema/t/ddl_mems_by_account_by_event_name.test
new file mode 100644
index 00000000..34d08cfe
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_mems_by_account_by_event_name.test
@@ -0,0 +1,19 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.memory_summary_by_account_by_event_name
+ add column foo integer;
+
+truncate table performance_schema.memory_summary_by_account_by_event_name;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.memory_summary_by_account_by_event_name
+ ADD INDEX test_index(USERNAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.memory_summary_by_account_by_event_name(USERNAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_mems_by_host_by_event_name.test b/mysql-test/suite/perfschema/t/ddl_mems_by_host_by_event_name.test
new file mode 100644
index 00000000..fc2e8c05
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_mems_by_host_by_event_name.test
@@ -0,0 +1,19 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.memory_summary_by_host_by_event_name
+ add column foo integer;
+
+truncate table performance_schema.memory_summary_by_host_by_event_name;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.memory_summary_by_host_by_event_name
+ ADD INDEX test_index(USERNAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.memory_summary_by_host_by_event_name(USERNAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_mems_by_thread_by_event_name.test b/mysql-test/suite/perfschema/t/ddl_mems_by_thread_by_event_name.test
new file mode 100644
index 00000000..d4fdf155
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_mems_by_thread_by_event_name.test
@@ -0,0 +1,19 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.memory_summary_by_thread_by_event_name
+ add column foo integer;
+
+truncate table performance_schema.memory_summary_by_thread_by_event_name;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.memory_summary_by_thread_by_event_name
+ ADD INDEX test_index(USERNAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.memory_summary_by_thread_by_event_name(USERNAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_mems_by_user_by_event_name.test b/mysql-test/suite/perfschema/t/ddl_mems_by_user_by_event_name.test
new file mode 100644
index 00000000..03e5cebe
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_mems_by_user_by_event_name.test
@@ -0,0 +1,19 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.memory_summary_by_user_by_event_name
+ add column foo integer;
+
+truncate table performance_schema.memory_summary_by_user_by_event_name;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.memory_summary_by_user_by_event_name
+ ADD INDEX test_index(USERNAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.memory_summary_by_user_by_event_name(USERNAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_mems_global_by_event_name.test b/mysql-test/suite/perfschema/t/ddl_mems_global_by_event_name.test
new file mode 100644
index 00000000..a2c48997
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_mems_global_by_event_name.test
@@ -0,0 +1,19 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.memory_summary_global_by_event_name
+ add column foo integer;
+
+truncate table performance_schema.memory_summary_global_by_event_name;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.memory_summary_global_by_event_name
+ ADD INDEX test_index(USERNAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.memory_summary_global_by_event_name(USERNAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_metadata_locks.test b/mysql-test/suite/perfschema/t/ddl_metadata_locks.test
new file mode 100644
index 00000000..520b8fcd
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_metadata_locks.test
@@ -0,0 +1,17 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.metadata_locks add column foo integer;
+
+-- error ER_WRONG_PERFSCHEMA_USAGE
+truncate table performance_schema.metadata_locks;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.metadata_locks ADD INDEX test_index(TIMER_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.metadata_locks(TIMER_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_mutex_instances.test b/mysql-test/suite/perfschema/t/ddl_mutex_instances.test
new file mode 100644
index 00000000..0fb21ae8
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_mutex_instances.test
@@ -0,0 +1,17 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.mutex_instances add column foo integer;
+
+-- error ER_WRONG_PERFSCHEMA_USAGE
+truncate table performance_schema.mutex_instances;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.mutex_instances ADD INDEX test_index(NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.mutex_instances(NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_os_global_by_type.test b/mysql-test/suite/perfschema/t/ddl_os_global_by_type.test
new file mode 100644
index 00000000..43c9017a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_os_global_by_type.test
@@ -0,0 +1,19 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.objects_summary_global_by_type
+ add column foo integer;
+
+truncate table performance_schema.objects_summary_global_by_type;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.objects_summary_global_by_type
+ ADD INDEX test_index(OBJECT_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.objects_summary_global_by_type(OBJECT_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_performance_timers.test b/mysql-test/suite/perfschema/t/ddl_performance_timers.test
new file mode 100644
index 00000000..32125f74
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_performance_timers.test
@@ -0,0 +1,17 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.performance_timers add column foo integer;
+
+-- error ER_WRONG_PERFSCHEMA_USAGE
+truncate table performance_schema.performance_timers;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.performance_timers ADD INDEX test_index(TIMER_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.performance_timers(TIMER_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_prepared_statements_instances.test b/mysql-test/suite/perfschema/t/ddl_prepared_statements_instances.test
new file mode 100644
index 00000000..0cba4c48
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_prepared_statements_instances.test
@@ -0,0 +1,21 @@
+# This line and the line below is a temporary line for tests that do not need MyISAM in future, but need to be kept for tests that need it.
+#--source include/have_myisam.inc
+
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.prepared_statements_instances
+ add column foo integer;
+
+truncate table performance_schema.prepared_statements_instances;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.prepared_statements_instances ADD INDEX test_index(OWNER_OBJECT_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.prepared_statements_instances(OWNER_OBJECT_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_processlist.test b/mysql-test/suite/perfschema/t/ddl_processlist.test
new file mode 100644
index 00000000..d960bf2d
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_processlist.test
@@ -0,0 +1,32 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+
+select @@global.performance_schema_show_processlist into @save_processlist;
+set @@global.performance_schema_show_processlist = 'on';
+
+--error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.processlist
+ add column foo integer;
+
+--error ER_WRONG_PERFSCHEMA_USAGE
+truncate table performance_schema.processlist;
+
+--error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.processlist
+ add index test_index(info);
+
+--error ER_DBACCESS_DENIED_ERROR
+create unique index test_index
+ on performance_schema.processlist(host);
+
+-- error ER_DBACCESS_DENIED_ERROR
+drop index `PRIMARY`
+ on performance_schema.processlist;
+
+CREATE TABLE test.create_select
+ AS SELECT * from performance_schema.processlist;
+
+DROP TABLE test.create_select;
+
+set @@global.performance_schema_show_processlist = @save_processlist;
diff --git a/mysql-test/suite/perfschema/t/ddl_replication_applier_configuration.test b/mysql-test/suite/perfschema/t/ddl_replication_applier_configuration.test
new file mode 100644
index 00000000..bc7ef8c2
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_replication_applier_configuration.test
@@ -0,0 +1,22 @@
+# Tests for PERFORMANCE_SCHEMA
+
+# This test verifies the correct behaviour in case of invalid
+# usage of DDLs on the table replication_applier_configuration
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.replication_applier_configuration
+ ADD COLUMN foo integer;
+
+-- error ER_WRONG_PERFSCHEMA_USAGE
+TRUNCATE TABLE performance_schema.replication_applier_configuration;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.replication_applier_configuration
+ ADD INDEX test_index(desired_delay);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON
+ performance_schema.replication_applier_configuration(desired_delay);
diff --git a/mysql-test/suite/perfschema/t/ddl_replication_applier_status.test b/mysql-test/suite/perfschema/t/ddl_replication_applier_status.test
new file mode 100644
index 00000000..7cf1f656
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_replication_applier_status.test
@@ -0,0 +1,22 @@
+# Tests for PERFORMANCE_SCHEMA
+
+# This test verifies the correct behaviour in case of invalid
+# usage of DDLs on the table replication_applier_status
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.replication_applier_status
+ ADD COLUMN foo integer;
+
+-- error ER_WRONG_PERFSCHEMA_USAGE
+TRUNCATE TABLE performance_schema.replication_applier_status;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.replication_applier_status
+ ADD INDEX test_index(remaining_delay);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON
+ performance_schema.replication_applier_status(remaining_delay);
diff --git a/mysql-test/suite/perfschema/t/ddl_replication_applier_status_by_coordinator.test b/mysql-test/suite/perfschema/t/ddl_replication_applier_status_by_coordinator.test
new file mode 100644
index 00000000..0e5f172e
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_replication_applier_status_by_coordinator.test
@@ -0,0 +1,22 @@
+# Tests for PERFORMANCE_SCHEMA
+
+# This test verifies the correct behaviour in case of invalid
+# usage of DDLs on the table replication_applier_status_by_coordinator
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.replication_applier_status_by_coordinator
+ ADD COLUMN foo integer;
+
+-- error ER_WRONG_PERFSCHEMA_USAGE
+TRUNCATE TABLE performance_schema.replication_applier_status_by_coordinator;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.replication_applier_status_by_coordinator
+ ADD INDEX test_index(thread_id);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON
+ performance_schema.replication_applier_status_by_coordinator(thread_id);
diff --git a/mysql-test/suite/perfschema/t/ddl_replication_applier_status_by_worker.test b/mysql-test/suite/perfschema/t/ddl_replication_applier_status_by_worker.test
new file mode 100644
index 00000000..c5adf4ea
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_replication_applier_status_by_worker.test
@@ -0,0 +1,22 @@
+# Tests for PERFORMANCE_SCHEMA
+
+# This test verifies the correct behaviour in case of invalid
+# usage of DDLs on the table replication_applier_status_by_worker.
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.replication_applier_status_by_worker
+ add column foo integer;
+
+-- error ER_WRONG_PERFSCHEMA_USAGE
+TRUNCATE TABLE performance_schema.replication_applier_status_by_worker;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.replication_applier_status_by_worker
+ ADD INDEX test_index(worker_id);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON
+ performance_schema.replication_applier_status_by_worker(worker_id);
diff --git a/mysql-test/suite/perfschema/t/ddl_replication_connection_configuration.test b/mysql-test/suite/perfschema/t/ddl_replication_connection_configuration.test
new file mode 100644
index 00000000..4d1dd2dd
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_replication_connection_configuration.test
@@ -0,0 +1,22 @@
+# Tests for PERFORMANCE_SCHEMA
+
+# This test verifies the correct behaviour in case of invalid
+# usage of DDLs on the table replication_connection_configuration.
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.replication_connection_configuration
+ ADD COLUMN foo integer;
+
+-- error ER_WRONG_PERFSCHEMA_USAGE
+TRUNCATE TABLE performance_schema.replication_connection_configuration;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.replication_connection_configuration
+ ADD INDEX test_index(HOST);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.replication_connection_configuration(HOST);
diff --git a/mysql-test/suite/perfschema/t/ddl_replication_connection_status.test b/mysql-test/suite/perfschema/t/ddl_replication_connection_status.test
new file mode 100644
index 00000000..4420a0df
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_replication_connection_status.test
@@ -0,0 +1,22 @@
+# Tests for PERFORMANCE_SCHEMA
+
+# This test verifies the correct behaviour in case of invalid
+# usage of DDLs on the table replication_connection_status.
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.replication_connection_status
+ ADD COLUMN foo integer;
+
+-- error ER_WRONG_PERFSCHEMA_USAGE
+TRUNCATE TABLE performance_schema.replication_connection_status;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.replication_connection_status
+ ADD INDEX test_index(Thread_Id);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.replication_connection_status(Thread_Id);
diff --git a/mysql-test/suite/perfschema/t/ddl_replication_group_member_stats.test b/mysql-test/suite/perfschema/t/ddl_replication_group_member_stats.test
new file mode 100644
index 00000000..eae5ed12
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_replication_group_member_stats.test
@@ -0,0 +1,21 @@
+# Tests for PERFORMANCE_SCHEMA
+# This test verifies the correct behaviour in case of invalid
+# Usage of DDLs on the table replication_group_member_stats.
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.replication_group_member_stats
+ ADD COLUMN foo INTEGER;
+
+--error ER_WRONG_PERFSCHEMA_USAGE
+TRUNCATE TABLE performance_schema.replication_group_member_stats;
+
+--error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.replication_group_member_stats
+ ADD INDEX test_index(Member_Id);
+
+--error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.replication_group_member_stats(Member_Id);
diff --git a/mysql-test/suite/perfschema/t/ddl_replication_group_members.test b/mysql-test/suite/perfschema/t/ddl_replication_group_members.test
new file mode 100644
index 00000000..bcb2c962
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_replication_group_members.test
@@ -0,0 +1,22 @@
+# Tests for PERFORMANCE_SCHEMA
+
+# This test verifies the correct behaviour in case of invalid
+# usage of DDLs on the table replication_group_members.
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.replication_group_members
+ ADD COLUMN foo INTEGER;
+
+--error ER_WRONG_PERFSCHEMA_USAGE
+TRUNCATE TABLE performance_schema.replication_group_members;
+
+--error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.replication_group_members
+ ADD INDEX test_index(Member_Id);
+
+--error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.replication_group_members(Member_Id);
diff --git a/mysql-test/suite/perfschema/t/ddl_rwlock_instances.test b/mysql-test/suite/perfschema/t/ddl_rwlock_instances.test
new file mode 100644
index 00000000..6e2f6e8d
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_rwlock_instances.test
@@ -0,0 +1,17 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.rwlock_instances add column foo integer;
+
+-- error ER_WRONG_PERFSCHEMA_USAGE
+truncate table performance_schema.rwlock_instances;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.rwlock_instances ADD INDEX test_index(NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.rwlock_instances(NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_session_account_connect_attrs.test b/mysql-test/suite/perfschema/t/ddl_session_account_connect_attrs.test
new file mode 100644
index 00000000..5d472d38
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_session_account_connect_attrs.test
@@ -0,0 +1,15 @@
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.session_account_connect_attrs
+ ADD COLUMN foo INTEGER;
+
+-- error ER_WRONG_PERFSCHEMA_USAGE
+TRUNCATE TABLE performance_schema.session_account_connect_attrs;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.session_account_connect_attrs ADD INDEX test_index(ATTR_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.session_account_connect_attrs(ATTR_NAME);
diff --git a/mysql-test/suite/perfschema/t/ddl_session_connect_attrs.test b/mysql-test/suite/perfschema/t/ddl_session_connect_attrs.test
new file mode 100644
index 00000000..8f3e10ca
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_session_connect_attrs.test
@@ -0,0 +1,15 @@
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.session_connect_attrs
+ ADD COLUMN foo INTEGER;
+
+-- error ER_WRONG_PERFSCHEMA_USAGE
+TRUNCATE TABLE performance_schema.session_connect_attrs;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.session_connect_attrs ADD INDEX test_index(ATTR_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.session_connect_attrs(ATTR_NAME);
diff --git a/mysql-test/suite/perfschema/t/ddl_session_status.test b/mysql-test/suite/perfschema/t/ddl_session_status.test
new file mode 100644
index 00000000..5dfa74a0
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_session_status.test
@@ -0,0 +1,20 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.session_status
+ add column foo integer;
+
+-- error ER_WRONG_PERFSCHEMA_USAGE
+truncate table performance_schema.session_status;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.session_status
+ ADD INDEX test_index(VARIABLE_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.session_status(VARIABLE_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_session_variables.test b/mysql-test/suite/perfschema/t/ddl_session_variables.test
new file mode 100644
index 00000000..a649d2bc
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_session_variables.test
@@ -0,0 +1,20 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.session_variables
+ add column foo integer;
+
+-- error ER_WRONG_PERFSCHEMA_USAGE
+truncate table performance_schema.session_variables;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.session_variables
+ ADD INDEX test_index(VARIABLE_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.session_variables(VARIABLE_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_setup_actors.test b/mysql-test/suite/perfschema/t/ddl_setup_actors.test
new file mode 100644
index 00000000..73e2c988
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_setup_actors.test
@@ -0,0 +1,31 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.setup_actors add column foo integer;
+
+--disable_warnings
+drop table if exists test.setup_actors;
+--enable_warnings
+
+create table test.setup_actors as
+ select * from performance_schema.setup_actors;
+
+truncate table performance_schema.setup_actors;
+
+select count(*) from performance_schema.setup_actors;
+
+insert into performance_schema.setup_actors
+ select * from test.setup_actors;
+drop table test.setup_actors;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.setup_actors ADD INDEX test_index(HOST);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.setup_actors(HOST);
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.setup_actors ADD KEY ENA(ENABLED);
diff --git a/mysql-test/suite/perfschema/t/ddl_setup_consumers.test b/mysql-test/suite/perfschema/t/ddl_setup_consumers.test
new file mode 100644
index 00000000..16e231d3
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_setup_consumers.test
@@ -0,0 +1,17 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.setup_consumers add column foo integer;
+
+-- error ER_WRONG_PERFSCHEMA_USAGE
+truncate table performance_schema.setup_consumers;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.setup_consumers ADD INDEX test_index(NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.setup_consumers(NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_setup_instruments.test b/mysql-test/suite/perfschema/t/ddl_setup_instruments.test
new file mode 100644
index 00000000..3a8a9b6f
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_setup_instruments.test
@@ -0,0 +1,17 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.setup_instruments add column foo integer;
+
+-- error ER_WRONG_PERFSCHEMA_USAGE
+truncate table performance_schema.setup_instruments;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.setup_instruments ADD INDEX test_index(NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.setup_instruments(NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_setup_objects.test b/mysql-test/suite/perfschema/t/ddl_setup_objects.test
new file mode 100644
index 00000000..adf09ae1
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_setup_objects.test
@@ -0,0 +1,29 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.setup_objects add column foo integer;
+
+--disable_warnings
+drop table if exists test.setup_objects;
+--enable_warnings
+
+create table test.setup_objects as
+ select * from performance_schema.setup_objects;
+
+truncate table performance_schema.setup_objects;
+
+select count(*) from performance_schema.setup_objects;
+
+insert into performance_schema.setup_objects
+ select * from test.setup_objects;
+drop table test.setup_objects;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.setup_objects ADD INDEX test_index(OBJECT_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.setup_objects(OBJECT_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_setup_timers.test b/mysql-test/suite/perfschema/t/ddl_setup_timers.test
new file mode 100644
index 00000000..b344370a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_setup_timers.test
@@ -0,0 +1,17 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.setup_timers add column foo integer;
+
+-- error ER_WRONG_PERFSCHEMA_USAGE
+truncate table performance_schema.setup_timers;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.setup_timers ADD INDEX test_index(NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.setup_timers(NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_socket_instances.test b/mysql-test/suite/perfschema/t/ddl_socket_instances.test
new file mode 100644
index 00000000..c84a04b0
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_socket_instances.test
@@ -0,0 +1,17 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.socket_instances add column foo integer;
+
+-- error ER_WRONG_PERFSCHEMA_USAGE
+truncate table performance_schema.socket_instances;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.socket_instances ADD INDEX test_index(FILE_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.socket_instances(FILE_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_socket_summary_by_event_name.test b/mysql-test/suite/perfschema/t/ddl_socket_summary_by_event_name.test
new file mode 100644
index 00000000..01895a78
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_socket_summary_by_event_name.test
@@ -0,0 +1,16 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.socket_summary_by_instance add column foo integer;
+
+truncate table performance_schema.socket_summary_by_instance;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.socket_summary_by_instance ADD INDEX test_index(FILE_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.socket_summary_by_instance(FILE_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_socket_summary_by_instance.test b/mysql-test/suite/perfschema/t/ddl_socket_summary_by_instance.test
new file mode 100644
index 00000000..01895a78
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_socket_summary_by_instance.test
@@ -0,0 +1,16 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.socket_summary_by_instance add column foo integer;
+
+truncate table performance_schema.socket_summary_by_instance;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.socket_summary_by_instance ADD INDEX test_index(FILE_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.socket_summary_by_instance(FILE_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_status_by_account.test b/mysql-test/suite/perfschema/t/ddl_status_by_account.test
new file mode 100644
index 00000000..52f5d72f
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_status_by_account.test
@@ -0,0 +1,19 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.status_by_account
+ add column foo integer;
+
+truncate table performance_schema.status_by_account;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.status_by_account
+ ADD INDEX test_index(VARIABLE_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.status_by_account(VARIABLE_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_status_by_host.test b/mysql-test/suite/perfschema/t/ddl_status_by_host.test
new file mode 100644
index 00000000..418880d5
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_status_by_host.test
@@ -0,0 +1,19 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.status_by_host
+ add column foo integer;
+
+truncate table performance_schema.status_by_host;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.status_by_host
+ ADD INDEX test_index(VARIABLE_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.status_by_host(VARIABLE_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_status_by_thread.test b/mysql-test/suite/perfschema/t/ddl_status_by_thread.test
new file mode 100644
index 00000000..8ac778a2
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_status_by_thread.test
@@ -0,0 +1,19 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.status_by_thread
+ add column foo integer;
+
+truncate table performance_schema.status_by_thread;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.status_by_thread
+ ADD INDEX test_index(VARIABLE_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.status_by_thread(VARIABLE_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_status_by_user.test b/mysql-test/suite/perfschema/t/ddl_status_by_user.test
new file mode 100644
index 00000000..b0d97aeb
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_status_by_user.test
@@ -0,0 +1,19 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.status_by_user
+ add column foo integer;
+
+truncate table performance_schema.status_by_user;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.status_by_user
+ ADD INDEX test_index(VARIABLE_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.status_by_user(VARIABLE_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_table_handles.test b/mysql-test/suite/perfschema/t/ddl_table_handles.test
new file mode 100644
index 00000000..15ef69f3
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_table_handles.test
@@ -0,0 +1,17 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.table_handles add column foo integer;
+
+-- error ER_WRONG_PERFSCHEMA_USAGE
+truncate table performance_schema.table_handles;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.table_handles ADD INDEX test_index(TIMER_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.table_handles(TIMER_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_threads.test b/mysql-test/suite/perfschema/t/ddl_threads.test
new file mode 100644
index 00000000..3709d5c7
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_threads.test
@@ -0,0 +1,17 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.threads add column foo integer;
+
+-- error ER_WRONG_PERFSCHEMA_USAGE
+truncate table performance_schema.threads;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.threads ADD INDEX test_index(PROCESSLIST_ID);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.threads(PROCESSLIST_ID);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_tiws_by_index_usage.test b/mysql-test/suite/perfschema/t/ddl_tiws_by_index_usage.test
new file mode 100644
index 00000000..34f4475d
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_tiws_by_index_usage.test
@@ -0,0 +1,17 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.table_io_waits_summary_by_index_usage
+ add column foo integer;
+
+truncate table performance_schema.table_io_waits_summary_by_index_usage;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.table_io_waits_summary_by_index_usage ADD INDEX test_index(TABLE_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.table_io_waits_summary_by_index_usage(TABLE_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_tiws_by_table.test b/mysql-test/suite/perfschema/t/ddl_tiws_by_table.test
new file mode 100644
index 00000000..42294951
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_tiws_by_table.test
@@ -0,0 +1,17 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.table_io_waits_summary_by_table
+ add column foo integer;
+
+truncate table performance_schema.table_io_waits_summary_by_table;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.table_io_waits_summary_by_table ADD INDEX test_index(TABLE_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.table_io_waits_summary_by_table(TABLE_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_tlws_by_table.test b/mysql-test/suite/perfschema/t/ddl_tlws_by_table.test
new file mode 100644
index 00000000..d796e3d4
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_tlws_by_table.test
@@ -0,0 +1,17 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.table_lock_waits_summary_by_table
+ add column foo integer;
+
+truncate table performance_schema.table_lock_waits_summary_by_table;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.table_lock_waits_summary_by_table ADD INDEX test_index(TABLE_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.table_lock_waits_summary_by_table(TABLE_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_users.test b/mysql-test/suite/perfschema/t/ddl_users.test
new file mode 100644
index 00000000..84aba78a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_users.test
@@ -0,0 +1,17 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.users
+ add column foo integer;
+
+truncate table performance_schema.users;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.users ADD INDEX test_index(CURRENT_CONNECTIONS);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.users(CURRENT_CONNECTIONS);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_uvar_by_thread.test b/mysql-test/suite/perfschema/t/ddl_uvar_by_thread.test
new file mode 100644
index 00000000..d8ccda59
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_uvar_by_thread.test
@@ -0,0 +1,20 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.user_variables_by_thread
+ add column foo integer;
+
+-- error ER_WRONG_PERFSCHEMA_USAGE
+truncate table performance_schema.user_variables_by_thread;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.user_variables_by_thread
+ ADD INDEX test_index(VARIABLE_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.user_variables_by_thread(VARIABLE_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/ddl_variables_by_thread.test b/mysql-test/suite/perfschema/t/ddl_variables_by_thread.test
new file mode 100644
index 00000000..e5d04f09
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ddl_variables_by_thread.test
@@ -0,0 +1,20 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.variables_by_thread
+ add column foo integer;
+
+-- error ER_WRONG_PERFSCHEMA_USAGE
+truncate table performance_schema.variables_by_thread;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.variables_by_thread
+ ADD INDEX test_index(VARIABLE_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+ ON performance_schema.variables_by_thread(VARIABLE_NAME);
+
diff --git a/mysql-test/suite/perfschema/t/digest_null_literal.test b/mysql-test/suite/perfschema/t/digest_null_literal.test
new file mode 100644
index 00000000..91f1eec1
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/digest_null_literal.test
@@ -0,0 +1,32 @@
+# ----------------------------------------------------
+# Tests for the performance schema statement Digests.
+# ----------------------------------------------------
+
+# Test case to show behavior of statements digest when
+# parsing a NULL literal
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/no_protocol.inc
+
+TRUNCATE TABLE performance_schema.events_statements_summary_by_digest;
+
+--disable_query_log
+
+select NULL;
+select NULL FROM DUAL;
+select NULL, NULL;
+select NULL, NULL, NULL, 1, 2, 3, NULL, NULL;
+
+select 1 IS NULL;
+select 2 IS NOT NULL;
+select 1 IS NULL, 2 IS NULL, 3 IS NOT NULL, 4 IS NOT NULL;
+
+create table foo (a int DEFAULT NULL, b int NOT NULL DEFAULT 1, c int NOT NULL);
+drop table foo;
+
+--enable_query_log
+
+SELECT SCHEMA_NAME, DIGEST_TEXT, COUNT_STAR
+ FROM performance_schema.events_statements_summary_by_digest;
+
diff --git a/mysql-test/suite/perfschema/t/digest_table_full-master.opt b/mysql-test/suite/perfschema/t/digest_table_full-master.opt
new file mode 100644
index 00000000..62798dfd
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/digest_table_full-master.opt
@@ -0,0 +1 @@
+--loose-performance-schema-digests-size=2
diff --git a/mysql-test/suite/perfschema/t/digest_table_full.test b/mysql-test/suite/perfschema/t/digest_table_full.test
new file mode 100644
index 00000000..605ea1f3
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/digest_table_full.test
@@ -0,0 +1,32 @@
+# ----------------------------------------------------
+# Tests for the performance schema statement Digests.
+# ----------------------------------------------------
+
+# Test case to show behavior of statements digest when
+# statement-digest-size is 0
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+# Initial Setup for Digest
+--source ../include/digest_setup.inc
+
+TRUNCATE TABLE performance_schema.events_statements_summary_by_digest;
+
+# Executing queries
+--source ../include/digest_execution.inc
+
+--echo ####################################
+--echo # QUERYING PS STATEMENT DIGEST
+--echo ####################################
+SELECT SCHEMA_NAME, DIGEST_TEXT, COUNT_STAR, SUM_ROWS_AFFECTED, SUM_WARNINGS,
+ SUM_ERRORS FROM performance_schema.events_statements_summary_by_digest;
+
+
+# Expect no digest
+SHOW GLOBAL VARIABLES LIKE "performance_schema_digests_size";
+SELECT COUNT(*) FROM performance_schema.events_statements_summary_by_digest;
+
+# Cleanup for Digest
+--source ../include/digest_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/digest_view.test b/mysql-test/suite/perfschema/t/digest_view.test
new file mode 100644
index 00000000..dd862aeb
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/digest_view.test
@@ -0,0 +1,153 @@
+# ----------------------------------------------------
+# Tests for the performance schema statement Digests.
+# ----------------------------------------------------
+
+# Test case to show behavior of statements digest when
+# using a view
+
+# Test requires: sp-protocol/ps-protocol/view-protocol/cursor-protocol disabled
+--source include/no_protocol.inc
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+CREATE TABLE test.v1 (a int, b int);
+INSERT INTO test.v1 VALUES (1, 100), (2, 200), (3, 300);
+
+CREATE TABLE test.t1 (a int, b int);
+INSERT INTO test.t1 VALUES (1, 100), (2, 200), (3, 300);
+
+
+TRUNCATE TABLE performance_schema.events_statements_summary_by_digest;
+
+#
+# test.v1 is a table.
+# Every query here is different, and should have a different digest.
+#
+
+EXPLAIN EXTENDED SELECT * from test.v1;
+EXPLAIN EXTENDED SELECT * from test.v1 where a = 1;
+EXPLAIN EXTENDED SELECT * from test.v1 where b > 100;
+EXPLAIN EXTENDED SELECT a, b from test.v1;
+EXPLAIN EXTENDED SELECT b, a from test.v1;
+
+SELECT * from test.v1;
+SELECT * from test.v1 where a = 1;
+SELECT * from test.v1 where b > 100;
+SELECT a, b from test.v1;
+SELECT b, a from test.v1;
+
+--echo #
+--echo # DIGESTS SEEN ON TABLE
+--echo #
+
+SELECT SCHEMA_NAME, DIGEST_TEXT, COUNT_STAR
+ FROM performance_schema.events_statements_summary_by_digest
+ ORDER BY DIGEST_TEXT;
+
+DROP TABLE test.v1;
+CREATE VIEW test.v1 AS SELECT * FROM test.t1;
+
+#
+# test.v1 is now a view.
+# the query digests should be unchanged.
+#
+
+EXPLAIN EXTENDED SELECT * from test.v1;
+EXPLAIN EXTENDED SELECT * from test.v1 where a = 1;
+EXPLAIN EXTENDED SELECT * from test.v1 where b > 100;
+EXPLAIN EXTENDED SELECT a, b from test.v1;
+EXPLAIN EXTENDED SELECT b, a from test.v1;
+
+SELECT * from test.v1;
+SELECT * from test.v1 where a = 1;
+SELECT * from test.v1 where b > 100;
+SELECT a, b from test.v1;
+SELECT b, a from test.v1;
+
+--echo #
+--echo # DIGESTS SEEN ON VIEW
+--echo #
+
+SELECT SCHEMA_NAME, DIGEST_TEXT, COUNT_STAR
+ FROM performance_schema.events_statements_summary_by_digest
+ ORDER BY DIGEST_TEXT;
+
+DROP VIEW test.v1;
+DROP TABLE test.t1;
+
+# ----------------------------------------------------
+# Tests for the performance schema statement Digests.
+# ----------------------------------------------------
+
+# Test case to show behavior of statements digest when
+# using a view
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/no_protocol.inc
+
+CREATE TABLE test.v1 (a int, b int);
+INSERT INTO test.v1 VALUES (1, 100), (2, 200), (3, 300);
+
+CREATE TABLE test.t1 (a int, b int);
+INSERT INTO test.t1 VALUES (1, 100), (2, 200), (3, 300);
+
+
+TRUNCATE TABLE performance_schema.events_statements_summary_by_digest;
+
+#
+# test.v1 is a table.
+# Every query here is different, and should have a different digest.
+#
+
+EXPLAIN SELECT * from test.v1;
+EXPLAIN SELECT * from test.v1 where a = 1;
+EXPLAIN SELECT * from test.v1 where b > 100;
+EXPLAIN SELECT a, b from test.v1;
+EXPLAIN SELECT b, a from test.v1;
+
+SELECT * from test.v1;
+SELECT * from test.v1 where a = 1;
+SELECT * from test.v1 where b > 100;
+SELECT a, b from test.v1;
+SELECT b, a from test.v1;
+
+--echo #
+--echo # DIGESTS SEEN ON TABLE
+--echo #
+
+SELECT SCHEMA_NAME, DIGEST, DIGEST_TEXT, COUNT_STAR
+ FROM performance_schema.events_statements_summary_by_digest
+ ORDER BY DIGEST_TEXT;
+
+DROP TABLE test.v1;
+CREATE VIEW test.v1 AS SELECT * FROM test.t1;
+
+#
+# test.v1 is now a view.
+# the query digests should be unchanged.
+#
+
+EXPLAIN SELECT * from test.v1;
+EXPLAIN SELECT * from test.v1 where a = 1;
+EXPLAIN SELECT * from test.v1 where b > 100;
+EXPLAIN SELECT a, b from test.v1;
+EXPLAIN SELECT b, a from test.v1;
+
+SELECT * from test.v1;
+SELECT * from test.v1 where a = 1;
+SELECT * from test.v1 where b > 100;
+SELECT a, b from test.v1;
+SELECT b, a from test.v1;
+
+--echo #
+--echo # DIGESTS SEEN ON VIEW
+--echo #
+
+SELECT SCHEMA_NAME, DIGEST, DIGEST_TEXT, COUNT_STAR
+ FROM performance_schema.events_statements_summary_by_digest
+ ORDER BY DIGEST_TEXT;
+
+DROP VIEW test.v1;
+DROP TABLE test.t1;
+
diff --git a/mysql-test/suite/perfschema/t/disabled.def b/mysql-test/suite/perfschema/t/disabled.def
new file mode 100644
index 00000000..2dc57ee9
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/disabled.def
@@ -0,0 +1,12 @@
+##############################################################################
+#
+# List the test cases that are to be disabled temporarily.
+#
+# Separate the test case name and the comment with ':'.
+#
+# <testcasename> : BUG#<xxxx> <date disabled> <disabler> <comment>
+#
+# Do not use any TAB characters for whitespace.
+#
+##############################################################################
+# perfschema.pfs_ccccccc : Bug#nnnnnnnn 2014-09-10 Anitha Frequent failures on PB2
diff --git a/mysql-test/suite/perfschema/t/discovery.test b/mysql-test/suite/perfschema/t/discovery.test
new file mode 100644
index 00000000..811e99da
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/discovery.test
@@ -0,0 +1,15 @@
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--echo #
+--echo # MDEV-7922 - ERROR 1939 (HY000): Engine PERFORMANCE_SCHEMA failed to
+--echo # discover table
+--echo #
+FLUSH TABLES;
+CREATE DATABASE test_drop;
+USE test_drop;
+DROP DATABASE test_drop;
+--disable_result_log
+SELECT TABLE_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='performance_schema';
+--enable_result_log
+SELECT @@warning_count;
diff --git a/mysql-test/suite/perfschema/t/dml_accounts.test b/mysql-test/suite/perfschema/t/dml_accounts.test
new file mode 100644
index 00000000..84c6cee9
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_accounts.test
@@ -0,0 +1,47 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.accounts
+ limit 1;
+
+select * from performance_schema.accounts
+ where user='FOO' or host='BAR';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.accounts
+ set user='FOO', host='BAR',
+ current_connections=1, total_connections=2;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.accounts
+ set current_connections=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.accounts
+ set current_connections=12 where host like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.accounts
+ where total_connections=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.accounts;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.accounts READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.accounts WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='accounts';
diff --git a/mysql-test/suite/perfschema/t/dml_cond_instances.test b/mysql-test/suite/perfschema/t/dml_cond_instances.test
new file mode 100644
index 00000000..3d3d0194
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_cond_instances.test
@@ -0,0 +1,41 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.cond_instances limit 1;
+
+select * from performance_schema.cond_instances
+ where name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.cond_instances
+ set name='FOO', object_instance_begin=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.cond_instances
+ set name='FOO';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.cond_instances
+ where name like "wait/%";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.cond_instances;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.cond_instances READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.cond_instances WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='cond_instances';
diff --git a/mysql-test/suite/perfschema/t/dml_esgs_by_account_by_event_name.test b/mysql-test/suite/perfschema/t/dml_esgs_by_account_by_event_name.test
new file mode 100644
index 00000000..fb54b332
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_esgs_by_account_by_event_name.test
@@ -0,0 +1,48 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_stages_summary_by_account_by_event_name
+ where event_name like 'stage/%' limit 1;
+
+select * from performance_schema.events_stages_summary_by_account_by_event_name
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_stages_summary_by_account_by_event_name
+ set event_name='FOO', user='BAR', host='BAZ',
+ count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_stages_summary_by_account_by_event_name
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_stages_summary_by_account_by_event_name
+ set count_star=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_stages_summary_by_account_by_event_name
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_stages_summary_by_account_by_event_name;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_stages_summary_by_account_by_event_name READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_stages_summary_by_account_by_event_name WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='events_stages_summary_by_account_by_event_name';
diff --git a/mysql-test/suite/perfschema/t/dml_esgs_by_host_by_event_name.test b/mysql-test/suite/perfschema/t/dml_esgs_by_host_by_event_name.test
new file mode 100644
index 00000000..e7a8e465
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_esgs_by_host_by_event_name.test
@@ -0,0 +1,48 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_stages_summary_by_host_by_event_name
+ where event_name like 'stage/%' limit 1;
+
+select * from performance_schema.events_stages_summary_by_host_by_event_name
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_stages_summary_by_host_by_event_name
+ set event_name='FOO', thread_id=1,
+ count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_stages_summary_by_host_by_event_name
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_stages_summary_by_host_by_event_name
+ set count_star=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_stages_summary_by_host_by_event_name
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_stages_summary_by_host_by_event_name;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_stages_summary_by_host_by_event_name READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_stages_summary_by_host_by_event_name WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='events_stages_summary_by_host_by_event_name';
diff --git a/mysql-test/suite/perfschema/t/dml_esgs_by_thread_by_event_name.test b/mysql-test/suite/perfschema/t/dml_esgs_by_thread_by_event_name.test
new file mode 100644
index 00000000..f7675363
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_esgs_by_thread_by_event_name.test
@@ -0,0 +1,48 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_stages_summary_by_thread_by_event_name
+ where event_name like 'stage/%' limit 1;
+
+select * from performance_schema.events_stages_summary_by_thread_by_event_name
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_stages_summary_by_thread_by_event_name
+ set event_name='FOO', thread_id=1,
+ count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_stages_summary_by_thread_by_event_name
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_stages_summary_by_thread_by_event_name
+ set count_star=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_stages_summary_by_thread_by_event_name
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_stages_summary_by_thread_by_event_name;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_stages_summary_by_thread_by_event_name READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_stages_summary_by_thread_by_event_name WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='events_stages_summary_by_thread_by_event_name';
diff --git a/mysql-test/suite/perfschema/t/dml_esgs_by_user_by_event_name.test b/mysql-test/suite/perfschema/t/dml_esgs_by_user_by_event_name.test
new file mode 100644
index 00000000..d0e12664
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_esgs_by_user_by_event_name.test
@@ -0,0 +1,48 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_stages_summary_by_user_by_event_name
+ where event_name like 'stage/%' limit 1;
+
+select * from performance_schema.events_stages_summary_by_user_by_event_name
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_stages_summary_by_user_by_event_name
+ set event_name='FOO', user='BAR',
+ count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_stages_summary_by_user_by_event_name
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_stages_summary_by_user_by_event_name
+ set count_star=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_stages_summary_by_user_by_event_name
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_stages_summary_by_user_by_event_name;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_stages_summary_by_user_by_event_name READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_stages_summary_by_user_by_event_name WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='events_stages_summary_by_user_by_event_name';
diff --git a/mysql-test/suite/perfschema/t/dml_esgs_global_by_event_name.test b/mysql-test/suite/perfschema/t/dml_esgs_global_by_event_name.test
new file mode 100644
index 00000000..bca0e4ed
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_esgs_global_by_event_name.test
@@ -0,0 +1,47 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_stages_summary_global_by_event_name
+ where event_name like 'stage/%' limit 1;
+
+select * from performance_schema.events_stages_summary_global_by_event_name
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_stages_summary_global_by_event_name
+ set event_name='FOO', count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_stages_summary_global_by_event_name
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_stages_summary_global_by_event_name
+ set count_star=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_stages_summary_global_by_event_name
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_stages_summary_global_by_event_name;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_stages_summary_global_by_event_name READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_stages_summary_global_by_event_name WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='events_stages_summary_global_by_event_name';
diff --git a/mysql-test/suite/perfschema/t/dml_esms_by_account_by_event_name.test b/mysql-test/suite/perfschema/t/dml_esms_by_account_by_event_name.test
new file mode 100644
index 00000000..f86baaef
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_esms_by_account_by_event_name.test
@@ -0,0 +1,48 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_statements_summary_by_account_by_event_name
+ where event_name like 'statement/%' limit 1;
+
+select * from performance_schema.events_statements_summary_by_account_by_event_name
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_statements_summary_by_account_by_event_name
+ set event_name='FOO', user='BAR', host='BAZ',
+ count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_statements_summary_by_account_by_event_name
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_statements_summary_by_account_by_event_name
+ set count_star=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_statements_summary_by_account_by_event_name
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_statements_summary_by_account_by_event_name;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_statements_summary_by_account_by_event_name READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_statements_summary_by_account_by_event_name WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='events_statements_summary_by_account_by_event_name';
diff --git a/mysql-test/suite/perfschema/t/dml_esms_by_digest.test b/mysql-test/suite/perfschema/t/dml_esms_by_digest.test
new file mode 100644
index 00000000..5bdeeb10
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_esms_by_digest.test
@@ -0,0 +1,69 @@
+# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License, version 2.0,
+# as published by the Free Software Foundation.
+#
+# This program is also distributed with certain software (including
+# but not limited to OpenSSL) that is licensed under separate terms,
+# as designated in a particular file or component or in included license
+# documentation. The authors of MySQL hereby grant you an additional
+# permission to link the program and your derivative works with the
+# separately licensed software that they have included with MySQL.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License, version 2.0, for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
+
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+#--disable_result_log
+select * from performance_schema.events_statements_summary_by_digest
+ where digest like 'XXYYZZ%' limit 1;
+
+select * from performance_schema.events_statements_summary_by_digest
+ where digest='XXYYZZ';
+#--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_statements_summary_by_digest
+ set digest='XXYYZZ', count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_statements_summary_by_digest
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_statements_summary_by_digest
+ set count_star=12 where digest like "XXYYZZ";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_statements_summary_by_digest
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_statements_summary_by_digest;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_statements_summary_by_digest READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_statements_summary_by_digest WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='events_statements_summary_by_digest';
diff --git a/mysql-test/suite/perfschema/t/dml_esms_by_host_by_event_name.test b/mysql-test/suite/perfschema/t/dml_esms_by_host_by_event_name.test
new file mode 100644
index 00000000..19547d99
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_esms_by_host_by_event_name.test
@@ -0,0 +1,48 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_statements_summary_by_host_by_event_name
+ where event_name like 'statement/%' limit 1;
+
+select * from performance_schema.events_statements_summary_by_host_by_event_name
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_statements_summary_by_host_by_event_name
+ set event_name='FOO', thread_id=1,
+ count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_statements_summary_by_host_by_event_name
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_statements_summary_by_host_by_event_name
+ set count_star=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_statements_summary_by_host_by_event_name
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_statements_summary_by_host_by_event_name;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_statements_summary_by_host_by_event_name READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_statements_summary_by_host_by_event_name WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='events_statements_summary_by_host_by_event_name';
diff --git a/mysql-test/suite/perfschema/t/dml_esms_by_program.test b/mysql-test/suite/perfschema/t/dml_esms_by_program.test
new file mode 100644
index 00000000..b80b9aa5
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_esms_by_program.test
@@ -0,0 +1,44 @@
+# This line and the line below is a temporary line for tests that do not need MyISAM in future, but need to be kept for tests that need it.
+#--source include/have_myisam.inc
+
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+#--disable_result_log
+select * from performance_schema.events_statements_summary_by_program
+ where object_name like 'XXYYZZ%' limit 1;
+
+select * from performance_schema.events_statements_summary_by_program
+ where object_name='XXYYZZ';
+#--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_statements_summary_by_program
+ set object_name='XXYYZZ', count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_statements_summary_by_program
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_statements_summary_by_program
+ set count_star=12 where object_name like "XXYYZZ";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_statements_summary_by_program
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_statements_summary_by_program;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_statements_summary_by_program READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_statements_summary_by_program WRITE;
+UNLOCK TABLES;
+
diff --git a/mysql-test/suite/perfschema/t/dml_esms_by_thread_by_event_name.test b/mysql-test/suite/perfschema/t/dml_esms_by_thread_by_event_name.test
new file mode 100644
index 00000000..f28ae4d3
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_esms_by_thread_by_event_name.test
@@ -0,0 +1,48 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_statements_summary_by_thread_by_event_name
+ where event_name like 'statement/%' limit 1;
+
+select * from performance_schema.events_statements_summary_by_thread_by_event_name
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_statements_summary_by_thread_by_event_name
+ set event_name='FOO', thread_id=1,
+ count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_statements_summary_by_thread_by_event_name
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_statements_summary_by_thread_by_event_name
+ set count_star=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_statements_summary_by_thread_by_event_name
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_statements_summary_by_thread_by_event_name;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_statements_summary_by_thread_by_event_name READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_statements_summary_by_thread_by_event_name WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='events_statements_summary_by_thread_by_event_name';
diff --git a/mysql-test/suite/perfschema/t/dml_esms_by_user_by_event_name.test b/mysql-test/suite/perfschema/t/dml_esms_by_user_by_event_name.test
new file mode 100644
index 00000000..db6d2d84
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_esms_by_user_by_event_name.test
@@ -0,0 +1,48 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_statements_summary_by_user_by_event_name
+ where event_name like 'statement/%' limit 1;
+
+select * from performance_schema.events_statements_summary_by_user_by_event_name
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_statements_summary_by_user_by_event_name
+ set event_name='FOO', user='BAR',
+ count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_statements_summary_by_user_by_event_name
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_statements_summary_by_user_by_event_name
+ set count_star=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_statements_summary_by_user_by_event_name
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_statements_summary_by_user_by_event_name;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_statements_summary_by_user_by_event_name READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_statements_summary_by_user_by_event_name WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='events_statements_summary_by_user_by_event_name';
diff --git a/mysql-test/suite/perfschema/t/dml_esms_global_by_event_name.test b/mysql-test/suite/perfschema/t/dml_esms_global_by_event_name.test
new file mode 100644
index 00000000..108efeee
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_esms_global_by_event_name.test
@@ -0,0 +1,47 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_statements_summary_global_by_event_name
+ where event_name like 'statement/%' limit 1;
+
+select * from performance_schema.events_statements_summary_global_by_event_name
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_statements_summary_global_by_event_name
+ set event_name='FOO', count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_statements_summary_global_by_event_name
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_statements_summary_global_by_event_name
+ set count_star=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_statements_summary_global_by_event_name
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_statements_summary_global_by_event_name;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_statements_summary_global_by_event_name READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_statements_summary_global_by_event_name WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='events_statements_summary_global_by_event_name';
diff --git a/mysql-test/suite/perfschema/t/dml_ets_by_account_by_event_name.test b/mysql-test/suite/perfschema/t/dml_ets_by_account_by_event_name.test
new file mode 100644
index 00000000..ede5f708
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_ets_by_account_by_event_name.test
@@ -0,0 +1,42 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_transactions_summary_by_account_by_event_name
+ where event_name in ('transaction') limit 1;
+
+select * from performance_schema.events_transactions_summary_by_account_by_event_name
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_transactions_summary_by_account_by_event_name
+ set event_name='FOO', user='BAR', host='BAZ',
+ count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_transactions_summary_by_account_by_event_name
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_transactions_summary_by_account_by_event_name
+ set count_star=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_transactions_summary_by_account_by_event_name
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_transactions_summary_by_account_by_event_name;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_transactions_summary_by_account_by_event_name READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_transactions_summary_by_account_by_event_name WRITE;
+UNLOCK TABLES;
+
diff --git a/mysql-test/suite/perfschema/t/dml_ets_by_host_by_event_name.test b/mysql-test/suite/perfschema/t/dml_ets_by_host_by_event_name.test
new file mode 100644
index 00000000..a2163b16
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_ets_by_host_by_event_name.test
@@ -0,0 +1,42 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_transactions_summary_by_host_by_event_name
+ where event_name in ('transaction') limit 1;
+
+select * from performance_schema.events_transactions_summary_by_host_by_event_name
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_transactions_summary_by_host_by_event_name
+ set event_name='FOO', thread_id=1,
+ count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_transactions_summary_by_host_by_event_name
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_transactions_summary_by_host_by_event_name
+ set count_star=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_transactions_summary_by_host_by_event_name
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_transactions_summary_by_host_by_event_name;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_transactions_summary_by_host_by_event_name READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_transactions_summary_by_host_by_event_name WRITE;
+UNLOCK TABLES;
+
diff --git a/mysql-test/suite/perfschema/t/dml_ets_by_thread_by_event_name.test b/mysql-test/suite/perfschema/t/dml_ets_by_thread_by_event_name.test
new file mode 100644
index 00000000..bbbb0cad
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_ets_by_thread_by_event_name.test
@@ -0,0 +1,42 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_transactions_summary_by_thread_by_event_name
+ where event_name in ('transaction') limit 1;
+
+select * from performance_schema.events_transactions_summary_by_thread_by_event_name
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_transactions_summary_by_thread_by_event_name
+ set event_name='FOO', thread_id=1,
+ count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_transactions_summary_by_thread_by_event_name
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_transactions_summary_by_thread_by_event_name
+ set count_star=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_transactions_summary_by_thread_by_event_name
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_transactions_summary_by_thread_by_event_name;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_transactions_summary_by_thread_by_event_name READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_transactions_summary_by_thread_by_event_name WRITE;
+UNLOCK TABLES;
+
diff --git a/mysql-test/suite/perfschema/t/dml_ets_by_user_by_event_name.test b/mysql-test/suite/perfschema/t/dml_ets_by_user_by_event_name.test
new file mode 100644
index 00000000..dcca969c
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_ets_by_user_by_event_name.test
@@ -0,0 +1,42 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_transactions_summary_by_user_by_event_name
+ where event_name in ('transaction') limit 1;
+
+select * from performance_schema.events_transactions_summary_by_user_by_event_name
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_transactions_summary_by_user_by_event_name
+ set event_name='FOO', user='BAR',
+ count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_transactions_summary_by_user_by_event_name
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_transactions_summary_by_user_by_event_name
+ set count_star=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_transactions_summary_by_user_by_event_name
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_transactions_summary_by_user_by_event_name;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_transactions_summary_by_user_by_event_name READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_transactions_summary_by_user_by_event_name WRITE;
+UNLOCK TABLES;
+
diff --git a/mysql-test/suite/perfschema/t/dml_ets_global_by_event_name.test b/mysql-test/suite/perfschema/t/dml_ets_global_by_event_name.test
new file mode 100644
index 00000000..f5c11cf8
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_ets_global_by_event_name.test
@@ -0,0 +1,41 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_transactions_summary_global_by_event_name
+ where event_name in ('transaction') limit 1;
+
+select * from performance_schema.events_transactions_summary_global_by_event_name
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_transactions_summary_global_by_event_name
+ set event_name='FOO', count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_transactions_summary_global_by_event_name
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_transactions_summary_global_by_event_name
+ set count_star=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_transactions_summary_global_by_event_name
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_transactions_summary_global_by_event_name;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_transactions_summary_global_by_event_name READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_transactions_summary_global_by_event_name WRITE;
+UNLOCK TABLES;
+
diff --git a/mysql-test/suite/perfschema/t/dml_events_stages_current.test b/mysql-test/suite/perfschema/t/dml_events_stages_current.test
new file mode 100644
index 00000000..20dc1927
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_events_stages_current.test
@@ -0,0 +1,47 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_stages_current
+ where event_name like 'stage/%' limit 1;
+
+select * from performance_schema.events_stages_current
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_stages_current
+ set thread_id='1', event_id=1,
+ event_name='FOO', timer_start=1, timer_end=2, timer_wait=3;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_stages_current
+ set timer_start=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_stages_current
+ set timer_start=12 where thread_id=0;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_stages_current
+ where thread_id=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_stages_current;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_stages_current READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_stages_current WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='events_stages_current';
diff --git a/mysql-test/suite/perfschema/t/dml_events_stages_history.test b/mysql-test/suite/perfschema/t/dml_events_stages_history.test
new file mode 100644
index 00000000..ab62e23a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_events_stages_history.test
@@ -0,0 +1,53 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_stages_history
+ where event_name like 'stage/%' limit 1;
+
+select * from performance_schema.events_stages_history
+ where event_name='FOO';
+
+select * from performance_schema.events_stages_history
+ where event_name like 'stage/%' order by timer_wait limit 1;
+
+select * from performance_schema.events_stages_history
+ where event_name like 'stage/%' order by timer_wait desc limit 1;
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_stages_history
+ set thread_id='1', event_id=1,
+ event_name='FOO', timer_start=1, timer_end=2, timer_wait=3;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_stages_history
+ set timer_start=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_stages_history
+ set timer_start=12 where thread_id=0;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_stages_history
+ where thread_id=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_stages_history;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_stages_history READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_stages_history WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='events_stages_history';
diff --git a/mysql-test/suite/perfschema/t/dml_events_stages_history_long.test b/mysql-test/suite/perfschema/t/dml_events_stages_history_long.test
new file mode 100644
index 00000000..ef342f1a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_events_stages_history_long.test
@@ -0,0 +1,53 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_stages_history_long
+ where event_name like 'stage/%' limit 1;
+
+select * from performance_schema.events_stages_history_long
+ where event_name='FOO';
+
+select * from performance_schema.events_stages_history_long
+ where event_name like 'stage/%' order by timer_wait limit 1;
+
+select * from performance_schema.events_stages_history_long
+ where event_name like 'stage/%' order by timer_wait desc limit 1;
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_stages_history_long
+ set thread_id='1', event_id=1,
+ event_name='FOO', timer_start=1, timer_end=2, timer_wait=3;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_stages_history_long
+ set timer_start=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_stages_history_long
+ set timer_start=12 where thread_id=0;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_stages_history_long
+ where thread_id=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_stages_history_long;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_stages_history_long READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_stages_history_long WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='events_stages_history_long';
diff --git a/mysql-test/suite/perfschema/t/dml_events_statements_current.test b/mysql-test/suite/perfschema/t/dml_events_statements_current.test
new file mode 100644
index 00000000..1bf00320
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_events_statements_current.test
@@ -0,0 +1,47 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_statements_current
+ where event_name like 'statement/%' limit 1;
+
+select * from performance_schema.events_statements_current
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_statements_current
+ set thread_id='1', event_id=1,
+ event_name='FOO', timer_start=1, timer_end=2, timer_wait=3;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_statements_current
+ set timer_start=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_statements_current
+ set timer_start=12 where thread_id=0;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_statements_current
+ where thread_id=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_statements_current;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_statements_current READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_statements_current WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='events_statements_current';
diff --git a/mysql-test/suite/perfschema/t/dml_events_statements_history.test b/mysql-test/suite/perfschema/t/dml_events_statements_history.test
new file mode 100644
index 00000000..7e5e0d38
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_events_statements_history.test
@@ -0,0 +1,53 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_statements_history
+ where event_name like 'statement/%' limit 1;
+
+select * from performance_schema.events_statements_history
+ where event_name='FOO';
+
+select * from performance_schema.events_statements_history
+ where event_name like 'statement/%' order by timer_wait limit 1;
+
+select * from performance_schema.events_statements_history
+ where event_name like 'statement/%' order by timer_wait desc limit 1;
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_statements_history
+ set thread_id='1', event_id=1,
+ event_name='FOO', timer_start=1, timer_end=2, timer_wait=3;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_statements_history
+ set timer_start=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_statements_history
+ set timer_start=12 where thread_id=0;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_statements_history
+ where thread_id=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_statements_history;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_statements_history READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_statements_history WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='events_statements_history';
diff --git a/mysql-test/suite/perfschema/t/dml_events_statements_history_long.test b/mysql-test/suite/perfschema/t/dml_events_statements_history_long.test
new file mode 100644
index 00000000..bc481fe1
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_events_statements_history_long.test
@@ -0,0 +1,53 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_statements_history_long
+ where event_name like 'statement/%' limit 1;
+
+select * from performance_schema.events_statements_history_long
+ where event_name='FOO';
+
+select * from performance_schema.events_statements_history_long
+ where event_name like 'statement/%' order by timer_wait limit 1;
+
+select * from performance_schema.events_statements_history_long
+ where event_name like 'statement/%' order by timer_wait desc limit 1;
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_statements_history_long
+ set thread_id='1', event_id=1,
+ event_name='FOO', timer_start=1, timer_end=2, timer_wait=3;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_statements_history_long
+ set timer_start=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_statements_history_long
+ set timer_start=12 where thread_id=0;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_statements_history_long
+ where thread_id=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_statements_history_long;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_statements_history_long READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_statements_history_long WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='events_statements_history_long';
diff --git a/mysql-test/suite/perfschema/t/dml_events_transactions_current.test b/mysql-test/suite/perfschema/t/dml_events_transactions_current.test
new file mode 100644
index 00000000..99ab2eda
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_events_transactions_current.test
@@ -0,0 +1,41 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_transactions_current
+ where event_name in ('transaction') limit 1;
+
+select * from performance_schema.events_transactions_current
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_transactions_current
+ set thread_id='1', event_id=1,
+ event_name='FOO', timer_start=1, timer_end=2, timer_wait=3;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_transactions_current
+ set timer_start=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_transactions_current
+ set timer_start=12 where thread_id=0;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_transactions_current
+ where thread_id=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_transactions_current;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_transactions_current READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_transactions_current WRITE;
+UNLOCK TABLES;
+
diff --git a/mysql-test/suite/perfschema/t/dml_events_transactions_history.test b/mysql-test/suite/perfschema/t/dml_events_transactions_history.test
new file mode 100644
index 00000000..dfad802f
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_events_transactions_history.test
@@ -0,0 +1,47 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_transactions_history
+ where event_name in ('transaction') limit 1;
+
+select * from performance_schema.events_transactions_history
+ where event_name='FOO';
+
+select * from performance_schema.events_transactions_history
+ where event_name in ('transaction') order by timer_wait limit 1;
+
+select * from performance_schema.events_transactions_history
+ where event_name in ('transaction') order by timer_wait desc limit 1;
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_transactions_history
+ set thread_id='1', event_id=1,
+ event_name='FOO', timer_start=1, timer_end=2, timer_wait=3;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_transactions_history
+ set timer_start=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_transactions_history
+ set timer_start=12 where thread_id=0;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_transactions_history
+ where thread_id=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_transactions_history;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_transactions_history READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_transactions_history WRITE;
+UNLOCK TABLES;
+
diff --git a/mysql-test/suite/perfschema/t/dml_events_transactions_history_long.test b/mysql-test/suite/perfschema/t/dml_events_transactions_history_long.test
new file mode 100644
index 00000000..b78f3e16
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_events_transactions_history_long.test
@@ -0,0 +1,47 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_transactions_history_long
+ where event_name in ('transaction') limit 1;
+
+select * from performance_schema.events_transactions_history_long
+ where event_name='FOO';
+
+select * from performance_schema.events_transactions_history_long
+ where event_name in ('transaction') order by timer_wait limit 1;
+
+select * from performance_schema.events_transactions_history_long
+ where event_name in ('transaction') order by timer_wait desc limit 1;
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_transactions_history_long
+ set thread_id='1', event_id=1,
+ event_name='FOO', timer_start=1, timer_end=2, timer_wait=3;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_transactions_history_long
+ set timer_start=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_transactions_history_long
+ set timer_start=12 where thread_id=0;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_transactions_history_long
+ where thread_id=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_transactions_history_long;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_transactions_history_long READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_transactions_history_long WRITE;
+UNLOCK TABLES;
+
diff --git a/mysql-test/suite/perfschema/t/dml_events_waits_current.test b/mysql-test/suite/perfschema/t/dml_events_waits_current.test
new file mode 100644
index 00000000..15f1e716
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_events_waits_current.test
@@ -0,0 +1,47 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_waits_current
+ where event_name like 'Wait/Synch/%' limit 1;
+
+select * from performance_schema.events_waits_current
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_waits_current
+ set thread_id='1', event_id=1,
+ event_name='FOO', timer_start=1, timer_end=2, timer_wait=3;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_waits_current
+ set timer_start=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_waits_current
+ set timer_start=12 where thread_id=0;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_waits_current
+ where thread_id=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_waits_current;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_waits_current READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_waits_current WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='events_waits_current';
diff --git a/mysql-test/suite/perfschema/t/dml_events_waits_history.test b/mysql-test/suite/perfschema/t/dml_events_waits_history.test
new file mode 100644
index 00000000..0ecb4c20
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_events_waits_history.test
@@ -0,0 +1,53 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_waits_history
+ where event_name like 'Wait/Synch/%' limit 1;
+
+select * from performance_schema.events_waits_history
+ where event_name='FOO';
+
+select * from performance_schema.events_waits_history
+ where event_name like 'Wait/Synch/%' order by timer_wait limit 1;
+
+select * from performance_schema.events_waits_history
+ where event_name like 'Wait/Synch/%' order by timer_wait desc limit 1;
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_waits_history
+ set thread_id='1', event_id=1,
+ event_name='FOO', timer_start=1, timer_end=2, timer_wait=3;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_waits_history
+ set timer_start=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_waits_history
+ set timer_start=12 where thread_id=0;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_waits_history
+ where thread_id=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_waits_history;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_waits_history READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_waits_history WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='events_waits_history';
diff --git a/mysql-test/suite/perfschema/t/dml_events_waits_history_long.test b/mysql-test/suite/perfschema/t/dml_events_waits_history_long.test
new file mode 100644
index 00000000..a5857548
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_events_waits_history_long.test
@@ -0,0 +1,53 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_waits_history_long
+ where event_name like 'Wait/Synch/%' limit 1;
+
+select * from performance_schema.events_waits_history_long
+ where event_name='FOO';
+
+select * from performance_schema.events_waits_history_long
+ where event_name like 'Wait/Synch/%' order by timer_wait limit 1;
+
+select * from performance_schema.events_waits_history_long
+ where event_name like 'Wait/Synch/%' order by timer_wait desc limit 1;
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_waits_history_long
+ set thread_id='1', event_id=1,
+ event_name='FOO', timer_start=1, timer_end=2, timer_wait=3;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_waits_history_long
+ set timer_start=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_waits_history_long
+ set timer_start=12 where thread_id=0;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_waits_history_long
+ where thread_id=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_waits_history_long;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_waits_history_long READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_waits_history_long WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='events_waits_history_long';
diff --git a/mysql-test/suite/perfschema/t/dml_ews_by_account_by_event_name.test b/mysql-test/suite/perfschema/t/dml_ews_by_account_by_event_name.test
new file mode 100644
index 00000000..ca33c15c
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_ews_by_account_by_event_name.test
@@ -0,0 +1,47 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 #
+select * from performance_schema.events_waits_summary_by_account_by_event_name
+ where event_name like 'Wait/Synch/%' limit 1;
+
+select * from performance_schema.events_waits_summary_by_account_by_event_name
+ where event_name='FOO';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_waits_summary_by_account_by_event_name
+ set event_name='FOO', user='BAR', host='BAZ',
+ count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_waits_summary_by_account_by_event_name
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_waits_summary_by_account_by_event_name
+ set count_star=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_waits_summary_by_account_by_event_name
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_waits_summary_by_account_by_event_name;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_waits_summary_by_account_by_event_name READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_waits_summary_by_account_by_event_name WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='events_waits_summary_by_account_by_event_name';
diff --git a/mysql-test/suite/perfschema/t/dml_ews_by_host_by_event_name.test b/mysql-test/suite/perfschema/t/dml_ews_by_host_by_event_name.test
new file mode 100644
index 00000000..f2123fa0
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_ews_by_host_by_event_name.test
@@ -0,0 +1,47 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 #
+select * from performance_schema.events_waits_summary_by_host_by_event_name
+ where event_name like 'Wait/Synch/%' limit 1;
+
+select * from performance_schema.events_waits_summary_by_host_by_event_name
+ where event_name='FOO';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_waits_summary_by_host_by_event_name
+ set event_name='FOO', thread_id=1,
+ count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_waits_summary_by_host_by_event_name
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_waits_summary_by_host_by_event_name
+ set count_star=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_waits_summary_by_host_by_event_name
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_waits_summary_by_host_by_event_name;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_waits_summary_by_host_by_event_name READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_waits_summary_by_host_by_event_name WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='events_waits_summary_by_host_by_event_name';
diff --git a/mysql-test/suite/perfschema/t/dml_ews_by_instance.test b/mysql-test/suite/perfschema/t/dml_ews_by_instance.test
new file mode 100644
index 00000000..0645dadd
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_ews_by_instance.test
@@ -0,0 +1,60 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_waits_summary_by_instance
+ where event_name like 'Wait/Synch/%' limit 1;
+
+select * from performance_schema.events_waits_summary_by_instance
+ where event_name='FOO';
+
+select * from performance_schema.events_waits_summary_by_instance
+ order by count_star limit 1;
+
+select * from performance_schema.events_waits_summary_by_instance
+ order by count_star desc limit 1;
+
+select * from performance_schema.events_waits_summary_by_instance
+ where min_timer_wait > 0 order by count_star limit 1;
+
+select * from performance_schema.events_waits_summary_by_instance
+ where min_timer_wait > 0 order by count_star desc limit 1;
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_waits_summary_by_instance
+ set event_name='FOO', object_instance_begin=0,
+ count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_waits_summary_by_instance
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_waits_summary_by_instance
+ set count_star=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_waits_summary_by_instance
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_waits_summary_by_instance;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_waits_summary_by_instance READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_waits_summary_by_instance WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='events_waits_summary_by_instance';
diff --git a/mysql-test/suite/perfschema/t/dml_ews_by_thread_by_event_name.test b/mysql-test/suite/perfschema/t/dml_ews_by_thread_by_event_name.test
new file mode 100644
index 00000000..1b1e0147
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_ews_by_thread_by_event_name.test
@@ -0,0 +1,48 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_waits_summary_by_thread_by_event_name
+ where event_name like 'Wait/Synch/%' limit 1;
+
+select * from performance_schema.events_waits_summary_by_thread_by_event_name
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_waits_summary_by_thread_by_event_name
+ set event_name='FOO', thread_id=1,
+ count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_waits_summary_by_thread_by_event_name
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_waits_summary_by_thread_by_event_name
+ set count_star=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_waits_summary_by_thread_by_event_name
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_waits_summary_by_thread_by_event_name;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_waits_summary_by_thread_by_event_name READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_waits_summary_by_thread_by_event_name WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='events_waits_summary_by_thread_by_event_name';
diff --git a/mysql-test/suite/perfschema/t/dml_ews_by_user_by_event_name.test b/mysql-test/suite/perfschema/t/dml_ews_by_user_by_event_name.test
new file mode 100644
index 00000000..4e89ec7a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_ews_by_user_by_event_name.test
@@ -0,0 +1,47 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 #
+select * from performance_schema.events_waits_summary_by_user_by_event_name
+ where event_name like 'Wait/Synch/%' limit 1;
+
+select * from performance_schema.events_waits_summary_by_user_by_event_name
+ where event_name='FOO';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_waits_summary_by_user_by_event_name
+ set event_name='FOO', user='BAR',
+ count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_waits_summary_by_user_by_event_name
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_waits_summary_by_user_by_event_name
+ set count_star=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_waits_summary_by_user_by_event_name
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_waits_summary_by_user_by_event_name;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_waits_summary_by_user_by_event_name READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_waits_summary_by_user_by_event_name WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='events_waits_summary_by_user_by_event_name';
diff --git a/mysql-test/suite/perfschema/t/dml_ews_global_by_event_name.test b/mysql-test/suite/perfschema/t/dml_ews_global_by_event_name.test
new file mode 100644
index 00000000..d32e23ff
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_ews_global_by_event_name.test
@@ -0,0 +1,47 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.events_waits_summary_global_by_event_name
+ where event_name like 'Wait/Synch/%' limit 1;
+
+select * from performance_schema.events_waits_summary_global_by_event_name
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.events_waits_summary_global_by_event_name
+ set event_name='FOO', count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_waits_summary_global_by_event_name
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.events_waits_summary_global_by_event_name
+ set count_star=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_waits_summary_global_by_event_name
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.events_waits_summary_global_by_event_name;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_waits_summary_global_by_event_name READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.events_waits_summary_global_by_event_name WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='events_waits_summary_global_by_event_name';
diff --git a/mysql-test/suite/perfschema/t/dml_file_instances.test b/mysql-test/suite/perfschema/t/dml_file_instances.test
new file mode 100644
index 00000000..820700b6
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_file_instances.test
@@ -0,0 +1,113 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/have_innodb.inc
+
+--disable_result_log
+select * from performance_schema.file_instances limit 1;
+
+select * from performance_schema.file_instances
+ where file_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.file_instances
+ set file_name='FOO', event_name='BAR', open_count=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.file_instances
+ set file_name='FOO';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.file_instances
+ where event_name like "wait/%";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.file_instances;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.file_instances READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.file_instances WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='file_instances';
+
+--echo ###
+--echo ### Bug#26152751: INNODB LEAKS MEMORY, PERFORMANCE_SCHEMA FILE_INSTANCES
+--echo ### #SQL-IB3129987-252773.IBD
+--echo ###
+
+CREATE DATABASE db_26152751;
+USE db_26152751;
+
+SELECT FILE_NAME FROM performance_schema.file_instances WHERE FILE_NAME LIKE "%t_db_26152751%" ORDER BY FILE_NAME;
+
+CREATE TABLE t_db_26152751 (a INT) ENGINE=MYISAM;
+
+--sorted_result
+--replace_regex /.*\/t_db_26152751/t_db_26152751/
+SELECT FILE_NAME FROM performance_schema.file_instances WHERE FILE_NAME LIKE "%t_db_26152751%" ORDER BY FILE_NAME;
+
+RENAME TABLE t_db_26152751 to t_db_26152751_new;
+
+--sorted_result
+--replace_regex /.*\/t_db_26152751/t_db_26152751/
+SELECT FILE_NAME FROM performance_schema.file_instances WHERE FILE_NAME LIKE "%t_db_26152751%" ORDER BY FILE_NAME;
+
+RENAME TABLE t_db_26152751_new to t_db_26152751;
+
+--sorted_result
+--replace_regex /.*\/t_db_26152751/t_db_26152751/
+SELECT FILE_NAME FROM performance_schema.file_instances WHERE FILE_NAME LIKE "%t_db_26152751%" ORDER BY FILE_NAME;
+
+ALTER TABLE t_db_26152751 ADD COLUMN b INT;
+
+--replace_regex /.*\/t_db_26152751/t_db_26152751/
+SELECT FILE_NAME FROM performance_schema.file_instances WHERE FILE_NAME LIKE "%t_db_26152751%" ORDER BY FILE_NAME;
+
+DROP TABLE t_db_26152751;
+
+SELECT FILE_NAME FROM performance_schema.file_instances WHERE FILE_NAME LIKE "%t_db_26152751%" ORDER BY FILE_NAME;
+
+CREATE TABLE t_db_26152751 (a INT) ENGINE=INNODB;
+
+--replace_regex /.*\/t_db_26152751/t_db_26152751/
+SELECT FILE_NAME FROM performance_schema.file_instances WHERE FILE_NAME LIKE "%t_db_26152751%" ORDER BY FILE_NAME;
+
+RENAME TABLE t_db_26152751 to t_db_26152751_new;
+
+--replace_regex /.*\/t_db_26152751/t_db_26152751/
+SELECT FILE_NAME FROM performance_schema.file_instances WHERE FILE_NAME LIKE "%t_db_26152751%" ORDER BY FILE_NAME;
+
+RENAME TABLE t_db_26152751_new to t_db_26152751;
+
+--replace_regex /.*\/t_db_26152751/t_db_26152751/
+SELECT FILE_NAME FROM performance_schema.file_instances WHERE FILE_NAME LIKE "%t_db_26152751%" ORDER BY FILE_NAME;
+
+ALTER TABLE t_db_26152751 ADD COLUMN b INT;
+
+--replace_regex /.*\/t_db_26152751/t_db_26152751/
+SELECT FILE_NAME FROM performance_schema.file_instances WHERE FILE_NAME LIKE "%t_db_26152751%" ORDER BY FILE_NAME;
+
+DROP TABLE t_db_26152751;
+
+SELECT FILE_NAME FROM performance_schema.file_instances WHERE FILE_NAME LIKE "%t_db_26152751%" ORDER BY FILE_NAME;
+
+DROP DATABASE db_26152751;
+
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='file_instances';
diff --git a/mysql-test/suite/perfschema/t/dml_fs_by_event_name.test b/mysql-test/suite/perfschema/t/dml_fs_by_event_name.test
new file mode 100644
index 00000000..50c6486e
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_fs_by_event_name.test
@@ -0,0 +1,47 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.file_summary_by_event_name
+ where event_name like 'Wait/io/%' limit 1;
+
+select * from performance_schema.file_summary_by_event_name
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.file_summary_by_event_name
+ set event_name='FOO', count_read=1, count_write=2,
+ sum_number_of_bytes_read=4, sum_number_of_bytes_write=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.file_summary_by_event_name
+ set count_read=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.file_summary_by_event_name
+ set count_write=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.file_summary_by_event_name
+ where count_read=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.file_summary_by_event_name;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.file_summary_by_event_name READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.file_summary_by_event_name WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='file_summary_by_event_name';
diff --git a/mysql-test/suite/perfschema/t/dml_fs_by_instance.test b/mysql-test/suite/perfschema/t/dml_fs_by_instance.test
new file mode 100644
index 00000000..f175e76f
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_fs_by_instance.test
@@ -0,0 +1,47 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.file_summary_by_instance
+ where event_name like 'Wait/io/%' limit 1;
+
+select * from performance_schema.file_summary_by_instance
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.file_summary_by_instance
+ set event_name='FOO', count_read=1, count_write=2,
+ sum_number_of_bytes_read=4, sum_number_of_bytes_write=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.file_summary_by_instance
+ set count_read=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.file_summary_by_instance
+ set count_write=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.file_summary_by_instance
+ where count_read=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.file_summary_by_instance;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.file_summary_by_instance READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.file_summary_by_instance WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='file_summary_by_instance';
diff --git a/mysql-test/suite/perfschema/t/dml_global_status.test b/mysql-test/suite/perfschema/t/dml_global_status.test
new file mode 100644
index 00000000..65f7c3f5
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_global_status.test
@@ -0,0 +1,36 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.global_status
+ where variable_name like 'bytes_%' limit 1;
+
+select * from performance_schema.global_status
+ where variable_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.global_status
+ set variable_name='FOO', variable_value='BAR';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.global_status
+ set variable_name='FOO', variable_value='BAR';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.global_status
+ where variable_name <> 'FOO';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.global_status;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.global_status READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.global_status WRITE;
+UNLOCK TABLES;
+
diff --git a/mysql-test/suite/perfschema/t/dml_global_variables.test b/mysql-test/suite/perfschema/t/dml_global_variables.test
new file mode 100644
index 00000000..20507732
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_global_variables.test
@@ -0,0 +1,36 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.global_variables
+ where variable_name like 'autocommit%' limit 1;
+
+select * from performance_schema.global_variables
+ where variable_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.global_variables
+ set variable_name='FOO', variable_value='BAR';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.global_variables
+ set variable_name='FOO', variable_value='BAR';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.global_variables
+ where variable_name <> 'FOO';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.global_variables;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.global_variables READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.global_variables WRITE;
+UNLOCK TABLES;
+
diff --git a/mysql-test/suite/perfschema/t/dml_handler.test b/mysql-test/suite/perfschema/t/dml_handler.test
new file mode 100644
index 00000000..d289d89c
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_handler.test
@@ -0,0 +1,46 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+#==============================================================================
+# This test verifies that the peformance schema storage engine does not support
+# HANDLER operations.
+#
+# Get the list of tables from information_schema.tables, store the table names
+# in a temporary table. For each table in the list, attempt a HANDLER ... OPEN,
+# which should return error 1031, "Table storage engine for '<table name>'
+# doesn't have this option."
+#
+--echo #
+--echo # Create a temporary table of performance schema table names
+--echo #
+
+CREATE TEMPORARY TABLE table_list (id INT AUTO_INCREMENT, PRIMARY KEY (id)) AS
+ SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
+ WHERE TABLE_SCHEMA='performance_schema'
+ ORDER BY TABLE_NAME;
+
+--enable_prepare_warnings
+
+SELECT COUNT(*) FROM table_list INTO @table_count;
+
+let $count=`SELECT @table_count`;
+
+--echo #
+--echo # For each table in the performance schema, attempt HANDLER...OPEN,
+--echo # which should fail with an error 1031, ER_ILLEGAL_HA.
+--echo #
+
+while ($count > 0)
+{
+ eval SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=$count;
+ let $table_name = `SELECT @table_name`;
+ --error ER_ILLEGAL_HA
+ eval HANDLER performance_schema.$table_name OPEN;
+ dec $count;
+}
+
+--disable_prepare_warnings
+
+DROP TEMPORARY TABLE table_list;
diff --git a/mysql-test/suite/perfschema/t/dml_host_cache.test b/mysql-test/suite/perfschema/t/dml_host_cache.test
new file mode 100644
index 00000000..3968c08f
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_host_cache.test
@@ -0,0 +1,49 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.host_cache
+ where IP like '%' limit 1;
+
+select * from performance_schema.host_cache
+ where IP='localhost';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.host_cache
+ set IP='FOO', SUM_BLOCKING_ERRORS=1, COUNT_FCRDNS_ERRORS=2;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.host_cache
+ set COUNT_UNKNOWN_ERRORS=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.host_cache
+ set SUM_BLOCKING_ERRORS=12 where IP='127.0.0.1';
+
+select HOST from performance_schema.host_cache
+ where IP='::1';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.host_cache
+ where IP='::1';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.host_cache;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.host_cache READ;
+UNLOCK TABLES;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.host_cache WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='host_cache';
diff --git a/mysql-test/suite/perfschema/t/dml_hosts.test b/mysql-test/suite/perfschema/t/dml_hosts.test
new file mode 100644
index 00000000..83caed37
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_hosts.test
@@ -0,0 +1,47 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.hosts
+ limit 1;
+
+select * from performance_schema.hosts
+ where host='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.hosts
+ set host='FOO',
+ current_connections=1, total_connections=2;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.hosts
+ set current_connections=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.hosts
+ set current_connections=12 where host like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.hosts
+ where total_connections=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.hosts;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.hosts READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.hosts WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='hosts';
diff --git a/mysql-test/suite/perfschema/t/dml_mems_by_account_by_event_name.test b/mysql-test/suite/perfschema/t/dml_mems_by_account_by_event_name.test
new file mode 100644
index 00000000..2d23feba
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_mems_by_account_by_event_name.test
@@ -0,0 +1,48 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.memory_summary_by_account_by_event_name
+ where event_name like 'memory/%' limit 1;
+
+select * from performance_schema.memory_summary_by_account_by_event_name
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.memory_summary_by_account_by_event_name
+ set event_name='FOO', user='BAR', host='BAZ',
+ count_alloc=1, count_free=2, sum_number_of_bytes_alloc=3,
+ sum_number_of_bytes_free=4, low_count_used=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.memory_summary_by_account_by_event_name
+ set count_alloc=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.memory_summary_by_account_by_event_name
+ set count_alloc=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.memory_summary_by_account_by_event_name
+ where count_alloc=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.memory_summary_by_account_by_event_name;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.memory_summary_by_account_by_event_name READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.memory_summary_by_account_by_event_name WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='memory_summary_by_account_by_event_name';
diff --git a/mysql-test/suite/perfschema/t/dml_mems_by_host_by_event_name.test b/mysql-test/suite/perfschema/t/dml_mems_by_host_by_event_name.test
new file mode 100644
index 00000000..421771bd
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_mems_by_host_by_event_name.test
@@ -0,0 +1,48 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.memory_summary_by_host_by_event_name
+ where event_name like 'memory/%' limit 1;
+
+select * from performance_schema.memory_summary_by_host_by_event_name
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.memory_summary_by_host_by_event_name
+ set event_name='FOO', host='BAZ',
+ count_alloc=1, count_free=2, sum_number_of_bytes_alloc=3,
+ sum_number_of_bytes_free=4, low_count_used=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.memory_summary_by_host_by_event_name
+ set count_alloc=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.memory_summary_by_host_by_event_name
+ set count_alloc=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.memory_summary_by_host_by_event_name
+ where count_alloc=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.memory_summary_by_host_by_event_name;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.memory_summary_by_host_by_event_name READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.memory_summary_by_host_by_event_name WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='memory_summary_by_host_by_event_name';
diff --git a/mysql-test/suite/perfschema/t/dml_mems_by_thread_by_event_name.test b/mysql-test/suite/perfschema/t/dml_mems_by_thread_by_event_name.test
new file mode 100644
index 00000000..5a75dbe7
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_mems_by_thread_by_event_name.test
@@ -0,0 +1,42 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.memory_summary_by_thread_by_event_name
+ where event_name like 'memory/%' limit 1;
+
+select * from performance_schema.memory_summary_by_thread_by_event_name
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.memory_summary_by_thread_by_event_name
+ set event_name='FOO', thread_id=12,
+ count_alloc=1, count_free=2, sum_number_of_bytes_alloc=3,
+ sum_number_of_bytes_free=4, low_count_used=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.memory_summary_by_thread_by_event_name
+ set count_alloc=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.memory_summary_by_thread_by_event_name
+ set count_alloc=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.memory_summary_by_thread_by_event_name
+ where count_alloc=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.memory_summary_by_thread_by_event_name;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.memory_summary_by_thread_by_event_name READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.memory_summary_by_thread_by_event_name WRITE;
+UNLOCK TABLES;
+
diff --git a/mysql-test/suite/perfschema/t/dml_mems_by_user_by_event_name.test b/mysql-test/suite/perfschema/t/dml_mems_by_user_by_event_name.test
new file mode 100644
index 00000000..2ea8cb27
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_mems_by_user_by_event_name.test
@@ -0,0 +1,48 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.memory_summary_by_user_by_event_name
+ where event_name like 'memory/%' limit 1;
+
+select * from performance_schema.memory_summary_by_user_by_event_name
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.memory_summary_by_user_by_event_name
+ set event_name='FOO', user='BAR',
+ count_alloc=1, count_free=2, sum_number_of_bytes_alloc=3,
+ sum_number_of_bytes_free=4, low_count_used=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.memory_summary_by_user_by_event_name
+ set count_alloc=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.memory_summary_by_user_by_event_name
+ set count_alloc=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.memory_summary_by_user_by_event_name
+ where count_alloc=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.memory_summary_by_user_by_event_name;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.memory_summary_by_user_by_event_name READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.memory_summary_by_user_by_event_name WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='memory_summary_by_user_by_event_name';
diff --git a/mysql-test/suite/perfschema/t/dml_mems_global_by_event_name.test b/mysql-test/suite/perfschema/t/dml_mems_global_by_event_name.test
new file mode 100644
index 00000000..aac560ef
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_mems_global_by_event_name.test
@@ -0,0 +1,48 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.memory_summary_global_by_event_name
+ where event_name like 'memory/%' limit 1;
+
+select * from performance_schema.memory_summary_global_by_event_name
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.memory_summary_global_by_event_name
+ set event_name='FOO',
+ count_alloc=1, count_free=2, sum_number_of_bytes_alloc=3,
+ sum_number_of_bytes_free=4, low_count_used=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.memory_summary_global_by_event_name
+ set count_alloc=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.memory_summary_global_by_event_name
+ set count_alloc=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.memory_summary_global_by_event_name
+ where count_alloc=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.memory_summary_global_by_event_name;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.memory_summary_global_by_event_name READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.memory_summary_global_by_event_name WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='memory_summary_global_by_event_name';
diff --git a/mysql-test/suite/perfschema/t/dml_metadata_locks.test b/mysql-test/suite/perfschema/t/dml_metadata_locks.test
new file mode 100644
index 00000000..92448a15
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_metadata_locks.test
@@ -0,0 +1,41 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.metadata_locks;
+--enable_result_log
+
+select * from performance_schema.metadata_locks
+ where object_name='foo';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.metadata_locks
+ set object_name='FOO', owner_thread_id=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.metadata_locks
+ set owner_thread_id=12 where object_name='foo';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.metadata_locks;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.metadata_locks
+ where timer_name='CYCLE';
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.metadata_locks READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.metadata_locks WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='metadata_locks';
diff --git a/mysql-test/suite/perfschema/t/dml_mutex_instances.test b/mysql-test/suite/perfschema/t/dml_mutex_instances.test
new file mode 100644
index 00000000..c0d6f2e5
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_mutex_instances.test
@@ -0,0 +1,41 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.mutex_instances limit 1;
+
+select * from performance_schema.mutex_instances
+ where name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.mutex_instances
+ set name='FOO', object_instance_begin=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.mutex_instances
+ set name='FOO';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.mutex_instances
+ where name like "wait/%";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.mutex_instances;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.mutex_instances READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.mutex_instances WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='mutex_instances';
diff --git a/mysql-test/suite/perfschema/t/dml_os_global_by_type.test b/mysql-test/suite/perfschema/t/dml_os_global_by_type.test
new file mode 100644
index 00000000..010423f9
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_os_global_by_type.test
@@ -0,0 +1,63 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 #
+select * from performance_schema.objects_summary_global_by_type
+ where object_schema = 'performance_schema' limit 1;
+
+select * from performance_schema.objects_summary_global_by_type
+ where object_schema='FOO';
+
+--replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 #
+select * from performance_schema.objects_summary_global_by_type
+ order by count_star limit 1;
+
+--replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 #
+select * from performance_schema.objects_summary_global_by_type
+ order by count_star desc limit 1;
+
+--replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 #
+select * from performance_schema.objects_summary_global_by_type
+ where object_type = 'TABLE' order by object_schema, object_name limit 1;
+
+--replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 #
+select * from performance_schema.objects_summary_global_by_type
+ where object_type = 'TABLE' order by object_schema desc, object_name desc limit 1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.objects_summary_global_by_type
+ set object_type='TABLE', schema_name='FOO', object_name='BAR',
+ count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.objects_summary_global_by_type
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.objects_summary_global_by_type
+ set count_star=12 where object_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.objects_summary_global_by_type
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.objects_summary_global_by_type;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.objects_summary_global_by_type READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.objects_summary_global_by_type WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='objects_summary_global_by_type';
diff --git a/mysql-test/suite/perfschema/t/dml_performance_timers.test b/mysql-test/suite/perfschema/t/dml_performance_timers.test
new file mode 100644
index 00000000..af6d2a2a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_performance_timers.test
@@ -0,0 +1,43 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/have_timer_cycle.inc
+
+--replace_column 2 <frequency> 3 <resolution> 4 <overhead>
+select * from performance_schema.performance_timers;
+
+--replace_column 2 <frequency> 3 <resolution> 4 <overhead>
+select * from performance_schema.performance_timers
+ where timer_name='CYCLE';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.performance_timers
+ set timer_name='FOO', timer_frequency=1,
+ timer_resolution=2, timer_overhead=3;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.performance_timers
+ set timer_frequency=12 where timer_name='CYCLE';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.performance_timers;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.performance_timers
+ where timer_name='CYCLE';
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.performance_timers READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.performance_timers WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='performance_timers';
diff --git a/mysql-test/suite/perfschema/t/dml_prepared_statements_instances.test b/mysql-test/suite/perfschema/t/dml_prepared_statements_instances.test
new file mode 100644
index 00000000..3c96740d
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_prepared_statements_instances.test
@@ -0,0 +1,43 @@
+# This line and the line below is a temporary line for tests that do not need MyISAM in future, but need to be kept for tests that need it.
+#--source include/have_myisam.inc
+
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+#--disable_result_log
+select * from performance_schema.prepared_statements_instances
+ where owner_object_name like 'XXYYZZ%' limit 1;
+
+select * from performance_schema.prepared_statements_instances
+ where owner_object_name='XXYYZZ';
+#--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.prepared_statements_instances
+ set owner_object_name='XXYYZZ', count_execute=1, sum_timer_execute=2,
+ min_timer_execute=3, avg_timer_execute=4, max_timer_execute=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.prepared_statements_instances set count_execute=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.prepared_statements_instances
+ set count_execute=12 where owner_object_name like "XXYYZZ";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.prepared_statements_instances
+ where count_execute=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.prepared_statements_instances;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.prepared_statements_instances READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.prepared_statements_instances WRITE;
+UNLOCK TABLES;
+
diff --git a/mysql-test/suite/perfschema/t/dml_processlist.test b/mysql-test/suite/perfschema/t/dml_processlist.test
new file mode 100644
index 00000000..c075db3e
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_processlist.test
@@ -0,0 +1,39 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+
+select @@global.performance_schema_show_processlist into @save_processlist;
+set @@global.performance_schema_show_processlist = 'on';
+
+--disable_result_log
+select * from performance_schema.processlist
+ where user like 'event_scheduler';
+
+select * from performance_schema.processlist
+ where user = 'FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.processlist
+ values (12, 'foo', 'bar', 'test', null, 1000, 'state', 'info');
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.processlist
+ set id=12, user='foo';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.processlist
+ where id <> 99;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.processlist;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.processlist READ;
+UNLOCK TABLES;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.processlist WRITE;
+UNLOCK TABLES;
+
+set @@global.performance_schema_show_processlist = @save_processlist;
diff --git a/mysql-test/suite/perfschema/t/dml_replication_applier_configuration.test b/mysql-test/suite/perfschema/t/dml_replication_applier_configuration.test
new file mode 100644
index 00000000..f465e8f7
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_replication_applier_configuration.test
@@ -0,0 +1,38 @@
+# Tests for PERFORMANCE_SCHEMA
+
+# This test verifies the correct behaviour in case of invalid
+# usage of DMLs on the table replication_applier_configuration.
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+SELECT * FROM performance_schema.replication_applier_configuration
+ LIMIT 1;
+
+sELECT * FROM performance_schema.replication_applier_configuration
+ WHERE desired_delay=12;
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+INSERT INTO performance_schema.replication_applier_configuration
+ SET desired_delay=2;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+UPDATE performance_schema.replication_applier_configuration
+ SET desired_delay=12 WHERE desired_delay=2;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+DELETE FROM performance_schema.replication_applier_configuration
+ WHERE desired_delay=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+DELETE FROM performance_schema.replication_applier_configuration;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.replication_applier_configuration READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.replication_applier_configuration WRITE;
+UNLOCK TABLES;
diff --git a/mysql-test/suite/perfschema/t/dml_replication_applier_status.test b/mysql-test/suite/perfschema/t/dml_replication_applier_status.test
new file mode 100644
index 00000000..d2738c1c
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_replication_applier_status.test
@@ -0,0 +1,42 @@
+# Tests for PERFORMANCE_SCHEMA
+
+# This test verifies the correct behaviour in case of invalid
+# usage of DMLs on the table replication_applier_status.
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+SELECT * FROM performance_schema.replication_applier_status
+ LIMIT 1;
+
+SELECT * FROM performance_schema.replication_applier_status
+ WHERE service_state='YES' OR remaining_delay=12;
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+INSERT INTO performance_schema.replication_applier_status
+ SET service_state='YES', remaining_delay=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+UPDATE performance_schema.replication_applier_status
+ SET remaining_delay=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+UPDATE performance_schema.replication_applier_status
+ SET remaining_delay=12 WHERE service_state='YES';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+DELETE FROM performance_schema.replication_applier_status
+ WHERE service_state='YES';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+DELETE FROM performance_schema.replication_applier_status;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.replication_applier_status READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.replication_applier_status WRITE;
+UNLOCK TABLES;
diff --git a/mysql-test/suite/perfschema/t/dml_replication_applier_status_by_coordinator.test b/mysql-test/suite/perfschema/t/dml_replication_applier_status_by_coordinator.test
new file mode 100644
index 00000000..6c1b82b8
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_replication_applier_status_by_coordinator.test
@@ -0,0 +1,43 @@
+# Tests for PERFORMANCE_SCHEMA
+
+# This test verifies the correct behaviour in case of invalid
+# usage of DMLs on the table replication_applier_status_by_coordinator
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+SELECT * FROM performance_schema.replication_applier_status_by_coordinator
+ LIMIT 1;
+
+SELECT * FROM performance_schema.replication_applier_status_by_coordinator
+ WHERE service_state='YES' or last_error_message='ERROR';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+INSERT INTO performance_schema.replication_applier_status_by_coordinator
+ SET service_state='YES', last_error_message='ERROR', thread_id=2,
+ last_error_number=1234;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+UPDATE performance_schema.replication_applier_status_by_coordinator
+ SET last_error_number=1234;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+UPDATE performance_schema.replication_applier_status_by_coordinator
+ SET last_error_number=1234 where service_state like "YES";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+DELETE FROM performance_schema.replication_applier_status_by_coordinator
+ WHERE thread_id=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+DELETE FROM performance_schema.replication_applier_status_by_coordinator;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.replication_applier_status_by_coordinator READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.replication_applier_status_by_coordinator WRITE;
+UNLOCK TABLES;
diff --git a/mysql-test/suite/perfschema/t/dml_replication_applier_status_by_worker.test b/mysql-test/suite/perfschema/t/dml_replication_applier_status_by_worker.test
new file mode 100644
index 00000000..6c218a99
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_replication_applier_status_by_worker.test
@@ -0,0 +1,50 @@
+# Tests for PERFORMANCE_SCHEMA
+
+# This test verifies the correct behaviour in case of invalid
+# usage of DMLs on the table replication_applier_status_by_worker.
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+SELECT * FROM performance_schema.replication_applier_status_by_worker
+ LIMIT 1;
+
+SELECT * FROM performance_schema.replication_applier_status_by_worker
+ WHERE service_state='YES' OR last_error_message='ERROR';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+INSERT INTO performance_schema.replication_applier_status_by_worker
+ SET service_state='YES', last_error_message='ERROR',
+ worker_id=1, thread_id=2, last_error_number=1234;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+UPDATE performance_schema.replication_applier_status_by_worker
+ SET worker_id=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+UPDATE performance_schema.replication_applier_status_by_worker
+ SET worker_d=12 where service_state like "YES";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+DELETE FROM performance_schema.replication_applier_status_by_worker
+ WHERE worker_id=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+DELETE FROM performance_schema.replication_applier_status_by_worker;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.replication_applier_status_by_worker READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.replication_applier_status_by_worker WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='replication_applier_status_by_worker';
diff --git a/mysql-test/suite/perfschema/t/dml_replication_connection_configuration.test b/mysql-test/suite/perfschema/t/dml_replication_connection_configuration.test
new file mode 100644
index 00000000..b787cbf8
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_replication_connection_configuration.test
@@ -0,0 +1,43 @@
+# Tests for PERFORMANCE_SCHEMA
+
+# This test verifies the correct behaviour in case of invalid
+# usage of DMLs on the table replication_connection_configuration.
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+SELECT * FROM performance_schema.replication_connection_configuration
+ LIMIT 1;
+
+SELECT * FROM performance_schema.replication_connection_configuration
+ WHERE user='FOO' or host='BAR';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+INSERT INTO performance_schema.replication_connection_configuration
+ SET user='FOO', host='BAR',
+ port=1, connection_retry_count=2;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+UPDATE performance_schema.replication_connection_configuration
+ SET connection_retry_interval=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+UPDATE performance_schema.replication_connection_configuration
+ SET connection_retry_interval=12 WHERE host LIKE "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+DELETE FROM performance_schema.replication_connection_configuration
+ WHERE connection_retry_count=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+DELETE FROM performance_schema.replication_connection_configuration;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.replication_connection_configuration READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.replication_connection_configuration WRITE;
+UNLOCK TABLES;
diff --git a/mysql-test/suite/perfschema/t/dml_replication_connection_status.test b/mysql-test/suite/perfschema/t/dml_replication_connection_status.test
new file mode 100644
index 00000000..207ee9f5
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_replication_connection_status.test
@@ -0,0 +1,43 @@
+# Tests for PERFORMANCE_SCHEMA
+
+# This test verifies the correct behaviour in case of invalid
+# usage of DMLs on the table replication_connection_status.
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+SELECT * FROM performance_schema.replication_connection_status
+ LIMIT 1;
+
+SELECT * FROM performance_schema.replication_connection_status
+ WHERE received_transaction_set='FOO' OR last_error_message='BAR';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+INSERT INTO performance_schema.replication_connection_status
+ SET received_transaction_set='FOO', last_error_message='BAR',
+ thread_id=1, last_error_number=2;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+UPDATE performance_schema.replication_connection_status
+ SET last_error_number=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+UPDATE performance_schema.replication_connection_status
+ SET thread_id=12 WHERE received_transaction_set like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+DELETE FROM performance_schema.replication_connection_status
+ WHERE last_error_number=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+DELETE FROM performance_schema.replication_connection_status;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.replication_connection_status READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.replication_connection_status WRITE;
+UNLOCK TABLES;
diff --git a/mysql-test/suite/perfschema/t/dml_replication_group_member_stats.test b/mysql-test/suite/perfschema/t/dml_replication_group_member_stats.test
new file mode 100644
index 00000000..db42ce2d
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_replication_group_member_stats.test
@@ -0,0 +1,38 @@
+# This test verifies the correct behaviour in case of invalid
+# usage of DMLs on the table replication_group_member_stats
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+SELECT * FROM performance_schema.replication_group_member_stats
+ LIMIT 1;
+
+SELECT * FROM performance_schema.replication_group_member_stats
+ WHERE channel_name='FOO';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+INSERT INTO performance_schema.replication_group_member_stats
+ SET channel_name='FOO', node_id=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+UPDATE performance_schema.replication_group_member_stats
+ SET member_id=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+UPDATE performance_schema.replication_group_member_stats
+ SET member_id=12 WHERE group_name LIKE "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+DELETE FROM performance_schema.replication_group_member_stats
+ WHERE member_id=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+DELETE FROM performance_schema.replication_group_member_stats;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.replication_group_member_stats READ;
+UNLOCK TABLES;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.replication_group_member_stats WRITE;
+UNLOCK TABLES;
diff --git a/mysql-test/suite/perfschema/t/dml_replication_group_members.test b/mysql-test/suite/perfschema/t/dml_replication_group_members.test
new file mode 100644
index 00000000..1a49b2d1
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_replication_group_members.test
@@ -0,0 +1,40 @@
+# This test verifies the correct behaviour in case of invalid
+# usage of DMLs on the table replication_group_members.
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+SELECT * FROM performance_schema.replication_group_members
+ LIMIT 1;
+
+SELECT * FROM performance_schema.replication_group_members
+ WHERE channel_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+INSERT INTO performance_schema.replication_group_members
+ SET channel_name='FOO', member_id=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+UPDATE performance_schema.replication_group_members
+ SET member_id=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+UPDATE performance_schema.replication_group_members
+ SET member_id=12 WHERE channel_name LIKE "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+DELETE FROM performance_schema.replication_group_members
+ WHERE member_id=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+DELETE FROM performance_schema.replication_group_members;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.replication_group_members READ;
+UNLOCK TABLES;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.replication_group_members WRITE;
+UNLOCK TABLES;
diff --git a/mysql-test/suite/perfschema/t/dml_rwlock_instances.test b/mysql-test/suite/perfschema/t/dml_rwlock_instances.test
new file mode 100644
index 00000000..1230c680
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_rwlock_instances.test
@@ -0,0 +1,41 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.rwlock_instances limit 1;
+
+select * from performance_schema.rwlock_instances
+ where name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.rwlock_instances
+ set name='FOO', object_instance_begin=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.rwlock_instances
+ set name='FOO';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.rwlock_instances
+ where name like "wait/%";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.rwlock_instances;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.rwlock_instances READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.rwlock_instances WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='rwlock_instances';
diff --git a/mysql-test/suite/perfschema/t/dml_session_account_connect_attrs.test b/mysql-test/suite/perfschema/t/dml_session_account_connect_attrs.test
new file mode 100644
index 00000000..3ed60c57
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_session_account_connect_attrs.test
@@ -0,0 +1,47 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+SELECT * FROM performance_schema.session_account_connect_attrs
+ LIMIT 1;
+
+SELECT * FROM performance_schema.session_account_connect_attrs
+ where ATTR_NAME='FOO' OR ATTR_VALUE='BAR';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+INSERT INTO performance_schema.session_account_connect_attrs
+ SET ATTR_NAME='FOO', ATTR_VALUE='BAR',
+ ORDINAL_POSITION=100, PROCESS_ID=102;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+UPDATE performance_schema.session_account_connect_attrs
+ SET ATTR_NAME='FOO';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+UPDATE performance_schema.session_account_connect_attrs
+ SET ATTR_NAME='FOO' WHERE ATTR_VALUE='BAR';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+DELETE FROM performance_schema.session_account_connect_attrs
+ WHERE ATTR_VALUE='BAR';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+DELETE FROM performance_schema.session_account_connect_attrs;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.session_account_connect_attrs READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.session_account_connect_attrs WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='session_account_connect_attrs';
diff --git a/mysql-test/suite/perfschema/t/dml_session_connect_attrs.test b/mysql-test/suite/perfschema/t/dml_session_connect_attrs.test
new file mode 100644
index 00000000..b0a40d73
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_session_connect_attrs.test
@@ -0,0 +1,47 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+SELECT * FROM performance_schema.session_connect_attrs
+ LIMIT 1;
+
+SELECT * FROM performance_schema.session_connect_attrs
+ where ATTR_NAME='FOO' OR ATTR_VALUE='BAR';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+INSERT INTO performance_schema.session_connect_attrs
+ SET ATTR_NAME='FOO', ATTR_VALUE='BAR',
+ ORDINAL_POSITION=100, PROCESS_ID=102;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+UPDATE performance_schema.session_connect_attrs
+ SET ATTR_NAME='FOO';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+UPDATE performance_schema.session_connect_attrs
+ SET ATTR_NAME='FOO' WHERE ATTR_VALUE='BAR';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+DELETE FROM performance_schema.session_connect_attrs
+ WHERE ATTR_VALUE='BAR';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+DELETE FROM performance_schema.session_connect_attrs;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.session_connect_attrs READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.session_connect_attrs WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='session_connect_attrs';
diff --git a/mysql-test/suite/perfschema/t/dml_session_status.test b/mysql-test/suite/perfschema/t/dml_session_status.test
new file mode 100644
index 00000000..c5995738
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_session_status.test
@@ -0,0 +1,36 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.session_status
+ where variable_name like 'bytes_%' limit 1;
+
+select * from performance_schema.session_status
+ where variable_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.session_status
+ set variable_name='FOO', variable_value='BAR';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.session_status
+ set variable_name='FOO', variable_value='BAR';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.session_status
+ where variable_name <> 'FOO';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.session_status;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.session_status READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.session_status WRITE;
+UNLOCK TABLES;
+
diff --git a/mysql-test/suite/perfschema/t/dml_session_variables.test b/mysql-test/suite/perfschema/t/dml_session_variables.test
new file mode 100644
index 00000000..0640ce05
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_session_variables.test
@@ -0,0 +1,36 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.session_variables
+ where variable_name like 'bytes_%' limit 1;
+
+select * from performance_schema.session_variables
+ where variable_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.session_variables
+ set variable_name='FOO', variable_value='BAR';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.session_variables
+ set variable_name='FOO', variable_value='BAR';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.session_variables
+ where variable_name <> 'FOO';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.session_variables;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.session_variables READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.session_variables WRITE;
+UNLOCK TABLES;
+
diff --git a/mysql-test/suite/perfschema/t/dml_setup_actors.test b/mysql-test/suite/perfschema/t/dml_setup_actors.test
new file mode 100644
index 00000000..e6c17de3
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_setup_actors.test
@@ -0,0 +1,147 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_warnings
+drop table if exists test.setup_actors;
+--enable_warnings
+
+# Save the setup
+create table test.setup_actors as
+ select * from performance_schema.setup_actors;
+
+# Inserting Duplicate values in the table should
+# throw error
+--error ER_DUP_KEY
+insert into performance_schema.setup_actors
+ values ('%','%','%','YES', 'YES');
+--error ER_DUP_KEY
+insert into performance_schema.setup_actors
+ values ('%','%','%','NO', 'NO');
+
+truncate table performance_schema.setup_actors;
+
+select * from performance_schema.setup_actors;
+
+select * from performance_schema.setup_actors
+ where user = '%';
+
+insert into performance_schema.setup_actors
+ set user='Joe', host='localhost';
+
+insert into performance_schema.setup_actors
+ set user='Joe', host='%';
+
+insert into performance_schema.setup_actors
+ set user='%', host='server1';
+
+insert into performance_schema.setup_actors
+ set user='%', host='%';
+
+# Insert with wrong value for ENABLED column
+--error 1265
+insert into performance_schema.setup_actors
+ values ('localhost', 'user1', '%', 'NO%', 'NO');
+
+# Insert with wrong value for HISTORY column
+--error 1265
+insert into performance_schema.setup_actors
+ values ('localhost', 'user1', '%', 'NO', 'KO');
+
+select * from performance_schema.setup_actors
+ order by USER, HOST;
+
+--error ER_WRONG_PERFSCHEMA_USAGE
+update performance_schema.setup_actors
+ set user='ILLEGAL';
+
+--error ER_WRONG_PERFSCHEMA_USAGE
+update performance_schema.setup_actors
+ set host='ILLEGAL';
+
+--error ER_WRONG_PERFSCHEMA_USAGE
+update performance_schema.setup_actors
+ set role='ILLEGAL';
+
+# update on ENABLED column is allowed
+update performance_schema.setup_actors
+ set ENABLED='YES';
+
+# update on HISTORY column is allowed
+update performance_schema.setup_actors
+ set HISTORY='YES';
+
+# update on ENABLED column with wrong values
+#throws error
+--error 1265
+update performance_schema.setup_actors
+ set ENABLED='';
+
+--error 1265
+update performance_schema.setup_actors
+ set ENABLED='YESS';
+
+--error 1265
+update performance_schema.setup_actors
+ set ENABLED='NO%';
+
+--error ER_BAD_NULL_ERROR
+update performance_schema.setup_actors
+ set ENABLED=NULL;
+
+--error 1265
+update performance_schema.setup_actors
+ set HISTORY='YESS';
+
+--error 1265
+update performance_schema.setup_actors
+ set HISTORY='NO%';
+
+--error ER_BAD_NULL_ERROR
+update performance_schema.setup_actors
+ set HISTORY=NULL;
+
+select * from performance_schema.setup_actors
+ order by USER, HOST;
+
+delete from performance_schema.setup_actors
+ where user = 'Joe' and host = 'localhost';
+
+select * from performance_schema.setup_actors
+ order by USER, HOST;
+
+delete from performance_schema.setup_actors;
+
+select * from performance_schema.setup_actors
+ order by USER, HOST;
+
+LOCK TABLES performance_schema.setup_actors READ;
+UNLOCK TABLES;
+
+LOCK TABLES performance_schema.setup_actors WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # WL#2284: Increase the length of a user name
+--echo #
+
+insert into performance_schema.setup_actors
+ set user='user_name_len_22_01234', host='localhost';
+
+delete from performance_schema.setup_actors
+ where user = 'user_name_len_22_01234' and host = 'localhost';
+
+
+# Restore the setup
+truncate table performance_schema.setup_actors;
+insert into performance_schema.setup_actors
+ select * from test.setup_actors;
+drop table test.setup_actors;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='setup_actors';
diff --git a/mysql-test/suite/perfschema/t/dml_setup_consumers.test b/mysql-test/suite/perfschema/t/dml_setup_consumers.test
new file mode 100644
index 00000000..78eeca01
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_setup_consumers.test
@@ -0,0 +1,46 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+select * from performance_schema.setup_consumers;
+
+select * from performance_schema.setup_consumers
+ where name='events_waits_current';
+
+select * from performance_schema.setup_consumers
+ where enabled='YES';
+
+select * from performance_schema.setup_consumers
+ where enabled='NO';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.setup_consumers
+ set name='FOO', enabled='YES';
+
+--error ER_WRONG_PERFSCHEMA_USAGE
+update performance_schema.setup_consumers
+ set name='FOO';
+
+update performance_schema.setup_consumers
+ set enabled='YES';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.setup_consumers;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.setup_consumers
+ where name='events_waits_current';
+
+LOCK TABLES performance_schema.setup_consumers READ;
+UNLOCK TABLES;
+
+LOCK TABLES performance_schema.setup_consumers WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='setup_consumers';
diff --git a/mysql-test/suite/perfschema/t/dml_setup_instruments.test b/mysql-test/suite/perfschema/t/dml_setup_instruments.test
new file mode 100644
index 00000000..f66f8d28
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_setup_instruments.test
@@ -0,0 +1,110 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+# The query result are not re producible,
+# due to variations in platforms and plugins
+# We still execute the select statement, for:
+# - code coverage
+# - make sure it does not crash
+# - valgrind coverage
+
+--disable_result_log
+select * from performance_schema.setup_instruments;
+--enable_result_log
+
+# DEBUG_SYNC::mutex is dependent on the build (DEBUG only)
+
+select * from performance_schema.setup_instruments
+ where name like 'Wait/Synch/Mutex/sql/%'
+ and name not in ('wait/synch/mutex/sql/DEBUG_SYNC::mutex')
+ order by name limit 10;
+
+# CRYPTO_dynlock_value::lock is dependent on the build (SSL)
+# LOCK_named_pipe_full_access_group is dependent on the build (Windows)
+
+select * from performance_schema.setup_instruments
+ where name like 'Wait/Synch/Rwlock/sql/%'
+ and name not in (
+ 'wait/synch/rwlock/sql/CRYPTO_dynlock_value::lock',
+ 'wait/synch/rwlock/sql/LOCK_named_pipe_full_access_group')
+ order by name limit 10;
+
+# COND_handler_count is dependent on the build (Windows only)
+# DEBUG_SYNC::cond is dependent on the build (DEBUG only)
+# COND_main_thread_in_use is dependent on the build (non Windows)
+# COND_start_signal_handler is dependent on the build (non Windows)
+
+select * from performance_schema.setup_instruments
+ where name like 'Wait/Synch/Cond/sql/%'
+ and name not in (
+ 'wait/synch/cond/sql/COND_open',
+ 'wait/synch/cond/sql/COND_handler_count',
+ 'wait/synch/cond/sql/DEBUG_SYNC::cond',
+ 'wait/synch/cond/sql/COND_socket_listener_active',
+ 'wait/synch/cond/sql/COND_start_signal_handler')
+ order by name limit 10;
+
+--disable_result_log
+select * from performance_schema.setup_instruments
+ where name='Wait';
+--enable_result_log
+
+--disable_result_log
+select * from performance_schema.setup_instruments
+ where enabled='YES';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.setup_instruments
+ set name='FOO', enabled='YES', timed='YES';
+
+--error ER_WRONG_PERFSCHEMA_USAGE
+update performance_schema.setup_instruments
+ set name='FOO';
+
+update performance_schema.setup_instruments
+ set enabled='NO';
+
+update performance_schema.setup_instruments
+ set timed='NO';
+
+--disable_result_log
+select * from performance_schema.setup_instruments;
+--enable_result_log
+
+update performance_schema.setup_instruments
+ set enabled='YES', timed='YES';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.setup_instruments;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.setup_instruments
+ where name like 'Wait/Synch/%';
+
+LOCK TABLES performance_schema.setup_instruments READ;
+UNLOCK TABLES;
+
+LOCK TABLES performance_schema.setup_instruments WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # Bug#13813193 ASSERTION `TABLE->READ_SET ==
+--echo # &TABLE->DEF_READ_SET' FAILED / MYSQL_UPDATE
+--echo #
+UPDATE performance_schema.setup_instruments SET timed='NO'
+ORDER BY RAND();
+
+# Test cleanup
+
+update performance_schema.setup_instruments
+ set enabled='YES', TIMED='YES';
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='setup_instruments';
diff --git a/mysql-test/suite/perfschema/t/dml_setup_objects.test b/mysql-test/suite/perfschema/t/dml_setup_objects.test
new file mode 100644
index 00000000..3055cd8b
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_setup_objects.test
@@ -0,0 +1,102 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_warnings
+drop table if exists test.setup_objects;
+--enable_warnings
+SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
+# Save the setup
+create table test.setup_objects as
+ select * from performance_schema.setup_objects;
+truncate table performance_schema.setup_objects;
+
+# Test
+
+select * from performance_schema.setup_objects;
+
+select * from performance_schema.setup_objects
+ order by object_type, object_schema, object_name;
+
+select * from performance_schema.setup_objects
+ where object_type = 'TABLE'
+ order by object_type, object_schema, object_name;
+
+select * from performance_schema.setup_objects
+ order by object_type, object_schema, object_name;
+
+set sql_mode= '';
+--error ER_NO_REFERENCED_ROW_2
+insert into performance_schema.setup_objects
+ set object_type='ILLEGAL', object_schema='FOO', object_name='BAR',
+ enabled='YES', timed='YES';
+set sql_mode= DEFAULT;
+
+insert into performance_schema.setup_objects
+ set object_type='TABLE', object_schema='FOO', object_name='BAR',
+ enabled='YES', timed='YES';
+
+--error ER_DUP_KEY
+insert into performance_schema.setup_objects
+ set object_type='TABLE', object_schema='FOO', object_name='BAR',
+ enabled='YES', timed='NO';
+
+delete from performance_schema.setup_objects
+ where object_type='TABLE' and object_schema='FOO';
+
+select * from performance_schema.setup_objects
+ order by object_type, object_schema, object_name;
+
+insert into performance_schema.setup_objects
+ set object_type='TABLE', object_schema='FOO', object_name='BAR',
+ enabled='NO', timed='YES';
+
+select * from performance_schema.setup_objects
+ order by object_type, object_schema, object_name;
+
+--error ER_WRONG_PERFSCHEMA_USAGE
+set statement sql_mode = '' for
+update performance_schema.setup_objects
+ set object_type='ILLEGAL';
+
+--error ER_WRONG_PERFSCHEMA_USAGE
+update performance_schema.setup_objects
+ set object_schema='ILLEGAL';
+
+--error ER_WRONG_PERFSCHEMA_USAGE
+update performance_schema.setup_objects
+ set object_name='ILLEGAL';
+
+update performance_schema.setup_objects
+ set enabled='NO', timed='NO';
+
+select * from performance_schema.setup_objects
+ order by object_type, object_schema, object_name;
+
+update performance_schema.setup_objects
+ set enabled='YES', timed='YES';
+
+delete from performance_schema.setup_objects
+ where object_type = 'TABLE';
+
+delete from performance_schema.setup_objects;
+
+LOCK TABLES performance_schema.setup_objects READ;
+UNLOCK TABLES;
+
+LOCK TABLES performance_schema.setup_objects WRITE;
+UNLOCK TABLES;
+
+# Restore the setup
+truncate table performance_schema.setup_objects;
+insert into performance_schema.setup_objects
+ select * from test.setup_objects;
+drop table test.setup_objects;
+SET sql_mode = default;
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='setup_objects';
diff --git a/mysql-test/suite/perfschema/t/dml_setup_timers.test b/mysql-test/suite/perfschema/t/dml_setup_timers.test
new file mode 100644
index 00000000..6a90c669
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_setup_timers.test
@@ -0,0 +1,76 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/have_timer_cycle.inc
+
+# Set to a known state
+update performance_schema.setup_timers
+ set timer_name='CYCLE' where name="wait";
+update performance_schema.setup_timers
+ set timer_name='NANOSECOND' where name="stage";
+update performance_schema.setup_timers
+ set timer_name='NANOSECOND' where name="statement";
+update performance_schema.setup_timers
+ set timer_name='MICROSECOND' where name="transaction";
+update performance_schema.setup_timers
+ set timer_name='MICROSECOND' where name="idle";
+
+select * from performance_schema.setup_timers;
+
+select * from performance_schema.setup_timers
+ where name='Wait';
+
+select * from performance_schema.setup_timers
+ where timer_name='CYCLE';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.setup_timers
+ set name='FOO', timer_name='CYCLE';
+
+--error ER_WRONG_PERFSCHEMA_USAGE
+update performance_schema.setup_timers
+ set name='FOO';
+
+update performance_schema.setup_timers
+ set timer_name='MILLISECOND';
+
+select * from performance_schema.setup_timers;
+
+update performance_schema.setup_timers
+ set timer_name='CYCLE';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.setup_timers;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.setup_timers
+ where name='Wait';
+
+LOCK TABLES performance_schema.setup_timers READ;
+UNLOCK TABLES;
+
+LOCK TABLES performance_schema.setup_timers WRITE;
+UNLOCK TABLES;
+
+# Cleanup, restore the default values
+
+update performance_schema.setup_timers
+ set timer_name='CYCLE' where name="wait";
+update performance_schema.setup_timers
+ set timer_name='NANOSECOND' where name="stage";
+update performance_schema.setup_timers
+ set timer_name='NANOSECOND' where name="statement";
+update performance_schema.setup_timers
+ set timer_name='MICROSECOND' where name="transaction";
+update performance_schema.setup_timers
+ set timer_name='MICROSECOND' where name="idle";
+
+select * from performance_schema.setup_timers;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='setup_timers';
diff --git a/mysql-test/suite/perfschema/t/dml_socket_instances.test b/mysql-test/suite/perfschema/t/dml_socket_instances.test
new file mode 100644
index 00000000..2f92c0f5
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_socket_instances.test
@@ -0,0 +1,41 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.socket_instances limit 1;
+
+select * from performance_schema.socket_instances
+ where ip='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.socket_instances
+ set ip='FOO', event_name='BAR', port=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.socket_instances
+ set ip='FOO';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.socket_instances
+ where event_name like "wait/%";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.socket_instances;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.socket_instances READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.socket_instances WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='socket_instances';
diff --git a/mysql-test/suite/perfschema/t/dml_socket_summary_by_event_name.test b/mysql-test/suite/perfschema/t/dml_socket_summary_by_event_name.test
new file mode 100644
index 00000000..3fbea327
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_socket_summary_by_event_name.test
@@ -0,0 +1,48 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.socket_summary_by_event_name
+ limit 1;
+
+select * from performance_schema.socket_summary_by_event_name
+ where event_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.socket_summary_by_event_name
+ set event_name='FOO',
+ count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.socket_summary_by_event_name
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.socket_summary_by_event_name
+ set count_star=12 where event_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.socket_summary_by_event_name
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.socket_summary_by_event_name;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.socket_summary_by_event_name READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.socket_summary_by_event_name WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='socket_summary_by_event_name';
diff --git a/mysql-test/suite/perfschema/t/dml_socket_summary_by_instance.test b/mysql-test/suite/perfschema/t/dml_socket_summary_by_instance.test
new file mode 100644
index 00000000..d55cf243
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_socket_summary_by_instance.test
@@ -0,0 +1,48 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.socket_summary_by_instance
+ limit 1;
+
+select * from performance_schema.socket_summary_by_instance
+ where object_instance_begin='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.socket_summary_by_instance
+ set object_instance_begin=1,
+ count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.socket_summary_by_instance
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.socket_summary_by_instance
+ set count_star=12 where object_instance_begin like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.socket_summary_by_instance
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.socket_summary_by_instance;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.socket_summary_by_instance READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.socket_summary_by_instance WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='socket_summary_by_instance';
diff --git a/mysql-test/suite/perfschema/t/dml_status_by_account.test b/mysql-test/suite/perfschema/t/dml_status_by_account.test
new file mode 100644
index 00000000..5b31a572
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_status_by_account.test
@@ -0,0 +1,40 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.status_by_account
+ where variable_name like 'bytes_%' limit 1;
+
+select * from performance_schema.status_by_account
+ where variable_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.status_by_account
+ set user='USER', host='HOST', variable_name='FOO', variable_value='BAR';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.status_by_account
+ set variable_name='FOO', variable_value='BAR';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.status_by_account
+ set variable_name='FOO' where user <> 'USER';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.status_by_account
+ where user <> 'USER';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.status_by_account;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.status_by_account READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.status_by_account WRITE;
+UNLOCK TABLES;
+
diff --git a/mysql-test/suite/perfschema/t/dml_status_by_host.test b/mysql-test/suite/perfschema/t/dml_status_by_host.test
new file mode 100644
index 00000000..6c5c4462
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_status_by_host.test
@@ -0,0 +1,40 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.status_by_host
+ where variable_name like 'bytes_%' limit 1;
+
+select * from performance_schema.status_by_host
+ where variable_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.status_by_host
+ set host='HOST', variable_name='FOO', variable_value='BAR';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.status_by_host
+ set variable_name='FOO', variable_value='BAR';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.status_by_host
+ set variable_name='FOO' where host <> 'HOST';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.status_by_host
+ where host <> 'HOST';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.status_by_host;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.status_by_host READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.status_by_host WRITE;
+UNLOCK TABLES;
+
diff --git a/mysql-test/suite/perfschema/t/dml_status_by_thread.test b/mysql-test/suite/perfschema/t/dml_status_by_thread.test
new file mode 100644
index 00000000..09022b05
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_status_by_thread.test
@@ -0,0 +1,40 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.status_by_thread
+ where variable_name like 'bytes_%' limit 1;
+
+select * from performance_schema.status_by_thread
+ where variable_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.status_by_thread
+ set thread_id=1, variable_name='FOO', variable_value='BAR';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.status_by_thread
+ set variable_name='FOO', variable_value='BAR';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.status_by_thread
+ set variable_name='FOO' where thread_id=0;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.status_by_thread
+ where thread_id=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.status_by_thread;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.status_by_thread READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.status_by_thread WRITE;
+UNLOCK TABLES;
+
diff --git a/mysql-test/suite/perfschema/t/dml_status_by_user.test b/mysql-test/suite/perfschema/t/dml_status_by_user.test
new file mode 100644
index 00000000..25cba557
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_status_by_user.test
@@ -0,0 +1,40 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.status_by_user
+ where variable_name like 'bytes_%' limit 1;
+
+select * from performance_schema.status_by_user
+ where variable_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.status_by_user
+ set user='USER', variable_name='FOO', variable_value='BAR';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.status_by_user
+ set variable_name='FOO', variable_value='BAR';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.status_by_user
+ set variable_name='FOO' where user <> 'USER';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.status_by_user
+ where user <> 'USER';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.status_by_user;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.status_by_user READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.status_by_user WRITE;
+UNLOCK TABLES;
+
diff --git a/mysql-test/suite/perfschema/t/dml_table_handles.test b/mysql-test/suite/perfschema/t/dml_table_handles.test
new file mode 100644
index 00000000..31f5fe0b
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_table_handles.test
@@ -0,0 +1,35 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.table_handles;
+--enable_result_log
+
+select * from performance_schema.table_handles
+ where object_name='foo';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.table_handles
+ set object_name='FOO', owner_event_id=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.table_handles
+ set owner_event_id=12 where object_name='foo';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.table_handles;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.table_handles
+ where timer_name='CYCLE';
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.table_handles READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.table_handles WRITE;
+UNLOCK TABLES;
+
diff --git a/mysql-test/suite/perfschema/t/dml_threads.test b/mysql-test/suite/perfschema/t/dml_threads.test
new file mode 100644
index 00000000..f6239d58
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_threads.test
@@ -0,0 +1,56 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.threads
+ where name like 'Thread/%' limit 1;
+
+select * from performance_schema.threads
+ where name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.threads
+ set name='FOO', thread_id=1, processlist_id=2;
+
+--error ER_WRONG_PERFSCHEMA_USAGE
+update performance_schema.threads
+ set thread_id=12;
+
+--error ER_WRONG_PERFSCHEMA_USAGE
+update performance_schema.threads
+ set thread_id=12 where PROCESSLIST_ID=connection_id();
+
+update performance_schema.threads
+ set instrumented= 'NO' where PROCESSLIST_ID=connection_id();
+
+select instrumented from performance_schema.threads
+ where PROCESSLIST_ID=connection_id();
+
+update performance_schema.threads
+ set instrumented= 'YES' where PROCESSLIST_ID=connection_id();
+
+select instrumented from performance_schema.threads
+ where PROCESSLIST_ID=connection_id();
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.threads
+ where id=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.threads;
+
+LOCK TABLES performance_schema.threads READ;
+UNLOCK TABLES;
+
+LOCK TABLES performance_schema.threads WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='threads';
diff --git a/mysql-test/suite/perfschema/t/dml_tiws_by_index_usage.test b/mysql-test/suite/perfschema/t/dml_tiws_by_index_usage.test
new file mode 100644
index 00000000..e3b6405a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_tiws_by_index_usage.test
@@ -0,0 +1,48 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.table_io_waits_summary_by_index_usage
+ limit 1;
+
+select * from performance_schema.table_io_waits_summary_by_index_usage
+ where object_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.table_io_waits_summary_by_index_usage
+ set object_type='TABLE', object_name='FOO', object_schema='BAR',
+ count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.table_io_waits_summary_by_index_usage
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.table_io_waits_summary_by_index_usage
+ set count_star=12 where object_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.table_io_waits_summary_by_index_usage
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.table_io_waits_summary_by_index_usage;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.table_io_waits_summary_by_index_usage READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.table_io_waits_summary_by_index_usage WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='table_io_waits_summary_by_index_usage';
diff --git a/mysql-test/suite/perfschema/t/dml_tiws_by_table.test b/mysql-test/suite/perfschema/t/dml_tiws_by_table.test
new file mode 100644
index 00000000..c00cec31
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_tiws_by_table.test
@@ -0,0 +1,48 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.table_io_waits_summary_by_table
+ limit 1;
+
+select * from performance_schema.table_io_waits_summary_by_table
+ where object_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.table_io_waits_summary_by_table
+ set object_type='TABLE', object_name='FOO', object_schema='BAR',
+ count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.table_io_waits_summary_by_table
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.table_io_waits_summary_by_table
+ set count_star=12 where object_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.table_io_waits_summary_by_table
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.table_io_waits_summary_by_table;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.table_io_waits_summary_by_table READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.table_io_waits_summary_by_table WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='table_io_waits_summary_by_table';
diff --git a/mysql-test/suite/perfschema/t/dml_tlws_by_table.test b/mysql-test/suite/perfschema/t/dml_tlws_by_table.test
new file mode 100644
index 00000000..ab76d85f
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_tlws_by_table.test
@@ -0,0 +1,48 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.table_lock_waits_summary_by_table
+ limit 1;
+
+select * from performance_schema.table_lock_waits_summary_by_table
+ where object_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.table_lock_waits_summary_by_table
+ set object_type='TABLE', object_name='FOO', object_schema='BAR',
+ count_star=1, sum_timer_wait=2, min_timer_wait=3,
+ avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.table_lock_waits_summary_by_table
+ set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.table_lock_waits_summary_by_table
+ set count_star=12 where object_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.table_lock_waits_summary_by_table
+ where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.table_lock_waits_summary_by_table;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.table_lock_waits_summary_by_table READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.table_lock_waits_summary_by_table WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='table_lock_waits_summary_by_table';
diff --git a/mysql-test/suite/perfschema/t/dml_users.test b/mysql-test/suite/perfschema/t/dml_users.test
new file mode 100644
index 00000000..68942d27
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_users.test
@@ -0,0 +1,47 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.users
+ limit 1;
+
+select * from performance_schema.users
+ where user='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.users
+ set user='FOO',
+ current_connections=1, total_connections=2;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.users
+ set current_connections=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.users
+ set current_connections=12 where user like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.users
+ where total_connections=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.users;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.users READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.users WRITE;
+UNLOCK TABLES;
+
+--echo #
+--echo # MDEV-25325 column_comment for performance_schema tables
+--echo #
+select column_name, column_comment
+from information_schema.columns
+where table_schema='performance_schema' and table_name='users';
diff --git a/mysql-test/suite/perfschema/t/dml_uvar_by_thread.test b/mysql-test/suite/perfschema/t/dml_uvar_by_thread.test
new file mode 100644
index 00000000..71518d35
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_uvar_by_thread.test
@@ -0,0 +1,48 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.user_variables_by_thread
+ where variable_name like 'foo%' limit 1;
+
+select * from performance_schema.user_variables_by_thread
+ where variable_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.user_variables_by_thread
+ set thread_id=12, variable_name='foo', variable_value='bar';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.user_variables_by_thread
+ set thread_id=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.user_variables_by_thread
+ set thread_id=12 where variable_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.user_variables_by_thread
+ where thread_id=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.user_variables_by_thread;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.user_variables_by_thread READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.user_variables_by_thread WRITE;
+UNLOCK TABLES;
+
+DELIMITER |;
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE TRIGGER test_uvar_trigger
+ AFTER INSERT ON performance_schema.user_variables_by_thread
+ FOR EACH ROW BEGIN
+ set @a='OK';
+END|
+DELIMITER ;|
diff --git a/mysql-test/suite/perfschema/t/dml_variables_by_thread.test b/mysql-test/suite/perfschema/t/dml_variables_by_thread.test
new file mode 100644
index 00000000..db087d58
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/dml_variables_by_thread.test
@@ -0,0 +1,40 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_result_log
+select * from performance_schema.variables_by_thread
+ where variable_name like 'autocommit%' limit 1;
+
+select * from performance_schema.variables_by_thread
+ where variable_name='FOO';
+--enable_result_log
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.variables_by_thread
+ set thread_id=1, variable_name='FOO', variable_value='BAR';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.variables_by_thread
+ set variable_name='FOO', variable_value='BAR';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.variables_by_thread
+ set variable_name='FOO' where thread_id=0;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.variables_by_thread
+ where thread_id=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.variables_by_thread;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.variables_by_thread READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.variables_by_thread WRITE;
+UNLOCK TABLES;
+
diff --git a/mysql-test/suite/perfschema/t/event_aggregate-master.opt b/mysql-test/suite/perfschema/t/event_aggregate-master.opt
new file mode 100644
index 00000000..596f6baf
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/event_aggregate-master.opt
@@ -0,0 +1,2 @@
+--general_log
+--log-output=FILE
diff --git a/mysql-test/suite/perfschema/t/event_aggregate.test b/mysql-test/suite/perfschema/t/event_aggregate.test
new file mode 100644
index 00000000..685cbbae
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/event_aggregate.test
@@ -0,0 +1,5 @@
+# Tests for the performance schema
+#
+--source ../include/event_aggregate_setup.inc
+--source ../include/event_aggregate_load.inc
+--source ../include/event_aggregate_cleanup.inc
diff --git a/mysql-test/suite/perfschema/t/event_aggregate_no_a-master.opt b/mysql-test/suite/perfschema/t/event_aggregate_no_a-master.opt
new file mode 100644
index 00000000..276c2eb7
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/event_aggregate_no_a-master.opt
@@ -0,0 +1,3 @@
+--general_log
+--log-output=FILE
+--loose-performance_schema_accounts_size=0
diff --git a/mysql-test/suite/perfschema/t/event_aggregate_no_a.test b/mysql-test/suite/perfschema/t/event_aggregate_no_a.test
new file mode 100644
index 00000000..685cbbae
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/event_aggregate_no_a.test
@@ -0,0 +1,5 @@
+# Tests for the performance schema
+#
+--source ../include/event_aggregate_setup.inc
+--source ../include/event_aggregate_load.inc
+--source ../include/event_aggregate_cleanup.inc
diff --git a/mysql-test/suite/perfschema/t/event_aggregate_no_a_no_h-master.opt b/mysql-test/suite/perfschema/t/event_aggregate_no_a_no_h-master.opt
new file mode 100644
index 00000000..dd39eca9
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/event_aggregate_no_a_no_h-master.opt
@@ -0,0 +1,4 @@
+--general_log
+--log-output=FILE
+--loose-performance_schema_accounts_size=0
+--loose-performance_schema_hosts_size=0
diff --git a/mysql-test/suite/perfschema/t/event_aggregate_no_a_no_h.test b/mysql-test/suite/perfschema/t/event_aggregate_no_a_no_h.test
new file mode 100644
index 00000000..685cbbae
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/event_aggregate_no_a_no_h.test
@@ -0,0 +1,5 @@
+# Tests for the performance schema
+#
+--source ../include/event_aggregate_setup.inc
+--source ../include/event_aggregate_load.inc
+--source ../include/event_aggregate_cleanup.inc
diff --git a/mysql-test/suite/perfschema/t/event_aggregate_no_a_no_u-master.opt b/mysql-test/suite/perfschema/t/event_aggregate_no_a_no_u-master.opt
new file mode 100644
index 00000000..0559a16c
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/event_aggregate_no_a_no_u-master.opt
@@ -0,0 +1,4 @@
+--general_log
+--log-output=FILE
+--loose-performance_schema_accounts_size=0
+--loose-performance_schema_users_size=0
diff --git a/mysql-test/suite/perfschema/t/event_aggregate_no_a_no_u.test b/mysql-test/suite/perfschema/t/event_aggregate_no_a_no_u.test
new file mode 100644
index 00000000..685cbbae
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/event_aggregate_no_a_no_u.test
@@ -0,0 +1,5 @@
+# Tests for the performance schema
+#
+--source ../include/event_aggregate_setup.inc
+--source ../include/event_aggregate_load.inc
+--source ../include/event_aggregate_cleanup.inc
diff --git a/mysql-test/suite/perfschema/t/event_aggregate_no_a_no_u_no_h-master.opt b/mysql-test/suite/perfschema/t/event_aggregate_no_a_no_u_no_h-master.opt
new file mode 100644
index 00000000..795fa013
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/event_aggregate_no_a_no_u_no_h-master.opt
@@ -0,0 +1,5 @@
+--general_log
+--log-output=FILE
+--loose-performance_schema_accounts_size=0
+--loose-performance_schema_users_size=0
+--loose-performance_schema_hosts_size=0
diff --git a/mysql-test/suite/perfschema/t/event_aggregate_no_a_no_u_no_h.test b/mysql-test/suite/perfschema/t/event_aggregate_no_a_no_u_no_h.test
new file mode 100644
index 00000000..685cbbae
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/event_aggregate_no_a_no_u_no_h.test
@@ -0,0 +1,5 @@
+# Tests for the performance schema
+#
+--source ../include/event_aggregate_setup.inc
+--source ../include/event_aggregate_load.inc
+--source ../include/event_aggregate_cleanup.inc
diff --git a/mysql-test/suite/perfschema/t/event_aggregate_no_h-master.opt b/mysql-test/suite/perfschema/t/event_aggregate_no_h-master.opt
new file mode 100644
index 00000000..89ecbaa6
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/event_aggregate_no_h-master.opt
@@ -0,0 +1,3 @@
+--general_log
+--log-output=FILE
+--loose-performance_schema_hosts_size=0
diff --git a/mysql-test/suite/perfschema/t/event_aggregate_no_h.test b/mysql-test/suite/perfschema/t/event_aggregate_no_h.test
new file mode 100644
index 00000000..685cbbae
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/event_aggregate_no_h.test
@@ -0,0 +1,5 @@
+# Tests for the performance schema
+#
+--source ../include/event_aggregate_setup.inc
+--source ../include/event_aggregate_load.inc
+--source ../include/event_aggregate_cleanup.inc
diff --git a/mysql-test/suite/perfschema/t/event_aggregate_no_u-master.opt b/mysql-test/suite/perfschema/t/event_aggregate_no_u-master.opt
new file mode 100644
index 00000000..d6ee950e
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/event_aggregate_no_u-master.opt
@@ -0,0 +1,3 @@
+--general_log
+--log-output=FILE
+--loose-performance_schema_users_size=0
diff --git a/mysql-test/suite/perfschema/t/event_aggregate_no_u.test b/mysql-test/suite/perfschema/t/event_aggregate_no_u.test
new file mode 100644
index 00000000..685cbbae
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/event_aggregate_no_u.test
@@ -0,0 +1,5 @@
+# Tests for the performance schema
+#
+--source ../include/event_aggregate_setup.inc
+--source ../include/event_aggregate_load.inc
+--source ../include/event_aggregate_cleanup.inc
diff --git a/mysql-test/suite/perfschema/t/event_aggregate_no_u_no_h-master.opt b/mysql-test/suite/perfschema/t/event_aggregate_no_u_no_h-master.opt
new file mode 100644
index 00000000..7ac60706
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/event_aggregate_no_u_no_h-master.opt
@@ -0,0 +1,4 @@
+--general_log
+--log-output=FILE
+--loose-performance_schema_users_size=0
+--loose-performance_schema_hosts_size=0
diff --git a/mysql-test/suite/perfschema/t/event_aggregate_no_u_no_h.test b/mysql-test/suite/perfschema/t/event_aggregate_no_u_no_h.test
new file mode 100644
index 00000000..685cbbae
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/event_aggregate_no_u_no_h.test
@@ -0,0 +1,5 @@
+# Tests for the performance schema
+#
+--source ../include/event_aggregate_setup.inc
+--source ../include/event_aggregate_load.inc
+--source ../include/event_aggregate_cleanup.inc
diff --git a/mysql-test/suite/perfschema/t/file_misc-master.opt b/mysql-test/suite/perfschema/t/file_misc-master.opt
new file mode 100644
index 00000000..9d6fb53f
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/file_misc-master.opt
@@ -0,0 +1 @@
+--loose-performance-schema-max-file-instances=0
diff --git a/mysql-test/suite/perfschema/t/file_misc.test b/mysql-test/suite/perfschema/t/file_misc.test
new file mode 100644
index 00000000..e495aa90
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/file_misc.test
@@ -0,0 +1,11 @@
+
+# Bug#22118669 - ASSERTION `PFS_FILE != __NULL' FAILED
+
+# Cause a temporary file to be instrumented,
+# while there are no file instruments available.
+
+--disable_result_log
+select * from information_schema.columns ORDER BY table_name;
+--enable_result_log
+
+
diff --git a/mysql-test/suite/perfschema/t/func_file_io.test b/mysql-test/suite/perfschema/t/func_file_io.test
new file mode 100644
index 00000000..e29b05b8
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/func_file_io.test
@@ -0,0 +1,193 @@
+##
+## WL#4814, 4.1.4 FILE IO
+##
+## Functional testing of File IO
+##
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+UPDATE performance_schema.setup_instruments SET enabled = 'NO', timed = 'YES';
+
+UPDATE performance_schema.setup_instruments SET enabled = 'YES'
+WHERE name LIKE 'wait/io/file/%';
+
+update performance_schema.threads SET instrumented = 'YES'
+ WHERE PROCESSLIST_ID=connection_id();
+
+# reset lost counters
+truncate table performance_schema.events_statements_summary_by_digest;
+flush status;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+#
+# TODO: Change to InnoDB when it gets instrumentation
+#
+
+CREATE TABLE t1 (id INT PRIMARY KEY, b CHAR(100) DEFAULT 'initial value')
+ENGINE=MyISAM;
+
+INSERT INTO t1 (id) VALUES (1), (2), (3), (4), (5), (6), (7), (8);
+
+TRUNCATE TABLE performance_schema.events_waits_history_long;
+TRUNCATE TABLE performance_schema.events_waits_history;
+TRUNCATE TABLE performance_schema.events_waits_current;
+
+#
+# FF1: Count for file should increase with instrumentation enabled and
+# FF2: Count for file should not increase with instrumentation disabled
+#
+
+SELECT * FROM t1 WHERE id = 1;
+
+SET @before_count = (SELECT SUM(TIMER_WAIT)
+ FROM performance_schema.events_waits_history_long
+ WHERE (EVENT_NAME = 'wait/io/file/myisam/dfile')
+ AND (OBJECT_NAME LIKE '%t1.MYD'));
+
+SELECT (@before_count >= 0) as have_before_count;
+SELECT IF(@before_count > 0, 'Success', 'Failure') has_instrumentation;
+
+SELECT * FROM t1 WHERE id < 4;
+
+SET @after_count = (SELECT SUM(TIMER_WAIT)
+ FROM performance_schema.events_waits_history_long
+ WHERE (EVENT_NAME = 'wait/io/file/myisam/dfile')
+ AND (OBJECT_NAME LIKE '%t1.MYD') AND (1 = 1));
+
+SELECT (@after_count >= 0) as have_after_count;
+SELECT IF((@after_count - @before_count) > 0, 'Success', 'Failure') test_ff1_timed;
+
+UPDATE performance_schema.setup_instruments SET enabled='NO';
+
+SET @before_count = (SELECT SUM(TIMER_WAIT)
+ FROM performance_schema.events_waits_history_long
+ WHERE (EVENT_NAME = 'wait/io/file/myisam/dfile')
+ AND (OBJECT_NAME LIKE '%t1.MYD') AND (2 = 2));
+
+SELECT (@before_count >= 0) as have_before_count;
+SELECT * FROM t1 WHERE id < 6;
+
+SET @after_count = (SELECT SUM(TIMER_WAIT)
+ FROM performance_schema.events_waits_history_long
+ WHERE (EVENT_NAME = 'wait/io/file/myisam/dfile')
+ AND (OBJECT_NAME LIKE '%t1.MYD') AND (3 = 3));
+
+SELECT (@after_count >= 0) as have_after_count;
+SELECT IF((COALESCE(@after_count, 0) - COALESCE(@before_count, 0)) = 0, 'Success', 'Failure') test_ff2_timed;
+
+#
+# Check not timed measurements
+#
+
+UPDATE performance_schema.setup_instruments SET enabled = 'YES'
+WHERE name LIKE 'wait/io/file/%';
+
+UPDATE performance_schema.setup_instruments SET timed = 'NO';
+
+TRUNCATE TABLE performance_schema.events_waits_history_long;
+TRUNCATE TABLE performance_schema.events_waits_history;
+TRUNCATE TABLE performance_schema.events_waits_current;
+
+SELECT * FROM t1 WHERE id > 4;
+
+SELECT * FROM performance_schema.events_waits_history_long
+WHERE TIMER_WAIT != NULL
+ OR TIMER_START != NULL
+ OR TIMER_END != NULL;
+
+SELECT * FROM performance_schema.events_waits_history
+WHERE TIMER_WAIT != NULL
+ OR TIMER_START != NULL
+ OR TIMER_END != NULL;
+
+SELECT * FROM performance_schema.events_waits_current
+WHERE TIMER_WAIT != NULL
+ OR TIMER_START != NULL
+ OR TIMER_END != NULL;
+
+UPDATE performance_schema.setup_instruments SET timed = 'YES';
+
+SELECT * FROM t1 WHERE id < 4;
+
+DROP TABLE t1;
+
+#
+# FF4: Use-case from Enterprise Monitor
+#
+
+--disable_result_log
+SELECT SUM(COUNT_READ) AS sum_count_read,
+ SUM(COUNT_WRITE) AS sum_count_write,
+ SUM(SUM_NUMBER_OF_BYTES_READ) AS sum_num_bytes_read,
+ SUM(SUM_NUMBER_OF_BYTES_WRITE) AS sum_num_bytes_write
+FROM performance_schema.file_summary_by_instance
+WHERE FILE_NAME LIKE CONCAT('%', @@tmpdir, '%') ORDER BY NULL;
+--enable_result_log
+
+#
+# FF5: Troubleshooting tasks
+#
+# These queries will give different results based on timing,
+# but at least they should not crash.
+#
+
+#
+# Total and average wait time for different events on system level
+#
+--disable_result_log
+SELECT EVENT_NAME, COUNT_STAR, AVG_TIMER_WAIT, SUM_TIMER_WAIT
+FROM performance_schema.events_waits_summary_global_by_event_name
+WHERE COUNT_STAR > 0
+ORDER BY SUM_TIMER_WAIT DESC
+LIMIT 10;
+--enable_result_log
+
+#
+# Total and average wait time for different users
+#
+
+--disable_result_log
+SELECT p.processlist_user, SUM(TIMER_WAIT) SUM_WAIT
+# ((TIME_TO_SEC(TIMEDIFF(NOW(), i.startup_time)) * 1000) / SUM(TIMER_WAIT)) * 100 WAIT_PERCENTAGE
+FROM performance_schema.events_waits_history_long h
+INNER JOIN performance_schema.threads p USING (THREAD_ID)
+GROUP BY p.processlist_user
+ORDER BY SUM_WAIT DESC
+LIMIT 20;
+--enable_result_log
+
+#
+# Total and average wait times for different events for a session
+#
+--disable_result_log
+SELECT h.EVENT_NAME, SUM(h.TIMER_WAIT) TOTAL_WAIT
+FROM performance_schema.events_waits_history_long h
+INNER JOIN performance_schema.threads p USING (THREAD_ID)
+WHERE p.PROCESSLIST_ID = 1
+GROUP BY h.EVENT_NAME
+HAVING TOTAL_WAIT > 0;
+--enable_result_log
+
+#
+# Which user reads and writes data
+#
+
+--disable_result_log
+SELECT p.processlist_user, h.operation, SUM(NUMBER_OF_BYTES) bytes
+FROM performance_schema.events_waits_history_long h
+INNER JOIN performance_schema.threads p USING (THREAD_ID)
+GROUP BY p.processlist_user, h.operation
+HAVING BYTES > 0
+ORDER BY p.processlist_user, h.operation;
+--enable_result_log
+
+# Clean-up.
+UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES';
+
+# In case of failure, will indicate the root cause
+show global status like "performance_schema%";
+
diff --git a/mysql-test/suite/perfschema/t/func_mutex.test b/mysql-test/suite/perfschema/t/func_mutex.test
new file mode 100644
index 00000000..19648521
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/func_mutex.test
@@ -0,0 +1,134 @@
+##
+## WL#4818, 4.1.3 MUTEXES, RW-LOCKS, ...
+##
+## Functional testing of mutexes and RW-locks
+##
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+UPDATE performance_schema.setup_instruments SET enabled = 'NO', timed = 'YES';
+
+UPDATE performance_schema.setup_instruments SET enabled = 'YES'
+WHERE name LIKE 'wait/synch/mutex/%'
+ OR name LIKE 'wait/synch/rwlock/%';
+
+# reset lost counters
+truncate table performance_schema.events_statements_summary_by_digest;
+flush status;
+
+# Make sure objects are instrumented
+select NAME from performance_schema.mutex_instances
+ where NAME = 'wait/synch/mutex/mysys/THR_LOCK::mutex' GROUP BY NAME;
+select NAME from performance_schema.rwlock_instances
+ where NAME = 'wait/synch/rwlock/sql/LOCK_grant' limit 1;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+#
+# TODO: Change to InnoDB when it gets instrumentation
+#
+
+CREATE TABLE t1 (id INT PRIMARY KEY, b CHAR(100) DEFAULT 'initial value')
+ENGINE=MyISAM;
+
+INSERT INTO t1 (id) VALUES (1), (2), (3), (4), (5), (6), (7), (8);
+
+#
+# FM1: Count for mutex should increase with instrumentation enabled and
+# FM2: Count for mutex should not increase with instrumentation disabled
+#
+
+TRUNCATE TABLE performance_schema.events_waits_history_long;
+TRUNCATE TABLE performance_schema.events_waits_history;
+TRUNCATE TABLE performance_schema.events_waits_current;
+
+SELECT * FROM t1 WHERE id = 1;
+
+SET @before_count = (SELECT SUM(TIMER_WAIT)
+ FROM performance_schema.events_waits_history_long
+ WHERE (EVENT_NAME = 'wait/synch/mutex/mysys/THR_LOCK::mutex'));
+
+SELECT * FROM t1;
+
+SET @after_count = (SELECT SUM(TIMER_WAIT)
+ FROM performance_schema.events_waits_history_long
+ WHERE (EVENT_NAME = 'wait/synch/mutex/mysys/THR_LOCK::mutex'));
+
+SELECT IF((@after_count - @before_count) > 0, 'Success', 'Failure') test_fm1_timed;
+
+UPDATE performance_schema.setup_instruments SET enabled = 'NO'
+WHERE NAME = 'wait/synch/mutex/mysys/THR_LOCK::mutex';
+
+TRUNCATE TABLE performance_schema.events_waits_history_long;
+TRUNCATE TABLE performance_schema.events_waits_history;
+TRUNCATE TABLE performance_schema.events_waits_current;
+
+SELECT * FROM t1 WHERE id = 1;
+
+SET @before_count = (SELECT SUM(TIMER_WAIT)
+ FROM performance_schema.events_waits_history_long
+ WHERE (EVENT_NAME = 'wait/synch/mutex/mysys/THR_LOCK::mutex'));
+
+SELECT * FROM t1;
+
+SET @after_count = (SELECT SUM(TIMER_WAIT)
+ FROM performance_schema.events_waits_history_long
+ WHERE (EVENT_NAME = 'wait/synch/mutex/mysys/THR_LOCK::mutex'));
+
+SELECT IF((COALESCE(@after_count, 0) - COALESCE(@before_count, 0)) = 0, 'Success', 'Failure') test_fm2_timed;
+
+#
+# Repeat for RW-lock
+#
+
+TRUNCATE TABLE performance_schema.events_waits_history_long;
+TRUNCATE TABLE performance_schema.events_waits_history;
+TRUNCATE TABLE performance_schema.events_waits_current;
+
+show variables like "%not_found%";
+
+SET @before_count = (SELECT SUM(TIMER_WAIT)
+ FROM performance_schema.events_waits_history_long
+ WHERE (EVENT_NAME = 'wait/synch/rwlock/sql/LOCK_system_variables_hash'));
+
+show variables like "%not_found%";
+
+SET @after_count = (SELECT SUM(TIMER_WAIT)
+ FROM performance_schema.events_waits_history_long
+ WHERE (EVENT_NAME = 'wait/synch/rwlock/sql/LOCK_system_variables_hash'));
+
+SELECT IF((@after_count - @before_count) > 0, 'Success', 'Failure') test_fm1_rw_timed;
+
+UPDATE performance_schema.setup_instruments SET enabled = 'NO'
+WHERE NAME = 'wait/synch/rwlock/sql/LOCK_system_variables_hash';
+
+TRUNCATE TABLE performance_schema.events_waits_history_long;
+TRUNCATE TABLE performance_schema.events_waits_history;
+TRUNCATE TABLE performance_schema.events_waits_current;
+
+show variables like "%not_found%";
+
+SET @before_count = (SELECT SUM(TIMER_WAIT)
+ FROM performance_schema.events_waits_history_long
+ WHERE (EVENT_NAME = 'wait/synch/rwlock/sql/LOCK_system_variables_hash'));
+
+show variables like "%not_found%";
+
+SET @after_count = (SELECT SUM(TIMER_WAIT)
+ FROM performance_schema.events_waits_history_long
+ WHERE (EVENT_NAME = 'LOCK_system_variables_hash'));
+
+SELECT IF((COALESCE(@after_count, 0) - COALESCE(@before_count, 0)) = 0, 'Success', 'Failure') test_fm2_rw_timed;
+
+# Clean-up.
+UPDATE performance_schema.setup_instruments SET enabled = 'YES';
+DROP TABLE t1;
+
+UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES';
+
+# In case of failure, will indicate the root cause
+show global status like "performance_schema%";
+
diff --git a/mysql-test/suite/perfschema/t/global_objects-master.opt b/mysql-test/suite/perfschema/t/global_objects-master.opt
new file mode 100644
index 00000000..b00c11c1
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/global_objects-master.opt
@@ -0,0 +1 @@
+--loose-performance-schema-instrument='%=OFF'
diff --git a/mysql-test/suite/perfschema/t/global_objects.test b/mysql-test/suite/perfschema/t/global_objects.test
new file mode 100644
index 00000000..cf041c14
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/global_objects.test
@@ -0,0 +1,29 @@
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/no_protocol.inc
+--source include/not_windows.inc
+
+# Bug#79784 update setup_instruments do not affect the global
+# mutex/rwlock/cond
+
+# Verify instruments are off by default, per *.opt file
+select count(*) from performance_schema.setup_instruments
+ where enabled='YES'
+ and name like "wait/%";
+
+# Verify that we have instrumented objects
+select count(*) > 0 from performance_schema.mutex_instances;
+select count(*) > 0 from performance_schema.rwlock_instances;
+select count(*) > 0 from performance_schema.cond_instances;
+select count(*) > 0 from performance_schema.socket_instances;
+
+# Check for some known global objects.
+select NAME from performance_schema.mutex_instances
+ where NAME = "wait/synch/mutex/sql/LOCK_gdl";
+select NAME from performance_schema.rwlock_instances
+ where NAME = "wait/synch/rwlock/sql/LOCK_system_variables_hash";
+select NAME from performance_schema.cond_instances
+ where NAME = "wait/synch/cond/sql/COND_server_started";
+select EVENT_NAME from performance_schema.socket_instances
+ where EVENT_NAME = "wait/io/socket/sql/client_connection";
diff --git a/mysql-test/suite/perfschema/t/global_read_lock.test b/mysql-test/suite/perfschema/t/global_read_lock.test
new file mode 100644
index 00000000..430d6eed
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/global_read_lock.test
@@ -0,0 +1,78 @@
+# Tests for PERFORMANCE_SCHEMA
+#
+# Test the effect of a flush tables with read lock on setup_ tables.
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+use performance_schema;
+
+# Make test robust against errors in other tests.
+# Ensure that instrumentation is turned on when we create new connection.
+update performance_schema.setup_instruments set enabled='YES';
+
+create user pfsuser@localhost;
+grant SELECT, UPDATE, LOCK TABLES on performance_schema.* to pfsuser@localhost;
+flush privileges;
+
+connect (con1, localhost, pfsuser, ,"*NO-ONE*");
+
+lock tables performance_schema.setup_instruments read;
+--disable_result_log
+select * from performance_schema.setup_instruments;
+--enable_result_log
+unlock tables;
+
+lock tables performance_schema.setup_instruments write;
+update performance_schema.setup_instruments set enabled='NO';
+update performance_schema.setup_instruments set enabled='YES';
+unlock tables;
+
+connection default;
+
+flush tables with read lock;
+
+connection con1;
+
+lock tables performance_schema.setup_instruments read;
+--disable_result_log
+select * from performance_schema.setup_instruments;
+--enable_result_log
+unlock tables;
+
+# This will block
+--send
+lock tables performance_schema.setup_instruments write;
+
+connection default;
+
+let $wait_condition= select 1 from performance_schema.events_waits_current where event_name like "wait/synch/cond/sql/MDL_context::COND_wait_status";
+
+--source include/wait_condition.inc
+
+# Observe the blocked thread in the performance schema :)
+select event_name,
+ left(source, locate(":", source)) as short_source,
+ if(timer_end IS NULL, NULL, "SET") as timer_end,
+ if(timer_wait IS NULL, NULL, "SET") as timer_wait,
+ operation
+ from performance_schema.events_waits_current
+ where event_name like "wait/synch/cond/sql/MDL_context::COND_wait_status";
+
+unlock tables;
+
+connection con1;
+--reap
+
+update performance_schema.setup_instruments set enabled='NO';
+update performance_schema.setup_instruments set enabled='YES';
+unlock tables;
+
+disconnect con1;
+--source include/wait_until_disconnected.inc
+
+connection default;
+
+drop user pfsuser@localhost;
+flush privileges;
+
diff --git a/mysql-test/suite/perfschema/t/grant.test b/mysql-test/suite/perfschema/t/grant.test
new file mode 100644
index 00000000..446965df
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/grant.test
@@ -0,0 +1,12 @@
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+#
+# MDEV-22884 Assertion `grant_table || grant_table_role' failed on perfschema
+#
+create user a@localhost;
+connect a,localhost,a;
+select * from performance_schema.global_status where variable_name='b';
+connection default;
+disconnect a;
+drop user a@localhost;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_again_allow.test b/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_again_allow.test
new file mode 100644
index 00000000..c96c8ea3
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_again_allow.test
@@ -0,0 +1,53 @@
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from DNS:
+# - getaddrinfo() fails with AGAIN
+# - reported in COUNT_ADDRINFO_TRANSIENT_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# [Warning] Host name 'santa.claus.ipv4.example.com' could not be resolved:
+# Temporary failure in name resolution
+call mtr.add_suppression("santa.claus.ipv4.example.com");
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+create user 'root'@'192.0.2.4';
+grant select on test.* to 'root'@'192.0.2.4';
+
+connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_error_again";
+
+connect (con2,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con2 is alive";
+select current_user();
+disconnect con2;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+connect (con3,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con3 is alive";
+select current_user();
+disconnect con3;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+revoke select on test.* from 'root'@'192.0.2.4';
+drop user 'root'@'192.0.2.4';
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_again_deny.test b/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_again_deny.test
new file mode 100644
index 00000000..00f5d218
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_again_deny.test
@@ -0,0 +1,48 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from DNS:
+# - getaddrinfo() fails with AGAIN
+# - reported in COUNT_ADDRINFO_TRANSIENT_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# [Warning] Host name 'santa.claus.ipv4.example.com' could not be resolved:
+# Temporary failure in name resolution
+call mtr.add_suppression("santa.claus.ipv4.example.com");
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_error_again";
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con2,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con3,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_bad_allow.test b/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_bad_allow.test
new file mode 100644
index 00000000..d2dff928
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_bad_allow.test
@@ -0,0 +1,56 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from DNS full round trip (FCRDNS):
+# - IP --> HOST --> IP returns no match
+# - reported in COUNT_FCRDNS_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# [Warning] Hostname 'santa.claus.ipv4.example.com' does not resolve to '192.0.2.4'.
+# [Note] Hostname 'santa.claus.ipv4.example.com' has the following IP addresses:
+# [Note] - 192.0.2.126
+# [Note] - 192.0.2.127
+call mtr.add_suppression("santa.claus.ipv4.example.com");
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+create user 'root'@'192.0.2.4';
+grant select on test.* to 'root'@'192.0.2.4';
+
+connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_fake_bad_ipv4";
+
+connect (con2,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con2 is alive";
+select current_user();
+disconnect con2;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+connect (con3,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con3 is alive";
+select current_user();
+disconnect con3;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+revoke select on test.* from 'root'@'192.0.2.4';
+drop user 'root'@'192.0.2.4';
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_bad_deny.test b/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_bad_deny.test
new file mode 100644
index 00000000..f37e1ed3
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_bad_deny.test
@@ -0,0 +1,50 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from DNS full round trip (FCRDNS):
+# - IP --> HOST --> IP returns no match
+# - reported in COUNT_FCRDNS_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# [Warning] Hostname 'santa.claus.ipv4.example.com' does not resolve to '192.0.2.4'.
+# [Note] Hostname 'santa.claus.ipv4.example.com' has the following IP addresses:
+# [Note] - 192.0.2.126
+# [Note] - 192.0.2.127
+call mtr.add_suppression("santa.claus.ipv4.example.com");
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_fake_bad_ipv4";
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con2,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con3,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_good_allow.test b/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_good_allow.test
new file mode 100644
index 00000000..d2b5352d
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_good_allow.test
@@ -0,0 +1,54 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate success from DNS full round trip (FCRDNS):
+# - IP --> HOST --> IP returns the client IP
+# - completes host validation in HOST_VALIDATED
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# [Warning] IP address '192.0.2.4' could not be resolved:
+# no reverse address mapping.
+call mtr.add_suppression("192.0.2.4");
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+create user 'root'@'santa.claus.ipv4.example.com';
+grant select on test.* to 'root'@'santa.claus.ipv4.example.com';
+
+connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_fake_good_ipv4";
+
+connect (con2,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con2 is alive";
+select current_user();
+disconnect con2;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+connect (con3,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con3 is alive";
+select current_user();
+disconnect con3;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+revoke select on test.* from 'root'@'santa.claus.ipv4.example.com';
+drop user 'root'@'santa.claus.ipv4.example.com';
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_good_deny.test b/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_good_deny.test
new file mode 100644
index 00000000..55afb6f0
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_good_deny.test
@@ -0,0 +1,48 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate success from DNS full round trip (FCRDNS):
+# - IP --> HOST --> IP returns the client IP
+# - completes host validation in HOST_VALIDATED
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# [Warning] IP address '192.0.2.4' could not be resolved:
+# no reverse address mapping.
+call mtr.add_suppression("192.0.2.4");
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_fake_good_ipv4";
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con2,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con3,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_noname_allow.test b/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_noname_allow.test
new file mode 100644
index 00000000..a6bd4c75
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_noname_allow.test
@@ -0,0 +1,58 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from DNS:
+# - getaddrinfo() fails with AGAIN
+# - reported in COUNT_ADDRINFO_TRANSIENT_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# [Warning] Host name 'santa.claus.ipv4.example.com' could not be resolved:
+# Name or service not known
+call mtr.add_suppression("santa.claus.ipv4.example.com");
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+create user 'root'@'santa.claus.ipv4.example.com';
+grant select on test.* to 'root'@'santa.claus.ipv4.example.com';
+create user 'root'@'192.0.2.4';
+grant select on test.* to 'root'@'192.0.2.4';
+
+connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_error_noname";
+
+connect (con2,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con2 is alive";
+select current_user();
+disconnect con2;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+connect (con3,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con3 is alive";
+select current_user();
+disconnect con3;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+revoke select on test.* from 'root'@'santa.claus.ipv4.example.com';
+revoke select on test.* from 'root'@'192.0.2.4';
+drop user 'root'@'santa.claus.ipv4.example.com';
+drop user 'root'@'192.0.2.4';
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_noname_deny.test b/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_noname_deny.test
new file mode 100644
index 00000000..41b8b25e
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_addrinfo_noname_deny.test
@@ -0,0 +1,48 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from DNS:
+# - getaddrinfo() fails with NONAME
+# - reported in COUNT_ADDRINFO_PERMANENT_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# [Warning] Host name 'santa.claus.ipv4.example.com' could not be resolved:
+# Name or service not known
+call mtr.add_suppression("santa.claus.ipv4.example.com");
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_error_noname";
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con2,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con3,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv4_auth_ed25519.test b/mysql-test/suite/perfschema/t/hostcache_ipv4_auth_ed25519.test
new file mode 100644
index 00000000..4c68d3af
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_auth_ed25519.test
@@ -0,0 +1,56 @@
+#
+# Tests for the performance_schema host_cache.
+#
+# Test authorization with auth plugins.
+# error reporting in:
+# - column COUNT_AUTH_PLUGIN_ERRORS
+# - column COUNT_PROXY_USER_ERRORS
+# - column COUNT_PROXY_USER_ACL_ERRORS
+
+source include/not_embedded.inc;
+source include/have_debug.inc;
+source include/have_perfschema.inc;
+source include/have_plugin_auth.inc;
+source include/have_hostname_cache.inc;
+
+if (!$AUTH_ED25519_SO) {
+ skip No auth_ed25519 plugin;
+}
+install soname 'auth_ed25519';
+
+# Enforce a clean state
+source ../include/wait_for_pfs_thread_count.inc;
+source ../include/hostcache_set_state.inc;
+
+create user plug1@'santa.claus.ipv4.example.com'
+ identified with ed25519;
+update mysql.global_priv set priv=json_set(priv, '$.authentication_string', 'foo') where user='plug1';
+flush privileges;
+
+create user plug2@'santa.claus.ipv4.example.com'
+ identified with ED25519 as 'vubFBzIrapbfHct1/J72dnUryz5VS7lA6XHH8sIx4TI';
+
+set @saved_dbug = @@global.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_fake_good_ipv4";
+
+replace_result $MASTER_MYPORT PORT $MASTER_MYSOCK SOCKET;
+error ER_ACCESS_DENIED_ERROR;
+connect con1, 127.0.0.1, plug1,foo,,$MASTER_MYPORT;
+source ../include/hostcache_dump.inc;
+
+replace_result $MASTER_MYPORT PORT $MASTER_MYSOCK SOCKET;
+error ER_ACCESS_DENIED_ERROR;
+connect con1, 127.0.0.1, plug2,bar,,$MASTER_MYPORT;
+source ../include/hostcache_dump.inc;
+
+connect con1, 127.0.0.1, plug2,foo,,$MASTER_MYPORT;
+select current_user();
+disconnect con1;
+connection default;
+source ../include/hostcache_dump.inc;
+
+drop user plug1@'santa.claus.ipv4.example.com';
+drop user plug2@'santa.claus.ipv4.example.com';
+
+set @@global.debug_dbug = @saved_dbug;
+uninstall plugin ed25519;
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv4_auth_plugin.test b/mysql-test/suite/perfschema/t/hostcache_ipv4_auth_plugin.test
new file mode 100644
index 00000000..6e149b83
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_auth_plugin.test
@@ -0,0 +1,92 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Test authorization with auth plugins.
+# error reporting in:
+# - column COUNT_AUTH_PLUGIN_ERRORS
+# - column COUNT_PROXY_USER_ERRORS
+# - column COUNT_PROXY_USER_ACL_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/have_perfschema.inc
+--source include/have_plugin_auth.inc
+--source include/have_hostname_cache.inc
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+CREATE USER 'plug'@'santa.claus.ipv4.example.com'
+ IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
+CREATE USER 'plug_dest'@'santa.claus.ipv4.example.com'
+ IDENTIFIED BY 'plug_test_passwd';
+GRANT SELECT ON test.* TO 'plug_dest'@'santa.claus.ipv4.example.com';
+
+connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_fake_good_ipv4";
+uninstall plugin test_plugin_server;
+
+--disable_query_log
+--error ER_PLUGIN_IS_NOT_LOADED
+connect (con2,"127.0.0.1",plug,plug_dest,test,$MASTER_MYPORT,,,auth_test_plugin);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_PLUGIN_IS_NOT_LOADED
+connect (con3,"127.0.0.1",plug,plug_dest,test,$MASTER_MYPORT,,,auth_test_plugin);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--replace_result $AUTH_TEST_PLUGIN_SO PLUGIN_AUTH
+eval install plugin test_plugin_server soname '$AUTH_TEST_PLUGIN_SO';
+
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR
+connect (con2,"127.0.0.1",plug,plug_dest,test,$MASTER_MYPORT,,,auth_test_plugin);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR
+connect (con3,"127.0.0.1",plug,plug_dest,test,$MASTER_MYPORT,,,auth_test_plugin);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+GRANT PROXY ON 'plug_dest'@'santa.claus.ipv4.example.com'
+ TO 'plug'@'santa.claus.ipv4.example.com';
+
+connect (con4,"127.0.0.1",plug,plug_dest,test,$MASTER_MYPORT,,,auth_test_plugin);
+select "Con4 is alive";
+select user();
+select current_user();
+disconnect con4;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+REVOKE ALL PRIVILEGES ON *.* FROM 'plug_dest'@'santa.claus.ipv4.example.com';
+REVOKE PROXY ON 'plug_dest'@'santa.claus.ipv4.example.com'
+ FROM 'plug'@'santa.claus.ipv4.example.com';
+DROP USER 'plug'@'santa.claus.ipv4.example.com';
+DROP USER 'plug_dest'@'santa.claus.ipv4.example.com';
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+delete from mysql.plugin where name='test_plugin_server';
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv4_blocked.test b/mysql-test/suite/perfschema/t/hostcache_ipv4_blocked.test
new file mode 100644
index 00000000..d304cc5a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_blocked.test
@@ -0,0 +1,161 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from client / server protocol:
+# - reported in COUNT_HANDSHAKE_ERRORS
+# aud further causes blocking errors:
+# - reported in SUM_CONNECT_ERRORS
+# - reported in COUNT_HOST_BLOCKED_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+select @@global.max_connect_errors into @saved_max_connect_errors;
+
+set global max_connect_errors = 3;
+
+create user 'root'@'santa.claus.ipv4.example.com';
+grant select on test.* to 'root'@'santa.claus.ipv4.example.com';
+
+create user 'quota'@'santa.claus.ipv4.example.com';
+grant select on test.* to 'quota'@'santa.claus.ipv4.example.com';
+
+connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_fake_good_ipv4,native_password_bad_reply";
+
+--disable_query_log
+--error ER_HANDSHAKE_ERROR
+connect (con2a,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HANDSHAKE_ERROR
+connect (con2b,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HANDSHAKE_ERROR
+connect (con2c,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HOST_IS_BLOCKED
+connect (con2d,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HOST_IS_BLOCKED
+connect (con2e,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+# Now that the host is blocked, check that flush works
+flush hosts;
+
+--disable_query_log
+--error ER_HANDSHAKE_ERROR
+connect (con3a,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HANDSHAKE_ERROR
+connect (con3b,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--connection default
+set global debug_dbug= "-d,native_password_bad_reply";
+
+--disable_query_log
+connect (con4,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+select "Valid connection should reset SUM_CONNECT_ERROR counter" as message;
+--disconnect con4
+--enable_query_log
+
+--connection default
+set global debug_dbug= "+d,native_password_bad_reply";
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HANDSHAKE_ERROR
+connect (con5a,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HANDSHAKE_ERROR
+connect (con5b,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HANDSHAKE_ERROR
+connect (con5c,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HOST_IS_BLOCKED
+connect (con5d,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HOST_IS_BLOCKED
+connect (con5e,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+revoke select on test.* from 'root'@'santa.claus.ipv4.example.com';
+drop user 'root'@'santa.claus.ipv4.example.com';
+
+revoke select on test.* from 'quota'@'santa.claus.ipv4.example.com';
+drop user 'quota'@'santa.claus.ipv4.example.com';
+
+set global max_connect_errors = @saved_max_connect_errors;
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv4_format.test b/mysql-test/suite/perfschema/t/hostcache_ipv4_format.test
new file mode 100644
index 00000000..989c82ef
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_format.test
@@ -0,0 +1,47 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from host names formats:
+# - reported in COUNT_FORMAT_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# [Warning] IP address '192.0.2.4' could not be resolved:
+# Name or service not known
+call mtr.add_suppression("192.0.2.4");
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_format_ipv4";
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con2,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con3,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv4_max_con-master.opt b/mysql-test/suite/perfschema/t/hostcache_ipv4_max_con-master.opt
new file mode 100644
index 00000000..87ad0bc3
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_max_con-master.opt
@@ -0,0 +1 @@
+--max-user-connections=1024
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv4_max_con.test b/mysql-test/suite/perfschema/t/hostcache_ipv4_max_con.test
new file mode 100644
index 00000000..6420b8b5
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_max_con.test
@@ -0,0 +1,264 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from per user quotas:
+# - reported in COUNT_MAX_USER_CONNECTION_ERRORS
+# - reported in COUNT_MAX_USER_CONNECTION_PER_HOUR_ERRORS
+# Simulate failures from server quotas:
+# - reported in COUNT_MAX_CONNECTION_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+select @@global.max_connections into @saved_max_connections;
+select @@global.max_user_connections into @saved_max_user_connections;
+
+create user 'quota'@'santa.claus.ipv4.example.com';
+grant select on test.* to 'quota'@'santa.claus.ipv4.example.com';
+grant usage on *.* to 'quota'@'santa.claus.ipv4.example.com'
+ with max_connections_per_hour 3;
+
+connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_fake_good_ipv4";
+
+connect (con2a,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+select "Con2a is alive";
+select current_user();
+disconnect con2a;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+connect (con2b,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+select "Con2b is alive";
+select current_user();
+disconnect con2b;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+connect (con2c,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+select "Con2c is alive";
+select current_user();
+disconnect con2c;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_USER_LIMIT_REACHED
+connect (con2d,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_USER_LIMIT_REACHED
+connect (con2e,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+# Wait for all disconnects
+--source ../include/wait_for_pfs_thread_count.inc
+
+grant usage on *.* to 'quota'@'santa.claus.ipv4.example.com'
+ with max_connections_per_hour 0;
+grant usage on *.* to 'quota'@'santa.claus.ipv4.example.com'
+ with max_user_connections 3;
+flush user_resources;
+
+connect (con3a,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+select "Con7 is alive";
+select current_user();
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+connect (con3b,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+select "Con3b is alive";
+select current_user();
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+connect (con3c,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+select "Con3c is alive";
+select current_user();
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_USER_LIMIT_REACHED
+connect (con3d,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_USER_LIMIT_REACHED
+connect (con3e,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+disconnect con3a;
+disconnect con3b;
+disconnect con3c;
+
+# Wait for all disconnects
+--source ../include/wait_for_pfs_thread_count.inc
+
+grant usage on *.* to 'quota'@'santa.claus.ipv4.example.com'
+ with max_user_connections 0;
+flush user_resources;
+
+set global max_user_connections = 3;
+
+connect (con4a,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+select "Con4a is alive";
+select current_user();
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+connect (con4b,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+select "Con4b is alive";
+select current_user();
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+connect (con4c,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+select "Con4c is alive";
+select current_user();
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_TOO_MANY_USER_CONNECTIONS
+connect (con4d,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_TOO_MANY_USER_CONNECTIONS
+connect (con4e,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+disconnect con4a;
+disconnect con4b;
+disconnect con4c;
+
+# Wait for all disconnects
+--source ../include/wait_for_pfs_thread_count.inc
+
+set global max_user_connections = 0;
+set global max_connections = 10;
+flush user_resources;
+
+connect (tmp_con1,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+connect (tmp_con2,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+connect (tmp_con3,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+connect (tmp_con4,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+connect (tmp_con5,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+connect (tmp_con6,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+connect (tmp_con7,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+
+connect (con5a,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+select "Con4a is alive";
+select current_user();
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+connect (con5b,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+select "Con5b is alive";
+select current_user();
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+# About error ER_CON_COUNT_ERROR:
+# - this error is associated with SQLSTATE 08004,
+# and returned from 2 places in the server code.
+# - which path returns the error is not predictable,
+# as it depends on the server load and thread scheduling
+# - one path returns a SQLSTATE of 08004
+# - another path returns no SQLSTATE at all,
+# and then the client sets a default value of HY000 for SQLSTATE
+#
+# Testing for error ER_CON_COUNT_ERROR alone causes this to
+# be printed in the result file:
+# - ERROR 08004: Too many connections
+# which in turn causes spurious test failures.
+#
+# To work around this, this scripts expect to see either
+# the error number ER_CON_COUNT_ERROR (it always does)
+# or the error number 9999 (it never does, this error does not exist).
+# The exact error number and SQLSTATE is not printed in the result file,
+# makig this test robust for both cases:
+# - ERROR 08004: Too many connections
+# - ERROR HY000: Too many connections
+
+--disable_query_log
+--error ER_CON_COUNT_ERROR, 9999
+connect (con5c,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_CON_COUNT_ERROR, 9999
+connect (con5d,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+disconnect con5a;
+disconnect con5b;
+--disconnect tmp_con1
+--disconnect tmp_con2
+--disconnect tmp_con3
+--disconnect tmp_con4
+--disconnect tmp_con5
+--disconnect tmp_con6
+--disconnect tmp_con7
+
+# Wait for all disconnects
+--source ../include/wait_for_pfs_thread_count.inc
+
+set global max_connections = @saved_max_connections;
+set global max_user_connections = @saved_max_user_connections;
+
+# revoke all privileges on test.* from 'quota'@'santa.claus.ipv4.example.com';
+drop user 'quota'@'santa.claus.ipv4.example.com';
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_again_allow.test b/mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_again_allow.test
new file mode 100644
index 00000000..5a2caf58
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_again_allow.test
@@ -0,0 +1,76 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from DNS:
+# - getnameinfo() fails with AGAIN
+# - reported in COUNT_NAMEINFO_TRANSIENT_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# [Warning] IP address '192.0.2.4' could not be resolved:
+# Temporary failure in name resolution
+call mtr.add_suppression("192.0.2.4");
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+create user 'root'@'192.0.2.4';
+grant select on test.* to 'root'@'192.0.2.4';
+create user 'root'@'santa.claus.ipv4.example.com';
+grant select on test.* to 'root'@'santa.claus.ipv4.example.com';
+
+connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_error_again";
+
+connect (con2,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con2 is alive";
+select current_user();
+disconnect con2;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+connect (con3,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con3 is alive";
+select current_user();
+disconnect con3;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_fake_good_ipv4";
+
+connect (con4,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con4 is alive";
+select current_user();
+disconnect con4;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+connect (con5,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con5 is alive";
+select current_user();
+disconnect con5;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+revoke select on test.* from 'root'@'192.0.2.4';
+revoke select on test.* from 'root'@'santa.claus.ipv4.example.com';
+drop user 'root'@'192.0.2.4';
+drop user 'root'@'santa.claus.ipv4.example.com';
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_again_deny.test b/mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_again_deny.test
new file mode 100644
index 00000000..6cd2664a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_again_deny.test
@@ -0,0 +1,66 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from DNS:
+# - getnameinfo() fails with AGAIN
+# - reported in COUNT_NAMEINFO_TRANSIENT_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# [Warning] IP address '192.0.2.4' could not be resolved:
+# Temporary failure in name resolution
+call mtr.add_suppression("192.0.2.4");
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_error_again";
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con2,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con3,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_fake_good_ipv4";
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con4,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con5,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_noname_allow.test b/mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_noname_allow.test
new file mode 100644
index 00000000..19a3ebe9
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_noname_allow.test
@@ -0,0 +1,54 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from DNS:
+# - getnameinfo() fails with NONAME
+# - reported in COUNT_NAMEINFO_PERMANENT_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# [Warning] IP address '192.0.2.4' could not be resolved:
+# no reverse address mapping.
+call mtr.add_suppression("192.0.2.4");
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+create user 'root'@'192.0.2.4';
+grant select on test.* to 'root'@'192.0.2.4';
+
+connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_error_noname";
+
+connect (con2,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con2 is alive";
+select current_user();
+disconnect con2;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+connect (con3,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con3 is alive";
+select current_user();
+disconnect con3;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+revoke select on test.* from 'root'@'192.0.2.4';
+drop user 'root'@'192.0.2.4';
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_noname_deny.test b/mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_noname_deny.test
new file mode 100644
index 00000000..28e5615d
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_nameinfo_noname_deny.test
@@ -0,0 +1,48 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from DNS:
+# - getnameinfo() fails with NONAME
+# - reported in COUNT_NAMEINFO_PERMANENT_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# [Warning] IP address '192.0.2.4' could not be resolved:
+# no reverse address mapping.
+call mtr.add_suppression("192.0.2.4");
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_error_noname";
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con2,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con3,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv4_passwd.test b/mysql-test/suite/perfschema/t/hostcache_ipv4_passwd.test
new file mode 100644
index 00000000..c6ff89f0
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_passwd.test
@@ -0,0 +1,87 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from user authentication:
+# - reported in COUNT_AUTHENTICATION_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+create user 'user_without'@'santa.claus.ipv4.example.com';
+create user 'user_with'@'santa.claus.ipv4.example.com'
+ identified by 'good_password';
+grant select on test.* to 'user_without'@'santa.claus.ipv4.example.com';
+grant select on test.* to 'user_with'@'santa.claus.ipv4.example.com';
+
+connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_fake_good_ipv4";
+
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR
+connect (con2a,"127.0.0.1",user_without,extra_password,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR
+connect (con2b,"127.0.0.1",user_without,extra_password,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR
+connect (con2c,"127.0.0.1",user_with,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR
+connect (con2d,"127.0.0.1",user_with,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR
+connect (con2e,"127.0.0.1",user_with,wrong_password,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR
+connect (con2f,"127.0.0.1",user_with,wrong_password,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+drop user 'user_with'@'santa.claus.ipv4.example.com';
+drop user 'user_without'@'santa.claus.ipv4.example.com';
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv4_ssl.test b/mysql-test/suite/perfschema/t/hostcache_ipv4_ssl.test
new file mode 100644
index 00000000..bd8d4898
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_ssl.test
@@ -0,0 +1,72 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from SSL:
+# - reported in COUNT_SSL_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+create user 'user_ssl'@'santa.claus.ipv4.example.com';
+create user 'user_ssl_x509'@'santa.claus.ipv4.example.com'
+ identified by 'good_password';
+grant select on test.* to 'user_ssl'@'santa.claus.ipv4.example.com'
+ REQUIRE SSL;
+grant select on test.* to 'user_ssl_x509'@'santa.claus.ipv4.example.com'
+ REQUIRE SUBJECT '/C=??/ST=??/L=??/
+ O=No such thing/
+ CN=Santa Claus/emailAddress=santa.claus@example.com';
+
+connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_fake_good_ipv4";
+
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR
+connect (con2a,"127.0.0.1",user_ssl,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR
+connect (con2b,"127.0.0.1",user_ssl,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR
+connect (con2c,"127.0.0.1",user_ssl_x509,good_password,test,$MASTER_MYPORT,,SSL);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR
+connect (con2d,"127.0.0.1",user_ssl_x509,good_password,test,$MASTER_MYPORT,,SSL);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+drop user 'user_ssl'@'santa.claus.ipv4.example.com';
+drop user 'user_ssl_x509'@'santa.claus.ipv4.example.com';
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_again_allow-master.opt b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_again_allow-master.opt
new file mode 100644
index 00000000..063beb40
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_again_allow-master.opt
@@ -0,0 +1,2 @@
+--disable-skip-name-resolve
+--bind-address=::
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_again_allow.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_again_allow.test
new file mode 100644
index 00000000..100fdffa
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_again_allow.test
@@ -0,0 +1,55 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from DNS:
+# - getaddrinfo() fails with AGAIN
+# - reported in COUNT_ADDRINFO_TRANSIENT_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/check_ipv6.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# [Warning] Host name 'santa.claus.ipv6.example.com' could not be resolved:
+# Temporary failure in name resolution
+call mtr.add_suppression("santa.claus.ipv6.example.com");
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+create user 'root'@'2001:db8::6:6';
+grant select on test.* to 'root'@'2001:db8::6:6';
+
+connect (con1,"::1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv6,getnameinfo_fake_ipv6,getaddrinfo_error_again";
+
+connect (con2,"::1",root,,test,$MASTER_MYPORT,);
+select "Con2 is alive";
+select current_user();
+disconnect con2;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+connect (con3,"::1",root,,test,$MASTER_MYPORT,);
+select "Con3 is alive";
+select current_user();
+disconnect con3;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+revoke select on test.* from 'root'@'2001:db8::6:6';
+drop user 'root'@'2001:db8::6:6';
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_again_deny-master.opt b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_again_deny-master.opt
new file mode 100644
index 00000000..063beb40
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_again_deny-master.opt
@@ -0,0 +1,2 @@
+--disable-skip-name-resolve
+--bind-address=::
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_again_deny.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_again_deny.test
new file mode 100644
index 00000000..8aafff74
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_again_deny.test
@@ -0,0 +1,49 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from DNS:
+# - getaddrinfo() fails with AGAIN
+# - reported in COUNT_ADDRINFO_TRANSIENT_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/check_ipv6.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# [Warning] Host name 'santa.claus.ipv6.example.com' could not be resolved:
+# Temporary failure in name resolution
+call mtr.add_suppression("santa.claus.ipv6.example.com");
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+connect (con1,"::1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv6,getnameinfo_fake_ipv6,getaddrinfo_error_again";
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con2,"::1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con3,"::1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_bad_allow-master.opt b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_bad_allow-master.opt
new file mode 100644
index 00000000..063beb40
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_bad_allow-master.opt
@@ -0,0 +1,2 @@
+--disable-skip-name-resolve
+--bind-address=::
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_bad_allow.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_bad_allow.test
new file mode 100644
index 00000000..eaf46a5c
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_bad_allow.test
@@ -0,0 +1,57 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from DNS full round trip (FCRDNS):
+# - IP --> HOST --> IP returns no match
+# - reported in COUNT_FCRDNS_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/check_ipv6.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# [Warning] Hostname 'santa.claus.ipv6.example.com' does not resolve to '2001:db8::6:6'.
+# [Note] Hostname 'santa.claus.ipv6.example.com' has the following IP addresses:
+# [Note] - 2001:db8::6:7e
+# [Note] - 2001:db8::6:7f
+call mtr.add_suppression("santa.claus.ipv6.example.com");
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+create user 'root'@'2001:db8::6:6';
+grant select on test.* to 'root'@'2001:db8::6:6';
+
+connect (con1,"::1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv6,getnameinfo_fake_ipv6,getaddrinfo_fake_bad_ipv6";
+
+connect (con2,"::1",root,,test,$MASTER_MYPORT,);
+select "Con2 is alive";
+select current_user();
+disconnect con2;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+connect (con3,"::1",root,,test,$MASTER_MYPORT,);
+select "Con3 is alive";
+select current_user();
+disconnect con3;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+revoke select on test.* from 'root'@'2001:db8::6:6';
+drop user 'root'@'2001:db8::6:6';
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_bad_deny-master.opt b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_bad_deny-master.opt
new file mode 100644
index 00000000..063beb40
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_bad_deny-master.opt
@@ -0,0 +1,2 @@
+--disable-skip-name-resolve
+--bind-address=::
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_bad_deny.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_bad_deny.test
new file mode 100644
index 00000000..6c4ede9d
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_bad_deny.test
@@ -0,0 +1,51 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from DNS full round trip (FCRDNS):
+# - IP --> HOST --> IP returns no match
+# - reported in COUNT_FCRDNS_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/check_ipv6.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# [Warning] Hostname 'santa.claus.ipv6.example.com' does not resolve to '2001:db8::6:6'.
+# [Note] Hostname 'santa.claus.ipv6.example.com' has the following IP addresses:
+# [Note] - 2001:db8::6:7e
+# [Note] - 2001:db8::6:7f
+call mtr.add_suppression("santa.claus.ipv6.example.com");
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+connect (con1,"::1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv6,getnameinfo_fake_ipv6,getaddrinfo_fake_bad_ipv6";
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con2,"::1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con3,"::1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_good_allow-master.opt b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_good_allow-master.opt
new file mode 100644
index 00000000..063beb40
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_good_allow-master.opt
@@ -0,0 +1,2 @@
+--disable-skip-name-resolve
+--bind-address=::
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_good_allow.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_good_allow.test
new file mode 100644
index 00000000..e290a5f8
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_good_allow.test
@@ -0,0 +1,55 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate success from DNS full round trip (FCRDNS):
+# - IP --> HOST --> IP returns the client IP
+# - completes host validation in HOST_VALIDATED
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/check_ipv6.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# [Warning] IP address '192.0.2.4' could not be resolved:
+# no reverse address mapping.
+call mtr.add_suppression("192.0.2.4");
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+create user 'root'@'santa.claus.ipv6.example.com';
+grant select on test.* to 'root'@'santa.claus.ipv6.example.com';
+
+connect (con1,"::1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv6,getnameinfo_fake_ipv6,getaddrinfo_fake_good_ipv6";
+
+connect (con2,"::1",root,,test,$MASTER_MYPORT,);
+select "Con2 is alive";
+select current_user();
+disconnect con2;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+connect (con3,"::1",root,,test,$MASTER_MYPORT,);
+select "Con3 is alive";
+select current_user();
+disconnect con3;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+revoke select on test.* from 'root'@'santa.claus.ipv6.example.com';
+drop user 'root'@'santa.claus.ipv6.example.com';
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_good_deny-master.opt b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_good_deny-master.opt
new file mode 100644
index 00000000..063beb40
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_good_deny-master.opt
@@ -0,0 +1,2 @@
+--disable-skip-name-resolve
+--bind-address=::
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_good_deny.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_good_deny.test
new file mode 100644
index 00000000..4feb0ffb
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_good_deny.test
@@ -0,0 +1,45 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate success from DNS full round trip (FCRDNS):
+# - IP --> HOST --> IP returns the client IP
+# - completes host validation in HOST_VALIDATED
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/check_ipv6.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+connect (con1,"::1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv6,getnameinfo_fake_ipv6,getaddrinfo_fake_good_ipv6";
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con2,"::1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con3,"::1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_noname_allow-master.opt b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_noname_allow-master.opt
new file mode 100644
index 00000000..063beb40
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_noname_allow-master.opt
@@ -0,0 +1,2 @@
+--disable-skip-name-resolve
+--bind-address=::
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_noname_allow.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_noname_allow.test
new file mode 100644
index 00000000..6b422a19
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_noname_allow.test
@@ -0,0 +1,58 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from DNS:
+# - getaddrinfo() fails with AGAIN
+# - reported in COUNT_ADDRINFO_TRANSIENT_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/check_ipv6.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# [Warning] Host name 'santa.claus.ipv6.example.com' could not be resolved:
+# Name or service not known
+call mtr.add_suppression("santa.claus.ipv6.example.com");
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+create user 'root'@'santa.claus.ipv6.example.com';
+grant select on test.* to 'root'@'santa.claus.ipv6.example.com';
+create user 'root'@'2001:db8::6:6';
+grant select on test.* to 'root'@'2001:db8::6:6';
+
+connect (con1,"::1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv6,getnameinfo_fake_ipv6,getaddrinfo_error_noname";
+
+connect (con2,"::1",root,,test,$MASTER_MYPORT,);
+select "Con2 is alive";
+select current_user();
+disconnect con2;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+connect (con3,"::1",root,,test,$MASTER_MYPORT,);
+select "Con3 is alive";
+select current_user();
+disconnect con3;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+revoke select on test.* from 'root'@'santa.claus.ipv6.example.com';
+revoke select on test.* from 'root'@'2001:db8::6:6';
+drop user 'root'@'santa.claus.ipv6.example.com';
+drop user 'root'@'2001:db8::6:6';
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_noname_deny-master.opt b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_noname_deny-master.opt
new file mode 100644
index 00000000..063beb40
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_noname_deny-master.opt
@@ -0,0 +1,2 @@
+--disable-skip-name-resolve
+--bind-address=::
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_noname_deny.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_noname_deny.test
new file mode 100644
index 00000000..c81b799e
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_addrinfo_noname_deny.test
@@ -0,0 +1,48 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from DNS:
+# - getaddrinfo() fails with NONAME
+# - reported in COUNT_ADDRINFO_PERMANENT_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/check_ipv6.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# [Warning] Host name 'santa.claus.ipv6.example.com' could not be resolved:
+# Name or service not known
+call mtr.add_suppression("santa.claus.ipv6.example.com");
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+connect (con1,"::1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv6,getnameinfo_fake_ipv6,getaddrinfo_error_noname";
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con2,"::1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con3,"::1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_auth_plugin-master.opt b/mysql-test/suite/perfschema/t/hostcache_ipv6_auth_plugin-master.opt
new file mode 100644
index 00000000..063beb40
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_auth_plugin-master.opt
@@ -0,0 +1,2 @@
+--disable-skip-name-resolve
+--bind-address=::
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_auth_plugin.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_auth_plugin.test
new file mode 100644
index 00000000..d2e4ed69
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_auth_plugin.test
@@ -0,0 +1,93 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Test authorization with auth plugins.
+# error reporting in:
+# - column COUNT_AUTH_PLUGIN_ERRORS
+# - column COUNT_PROXY_USER_ERRORS
+# - column COUNT_PROXY_USER_ACL_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/check_ipv6.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+--source include/have_plugin_auth.inc
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+CREATE USER 'plug'@'santa.claus.ipv6.example.com'
+ IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
+CREATE USER 'plug_dest'@'santa.claus.ipv6.example.com'
+ IDENTIFIED BY 'plug_test_passwd';
+GRANT SELECT ON test.* TO 'plug_dest'@'santa.claus.ipv6.example.com';
+
+connect (con1,"::1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv6,getnameinfo_fake_ipv6,getaddrinfo_fake_good_ipv6";
+uninstall plugin test_plugin_server;
+
+--disable_query_log
+--error ER_PLUGIN_IS_NOT_LOADED
+connect (con2,"::1",plug,plug_dest,test,$MASTER_MYPORT,,,auth_test_plugin);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_PLUGIN_IS_NOT_LOADED
+connect (con3,"::1",plug,plug_dest,test,$MASTER_MYPORT,,,auth_test_plugin);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--replace_result $AUTH_TEST_PLUGIN_SO PLUGIN_AUTH
+eval install plugin test_plugin_server soname '$AUTH_TEST_PLUGIN_SO';
+
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR
+connect (con2,"::1",plug,plug_dest,test,$MASTER_MYPORT,,,auth_test_plugin);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR
+connect (con3,"::1",plug,plug_dest,test,$MASTER_MYPORT,,,auth_test_plugin);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+GRANT PROXY ON 'plug_dest'@'santa.claus.ipv6.example.com'
+ TO 'plug'@'santa.claus.ipv6.example.com';
+
+connect (con4,"::1",plug,plug_dest,test,$MASTER_MYPORT,,,auth_test_plugin);
+select "Con4 is alive";
+select user();
+select current_user();
+disconnect con4;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+REVOKE ALL PRIVILEGES ON *.* FROM 'plug_dest'@'santa.claus.ipv6.example.com';
+REVOKE PROXY ON 'plug_dest'@'santa.claus.ipv6.example.com'
+ FROM 'plug'@'santa.claus.ipv6.example.com';
+DROP USER 'plug'@'santa.claus.ipv6.example.com';
+DROP USER 'plug_dest'@'santa.claus.ipv6.example.com';
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+delete from mysql.plugin where name='test_plugin_server';
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_blocked-master.opt b/mysql-test/suite/perfschema/t/hostcache_ipv6_blocked-master.opt
new file mode 100644
index 00000000..063beb40
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_blocked-master.opt
@@ -0,0 +1,2 @@
+--disable-skip-name-resolve
+--bind-address=::
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_blocked.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_blocked.test
new file mode 100644
index 00000000..6da99e02
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_blocked.test
@@ -0,0 +1,161 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from client / server protocol:
+# - reported in COUNT_HANDSHAKE_ERRORS
+# aud further causes blocking errors:
+# - reported in SUM_CONNECT_ERRORS
+# - reported in COUNT_HOST_BLOCKED_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/check_ipv6.inc
+--source include/have_perfschema.inc
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+select @@global.max_connect_errors into @saved_max_connect_errors;
+
+set global max_connect_errors = 3;
+
+create user 'root'@'santa.claus.ipv6.example.com';
+grant select on test.* to 'root'@'santa.claus.ipv6.example.com';
+
+create user 'quota'@'santa.claus.ipv6.example.com';
+grant select on test.* to 'quota'@'santa.claus.ipv6.example.com';
+
+connect (con1,"::1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv6,getnameinfo_fake_ipv6,getaddrinfo_fake_good_ipv6,native_password_bad_reply";
+
+--disable_query_log
+--error ER_HANDSHAKE_ERROR
+connect (con2a,"::1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HANDSHAKE_ERROR
+connect (con2b,"::1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HANDSHAKE_ERROR
+connect (con2c,"::1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HOST_IS_BLOCKED
+connect (con2d,"::1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HOST_IS_BLOCKED
+connect (con2e,"::1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+# Now that the host is blocked, check that flush works
+flush hosts;
+
+--disable_query_log
+--error ER_HANDSHAKE_ERROR
+connect (con3a,"::1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HANDSHAKE_ERROR
+connect (con3b,"::1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--connection default
+set global debug_dbug= "-d,native_password_bad_reply";
+
+--disable_query_log
+connect (con4,"::1",quota,,test,$MASTER_MYPORT,);
+select "Valid connection should reset SUM_CONNECT_ERROR counter" as message;
+--disconnect con4
+--enable_query_log
+
+--connection default
+set global debug_dbug= "+d,native_password_bad_reply";
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HANDSHAKE_ERROR
+connect (con5a,"::1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HANDSHAKE_ERROR
+connect (con5b,"::1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HANDSHAKE_ERROR
+connect (con5c,"::1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HOST_IS_BLOCKED
+connect (con5d,"::1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HOST_IS_BLOCKED
+connect (con5e,"::1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+revoke select on test.* from 'root'@'santa.claus.ipv6.example.com';
+drop user 'root'@'santa.claus.ipv6.example.com';
+
+revoke select on test.* from 'quota'@'santa.claus.ipv6.example.com';
+drop user 'quota'@'santa.claus.ipv6.example.com';
+
+set global max_connect_errors = @saved_max_connect_errors;
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_max_con-master.opt b/mysql-test/suite/perfschema/t/hostcache_ipv6_max_con-master.opt
new file mode 100644
index 00000000..a80feadb
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_max_con-master.opt
@@ -0,0 +1,3 @@
+--disable-skip-name-resolve
+--bind-address=::
+--max-user-connections=1024
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_max_con.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_max_con.test
new file mode 100644
index 00000000..6f83221c
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_max_con.test
@@ -0,0 +1,246 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from per user quotas:
+# - reported in COUNT_MAX_USER_CONNECTION_ERRORS
+# - reported in COUNT_MAX_USER_CONNECTION_PER_HOUR_ERRORS
+# Simulate failures from server quotas:
+# - reported in COUNT_MAX_CONNECTION_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/check_ipv6.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+SET @saved_max_connections=@@global.max_connections;
+SET @saved_max_user_connections=@@global.max_user_connections;
+
+create user 'quota'@'santa.claus.ipv6.example.com';
+grant select on test.* to 'quota'@'santa.claus.ipv6.example.com';
+grant usage on *.* to 'quota'@'santa.claus.ipv6.example.com'
+ with max_connections_per_hour 3;
+
+connect (con1,"::1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv6,getnameinfo_fake_ipv6,getaddrinfo_fake_good_ipv6";
+
+connect (con2a,"::1",quota,,test,$MASTER_MYPORT,);
+select "Con2a is alive";
+select current_user();
+disconnect con2a;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+connect (con2b,"::1",quota,,test,$MASTER_MYPORT,);
+select "Con2b is alive";
+select current_user();
+disconnect con2b;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+connect (con2c,"::1",quota,,test,$MASTER_MYPORT,);
+select "Con2c is alive";
+select current_user();
+disconnect con2c;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_USER_LIMIT_REACHED
+connect (con2d,"::1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_USER_LIMIT_REACHED
+connect (con2e,"::1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+# Wait for all disconnects
+--source ../include/wait_for_pfs_thread_count.inc
+
+grant usage on *.* to 'quota'@'santa.claus.ipv6.example.com'
+ with max_connections_per_hour 0;
+grant usage on *.* to 'quota'@'santa.claus.ipv6.example.com'
+ with max_user_connections 3;
+flush user_resources;
+
+connect (con3a,"::1",quota,,test,$MASTER_MYPORT,);
+select "Con7 is alive";
+select current_user();
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+connect (con3b,"::1",quota,,test,$MASTER_MYPORT,);
+select "Con3b is alive";
+select current_user();
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+connect (con3c,"::1",quota,,test,$MASTER_MYPORT,);
+select "Con3c is alive";
+select current_user();
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_USER_LIMIT_REACHED
+connect (con3d,"::1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_USER_LIMIT_REACHED
+connect (con3e,"::1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+disconnect con3a;
+disconnect con3b;
+disconnect con3c;
+
+# Wait for all disconnects
+--source ../include/wait_for_pfs_thread_count.inc
+
+grant usage on *.* to 'quota'@'santa.claus.ipv6.example.com'
+ with max_user_connections 0;
+flush user_resources;
+
+set global max_user_connections = 3;
+
+connect (con4a,"::1",quota,,test,$MASTER_MYPORT,);
+select "Con4a is alive";
+select current_user();
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+connect (con4b,"::1",quota,,test,$MASTER_MYPORT,);
+select "Con4b is alive";
+select current_user();
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+connect (con4c,"::1",quota,,test,$MASTER_MYPORT,);
+select "Con4c is alive";
+select current_user();
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_TOO_MANY_USER_CONNECTIONS
+connect (con4d,"::1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_TOO_MANY_USER_CONNECTIONS
+connect (con4e,"::1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+disconnect con4a;
+disconnect con4b;
+disconnect con4c;
+
+# Wait for all disconnects
+--source ../include/wait_for_pfs_thread_count.inc
+
+set global max_user_connections = 0;
+set global max_connections = 10;
+flush user_resources;
+
+connect (tmp_con1,"::1",quota,,test,$MASTER_MYPORT,);
+connect (tmp_con2,"::1",quota,,test,$MASTER_MYPORT,);
+connect (tmp_con3,"::1",quota,,test,$MASTER_MYPORT,);
+connect (tmp_con4,"::1",quota,,test,$MASTER_MYPORT,);
+connect (tmp_con5,"::1",quota,,test,$MASTER_MYPORT,);
+connect (tmp_con6,"::1",quota,,test,$MASTER_MYPORT,);
+connect (tmp_con7,"::1",quota,,test,$MASTER_MYPORT,);
+
+connect (con5a,"::1",quota,,test,$MASTER_MYPORT,);
+select "Con4a is alive";
+select current_user();
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+connect (con5b,"::1",quota,,test,$MASTER_MYPORT,);
+select "Con5b is alive";
+select current_user();
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+# About ER_CON_COUNT_ERROR,
+# See comments in hostcache_ipv4_max_con.test
+
+--disable_query_log
+--error ER_CON_COUNT_ERROR, 9999
+connect (con5c,"::1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_CON_COUNT_ERROR, 9999
+connect (con5d,"::1",quota,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+disconnect con5a;
+disconnect con5b;
+--disconnect tmp_con1
+--disconnect tmp_con2
+--disconnect tmp_con3
+--disconnect tmp_con4
+--disconnect tmp_con5
+--disconnect tmp_con6
+--disconnect tmp_con7
+
+# Wait for all disconnects
+--source ../include/wait_for_pfs_thread_count.inc
+
+set global max_connections = @saved_max_connections;
+set global max_user_connections = @saved_max_user_connections;
+
+# revoke all privileges on test.* from 'quota'@'santa.claus.ipv6.example.com';
+drop user 'quota'@'santa.claus.ipv6.example.com';
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_again_allow-master.opt b/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_again_allow-master.opt
new file mode 100644
index 00000000..063beb40
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_again_allow-master.opt
@@ -0,0 +1,2 @@
+--disable-skip-name-resolve
+--bind-address=::
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_again_allow.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_again_allow.test
new file mode 100644
index 00000000..896b9bb4
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_again_allow.test
@@ -0,0 +1,77 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from DNS:
+# - getnameinfo() fails with AGAIN
+# - reported in COUNT_NAMEINFO_TRANSIENT_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/check_ipv6.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# [Warning] IP address '2001:db8::6:6' could not be resolved:
+# Temporary failure in name resolution
+call mtr.add_suppression("2001:db8::6:6");
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+create user 'root'@'2001:db8::6:6';
+grant select on test.* to 'root'@'2001:db8::6:6';
+create user 'root'@'santa.claus.ipv6.example.com';
+grant select on test.* to 'root'@'santa.claus.ipv6.example.com';
+
+connect (con1,"::1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv6,getnameinfo_error_again";
+
+connect (con2,"::1",root,,test,$MASTER_MYPORT,);
+select "Con2 is alive";
+select current_user();
+disconnect con2;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+connect (con3,"::1",root,,test,$MASTER_MYPORT,);
+select "Con3 is alive";
+select current_user();
+disconnect con3;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv6,getnameinfo_fake_ipv6,getaddrinfo_fake_good_ipv6";
+
+connect (con4,"::1",root,,test,$MASTER_MYPORT,);
+select "Con4 is alive";
+select current_user();
+disconnect con4;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+connect (con5,"::1",root,,test,$MASTER_MYPORT,);
+select "Con5 is alive";
+select current_user();
+disconnect con5;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+revoke select on test.* from 'root'@'2001:db8::6:6';
+revoke select on test.* from 'root'@'santa.claus.ipv6.example.com';
+drop user 'root'@'2001:db8::6:6';
+drop user 'root'@'santa.claus.ipv6.example.com';
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_again_deny-master.opt b/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_again_deny-master.opt
new file mode 100644
index 00000000..063beb40
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_again_deny-master.opt
@@ -0,0 +1,2 @@
+--disable-skip-name-resolve
+--bind-address=::
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_again_deny.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_again_deny.test
new file mode 100644
index 00000000..17cc1ffa
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_again_deny.test
@@ -0,0 +1,67 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from DNS:
+# - getnameinfo() fails with AGAIN
+# - reported in COUNT_NAMEINFO_TRANSIENT_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/check_ipv6.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# [Warning] IP address '2001:db8::6:6' could not be resolved:
+# Temporary failure in name resolution
+call mtr.add_suppression("2001:db8::6:6");
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+connect (con1,"::1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv6,getnameinfo_error_again";
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con2,"::1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con3,"::1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv6,getnameinfo_fake_ipv6,getaddrinfo_fake_good_ipv6";
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con4,"::1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con5,"::1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_noname_allow-master.opt b/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_noname_allow-master.opt
new file mode 100644
index 00000000..063beb40
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_noname_allow-master.opt
@@ -0,0 +1,2 @@
+--disable-skip-name-resolve
+--bind-address=::
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_noname_allow.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_noname_allow.test
new file mode 100644
index 00000000..8e31420b
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_noname_allow.test
@@ -0,0 +1,55 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from DNS:
+# - getnameinfo() fails with NONAME
+# - reported in COUNT_NAMEINFO_PERMANENT_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/check_ipv6.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# [Warning] IP address '2001:db8::6:6' could not be resolved:
+# Name or service not known
+call mtr.add_suppression("2001:db8::6:6");
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+create user 'root'@'2001:db8::6:6';
+grant select on test.* to 'root'@'2001:db8::6:6';
+
+connect (con1,"::1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv6,getnameinfo_error_noname";
+
+connect (con2,"::1",root,,test,$MASTER_MYPORT,);
+select "Con2 is alive";
+select current_user();
+disconnect con2;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+connect (con3,"::1",root,,test,$MASTER_MYPORT,);
+select "Con3 is alive";
+select current_user();
+disconnect con3;
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+revoke select on test.* from 'root'@'2001:db8::6:6';
+drop user 'root'@'2001:db8::6:6';
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_noname_deny-master.opt b/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_noname_deny-master.opt
new file mode 100644
index 00000000..063beb40
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_noname_deny-master.opt
@@ -0,0 +1,2 @@
+--disable-skip-name-resolve
+--bind-address=::
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_noname_deny.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_noname_deny.test
new file mode 100644
index 00000000..ddffc820
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_nameinfo_noname_deny.test
@@ -0,0 +1,49 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from DNS:
+# - getnameinfo() fails with NONAME
+# - reported in COUNT_NAMEINFO_PERMANENT_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/check_ipv6.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# [Warning] IP address '2001:db8::6:6' could not be resolved:
+# Name or service not known
+call mtr.add_suppression("2001:db8::6:6");
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+connect (con1,"::1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv6,getnameinfo_error_noname";
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con2,"::1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_HOST_NOT_PRIVILEGED
+connect (con3,"::1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_passwd-master.opt b/mysql-test/suite/perfschema/t/hostcache_ipv6_passwd-master.opt
new file mode 100644
index 00000000..063beb40
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_passwd-master.opt
@@ -0,0 +1,2 @@
+--disable-skip-name-resolve
+--bind-address=::
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_passwd.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_passwd.test
new file mode 100644
index 00000000..7281a8b3
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_passwd.test
@@ -0,0 +1,85 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from user authentication:
+# - reported in COUNT_AUTHENTICATION_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/check_ipv6.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+create user 'user_without'@'santa.claus.ipv6.example.com';
+create user 'user_with'@'santa.claus.ipv6.example.com'
+ identified by 'good_password';
+grant select on test.* to 'user_without'@'santa.claus.ipv6.example.com';
+grant select on test.* to 'user_with'@'santa.claus.ipv6.example.com';
+
+connect (con1,"::1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv6,getnameinfo_fake_ipv6,getaddrinfo_fake_good_ipv6";
+
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR
+connect (con2a,"::1",user_without,extra_password,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR
+connect (con2b,"::1",user_without,extra_password,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR
+connect (con2c,"::1",user_with,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR
+connect (con2d,"::1",user_with,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR
+connect (con2e,"::1",user_with,wrong_password,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR
+connect (con2f,"::1",user_with,wrong_password,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+drop user 'user_with'@'santa.claus.ipv6.example.com';
+drop user 'user_without'@'santa.claus.ipv6.example.com';
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_ssl-master.opt b/mysql-test/suite/perfschema/t/hostcache_ipv6_ssl-master.opt
new file mode 100644
index 00000000..063beb40
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_ssl-master.opt
@@ -0,0 +1,2 @@
+--disable-skip-name-resolve
+--bind-address=::
diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_ssl.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_ssl.test
new file mode 100644
index 00000000..d822d9f9
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_ssl.test
@@ -0,0 +1,73 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from SSL:
+# - reported in COUNT_SSL_ERRORS
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/check_ipv6.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+create user 'user_ssl'@'santa.claus.ipv6.example.com';
+create user 'user_ssl_x509'@'santa.claus.ipv6.example.com'
+ identified by 'good_password';
+grant select on test.* to 'user_ssl'@'santa.claus.ipv6.example.com'
+ REQUIRE SSL;
+grant select on test.* to 'user_ssl_x509'@'santa.claus.ipv6.example.com'
+ REQUIRE SUBJECT '/C=??/ST=??/L=??/
+ O=No such thing/
+ CN=Santa Claus/emailAddress=santa.claus@example.com';
+
+connect (con1,"::1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_fake_ipv6,getnameinfo_fake_ipv6,getaddrinfo_fake_good_ipv6";
+
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR
+connect (con2a,"::1",user_ssl,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR
+connect (con2b,"::1",user_ssl,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR
+connect (con2c,"::1",user_ssl_x509,good_password,test,$MASTER_MYPORT,,SSL);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR
+connect (con2d,"::1",user_ssl_x509,good_password,test,$MASTER_MYPORT,,SSL);
+--enable_query_log
+
+--connection default
+--source ../include/hostcache_dump.inc
+
+drop user 'user_ssl'@'santa.claus.ipv6.example.com';
+drop user 'user_ssl_x509'@'santa.claus.ipv6.example.com';
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
diff --git a/mysql-test/suite/perfschema/t/hostcache_peer_addr.test b/mysql-test/suite/perfschema/t/hostcache_peer_addr.test
new file mode 100644
index 00000000..82742131
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/hostcache_peer_addr.test
@@ -0,0 +1,50 @@
+
+#
+# Tests for the performance_schema host_cache.
+#
+# Simulate failures from vio_peer_addr, reported in:
+# status variable Peer_address_errors
+
+--source include/not_embedded.inc
+--source include/have_debug.inc
+--source include/have_perfschema.inc
+--source include/have_hostname_cache.inc
+
+# Enforce a clean state
+--source ../include/wait_for_pfs_thread_count.inc
+--source ../include/hostcache_set_state.inc
+
+show global status like "connection_errors_%";
+
+connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+select "Con1 is alive";
+select current_user();
+disconnect con1;
+
+--connection default
+SET @saved_dbug = @@GLOBAL.debug_dbug;
+set global debug_dbug= "+d,vio_peer_addr_error";
+
+--disable_query_log
+--error ER_BAD_HOST_ERROR
+connect (con2,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+show global status like "connection_errors_%";
+--source ../include/hostcache_dump.inc
+
+--disable_query_log
+--error ER_BAD_HOST_ERROR
+connect (con3,"127.0.0.1",root,,test,$MASTER_MYPORT,);
+--enable_query_log
+
+--connection default
+show global status like "connection_errors_%";
+--source ../include/hostcache_dump.inc
+
+SET @@GLOBAL.debug_dbug = @saved_dbug;
+
+flush status;
+show global status like "connection_errors_%";
+
diff --git a/mysql-test/suite/perfschema/t/indexed_table_io.test b/mysql-test/suite/perfschema/t/indexed_table_io.test
new file mode 100644
index 00000000..03718771
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/indexed_table_io.test
@@ -0,0 +1,114 @@
+# Tests for PERFORMANCE_SCHEMA table io
+# Show the impact of an index
+
+# Setup
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+let $engine_type= MyISAM;
+
+--disable_warnings
+drop table if exists test.no_index_tab;
+drop table if exists test.index_tab;
+--enable_warnings
+
+let $table_io_select= select SUM(NUMBER_OF_BYTES)
+from performance_schema.events_waits_history_long
+where event_name like 'wait/io/table/%'
+and object_schema = 'test'
+and object_name = ;
+
+--source ../include/table_io_setup_helper.inc
+
+# Code to test
+
+eval create table test.no_index_tab
+ ( a int, b char(30) default 'Default') engine = $engine_type;
+eval create table test.index_tab
+ ( a int, b char(30) default 'Default', unique key uidx(a)) engine = $engine_type;
+# Make sure the proper engine is used
+show create table test.no_index_tab;
+show create table test.index_tab;
+
+truncate table performance_schema.events_waits_history_long;
+update performance_schema.setup_consumers set enabled='YES';
+--echo # Printing of 100 inserts per table is suppressed
+--disable_query_log
+let $run= 100;
+while ($run)
+{
+ eval insert into test.no_index_tab set a = $run;
+ eval insert into test.index_tab set a = $run;
+ dec $run;
+}
+--enable_query_log
+update performance_schema.setup_consumers set enabled='NO';
+eval $table_io_select 'no_index_tab';
+# Attention: There is no visible impact of index maintenance on table io
+# because the maintenance is handled by the storage engine themself.
+eval $table_io_select 'index_tab';
+
+select count(*) from test.no_index_tab;
+select count(*) from test.index_tab;
+
+# Testing Code
+
+--disable_ps2_protocol
+# For getting avg(a) inspection of
+# - all rows (test.no_index_tab)
+# - all unique index values (test.index_tab, assuming the optimizer decides to
+# process only the unique index)
+# --> No difference between numvber of accesses for no_index_tab and index_tab
+truncate table performance_schema.events_waits_history_long;
+update performance_schema.setup_consumers set enabled='YES';
+select avg(a) from test.no_index_tab;
+update performance_schema.setup_consumers set enabled='NO';
+eval $table_io_select 'no_index_tab';
+truncate table performance_schema.events_waits_history_long;
+update performance_schema.setup_consumers set enabled='YES';
+select avg(a) from test.index_tab;
+update performance_schema.setup_consumers set enabled='NO';
+eval $table_io_select 'index_tab';
+
+# With where a = 50 inspection of
+# - all rows (test.no_index_tab)
+# - 1 up to maybe a few unique index values (test.index_tab, assuming that the
+# optimizer decides to exploit the unique index)
+# --> index_tab requires much less accesses than no_index_tab
+truncate table performance_schema.events_waits_history_long;
+update performance_schema.setup_consumers set enabled='YES';
+select 1 as my_column from test.no_index_tab where a = 50;
+update performance_schema.setup_consumers set enabled='NO';
+eval $table_io_select 'no_index_tab';
+truncate table performance_schema.events_waits_history_long;
+update performance_schema.setup_consumers set enabled='YES';
+select 1 as my_column from test.index_tab where a = 50;
+update performance_schema.setup_consumers set enabled='NO';
+eval $table_io_select 'index_tab';
+
+# With where a = 50 inspection of
+# - all rows (test.no_index_tab)
+# - 1 up to maybe a few unique index values (test.index_tab, assuming that the
+# optimizer decides to exploit the unique index)
+# and remove one row for both cases
+# --> index_tab requires much less accesses than no_index_tab
+truncate table performance_schema.events_waits_history_long;
+update performance_schema.setup_consumers set enabled='YES';
+delete from test.no_index_tab where a = 51;
+update performance_schema.setup_consumers set enabled='NO';
+eval $table_io_select 'no_index_tab';
+truncate table performance_schema.events_waits_history_long;
+update performance_schema.setup_consumers set enabled='YES';
+delete from test.index_tab where a = 51;
+update performance_schema.setup_consumers set enabled='NO';
+eval $table_io_select 'index_tab';
+--enable_ps2_protocol
+
+# In case of failures, this will tell if table io are lost.
+show global status like 'performance_schema_%';
+
+# Cleanup
+drop table test.no_index_tab;
+drop table test.index_tab;
+--source ../include/table_io_cleanup_helper.inc
diff --git a/mysql-test/suite/perfschema/t/information_schema.test b/mysql-test/suite/perfschema/t/information_schema.test
new file mode 100644
index 00000000..937a1b4f
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/information_schema.test
@@ -0,0 +1,73 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+# Several selects so the output is readable
+
+# Note that TABLE_NAME is in uppercase is some platforms,
+# and in lowercase in others.
+# Using lower(TABLE_NAME) to have consistent results.
+
+select TABLE_SCHEMA, lower(TABLE_NAME), TABLE_CATALOG
+ from information_schema.tables
+ where TABLE_SCHEMA='performance_schema'
+ order by table_name;
+
+select lower(TABLE_NAME), TABLE_TYPE, ENGINE
+ from information_schema.tables
+ where TABLE_SCHEMA='performance_schema'
+ order by table_name;
+
+select lower(TABLE_NAME), VERSION, ROW_FORMAT
+ from information_schema.tables
+ where TABLE_SCHEMA='performance_schema'
+ order by table_name;
+
+# Query status and system variable tables separately because AVG_ROW_LENGTH
+# depends upon which plugins are loaded at the time of the query.
+#
+# TABLE_ROWS is unpredictable with autoscaling buffers
+select lower(TABLE_NAME), AVG_ROW_LENGTH
+ from information_schema.tables
+ where TABLE_SCHEMA='performance_schema' and
+ lower(TABLE_NAME) not regexp '^variables|variables$|^status|session_status|global_status'
+ order by table_name;
+
+--replace_column 2 table_rows 3 avg_row_len
+select lower(TABLE_NAME), TABLE_ROWS, AVG_ROW_LENGTH
+ from information_schema.tables
+ where TABLE_SCHEMA='performance_schema' and
+ lower(TABLE_NAME) regexp '^variables|variables$|^status|session_status|global_status'
+ order by table_name;
+
+select lower(TABLE_NAME), DATA_LENGTH, MAX_DATA_LENGTH
+ from information_schema.tables
+ where TABLE_SCHEMA='performance_schema'
+ order by table_name;
+
+select lower(TABLE_NAME), INDEX_LENGTH, DATA_FREE, AUTO_INCREMENT
+ from information_schema.tables
+ where TABLE_SCHEMA='performance_schema'
+ order by table_name;
+
+select lower(TABLE_NAME), CREATE_TIME, UPDATE_TIME, CHECK_TIME
+ from information_schema.tables
+ where TABLE_SCHEMA='performance_schema'
+ order by table_name;
+
+select lower(TABLE_NAME), TABLE_COLLATION, CHECKSUM
+ from information_schema.tables
+ where TABLE_SCHEMA='performance_schema'
+ order by table_name;
+
+select lower(TABLE_NAME), CREATE_OPTIONS
+ from information_schema.tables
+ where TABLE_SCHEMA='performance_schema'
+ order by table_name;
+
+select lower(TABLE_NAME), TABLE_COMMENT
+ from information_schema.tables
+ where TABLE_SCHEMA='performance_schema'
+ order by table_name;
+
diff --git a/mysql-test/suite/perfschema/t/innodb_events_transactions_history_long.test b/mysql-test/suite/perfschema/t/innodb_events_transactions_history_long.test
new file mode 100644
index 00000000..f13bfe87
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/innodb_events_transactions_history_long.test
@@ -0,0 +1,19 @@
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/have_innodb.inc
+
+--echo #
+--echo # MDEV-24600 performance_schema.events_transactions_history_long.trx_id
+--echo # reports garbage
+--echo #
+
+TRUNCATE performance_schema.events_transactions_history_long;
+
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+COMMIT;
+BEGIN;
+SELECT table_name FROM mysql.innodb_table_stats LIMIT 0 LOCK IN SHARE MODE;
+COMMIT;
+
+SELECT state,trx_id,gtid
+FROM performance_schema.events_transactions_history_long;
diff --git a/mysql-test/suite/perfschema/t/innodb_table_io.test b/mysql-test/suite/perfschema/t/innodb_table_io.test
new file mode 100644
index 00000000..3f187c01
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/innodb_table_io.test
@@ -0,0 +1,29 @@
+# Tests for PERFORMANCE_SCHEMA table io
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/have_innodb.inc
+--source ../include/table_io_setup_helper.inc
+
+let $engine_type= InnoDB;
+let $table_item= test.no_index_tab;
+--disable_warnings
+eval drop table if exists $table_item;
+--enable_warnings
+
+# Start recording events
+update performance_schema.setup_consumers set enabled='YES';
+insert into marker set a = 1;
+eval create table $table_item
+( a varchar(255) not null, b int not null) engine = $engine_type;
+insert into marker set a = 1;
+eval show create table $table_item;
+--source ../include/table_io_basic_dml.inc
+eval drop table $table_item;
+
+# Stop recording events + pull result
+--source ../include/table_io_result_helper.inc
+
+# Cleanup
+--source ../include/table_io_cleanup_helper.inc
+
diff --git a/mysql-test/suite/perfschema/t/io_cache-master.opt b/mysql-test/suite/perfschema/t/io_cache-master.opt
new file mode 100644
index 00000000..8f75ada3
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/io_cache-master.opt
@@ -0,0 +1,3 @@
+--binlog_cache_size=4096
+--binlog_stmt_cache_size=4096
+--log-bin=master-bin
diff --git a/mysql-test/suite/perfschema/t/io_cache.test b/mysql-test/suite/perfschema/t/io_cache.test
new file mode 100644
index 00000000..201d0425
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/io_cache.test
@@ -0,0 +1,121 @@
+################## suite/perfschema/t/io_cache.test###################
+# #
+# IO_CACHE is a file I/O caching mechanism that uses temporary files #
+# when the cache overflows. This test verifies that the temporary #
+# files created by the IO_CACHE buffers for the binlog_cache and #
+# binlog_stmt_cache are instrumented. #
+# #
+######################################################################
+
+--source include/have_perfschema.inc
+--source include/not_embedded.inc
+--source include/no_protocol.inc
+
+--echo #
+--echo ## Connection default
+--echo #
+--connection default
+--disable_warnings
+USE test;
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+SELECT @@global.binlog_cache_size;
+SELECT @@global.binlog_stmt_cache_size;
+SELECT * FROM performance_schema.setup_instruments WHERE name LIKE "%file/sql/io_cache%";
+
+--echo #
+--echo ## Connection con1
+--echo #
+connect(con1, localhost, root,,);
+USE test;
+CREATE TABLE t1 (s1 INT, s2 VARCHAR(4096));
+SET SESSION AUTOCOMMIT = 0;
+
+#
+# Force an IO_CACHE overflow and subsequent write to a temporary file.
+#
+START TRANSACTION;
+INSERT INTO t1 VALUES (1,'
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+');
+
+INSERT INTO t1 VALUES (2,'
+bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+');
+
+INSERT INTO t1 VALUES (3,'
+cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+');
+
+INSERT INTO t1 VALUES (4,'
+dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
+dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
+dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
+dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
+dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
+');
+
+INSERT INTO t1 VALUES (5,'
+eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
+eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
+eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
+eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
+eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
+');
+
+INSERT INTO t1 VALUES (6,'
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+');
+
+INSERT INTO t1 VALUES (7,'
+gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
+gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
+gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
+gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
+gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
+');
+
+INSERT INTO t1 VALUES (8,'
+hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
+hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
+hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
+hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
+hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
+');
+
+COMMIT;
+SELECT COUNT(*) FROM t1;
+--disconnect con1
+
+--echo #
+--echo ## Connection default
+--echo #
+--connection default
+SELECT COUNT(*) FROM test.t1;
+
+#
+# Verify that IO events on the temporary file.
+#
+SELECT COUNT(*) FROM performance_schema.file_summary_by_event_name WHERE event_name LIKE "%io_cache%";
+
+--connection default
+DROP TABLE t1;
+
+
+
diff --git a/mysql-test/suite/perfschema/t/max_program_zero-master.opt b/mysql-test/suite/perfschema/t/max_program_zero-master.opt
new file mode 100644
index 00000000..7803f9c5
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/max_program_zero-master.opt
@@ -0,0 +1,3 @@
+--loose-performance_schema_max_program_instances=0
+--loose-performance_schema_max_statement_stack=1
+--thread_stack=655360
diff --git a/mysql-test/suite/perfschema/t/max_program_zero.test b/mysql-test/suite/perfschema/t/max_program_zero.test
new file mode 100644
index 00000000..064ba2ae
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/max_program_zero.test
@@ -0,0 +1,48 @@
+#-------------------------------------------------------------
+# Tests for PERFORMANCE_SCHEMA stored programs instrumentation
+#-------------------------------------------------------------
+
+#
+# Test case to show the behaviour of stored program instrumentation
+# when values of the system variables performance_schema_max_program_instances &
+# performance_schema_max_statement_stack are zero.
+# PS table will return empty set
+#
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Values of variables server variables
+show global variables like "performance_schema_max_program_instances";
+show global variables like "performance_schema_max_statement_stack";
+
+--echo #####################
+--echo # Setup
+--echo #####################
+--source suite/perfschema/include/program_nested_setup.inc
+
+# Truncate summary table
+TRUNCATE performance_schema.events_statements_summary_by_program;
+
+--echo #####################
+--echo # Executing Queries
+--echo #####################
+--source suite/perfschema/include/program_nested_execution.inc
+
+--echo ###########################################
+--echo # Quering PS statement summary table #
+--echo ###########################################
+
+SELECT OBJECT_TYPE, OBJECT_NAME, OBJECT_SCHEMA
+ FROM performance_schema.events_statements_summary_by_program;
+
+SELECT COUNT(*) FROM performance_schema.events_statements_summary_by_program;
+
+--echo #####################
+--echo # Cleanup
+--echo #####################
+--source suite/perfschema/include/program_nested_cleanup.inc
+
+
diff --git a/mysql-test/suite/perfschema/t/mdl_func.test b/mysql-test/suite/perfschema/t/mdl_func.test
new file mode 100644
index 00000000..fc12bdac
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/mdl_func.test
@@ -0,0 +1,487 @@
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+# This test fails very frequently on a Windows builder.
+--source include/not_windows.inc
+
+UPDATE performance_schema.setup_instruments SET enabled = 'NO', timed = 'YES';
+
+UPDATE performance_schema.setup_instruments SET enabled = 'YES'
+WHERE name in ('wait/io/table/sql/handler',
+ 'wait/lock/table/sql/handler',
+ 'wait/lock/metadata/sql/mdl');
+
+set @orig_sql_mode= @@sql_mode;
+set sql_mode= (select replace(@@sql_mode,'NO_AUTO_CREATE_USER',''));
+grant ALL on *.* to user1@localhost;
+grant ALL on *.* to user2@localhost;
+set sql_mode= @orig_sql_mode;
+
+insert into performance_schema.setup_objects (object_type, object_schema, object_name, enabled, timed)
+ values ('TABLE', 'mtr', '%', 'NO', 'NO');
+
+--echo # Switch to (con1, localhost, user1, , )
+connect (con1, localhost, user1, , );
+
+let $user1_tid=`select THREAD_ID from performance_schema.threads where PROCESSLIST_ID=connection_id()`;
+
+--echo # Switch to (con2, localhost, user2, , )
+connect (con2, localhost, user2, , );
+
+let $user2_tid=`select THREAD_ID from performance_schema.threads where PROCESSLIST_ID=connection_id()`;
+
+--connection default
+
+--disable_query_log
+--eval set @user1_tid= $user1_tid;
+--eval set @user2_tid= $user2_tid;
+--enable_query_log
+
+--disable_warnings
+drop function if exists thread_id_name;
+--enable_warnings
+
+--delimiter //
+
+create function thread_id_name(THREAD_ID int)
+returns varchar(16)
+begin
+ if (THREAD_ID IS NULL)
+ then
+ return NULL;
+ end if;
+ if (THREAD_ID = @user1_tid)
+ then
+ return "USER1";
+ end if;
+ if (THREAD_ID = @user2_tid)
+ then
+ return "USER2";
+ end if;
+ return "OTHER";
+end;
+//
+
+delimiter ;//
+
+select thread_id_name(NULL);
+select thread_id_name(@user1_tid);
+select thread_id_name(@user2_tid);
+
+prepare dump_metadata_locks from
+ "select OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME,
+ LOCK_TYPE, LOCK_DURATION, LOCK_STATUS,
+ thread_id_name(OWNER_THREAD_ID) as OWNER_THREAD_ID
+ from performance_schema.metadata_locks
+ order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME,
+ LOCK_TYPE, LOCK_DURATION, LOCK_STATUS, OWNER_THREAD_ID;";
+
+prepare dump_table_handles from
+ "select OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME,
+ INTERNAL_LOCK, EXTERNAL_LOCK,
+ thread_id_name(OWNER_THREAD_ID) as OWNER_THREAD_ID
+ from performance_schema.table_handles
+ order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME,
+ INTERNAL_LOCK, EXTERNAL_LOCK, OWNER_THREAD_ID;";
+
+prepare dump_waits_current from
+ "select thread_id_name(THREAD_ID) as THREAD_ID,
+ EVENT_NAME,
+ TIMER_START is not NULL as TIMER_START_SET,
+ TIMER_END is not NULL as TIMER_END_SET,
+ OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME,
+ OPERATION
+ from performance_schema.events_waits_current
+ where event_name = \'wait/lock/metadata/sql/mdl\';";
+
+prepare dump_waits_history_long from
+ "select thread_id_name(THREAD_ID) as THREAD_ID,
+ EVENT_NAME,
+ TIMER_START is not NULL as TIMER_START_SET,
+ TIMER_END is not NULL as TIMER_END_SET,
+ OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME,
+ OPERATION
+ from performance_schema.events_waits_history_long
+ where event_name = \'wait/lock/metadata/sql/mdl\';";
+
+# reset lost counters
+truncate table performance_schema.events_statements_summary_by_digest;
+flush status;
+
+flush tables;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (id INT PRIMARY KEY, b CHAR(100) DEFAULT 'initial value');
+
+INSERT INTO t1 (id) VALUES (1), (2), (3), (4), (5), (6), (7), (8);
+
+TRUNCATE TABLE performance_schema.events_waits_history_long;
+TRUNCATE TABLE performance_schema.events_waits_history;
+TRUNCATE TABLE performance_schema.events_waits_current;
+
+--connection con1
+
+BEGIN;
+
+# MDL lock granted immediately, no wait.
+SELECT * from t1 where id=1;
+
+--connection default
+
+echo "---- Marker 1 ----";
+
+--vertical_results
+execute dump_metadata_locks;
+execute dump_table_handles;
+execute dump_waits_current;
+execute dump_waits_history_long;
+--horizontal_results
+
+--connection con1
+
+# The MDL lock is now released
+COMMIT;
+
+--connection default
+
+echo "---- Marker 2 ----";
+
+--vertical_results
+execute dump_metadata_locks;
+execute dump_table_handles;
+execute dump_waits_current;
+execute dump_waits_history_long;
+--horizontal_results
+
+--connection con1
+
+BEGIN;
+
+# MDL lock is granted immediately, no wait
+UPDATE t1 set b="new value" where id=2;
+
+--connection default
+
+echo "---- Marker 3 ----";
+
+--vertical_results
+execute dump_metadata_locks;
+execute dump_table_handles;
+execute dump_waits_current;
+execute dump_waits_history_long;
+--horizontal_results
+
+--connection con2
+
+BEGIN;
+
+# MDL lock is PENDING : waiting for the update transaction
+--send DROP TABLE t1;
+
+--connection default
+
+# Wait for the DROP TABLE t1 to block
+let $wait_condition=
+ select count(*) = 1 from performance_schema.events_waits_current
+ where event_name = 'wait/lock/metadata/sql/mdl'
+ and object_name = 't1';
+--source include/wait_condition.inc
+
+echo "---- Marker 4 ----";
+
+--vertical_results
+execute dump_metadata_locks;
+execute dump_table_handles;
+execute dump_waits_current;
+execute dump_waits_history_long;
+--horizontal_results
+
+--connection con1
+
+# MDL lock on the update is released,
+# MDL pending lock is granted for the drop table, then released.
+COMMIT;
+
+--connection con2
+
+# complete DROP TABLE t1
+--reap
+
+--connection default
+
+echo "---- Marker 5 ----";
+
+--vertical_results
+execute dump_metadata_locks;
+execute dump_table_handles;
+execute dump_waits_current;
+execute dump_waits_history_long;
+--horizontal_results
+
+--connection default
+
+TRUNCATE TABLE performance_schema.events_waits_history_long;
+TRUNCATE TABLE performance_schema.events_waits_history;
+TRUNCATE TABLE performance_schema.events_waits_current;
+create table t1 (a int);
+
+--connection con1
+
+# Get MDL read lock
+LOCK TABLE t1 READ;
+
+--connection default
+
+echo "---- Marker 6 ----";
+
+--vertical_results
+execute dump_metadata_locks;
+execute dump_table_handles;
+execute dump_waits_current;
+execute dump_waits_history_long;
+--horizontal_results
+
+--connection con2
+
+# User1 has a READ LOCK
+# User2 waiting for WRITE LOCK
+--send LOCK TABLE t1 write;
+
+--connection default
+
+# Wait for the LOCK TABLE t1 write to block
+let $wait_condition=
+ select count(*) = 1 from performance_schema.events_waits_current
+ where event_name = 'wait/lock/metadata/sql/mdl'
+ and object_name = 't1';
+--source include/wait_condition.inc
+
+echo "---- Marker 7 ----";
+
+--vertical_results
+execute dump_metadata_locks;
+execute dump_table_handles;
+execute dump_waits_current;
+execute dump_waits_history_long;
+--horizontal_results
+
+--connection con1
+
+# User1 releases a READ LOCK
+# User2 granted a WRITE LOCK
+UNLOCK TABLES;
+
+--connection con2
+
+# Complete LOCK TABLE t1 write
+--reap
+
+--connection default
+
+echo "---- Marker 8 ----";
+
+--vertical_results
+execute dump_metadata_locks;
+execute dump_table_handles;
+execute dump_waits_current;
+execute dump_waits_history_long;
+--horizontal_results
+
+--connection con1
+
+# User2 granted a WRITE LOCK
+# User1 waits for a READ LOCK
+--send LOCK TABLES t1 read;
+
+--connection default
+
+# Wait for the LOCK TABLES t1 READ to block
+let $wait_condition=
+ select count(*) = 1 from performance_schema.events_waits_current
+ where event_name = 'wait/lock/metadata/sql/mdl'
+ and object_name = 't1';
+--source include/wait_condition.inc
+
+echo "---- Marker 9 ----";
+
+--vertical_results
+execute dump_metadata_locks;
+execute dump_table_handles;
+execute dump_waits_current;
+execute dump_waits_history_long;
+--horizontal_results
+
+--connection con2
+
+UNLOCK TABLES;
+
+--connection con1
+
+# Complete LOCK TABLE t1 read
+--reap
+
+--connection default
+
+echo "---- Marker 10 ----";
+
+--vertical_results
+execute dump_metadata_locks;
+execute dump_table_handles;
+execute dump_waits_current;
+execute dump_waits_history_long;
+--horizontal_results
+
+--connection con1
+
+UNLOCK TABLES;
+
+--connection default
+
+echo "---- Marker 11 ----";
+
+--vertical_results
+execute dump_metadata_locks;
+execute dump_table_handles;
+execute dump_waits_current;
+execute dump_waits_history_long;
+--horizontal_results
+
+
+TRUNCATE TABLE performance_schema.events_waits_history_long;
+TRUNCATE TABLE performance_schema.events_waits_history;
+TRUNCATE TABLE performance_schema.events_waits_current;
+--connection con1
+
+BEGIN;
+
+# MDL lock is granted immediately, no wait
+UPDATE LOW_PRIORITY t1 SET a=8;
+
+--connection default
+
+echo "---- Marker 12 ----";
+
+--vertical_results
+execute dump_metadata_locks;
+execute dump_table_handles;
+execute dump_waits_current;
+execute dump_waits_history_long;
+--horizontal_results
+
+--connection con1
+COMMIT;
+
+--connection default
+
+TRUNCATE TABLE performance_schema.events_waits_history_long;
+TRUNCATE TABLE performance_schema.events_waits_history;
+TRUNCATE TABLE performance_schema.events_waits_current;
+
+--connection con1
+
+--disable_ps2_protocol
+SELECT GET_LOCK('test', 0);
+--enable_ps2_protocol
+
+--connection default
+
+echo "---- Marker 13 ----";
+
+--vertical_results
+execute dump_metadata_locks;
+execute dump_table_handles;
+execute dump_waits_current;
+execute dump_waits_history_long;
+--horizontal_results
+
+--connection con2
+
+--disable_ps2_protocol
+--send SELECT GET_LOCK('test', 120);
+--enable_ps2_protocol
+
+--connection default
+
+let $wait_condition=
+ select count(*) = 1 from performance_schema.events_waits_current
+ where event_name = 'wait/lock/metadata/sql/mdl'
+ and object_name = 'test';
+--source include/wait_condition.inc
+
+echo "---- Marker 14 ----";
+
+--vertical_results
+execute dump_metadata_locks;
+execute dump_table_handles;
+execute dump_waits_current;
+execute dump_waits_history_long;
+--horizontal_results
+
+--connection con1
+--disable_ps2_protocol
+SELECT RELEASE_LOCK('test');
+--enable_ps2_protocol
+
+--connection con2
+
+--reap
+
+--connection default
+
+echo "---- Marker 15 ----";
+
+--vertical_results
+execute dump_metadata_locks;
+execute dump_table_handles;
+execute dump_waits_current;
+execute dump_waits_history_long;
+--horizontal_results
+
+--connection con2
+--disable_ps2_protocol
+SELECT RELEASE_LOCK('test');
+--enable_ps2_protocol
+
+--connection default
+
+echo "---- Marker 16 ----";
+
+--vertical_results
+execute dump_metadata_locks;
+execute dump_table_handles;
+execute dump_waits_current;
+execute dump_waits_history_long;
+--horizontal_results
+
+# Cleanup
+
+--disconnect con1
+--disconnect con2
+
+--connection default
+
+drop table t1;
+
+UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES';
+
+revoke all privileges, grant option from user1@localhost;
+revoke all privileges, grant option from user2@localhost;
+
+drop user user1@localhost;
+drop user user2@localhost;
+
+drop function thread_id_name;
+
+drop prepare dump_metadata_locks;
+drop prepare dump_table_handles;
+drop prepare dump_waits_current;
+drop prepare dump_waits_history_long;
+
+delete from performance_schema.setup_objects
+ where object_schema='mtr';
+
+# In case of failure, will indicate the root cause
+show global status like "performance_schema%";
+
diff --git a/mysql-test/suite/perfschema/t/memory_aggregate-master.opt b/mysql-test/suite/perfschema/t/memory_aggregate-master.opt
new file mode 100644
index 00000000..cd204448
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/memory_aggregate-master.opt
@@ -0,0 +1 @@
+--query_cache_size=0
diff --git a/mysql-test/suite/perfschema/t/memory_aggregate.test b/mysql-test/suite/perfschema/t/memory_aggregate.test
new file mode 100644
index 00000000..a77dae2a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/memory_aggregate.test
@@ -0,0 +1,7 @@
+# Tests for the performance schema
+#
+--source include/have_64bit.inc
+--source ../include/memory_aggregate_setup.inc
+--source ../include/memory_aggregate_load.inc
+--source ../include/memory_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/memory_aggregate_32bit-master.opt b/mysql-test/suite/perfschema/t/memory_aggregate_32bit-master.opt
new file mode 100644
index 00000000..cd204448
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/memory_aggregate_32bit-master.opt
@@ -0,0 +1 @@
+--query_cache_size=0
diff --git a/mysql-test/suite/perfschema/t/memory_aggregate_32bit.test b/mysql-test/suite/perfschema/t/memory_aggregate_32bit.test
new file mode 100644
index 00000000..abd16212
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/memory_aggregate_32bit.test
@@ -0,0 +1,7 @@
+# Tests for the performance schema
+#
+--source include/have_32bit.inc
+--source ../include/memory_aggregate_setup.inc
+--source ../include/memory_aggregate_load.inc
+--source ../include/memory_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/memory_aggregate_no_a-master.opt b/mysql-test/suite/perfschema/t/memory_aggregate_no_a-master.opt
new file mode 100644
index 00000000..0cdab705
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/memory_aggregate_no_a-master.opt
@@ -0,0 +1,2 @@
+--query_cache_size=0
+--loose-performance_schema_accounts_size=0
diff --git a/mysql-test/suite/perfschema/t/memory_aggregate_no_a.test b/mysql-test/suite/perfschema/t/memory_aggregate_no_a.test
new file mode 100644
index 00000000..a77dae2a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/memory_aggregate_no_a.test
@@ -0,0 +1,7 @@
+# Tests for the performance schema
+#
+--source include/have_64bit.inc
+--source ../include/memory_aggregate_setup.inc
+--source ../include/memory_aggregate_load.inc
+--source ../include/memory_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/memory_aggregate_no_a_no_h-master.opt b/mysql-test/suite/perfschema/t/memory_aggregate_no_a_no_h-master.opt
new file mode 100644
index 00000000..30b8ed74
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/memory_aggregate_no_a_no_h-master.opt
@@ -0,0 +1,3 @@
+--query_cache_size=0
+--loose-performance_schema_accounts_size=0
+--loose-performance_schema_hosts_size=0
diff --git a/mysql-test/suite/perfschema/t/memory_aggregate_no_a_no_h.test b/mysql-test/suite/perfschema/t/memory_aggregate_no_a_no_h.test
new file mode 100644
index 00000000..a77dae2a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/memory_aggregate_no_a_no_h.test
@@ -0,0 +1,7 @@
+# Tests for the performance schema
+#
+--source include/have_64bit.inc
+--source ../include/memory_aggregate_setup.inc
+--source ../include/memory_aggregate_load.inc
+--source ../include/memory_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/memory_aggregate_no_a_no_u-master.opt b/mysql-test/suite/perfschema/t/memory_aggregate_no_a_no_u-master.opt
new file mode 100644
index 00000000..b0629a51
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/memory_aggregate_no_a_no_u-master.opt
@@ -0,0 +1,3 @@
+--query_cache_size=0
+--loose-performance_schema_accounts_size=0
+--loose-performance_schema_users_size=0
diff --git a/mysql-test/suite/perfschema/t/memory_aggregate_no_a_no_u.test b/mysql-test/suite/perfschema/t/memory_aggregate_no_a_no_u.test
new file mode 100644
index 00000000..a77dae2a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/memory_aggregate_no_a_no_u.test
@@ -0,0 +1,7 @@
+# Tests for the performance schema
+#
+--source include/have_64bit.inc
+--source ../include/memory_aggregate_setup.inc
+--source ../include/memory_aggregate_load.inc
+--source ../include/memory_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/memory_aggregate_no_a_no_u_no_h-master.opt b/mysql-test/suite/perfschema/t/memory_aggregate_no_a_no_u_no_h-master.opt
new file mode 100644
index 00000000..89df63a3
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/memory_aggregate_no_a_no_u_no_h-master.opt
@@ -0,0 +1,4 @@
+--query_cache_size=0
+--loose-performance_schema_accounts_size=0
+--loose-performance_schema_users_size=0
+--loose-performance_schema_hosts_size=0
diff --git a/mysql-test/suite/perfschema/t/memory_aggregate_no_a_no_u_no_h.test b/mysql-test/suite/perfschema/t/memory_aggregate_no_a_no_u_no_h.test
new file mode 100644
index 00000000..a77dae2a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/memory_aggregate_no_a_no_u_no_h.test
@@ -0,0 +1,7 @@
+# Tests for the performance schema
+#
+--source include/have_64bit.inc
+--source ../include/memory_aggregate_setup.inc
+--source ../include/memory_aggregate_load.inc
+--source ../include/memory_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/memory_aggregate_no_h-master.opt b/mysql-test/suite/perfschema/t/memory_aggregate_no_h-master.opt
new file mode 100644
index 00000000..d630f88b
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/memory_aggregate_no_h-master.opt
@@ -0,0 +1,2 @@
+--query_cache_size=0
+--loose-performance_schema_hosts_size=0
diff --git a/mysql-test/suite/perfschema/t/memory_aggregate_no_h.test b/mysql-test/suite/perfschema/t/memory_aggregate_no_h.test
new file mode 100644
index 00000000..a77dae2a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/memory_aggregate_no_h.test
@@ -0,0 +1,7 @@
+# Tests for the performance schema
+#
+--source include/have_64bit.inc
+--source ../include/memory_aggregate_setup.inc
+--source ../include/memory_aggregate_load.inc
+--source ../include/memory_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/memory_aggregate_no_u-master.opt b/mysql-test/suite/perfschema/t/memory_aggregate_no_u-master.opt
new file mode 100644
index 00000000..0d4faa03
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/memory_aggregate_no_u-master.opt
@@ -0,0 +1,2 @@
+--query_cache_size=0
+--loose-performance_schema_users_size=0
diff --git a/mysql-test/suite/perfschema/t/memory_aggregate_no_u.test b/mysql-test/suite/perfschema/t/memory_aggregate_no_u.test
new file mode 100644
index 00000000..a77dae2a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/memory_aggregate_no_u.test
@@ -0,0 +1,7 @@
+# Tests for the performance schema
+#
+--source include/have_64bit.inc
+--source ../include/memory_aggregate_setup.inc
+--source ../include/memory_aggregate_load.inc
+--source ../include/memory_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/memory_aggregate_no_u_no_h-master.opt b/mysql-test/suite/perfschema/t/memory_aggregate_no_u_no_h-master.opt
new file mode 100644
index 00000000..2a23af9d
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/memory_aggregate_no_u_no_h-master.opt
@@ -0,0 +1,3 @@
+--query_cache_size=0
+--loose-performance_schema_users_size=0
+--loose-performance_schema_hosts_size=0
diff --git a/mysql-test/suite/perfschema/t/memory_aggregate_no_u_no_h.test b/mysql-test/suite/perfschema/t/memory_aggregate_no_u_no_h.test
new file mode 100644
index 00000000..a77dae2a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/memory_aggregate_no_u_no_h.test
@@ -0,0 +1,7 @@
+# Tests for the performance schema
+#
+--source include/have_64bit.inc
+--source ../include/memory_aggregate_setup.inc
+--source ../include/memory_aggregate_load.inc
+--source ../include/memory_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/memory_table_io.test b/mysql-test/suite/perfschema/t/memory_table_io.test
new file mode 100644
index 00000000..f1e5f702
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/memory_table_io.test
@@ -0,0 +1,28 @@
+# Tests for PERFORMANCE_SCHEMA table io
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source ../include/table_io_setup_helper.inc
+
+let $engine_type= MEMORY;
+let $table_item= test.no_index_tab;
+--disable_warnings
+eval drop table if exists $table_item;
+--enable_warnings
+
+# Start recording events
+update performance_schema.setup_consumers set enabled='YES';
+insert into marker set a = 1;
+eval create table $table_item
+( a varchar(255) not null, b int not null) engine = $engine_type;
+insert into marker set a = 1;
+eval show create table $table_item;
+--source ../include/table_io_basic_dml.inc
+eval drop table $table_item;
+
+# Stop recording events + pull result
+--source ../include/table_io_result_helper.inc
+
+# Cleanup
+--source ../include/table_io_cleanup_helper.inc
+
diff --git a/mysql-test/suite/perfschema/t/merge_table_io.test b/mysql-test/suite/perfschema/t/merge_table_io.test
new file mode 100644
index 00000000..d4727525
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/merge_table_io.test
@@ -0,0 +1,46 @@
+# Tests for PERFORMANCE_SCHEMA table io
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source ../include/table_io_setup_helper.inc
+
+let $engine_type= MyISAM;
+let $table_item= test.no_index_tab;
+
+--disable_warnings
+eval drop table if exists $table_item;
+drop table if exists test.no_index_tab_1;
+drop table if exists test.no_index_tab_2;
+--enable_warnings
+
+# Start recording events
+update performance_schema.setup_consumers set enabled='YES';
+insert into marker set a = 1;
+eval create table test.no_index_tab_1
+( a varchar(255) not null, b int not null) engine = $engine_type;
+insert into marker set a = 1;
+create table test.no_index_tab_2 like test.no_index_tab_1;
+insert into marker set a = 1;
+eval create table $table_item
+ ( a varchar(255) not null, b int not null) engine = merge
+ union = (test.no_index_tab_1,test.no_index_tab_2) insert_method = first;
+insert into marker set a = 1;
+# Make sure the proper engine is used
+show create table test.no_index_tab_1;
+insert into marker set a = 1;
+show create table test.no_index_tab_2;
+insert into marker set a = 1;
+eval show create table $table_item;
+--source ../include/table_io_basic_dml.inc
+drop table test.no_index_tab_1;
+insert into marker set a = 1;
+drop table test.no_index_tab_2;
+insert into marker set a = 1;
+eval drop table $table_item;
+
+# Stop recording events + pull result
+--source ../include/table_io_result_helper.inc
+
+# Cleanup
+--source ../include/table_io_cleanup_helper.inc
+
diff --git a/mysql-test/suite/perfschema/t/misc.test b/mysql-test/suite/perfschema/t/misc.test
new file mode 100644
index 00000000..79c23c65
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/misc.test
@@ -0,0 +1,320 @@
+# Tests for PERFORMANCE_SCHEMA
+# Miscelaneous
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/have_innodb.inc
+--source include/no_protocol.inc
+
+#
+# Bug#12790483 OBJECTS_SUMMARY_GLOBAL_BY_TYPE AND RENAME TABLE
+#
+# Rename table leaves old tables names behind in
+# performance_schema.objects_summary_global_by_type
+#
+SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type
+ WHERE object_schema='test';
+
+CREATE TABLE test.t_before(a INT);
+INSERT INTO test.t_before VALUES (1);
+
+# The new table should appear in OBJECTS_SUMMARY_GLOBAL_BY_TYPE.
+
+SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type
+ WHERE object_schema='test';
+
+RENAME TABLE test.t_before TO test.t_after;
+
+# The renamed table should appear in OBJECTS_SUMMARY_GLOBAL_BY_TYPE, but only
+# after it is accessed.
+
+SELECT COUNT(*) FROM test.t_after;
+
+SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type
+ WHERE object_schema='test';
+
+DROP TABLE test.t_after;
+
+# The renamed table should not appear in OBJECTS_SUMMARY_GLOBAL_BY_TYPE.
+
+SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type
+ WHERE object_schema='test';
+
+#
+# Verify table views are ignored by the table io instrumentation.
+#
+
+CREATE TABLE test.t1(a INT);
+INSERT INTO test.t1 VALUES (1);
+CREATE VIEW test.v1 AS SELECT * FROM test.t1;
+SELECT COUNT(*) FROM test.v1;
+
+# Verify that a PFS table share was not created for the view.
+SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type
+ WHERE object_schema='test';
+
+DROP VIEW test.v1;
+DROP TABLE test.t1;
+
+SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type
+ WHERE object_schema='test';
+
+
+#
+# Bug#45496 Performance schema: assertion fails in
+# ha_perfschema::rnd_init:223
+#
+
+--disable_result_log
+SELECT EVENT_ID FROM performance_schema.events_waits_current
+WHERE THREAD_ID IN
+ (SELECT THREAD_ID FROM performance_schema.threads)
+AND EVENT_NAME IN
+ (SELECT NAME FROM performance_schema.setup_instruments
+ WHERE NAME LIKE "wait/synch/%")
+LIMIT 1;
+--enable_result_log
+
+#
+# Bug#45088 Should not be able to create tables of engine PERFORMANCE_SCHEMA
+#
+
+--error ER_CANT_CREATE_TABLE
+create table test.t1(a int) engine=performance_schema;
+
+# The table should not appear in OBJECTS_SUMMARY_GLOBAL_BY_TYPE
+
+SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type
+ WHERE object_schema='test';
+
+#
+# Bug#44897 Performance Schema: can create a ghost table in another database
+#
+
+--error ER_CANT_CREATE_TABLE
+create table test.t1 like performance_schema.events_waits_current;
+
+# The table should not appear in OBJECTS_SUMMARY_GLOBAL_BY_TYPE
+
+SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type
+ WHERE object_schema='test';
+
+#
+# Bug#44898 PerformanceSchema: can create a table in db performance_schema, cannot insert
+#
+
+--error ER_TABLEACCESS_DENIED_ERROR
+create table performance_schema.t1(a int);
+
+# The table should not appear in OBJECTS_SUMMARY_GLOBAL_BY_TYPE
+
+SELECT object_schema, object_name FROM performance_schema.objects_summary_global_by_type
+ WHERE object_schema='test';
+
+#
+# Bug#51447 performance schema evil twin files
+#
+
+--disable_warnings
+drop table if exists test.ghost;
+--enable_warnings
+
+create table test.ghost (a int, b int);
+alter table test.ghost add index index_a(a);
+alter table test.ghost add index index_b(b);
+insert into test.ghost values (1, 3);
+insert into test.ghost values (2, 4);
+select * from test.ghost;
+
+drop table test.ghost;
+
+# Shoud return nothing
+select * from performance_schema.file_instances
+ where file_name like "%ghost%";
+
+#
+# Bug#52586 Misleading error message on attempt to access
+# a P_S table using a wrong name
+
+--error ER_NO_SUCH_TABLE
+select * from performance_schema.no_such_table;
+
+#
+# Bug#12370950 - 60905: TABLE_IO_WAITS_SUMMARY_BY_INDEX_USAGE AGGREGATES NON-INSERT DML WRONGLY
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t_60905;
+--enable_warnings
+CREATE TABLE t_60905 (i INT, j INT, KEY(i)) ENGINE = InnoDB;
+INSERT INTO t_60905 VALUES
+(1,2), (3,4), (5,6), (7,8), (9,10);
+
+# should delete with a "single" PRIMARY lookup (2 PRIMARY fetch, 1 PRIMARY delete)
+DELETE FROM t_60905 WHERE i = 1;
+
+# should delete with a full scan (5 NULL fetch, 1 NULL delete)
+DELETE FROM t_60905 WHERE j = 8;
+
+# show the instrument data.
+SELECT object_schema,
+ object_name,
+ index_name,
+ count_fetch,
+ count_insert,
+ count_update,
+ count_delete
+ FROM performance_schema.table_io_waits_summary_by_index_usage
+ WHERE object_schema = 'test'
+ AND object_name = 't_60905';
+
+DROP TABLE t_60905;
+
+#
+# Bug#71278 NUMBER OF ROWS IN PERFORMANCE SCHEMA TABLES
+#
+
+show global variables like "performance_schema_max_thread_instances";
+explain select * from performance_schema.threads;
+
+#
+# Bug #73082 SHOW EVENTS in performance_schema gives Access Denied
+#
+
+use performance_schema;
+show events;
+show events from performance_schema;
+show events where Db= 'performance_schema';
+use test;
+
+
+#
+# Bug#11929832 - EVENTS_STATEMENTS_HISTORY HAS ERRORS=0 WHEN THERE ARE ERRORS
+#
+# Verify that SQL errors are properly counted.
+
+use test;
+truncate performance_schema.events_statements_history;
+truncate performance_schema.events_statements_history_long;
+
+--error ER_NO_SUCH_TABLE
+select * from t1;
+
+--echo
+select mysql_errno, returned_sqlstate, message_text, errors, warnings
+ from performance_schema.events_statements_history where errors > 0;
+
+--echo #
+select mysql_errno, returned_sqlstate, message_text, errors, warnings from
+ performance_schema.events_statements_history_long where errors > 0;
+
+#
+# Bug#20519832 - TRUNCATED SQL_TEXT values are not suffixed with '...'
+#
+# Verify that truncated SQL statements are suffixed with '...'
+
+use performance_schema;
+truncate performance_schema.events_statements_history;
+
+# Should truncate at 1024 bytes (1024 characters)
+select 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' AS A;
+
+# Should truncate at 1024 bytes (487 characters)
+
+select _utf8mb4 'òðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑòðÑÂÑ' as B;
+
+select count(*) from events_statements_history where sql_text like "%...";
+
+
+#
+# MDEV-10486 MariaDB 10.x does not update rows_examined in performance_schema tables
+# Verify that the rows_examined counter is set properly.
+
+use test;
+create table t1 (id int);
+insert into t1 values (1), (2), (3);
+truncate performance_schema.events_statements_history;
+select * from t1;
+insert into t1 select RAND()*10000 from t1;
+select sql_text, rows_examined from performance_schema.events_statements_history;
+drop table t1;
+
+--echo #
+--echo # MDEV-17896 Assertion `pfs->get_refcount() > 0' failed
+--echo # in release_table_share
+--echo #
+
+# There must be at least one available slot in PFS table_share_array for
+# this test to be meaningful. If there are no free slots we must
+# restart mysqld, it is the only way to reset PFS table_share_array
+let $query= SELECT COUNT(*)<@@performance_schema_max_table_instances FROM
+ performance_schema.objects_summary_global_by_type WHERE OBJECT_TYPE='TABLE';
+
+let $free_slots_available= `$query`;
+
+if (!$free_slots_available)
+{
+ source include/restart_mysqld.inc;
+}
+eval $query;
+
+CREATE TABLE t0(a INT);
+
+# TABLE_SHARE must be cached in the table definition cache.
+SELECT * FROM t0;
+
+# Dropping t0 using DROP TEMPORARY frees up a slot in table_share_array,
+# but the persistent table is not correctly dropped, i.e. TABLE_SHARE::m_psi
+# still points to that slot in table_share_array.
+DROP TEMPORARY TABLE IF EXISTS t0;
+
+# Try re-using each and every slot in PFS table_share_array. If bug is
+# there, we re-use t0 slot.
+# The newly created table that re-uses the t0 slot ends up
+# resetting the PFS_table_share refcount.
+let $i= `SELECT @@performance_schema_max_table_instances`;
+disable_query_log;
+while ($i)
+{
+ # Memory engine is here to reduce disk IO
+ eval CREATE TABLE t$i(a INT) ENGINE=MEMORY;
+ eval DROP TABLE t$i;
+ dec $i;
+}
+enable_query_log;
+
+# FLUSH TABLE crashes the server when PFS_table_share is found with
+# an unexpected refcount.
+FLUSH TABLE t0;
+DROP TABLE t0;
+
+--echo #
+--echo # MDEV-24364 Alter rename table does not remove PFS share
+--echo #
+create or replace table yt4 (x int) engine innodb;
+alter table yt4 rename to t1, algorithm=copy;
+drop tables t1;
+
+select object_type, object_schema, object_name
+from performance_schema.objects_summary_global_by_type
+where object_schema="test";
+
+--echo #
+--echo # MDEV-28344: sys.ps_setup_save and dependent procedures fail
+--echo # with ER_ILLEGAL_HA_CREATE_OPTION
+--echo #
+
+# It is not allowed to create temporary tables with performance schema
+--error ER_ILLEGAL_HA_CREATE_OPTION
+CREATE TEMPORARY TABLE t1 (t int) ENGINE = PERFORMANCE_SCHEMA;
+
+--error ER_ILLEGAL_HA_CREATE_OPTION
+CREATE TEMPORARY TABLE t1 LIKE performance_schema.setup_actors;
+
+SET @default_storage_engine_old = @@default_storage_engine;
+SET default_storage_engine = performance_schema;
+
+--error ER_ILLEGAL_HA_CREATE_OPTION
+CREATE TEMPORARY TABLE t1 (t int);
+
+SET @@default_storage_engine = @default_storage_engine_old; \ No newline at end of file
diff --git a/mysql-test/suite/perfschema/t/misc_global_status-master.opt b/mysql-test/suite/perfschema/t/misc_global_status-master.opt
new file mode 100644
index 00000000..26b61f08
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/misc_global_status-master.opt
@@ -0,0 +1 @@
+--loose-performance_schema_hosts_size=0
diff --git a/mysql-test/suite/perfschema/t/misc_global_status.test b/mysql-test/suite/perfschema/t/misc_global_status.test
new file mode 100644
index 00000000..c9ae14c1
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/misc_global_status.test
@@ -0,0 +1,142 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/have_query_cache_disabled.inc
+
+CREATE USER user1@localhost;
+CREATE USER user2@localhost;
+CREATE USER user3@localhost;
+
+grant ALL on *.* to user1@localhost;
+grant ALL on *.* to user2@localhost;
+grant ALL on *.* to user3@localhost;
+
+# To aggregate to accounts
+#SET GLOBAL show_compatibility_56=0;
+
+TRUNCATE TABLE performance_schema.accounts;
+
+FLUSH PRIVILEGES;
+
+CREATE TABLE test.t_range(a int, b int, PRIMARY KEY(a));
+
+INSERT INTO test.t_range values (1, 1), (2,2), (3, 3), (4, 4), (5, 5);
+INSERT INTO test.t_range values (6, 6), (7,7), (8, 8), (9, 9), (10, 10);
+
+FLUSH STATUS;
+
+let $initial= `SELECT VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME = 'Select_range'`;
+
+# Causes Select_range to increment (+1)
+--disable_ps2_protocol
+SELECT * from test.t_range where (a >= 3) AND (a <= 5);
+--enable_ps2_protocol
+
+SELECT * from performance_schema.session_status
+ WHERE VARIABLE_NAME = 'Select_range';
+
+--disable_query_log
+eval SELECT VARIABLE_NAME, (VARIABLE_VALUE - $initial) AS DELTA from performance_schema.global_status WHERE VARIABLE_NAME = 'Select_range';
+--enable_query_log
+
+connect(con1, localhost, user1,,);
+# Causes Select_range to increment (+1)
+--disable_ps2_protocol
+SELECT * from test.t_range where (a >= 3) AND (a <= 5);
+--enable_ps2_protocol
+
+SELECT * from performance_schema.session_status
+ WHERE VARIABLE_NAME = 'Select_range';
+
+--disable_query_log
+eval SELECT VARIABLE_NAME, (VARIABLE_VALUE - $initial) AS DELTA from performance_schema.global_status WHERE VARIABLE_NAME = 'Select_range';
+--enable_query_log
+
+connect(con2, localhost, user2,,);
+# Causes Select_range to increment (+2)
+--disable_ps2_protocol
+SELECT * from test.t_range where (a >= 3) AND (a <= 5);
+SELECT * from test.t_range where (a >= 4) AND (a <= 6);
+--enable_ps2_protocol
+
+SELECT * from performance_schema.session_status
+ WHERE VARIABLE_NAME = 'Select_range';
+
+--disable_query_log
+eval SELECT VARIABLE_NAME, (VARIABLE_VALUE - $initial) AS DELTA from performance_schema.global_status WHERE VARIABLE_NAME = 'Select_range';
+--enable_query_log
+
+connect(con3, localhost, user3,,);
+# Causes Select_range to increment (+3)
+--disable_ps2_protocol
+SELECT * from test.t_range where (a >= 3) AND (a <= 5);
+SELECT * from test.t_range where (a >= 4) AND (a <= 6);
+SELECT * from test.t_range where (a >= 5) AND (a <= 7);
+--enable_ps2_protocol
+
+SELECT * from performance_schema.session_status
+ WHERE VARIABLE_NAME = 'Select_range';
+
+--disable_query_log
+eval SELECT VARIABLE_NAME, (VARIABLE_VALUE - $initial) AS DELTA from performance_schema.global_status WHERE VARIABLE_NAME = 'Select_range';
+--enable_query_log
+
+--connection default
+
+--disable_query_log
+eval SELECT VARIABLE_NAME, (VARIABLE_VALUE - $initial) AS DELTA from performance_schema.global_status WHERE VARIABLE_NAME = 'Select_range';
+--enable_query_log
+
+SELECT `USER`, `HOST`, VARIABLE_NAME, VARIABLE_VALUE
+ FROM performance_schema.status_by_account WHERE VARIABLE_NAME = 'Select_range'
+ AND `USER` LIKE 'user%'
+ ORDER BY `USER`;
+
+--disconnect con1
+--disconnect con2
+
+# Wait till all disconnects are completed
+let $count_sessions= 2;
+--source include/wait_until_count_sessions.inc
+
+--disable_query_log
+eval SELECT VARIABLE_NAME, (VARIABLE_VALUE - $initial) AS DELTA from performance_schema.global_status WHERE VARIABLE_NAME = 'Select_range';
+--enable_query_log
+
+TRUNCATE TABLE performance_schema.accounts;
+
+--disable_query_log
+eval SELECT VARIABLE_NAME, (VARIABLE_VALUE - $initial) AS DELTA from performance_schema.global_status WHERE VARIABLE_NAME = 'Select_range';
+--enable_query_log
+
+--disconnect con3
+
+# Wait till all disconnects are completed
+let $count_sessions= 1;
+--source include/wait_until_count_sessions.inc
+
+--disable_query_log
+eval SELECT VARIABLE_NAME, (VARIABLE_VALUE - $initial) AS DELTA from performance_schema.global_status WHERE VARIABLE_NAME = 'Select_range';
+--enable_query_log
+
+# Make sure TRUNCATE on accounts does not add to global_status
+TRUNCATE TABLE performance_schema.accounts;
+
+--disable_query_log
+eval SELECT VARIABLE_NAME, (VARIABLE_VALUE - $initial) AS DELTA from performance_schema.global_status WHERE VARIABLE_NAME = 'Select_range';
+--enable_query_log
+
+DROP TABLE test.t_range;
+
+REVOKE ALL PRIVILEGES, GRANT OPTION FROM user1@localhost;
+REVOKE ALL PRIVILEGES, GRANT OPTION FROM user2@localhost;
+REVOKE ALL PRIVILEGES, GRANT OPTION FROM user3@localhost;
+DROP USER user1@localhost;
+DROP USER user2@localhost;
+DROP USER user3@localhost;
+
+#SET GLOBAL show_compatibility_56=1;
+
+FLUSH PRIVILEGES;
+
diff --git a/mysql-test/suite/perfschema/t/mks_timer-6258.test b/mysql-test/suite/perfschema/t/mks_timer-6258.test
new file mode 100644
index 00000000..2bc14abf
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/mks_timer-6258.test
@@ -0,0 +1,6 @@
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+#
+# MDEV-6258 MariaDB 10.0 performance schema timestamps relative to epoch
+#
+select distinct first_seen < DATE'2000-01-01', last_seen < DATE'2000-01-01' from performance_schema.events_statements_summary_by_digest;
diff --git a/mysql-test/suite/perfschema/t/multi_table_io.test b/mysql-test/suite/perfschema/t/multi_table_io.test
new file mode 100644
index 00000000..50bc4f6b
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/multi_table_io.test
@@ -0,0 +1,55 @@
+# Tests for PERFORMANCE_SCHEMA table io
+# Reveal that in case of statements using more than one base table
+# both show up in a correct way.
+
+# Setup
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_warnings
+drop schema if exists test1;
+drop table if exists test.t1;
+--enable_warnings
+
+create schema test1;
+let $engine_type= myisam;
+eval create table test.t1 (col1 bigint, col2 varchar(30)) engine = $engine_type;
+insert into test.t1 values(1,'One');
+create table test1.t2 like test.t1;
+# Make sure the proper engine is used
+show create table test.t1;
+show create table test1.t2;
+
+--source ../include/table_io_setup_helper.inc
+let $schema_to_dump= 'test','test1';
+
+# Start event recording
+update performance_schema.setup_consumers set enabled = 'YES';
+
+--disable_ps2_protocol
+# INSERT ... SELECT ...
+insert into test1.t2 select * from test.t1;
+insert into marker set a = 1;
+# JOIN
+select * from test.t1 natural join test1.t2;
+insert into marker set a = 1;
+# CORRELATED SUBQUERY
+select * from test.t1 where col2 = (select col2 from test1.t2 where test.t1.col1 = test1.t2.col1);
+insert into marker set a = 1;
+# UPDATE
+update test.t1 AS a natural join test1.t2 AS b SET a.col2 = 'updated' , b.col2 = 'updated';
+insert into marker set a = 1;
+# DELETE
+delete from test.t1, test1.t2 using test.t1 inner join test1.t2
+where test.t1.col1 = test1.t2.col1;
+--enable_ps2_protocol
+
+# Stop event recording + pull results
+--source ../include/table_io_result_helper.inc
+
+# Cleanup
+drop table test.t1;
+drop schema test1;
+--source ../include/table_io_cleanup_helper.inc
+
diff --git a/mysql-test/suite/perfschema/t/myisam_file_io.opt b/mysql-test/suite/perfschema/t/myisam_file_io.opt
new file mode 100644
index 00000000..5bec10ab
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/myisam_file_io.opt
@@ -0,0 +1 @@
+--loose-performance_schema_events_waits_history_long_size=5000
diff --git a/mysql-test/suite/perfschema/t/myisam_file_io.test b/mysql-test/suite/perfschema/t/myisam_file_io.test
new file mode 100644
index 00000000..96f24d8a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/myisam_file_io.test
@@ -0,0 +1,61 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+# Setup
+
+update performance_schema.setup_instruments set enabled='NO';
+update performance_schema.setup_instruments set enabled='YES'
+ where name like "wait/io/file/myisam/%";
+
+update performance_schema.setup_consumers
+ set enabled='YES';
+
+truncate table performance_schema.events_waits_history_long;
+
+# Reset lost counters to a known state
+truncate table performance_schema.events_statements_summary_by_digest;
+flush status;
+
+# Code to test
+
+--disable_warnings
+drop table if exists test.no_index_tab;
+--enable_warnings
+
+create table test.no_index_tab ( a varchar(255), b int ) engine=myisam;
+insert into no_index_tab set a = 'foo', b = 1;
+insert into no_index_tab set a = 'foo', b = 1;
+insert into no_index_tab set a = 'foo', b = 1;
+
+# Verification
+# Note that mi_create.c contains mysql_file_tell() calls in debug only,
+# so the result are filtered to remove 'tell'.
+# Note that even after setting other instruments to enabled='NO'
+# and truncating the events_waits_history_long table,
+# some events -- that were already started but not completed --
+# for other instruments could still be added in the history.
+# To protect against that, an extra where clause
+# "and event_name like "wait/io/file/myisam/%"
+# is added to the select to filter out the result.
+
+select event_name,
+ left(source, locate(":", source)) as short_source,
+ operation, number_of_bytes,
+ substring(object_name, locate("no_index_tab", object_name)) as short_name
+ from performance_schema.events_waits_history_long
+ where operation not like "tell"
+ and event_name like "wait/io/file/myisam/%"
+ having short_name <> ""
+ order by thread_id, event_id;
+
+# In case of failures, this will tell if file io are lost.
+show global status like 'performance_schema_%';
+
+# Cleanup
+
+update performance_schema.setup_instruments set enabled='YES';
+
+drop table test.no_index_tab;
+
diff --git a/mysql-test/suite/perfschema/t/myisam_table_io.test b/mysql-test/suite/perfschema/t/myisam_table_io.test
new file mode 100644
index 00000000..9d0b2560
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/myisam_table_io.test
@@ -0,0 +1,28 @@
+# Tests for PERFORMANCE_SCHEMA table io
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source ../include/table_io_setup_helper.inc
+
+let $engine_type= MyISAM;
+let $table_item= test.no_index_tab;
+--disable_warnings
+eval drop table if exists $table_item;
+--enable_warnings
+
+# Start recording events
+update performance_schema.setup_consumers set enabled='YES';
+insert into marker set a = 1;
+eval create table $table_item
+( a varchar(255) not null, b int not null) engine = $engine_type;
+insert into marker set a = 1;
+eval show create table $table_item;
+--source ../include/table_io_basic_dml.inc
+eval drop table $table_item;
+
+# Stop recording events + pull result
+--source ../include/table_io_result_helper.inc
+
+# Cleanup
+--source ../include/table_io_cleanup_helper.inc
+
diff --git a/mysql-test/suite/perfschema/t/nesting.test b/mysql-test/suite/perfschema/t/nesting.test
new file mode 100644
index 00000000..ee1581c2
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/nesting.test
@@ -0,0 +1,191 @@
+# Test to check the proper nesting of events
+
+## To skip the test with QC enabled till BUG#14830950 is fixed.
+#-- source include/have_QC_Disabled.inc
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+# On windows, the socket instrumentation collects an extra "opt"
+# event, which changes the test output.
+--source include/not_windows.inc
+--source include/no_protocol.inc
+# Work around MDEV-24232: WSREP causes extra operations on LOCK_thd_data etc.
+--source include/have_wsrep.inc
+--source ../include/wait_for_pfs_thread_count.inc
+
+--disable_query_log
+
+create user user1@localhost;
+grant ALL on *.* to user1@localhost;
+
+flush privileges;
+
+--disable_warnings
+drop table if exists test.setup_actors;
+--enable_warnings
+
+create table test.setup_actors as
+ select * from performance_schema.setup_actors;
+
+# Only instrument the user connections
+truncate table performance_schema.setup_actors;
+insert into performance_schema.setup_actors
+ set host= 'localhost', user= 'user1', role= '%';
+
+update performance_schema.threads set instrumented='NO';
+
+# Only instrument a few events of each kind
+update performance_schema.setup_instruments set enabled='NO', timed='NO';
+
+update performance_schema.setup_instruments set enabled='YES', timed='YES'
+ where name in ('idle',
+ 'wait/io/table/sql/handler',
+ 'wait/lock/table/sql/handler',
+ 'wait/io/socket/sql/client_connection',
+ 'wait/synch/rwlock/sql/LOCK_grant',
+ 'wait/synch/mutex/sql/THD::LOCK_thd_data',
+ 'wait/synch/mutex/sql/THD::LOCK_thd_kill',
+ 'wait/synch/mutex/sql/THD::LOCK_thd_query',
+ 'wait/io/file/sql/query_log');
+
+update performance_schema.setup_instruments set enabled='YES', timed='YES'
+ where name like ('stage/sql/%');
+
+update performance_schema.setup_instruments set enabled='YES', timed='YES'
+ where name in ('statement/sql/select',
+ 'statement/abstract/new_packet',
+ 'statement/abstract/Query',
+ 'statement/com/error');
+
+# Start from a known clean state, to avoid noise from previous tests
+truncate table performance_schema.events_statements_summary_by_digest;
+flush tables;
+flush status;
+
+truncate performance_schema.events_waits_current;
+truncate performance_schema.events_waits_history;
+truncate performance_schema.events_waits_history_long;
+truncate performance_schema.events_stages_current;
+truncate performance_schema.events_stages_history;
+truncate performance_schema.events_stages_history_long;
+truncate performance_schema.events_statements_current;
+truncate performance_schema.events_statements_history;
+truncate performance_schema.events_statements_history_long;
+
+--enable_query_log
+
+connect (con1, localhost, user1, , );
+
+select "MARKER_BEGIN" as marker;
+
+select "This is simple statement one" as payload;
+
+select "This is simple statement two" as payload;
+
+delimiter $$;
+select "This is the first part of a multi query" as payload;
+select "And this is the second part of a multi query" as payload;
+select "With a third part to make things complete" as payload;
+$$
+delimiter ;$$
+
+select "MARKER_END" as marker;
+
+select "Con1 is done with payload" as status;
+
+--connection default
+
+set @con1_tid = (select thread_id from performance_schema.threads
+ where processlist_user = 'user1');
+
+select (@con1_tid is not null) as expected;
+
+set @marker_begin = (select event_id from performance_schema.events_statements_history_long
+ where sql_text like "%MARKER_BEGIN%" and thread_id = @con1_tid);
+
+select (@marker_begin is not null) as expected;
+
+set @marker_end = (select end_event_id from performance_schema.events_statements_history_long
+ where sql_text like "%MARKER_END%" and thread_id = @con1_tid);
+
+select (@marker_end is not null) as expected;
+
+# Will point to what happened on spurious test failures
+show global status like "performance_schema%";
+
+#
+# This is the test itself:
+# the full trace of every recorded event between MARKER_BEGIN
+# end MARKER_END is dumped.
+# The value of EVENT_ID, END_EVENT_ID, NESTING_EVENT_TYPE, NESTING_EVENT_ID
+# should reflect the relations between each events,
+# and this structure should stay the same between runs.
+#
+# Things to observe in the output:
+# - there are IDLE events between top level queries,
+# - there are no IDLE events between multi queries
+# - STATEMENT starts right after the IDLE event
+# - STAGE init starts right after
+# - SOCKET events, when receiving the command,
+# are childrens of the STATEMENT select / STAGE init
+
+select * from (
+(
+select (event_id - @marker_begin) as relative_event_id,
+ (end_event_id - @marker_begin) as relative_end_event_id,
+ event_name,
+ sql_text as comment,
+ nesting_event_type,
+ (nesting_event_id - @marker_begin) as relative_nesting_event_id
+ from performance_schema.events_statements_history_long
+ where (thread_id = @con1_tid)
+ and (@marker_begin <= event_id)
+ and (end_event_id <= @marker_end)
+)
+union
+(
+select (event_id - @marker_begin) as relative_event_id,
+ (end_event_id - @marker_begin) as relative_end_event_id,
+ event_name,
+ "(stage)" as comment,
+ nesting_event_type,
+ (nesting_event_id - @marker_begin) as relative_nesting_event_id
+ from performance_schema.events_stages_history_long
+ where (thread_id = @con1_tid)
+ and (@marker_begin <= event_id)
+ and (end_event_id <= @marker_end)
+)
+union
+(
+select (event_id - @marker_begin) as relative_event_id,
+ (end_event_id - @marker_begin) as relative_end_event_id,
+ event_name,
+ operation as comment,
+ nesting_event_type,
+ (nesting_event_id - @marker_begin) as relative_nesting_event_id
+ from performance_schema.events_waits_history_long
+ where (thread_id = @con1_tid)
+ and (@marker_begin <= event_id)
+ and (end_event_id <= @marker_end)
+)
+) all_events
+order by relative_event_id asc;
+
+# test cleanup
+
+--disconnect con1
+
+--disable_query_log
+revoke all privileges, grant option from user1@localhost;
+drop user user1@localhost;
+flush privileges;
+
+truncate table performance_schema.setup_actors;
+insert into performance_schema.setup_actors
+ select * from test.setup_actors;
+drop table test.setup_actors;
+
+update performance_schema.threads set instrumented='YES';
+update performance_schema.setup_instruments set enabled='YES', timed='YES';
+
+--enable_query_log
diff --git a/mysql-test/suite/perfschema/t/no_threads-master.opt b/mysql-test/suite/perfschema/t/no_threads-master.opt
new file mode 100644
index 00000000..eea71a77
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/no_threads-master.opt
@@ -0,0 +1,5 @@
+--thread-handling=no-threads
+--loose-performance-schema-max-thread_instances=50
+--default-storage-engine=MyISAM
+--default-tmp-storage-engine=MyISAM
+--loose-skip-innodb
diff --git a/mysql-test/suite/perfschema/t/no_threads.test b/mysql-test/suite/perfschema/t/no_threads.test
new file mode 100644
index 00000000..b7b8767f
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/no_threads.test
@@ -0,0 +1,59 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+
+# Setup : in this main thread
+
+update performance_schema.setup_instruments set enabled='NO';
+update performance_schema.setup_consumers set enabled='YES';
+update performance_schema.setup_instruments set enabled='YES'
+ where name like "wait/synch/mutex/mysys/THR_LOCK_myisam";
+
+--disable_warnings
+drop table if exists test.t1;
+--enable_warnings
+
+truncate table performance_schema.events_waits_current;
+truncate table performance_schema.events_waits_history;
+truncate table performance_schema.events_waits_history_long;
+
+show global variables like "thread_handling";
+
+# Make sure no thread instrumentation is lost
+show status like "Performance_schema_thread_instances_lost";
+
+# Code to test : in this main thread
+
+create table test.t1(a int) engine=MYISAM;
+
+show global variables like "performance_schema";
+show global variables like "performance_schema_max_thread%";
+
+# Verification : in this main thread
+
+select count(*) from performance_schema.threads
+ where name like "thread/sql/main";
+
+select count(*) from performance_schema.threads
+ where name like "thread/sql/OneConnection";
+
+select event_name, operation,
+ left(source, locate(":", source)) as short_source
+ from performance_schema.events_waits_current;
+
+select event_name, operation,
+ left(source, locate(":", source)) as short_source
+ from performance_schema.events_waits_history;
+
+select event_name, operation,
+ left(source, locate(":", source)) as short_source
+ from performance_schema.events_waits_history_long;
+
+# Cleanup
+
+update performance_schema.setup_instruments set enabled='YES';
+
+drop table test.t1;
+
diff --git a/mysql-test/suite/perfschema/t/one_thread_per_con-master.opt b/mysql-test/suite/perfschema/t/one_thread_per_con-master.opt
new file mode 100644
index 00000000..d6685208
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/one_thread_per_con-master.opt
@@ -0,0 +1 @@
+--thread_handling=one-thread-per-connection
diff --git a/mysql-test/suite/perfschema/t/one_thread_per_con.test b/mysql-test/suite/perfschema/t/one_thread_per_con.test
new file mode 100644
index 00000000..11a203a1
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/one_thread_per_con.test
@@ -0,0 +1,70 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+# Setup
+
+--source ../include/setup_helper.inc
+
+# We use a myisam table here because CREATE TABLE has a known,
+# stable behavior (it will lock THR_LOCK_myisam once).
+# The point is not to test myisam, but to test that each
+# connection is properly instrumented, with one-thread-per-connection
+
+update performance_schema.setup_instruments set enabled='YES'
+ where name like "wait/synch/mutex/mysys/THR_LOCK_myisam";
+
+--disable_warnings
+drop table if exists test.t1;
+drop table if exists test.t2;
+drop table if exists test.t3;
+--enable_warnings
+
+truncate table performance_schema.events_waits_history_long;
+
+show global variables like "thread_handling";
+
+# Code to test
+
+connection con1;
+create table test.t1(a int) engine=MYISAM;
+
+connection con2;
+create table test.t2(a int) engine=MYISAM;
+
+connection con3;
+create table test.t3(a int) engine=MYISAM;
+
+# Verification
+
+connection default;
+--disable_query_log
+eval set @tid= $con1_THREAD_ID;
+--enable_query_log
+
+execute stmt_dump_events using @tid;
+execute stmt_dump_thread using @tid;
+
+--disable_query_log
+eval set @tid= $con2_THREAD_ID;
+--enable_query_log
+
+execute stmt_dump_events using @tid;
+execute stmt_dump_thread using @tid;
+
+--disable_query_log
+eval set @tid= $con3_THREAD_ID;
+--enable_query_log
+
+execute stmt_dump_events using @tid;
+execute stmt_dump_thread using @tid;
+
+# Cleanup
+
+drop table test.t1;
+drop table test.t2;
+drop table test.t3;
+
+--source ../include/cleanup_helper.inc
+
diff --git a/mysql-test/suite/perfschema/t/ortho_iter.test b/mysql-test/suite/perfschema/t/ortho_iter.test
new file mode 100644
index 00000000..d577b6db
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/ortho_iter.test
@@ -0,0 +1,307 @@
+# Tests for PERFORMANCE_SCHEMA
+# Verify the orthogonality of iterators (table*::rnd_next()),
+# for every table and instruments.
+
+--source include/not_embedded.inc
+--source include/no_valgrind_without_big.inc
+--source include/have_perfschema.inc
+
+--disable_warnings
+drop procedure if exists check_instrument;
+--enable_warnings
+
+# reset counters
+truncate table performance_schema.events_statements_summary_by_digest;
+flush status;
+
+# Print known global memory instruments (PSI_FLAG_GLOBAL),
+# see maintenance of count_global_expected below.
+
+# --echo "Known PSI_FLAG_GLOBAL memory instruments"
+# select name from performance_schema.setup_instruments
+# where (name like "memory/%")
+# and (name not like "memory/performance_schema/%")
+# and (name not in
+# (select event_name from
+# performance_schema.memory_summary_by_account_by_event_name));
+
+--enable_prepare_warnings
+
+delimiter $;
+create procedure check_instrument(in instr_name varchar(128))
+begin
+ declare save_count_expected integer;
+ declare count_expected integer;
+ declare count_builtin_expected integer;
+ declare count_global_expected integer;
+ declare is_wait integer;
+ declare is_wait_file integer;
+ declare is_wait_socket integer;
+ declare is_stage integer;
+ declare is_statement integer;
+ declare is_transaction integer;
+ declare is_memory integer;
+ declare is_wait_table integer;
+ declare is_wait_file_table integer;
+ declare is_wait_socket_table integer;
+ declare is_stage_table integer;
+ declare is_statement_table integer;
+ declare is_transaction_table integer;
+ declare is_memory_table integer;
+ declare is_memory_global_table integer;
+ declare pfs_table_name varchar(64);
+ declare msg varchar(512);
+ declare msg_detail varchar(512);
+ declare cmd_1 varchar(512);
+ declare cmd_2 varchar(512);
+ declare done integer default 0;
+ declare debug integer default 0;
+
+ declare pfs_cursor CURSOR FOR
+ select table_name from information_schema.tables
+ where table_schema= 'performance_schema'
+ and table_name like "%_by_event_name%"
+ order by table_name;
+
+ declare continue handler for sqlstate '02000'
+ set done = 1;
+
+ select (instr_name like "wait/%") or (instr_name like "idle") into is_wait;
+ select (instr_name like "wait/io/file/%") into is_wait_file;
+ select (instr_name like "wait/io/socket/%") into is_wait_socket;
+ select (instr_name like "stage/%") into is_stage;
+ select (instr_name like "statement/%") into is_statement;
+ select (instr_name like "memory/%") into is_memory;
+ select (instr_name like "transaction") into is_transaction;
+
+ select instr_name, is_wait, is_wait_file, is_wait_socket, is_stage, is_statement, is_memory, is_transaction;
+
+ select count(name)
+ from performance_schema.setup_instruments
+ where (name like (concat(instr_name, "%")))
+ and (not name like "%/abstract/%")
+ and (not name like "memory/performance_schema/%")
+ into save_count_expected;
+
+ select count(name)
+ from performance_schema.setup_instruments
+ where (name like (concat(instr_name, "%")))
+ and (name like "memory/performance_schema/%")
+ into count_builtin_expected;
+
+ select count(name)
+ from performance_schema.setup_instruments
+ where (name like (concat(instr_name, "%")))
+ and (name in (
+ "memory/sql/buffered_logs",
+ "memory/sql/sql_acl_mem",
+ "memory/sql/sql_acl_memex",
+ "memory/sql/acl_cache",
+ "memory/sql/TABLE_SHARE::mem_root",
+ "memory/sql/TABLE",
+ "memory/sql/Query_cache",
+ "memory/sql/native_functions",
+ "memory/sql/Event_basic::mem_root",
+ "memory/sql/root",
+ "memory/sql/load_env_plugins",
+ "memory/sql/plugin_ref",
+ "memory/sql/plugin_mem_root",
+ "memory/sql/plugin_bookmark",
+ "memory/csv/TINA_SHARE",
+ "memory/sql/tz_storage",
+ "memory/sql/servers_cache",
+ "memory/sql/udf_mem"
+ ))
+ into count_global_expected;
+
+ set cmd_1= "select count(*) from (select distinct event_name from performance_schema.";
+ set cmd_2= concat(" where event_name like \"",
+ instr_name,
+ "%\") t into @count_actual");
+
+ open pfs_cursor;
+ repeat
+ fetch pfs_cursor into pfs_table_name;
+ if not done then
+ select (pfs_table_name like "%waits%") into is_wait_table;
+ select (pfs_table_name like "file_summary%") into is_wait_file_table;
+ select (pfs_table_name like "socket_summary%") into is_wait_socket_table;
+ select (pfs_table_name like "%stages%") into is_stage_table;
+ select (pfs_table_name like "%statements%") into is_statement_table;
+ select (pfs_table_name like "%memory%") into is_memory_table;
+ select (pfs_table_name like "memory_summary_global_by_event_name") into is_memory_global_table;
+ select (pfs_table_name like "%transaction%") into is_transaction_table;
+
+ set count_expected = save_count_expected;
+
+ if is_memory_global_table
+ then
+ set count_expected = save_count_expected + count_builtin_expected;
+ end if;
+
+ if is_memory_table = 1 and is_memory_global_table = 0
+ then
+ set count_expected = save_count_expected - count_global_expected;
+ end if;
+
+ select concat("Checking table ", pfs_table_name, " ...") as status;
+ select concat(cmd_1, pfs_table_name, cmd_2) into @cmd;
+ if debug = 1
+ then
+ select @cmd;
+ end if;
+ prepare stmt from @cmd;
+ execute stmt;
+ drop prepare stmt;
+ set msg_detail= concat("table ", pfs_table_name,
+ ", instruments ", count_expected,
+ ", found ", @count_actual);
+
+ if is_wait = 1
+ then
+ if is_wait_table = 1 and @count_actual <> count_expected
+ then
+ set msg= concat("Missing wait events: ", msg_detail);
+ signal sqlstate '05000' set message_text= msg;
+ end if;
+
+ if is_wait_table = 0
+ and is_wait_file_table = 0
+ and is_wait_socket_table = 0
+ and @count_actual <> 0
+ then
+ set msg= concat("Unexpected wait events: ", msg_detail);
+ signal sqlstate '05000' set message_text= msg;
+ end if;
+ end if;
+
+ if is_wait_file = 1
+ then
+ if is_wait_file_table = 1 and @count_actual <> count_expected
+ then
+ set msg= concat("Missing wait/io/file events: ", msg_detail);
+ signal sqlstate '05000' set message_text= msg;
+ end if;
+
+ if is_wait_table = 0 and is_wait_file_table = 0 and @count_actual <> 0
+ then
+ set msg= concat("Unexpected wait/io/file events: ", msg_detail);
+ signal sqlstate '05000' set message_text= msg;
+ end if;
+ end if;
+
+ if is_wait_socket = 1
+ then
+ if is_wait_socket_table = 1 and @count_actual <> count_expected
+ then
+ set msg= concat("Missing wait/io/socket events: ", msg_detail);
+ signal sqlstate '05000' set message_text= msg;
+ end if;
+
+ if is_wait_table = 0 and is_wait_socket_table = 0 and @count_actual <> 0
+ then
+ set msg= concat("Unexpected wait/io/socket events: ", msg_detail);
+ signal sqlstate '05000' set message_text= msg;
+ end if;
+ end if;
+
+ if is_stage = 1
+ then
+ if is_stage_table = 1 and @count_actual <> count_expected
+ then
+ set msg= concat("Missing stage events: ", msg_detail);
+ signal sqlstate '05000' set message_text= msg;
+ end if;
+
+ if is_stage_table = 0 and @count_actual <> 0
+ then
+ set msg= concat("Unexpected stage events: ", msg_detail);
+ signal sqlstate '05000' set message_text= msg;
+ end if;
+ end if;
+
+ if is_statement = 1
+ then
+ if is_statement_table = 1 and @count_actual <> count_expected
+ then
+ set msg= concat("Missing statement events: ", msg_detail);
+ signal sqlstate '05000' set message_text= msg;
+ end if;
+
+ if is_statement_table = 0 and @count_actual <> 0
+ then
+ set msg= concat("Unexpected statement events: ", msg_detail);
+ signal sqlstate '05000' set message_text= msg;
+ end if;
+ end if;
+
+ if is_memory = 1
+ then
+ if is_memory_table = 1 and @count_actual <> count_expected
+ then
+ set msg= concat("Missing memory events: ", msg_detail);
+ signal sqlstate '05000' set message_text= msg;
+ end if;
+
+ if is_memory_table = 0 and @count_actual <> 0
+ then
+ set msg= concat("Unexpected memory events: ", msg_detail);
+ signal sqlstate '05000' set message_text= msg;
+ end if;
+ end if;
+
+ if is_transaction = 1
+ then
+ if is_transaction_table = 1 and @count_actual <> count_expected
+ then
+ set msg= concat("Missing transaction events: ", msg_detail);
+ signal sqlstate '05000' set message_text= msg;
+ end if;
+
+ if is_transaction_table = 0 and @count_actual <> 0
+ then
+ set msg= concat("Unexpected transaction events: ", msg_detail);
+ signal sqlstate '05000' set message_text= msg;
+ end if;
+ end if;
+
+ end if;
+ until done
+ end repeat;
+ close pfs_cursor;
+
+ -- Dont want to return a 02000 NOT FOUND, there should be a better way
+ signal sqlstate '01000' set message_text='Done', mysql_errno=12000;
+end
+$
+delimiter ;$
+
+--disable_prepare_warnings
+
+# Check the configuration is ok
+show global variables like "performance_schema%";
+
+call check_instrument("wait/synch/mutex/");
+call check_instrument("wait/synch/rwlock/");
+call check_instrument("wait/synch/sxlock/");
+call check_instrument("wait/synch/cond/");
+call check_instrument("wait/synch/");
+call check_instrument("wait/io/file/");
+call check_instrument("wait/io/socket/");
+call check_instrument("wait/io/table/");
+call check_instrument("wait/io/");
+call check_instrument("wait/lock/table/");
+call check_instrument("wait/lock/");
+call check_instrument("wait/");
+call check_instrument("stage/");
+call check_instrument("statement/com/");
+call check_instrument("statement/sql/");
+call check_instrument("statement/abstract/");
+call check_instrument("statement/");
+call check_instrument("idle");
+call check_instrument("memory/");
+call check_instrument("memory/performance_schema/");
+call check_instrument("transaction");
+
+drop procedure check_instrument;
+
diff --git a/mysql-test/suite/perfschema/t/part_table_io.test b/mysql-test/suite/perfschema/t/part_table_io.test
new file mode 100644
index 00000000..0b94d7ca
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/part_table_io.test
@@ -0,0 +1,30 @@
+# Tests for PERFORMANCE_SCHEMA table io
+
+--source include/have_partition.inc
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source ../include/table_io_setup_helper.inc
+
+let $engine_type= MyISAM;
+let $table_item= test.no_index_tab;
+--disable_warnings
+eval drop table if exists $table_item;
+--enable_warnings
+
+# Start recording events
+update performance_schema.setup_consumers set enabled='YES';
+insert into marker set a = 1;
+eval create table $table_item
+( a varchar(255) not null, b int not null) engine = $engine_type
+PARTITION BY KEY (b) PARTITIONS 2;
+insert into marker set a = 1;
+eval show create table $table_item;
+--source ../include/table_io_basic_dml.inc
+eval drop table $table_item;
+
+# Stop recording events + pull result
+--source ../include/table_io_result_helper.inc
+
+# Cleanup
+--source ../include/table_io_cleanup_helper.inc
+
diff --git a/mysql-test/suite/perfschema/t/partition.test b/mysql-test/suite/perfschema/t/partition.test
new file mode 100644
index 00000000..0b3b204d
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/partition.test
@@ -0,0 +1,16 @@
+--source include/have_perfschema.inc
+--source include/have_partition.inc
+
+--echo #
+--echo # MDEV-10679
+--echo # Server crashes in in mysql_create_frm_image upon query from
+--echo # performance schema in ps-protocol mode
+--echo #
+
+CREATE TABLE t1 (i INT);
+--error ER_PARTITION_MGMT_ON_NONPARTITIONED
+ALTER TABLE t1 ADD PARTITION (PARTITION p VALUES LESS THAN (1));
+--disable_result_log
+SELECT * FROM performance_schema.events_stages_summary_by_user_by_event_name;
+--enable_result_log
+DROP TABLE t1;
diff --git a/mysql-test/suite/perfschema/t/pfs_upgrade_event-master.opt b/mysql-test/suite/perfschema/t/pfs_upgrade_event-master.opt
new file mode 100644
index 00000000..275a585d
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/pfs_upgrade_event-master.opt
@@ -0,0 +1,2 @@
+--general_log=0
+--slow_query_log=0
diff --git a/mysql-test/suite/perfschema/t/pfs_upgrade_event.test b/mysql-test/suite/perfschema/t/pfs_upgrade_event.test
new file mode 100644
index 00000000..809e5e05
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/pfs_upgrade_event.test
@@ -0,0 +1,24 @@
+# Tests for PERFORMANCE_SCHEMA
+# Make sure mysql_upgrade does not destroy data in a 'performance_schema'
+# database.
+#
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/have_innodb.inc
+
+let $MYSQLD_DATADIR= `SELECT @@datadir`;
+
+--echo # Testing mysql_upgrade with EVENT performance_schema.user_event
+
+create event test.user_event on schedule every 1 day do
+ select "not supposed to be here";
+
+update mysql.event set db='performance_schema' where name='user_event';
+
+--source suite/perfschema/include/upgrade_check.inc
+
+select name from mysql.event where db='performance_schema';
+
+update mysql.event set db='test' where name='user_event';
+drop event test.user_event;
diff --git a/mysql-test/suite/perfschema/t/pfs_upgrade_func-master.opt b/mysql-test/suite/perfschema/t/pfs_upgrade_func-master.opt
new file mode 100644
index 00000000..275a585d
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/pfs_upgrade_func-master.opt
@@ -0,0 +1,2 @@
+--general_log=0
+--slow_query_log=0
diff --git a/mysql-test/suite/perfschema/t/pfs_upgrade_func.test b/mysql-test/suite/perfschema/t/pfs_upgrade_func.test
new file mode 100644
index 00000000..8f3a1c0e
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/pfs_upgrade_func.test
@@ -0,0 +1,24 @@
+# Tests for PERFORMANCE_SCHEMA
+# Make sure mysql_upgrade does not destroy data in a 'performance_schema'
+# database.
+#
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/have_innodb.inc
+
+let $MYSQLD_DATADIR= `SELECT @@datadir`;
+
+--echo # Testing mysql_upgrade with FUNCTION performance_schema.user_func
+
+create function test.user_func() returns integer
+ return 0;
+
+update mysql.proc set db='performance_schema' where name='user_func';
+
+--source suite/perfschema/include/upgrade_check.inc
+
+select name from mysql.proc where db='performance_schema';
+
+update mysql.proc set db='test' where name='user_func';
+drop function test.user_func;
diff --git a/mysql-test/suite/perfschema/t/pfs_upgrade_proc-master.opt b/mysql-test/suite/perfschema/t/pfs_upgrade_proc-master.opt
new file mode 100644
index 00000000..275a585d
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/pfs_upgrade_proc-master.opt
@@ -0,0 +1,2 @@
+--general_log=0
+--slow_query_log=0
diff --git a/mysql-test/suite/perfschema/t/pfs_upgrade_proc.test b/mysql-test/suite/perfschema/t/pfs_upgrade_proc.test
new file mode 100644
index 00000000..69250734
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/pfs_upgrade_proc.test
@@ -0,0 +1,24 @@
+# Tests for PERFORMANCE_SCHEMA
+# Make sure mysql_upgrade does not destroy data in a 'performance_schema'
+# database.
+#
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/have_innodb.inc
+
+let $MYSQLD_DATADIR= `SELECT @@datadir`;
+
+--echo # Testing mysql_upgrade with PROCEDURE performance_schema.user_proc
+
+create procedure test.user_proc()
+ select "Not supposed to be here";
+
+update mysql.proc set db='performance_schema' where name='user_proc';
+
+--source suite/perfschema/include/upgrade_check.inc
+
+select name from mysql.proc where db='performance_schema';
+
+update mysql.proc set db='test' where name='user_proc';
+drop procedure test.user_proc;
diff --git a/mysql-test/suite/perfschema/t/pfs_upgrade_table-master.opt b/mysql-test/suite/perfschema/t/pfs_upgrade_table-master.opt
new file mode 100644
index 00000000..275a585d
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/pfs_upgrade_table-master.opt
@@ -0,0 +1,2 @@
+--general_log=0
+--slow_query_log=0
diff --git a/mysql-test/suite/perfschema/t/pfs_upgrade_table.test b/mysql-test/suite/perfschema/t/pfs_upgrade_table.test
new file mode 100644
index 00000000..8c69f005
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/pfs_upgrade_table.test
@@ -0,0 +1,30 @@
+# Tests for PERFORMANCE_SCHEMA
+# Make sure mysql_upgrade does not destroy data in a 'performance_schema'
+# database.
+#
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/have_innodb.inc
+
+let $MYSQLD_DATADIR= `SELECT @@datadir`;
+
+--echo # Testing mysql_upgrade with TABLE performance_schema.user_table
+
+create table test.user_table(a int);
+
+--copy_file $MYSQLD_DATADIR/test/user_table.frm $MYSQLD_DATADIR/performance_schema/user_table.frm
+
+# Make sure the table is visible
+use performance_schema;
+show tables like "user_table";
+
+--source suite/perfschema/include/upgrade_check.inc
+
+# Make sure the table is still visible
+show tables like "user_table";
+
+use test;
+
+--remove_file $MYSQLD_DATADIR/performance_schema/user_table.frm
+drop table test.user_table;
diff --git a/mysql-test/suite/perfschema/t/pfs_upgrade_view-master.opt b/mysql-test/suite/perfschema/t/pfs_upgrade_view-master.opt
new file mode 100644
index 00000000..275a585d
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/pfs_upgrade_view-master.opt
@@ -0,0 +1,2 @@
+--general_log=0
+--slow_query_log=0
diff --git a/mysql-test/suite/perfschema/t/pfs_upgrade_view.test b/mysql-test/suite/perfschema/t/pfs_upgrade_view.test
new file mode 100644
index 00000000..57a7cad2
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/pfs_upgrade_view.test
@@ -0,0 +1,30 @@
+# Tests for PERFORMANCE_SCHEMA
+# Make sure mysql_upgrade does not destroy data in a 'performance_schema'
+# database.
+#
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/have_innodb.inc
+
+let $MYSQLD_DATADIR= `SELECT @@datadir`;
+
+--echo # Testing mysql_upgrade with VIEW performance_schema.user_view
+
+create view test.user_view as select "Not supposed to be here";
+
+--copy_file $MYSQLD_DATADIR/test/user_view.frm $MYSQLD_DATADIR/performance_schema/user_view.frm
+
+# Make sure the view is visible
+use performance_schema;
+show tables like "user_view";
+
+--source suite/perfschema/include/upgrade_check.inc
+
+# Make sure the view is still visible
+show tables like "user_view";
+
+use test;
+
+--remove_file $MYSQLD_DATADIR/performance_schema/user_view.frm
+drop view test.user_view;
diff --git a/mysql-test/suite/perfschema/t/prepared_statements.test b/mysql-test/suite/perfschema/t/prepared_statements.test
new file mode 100644
index 00000000..1c14b4cf
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/prepared_statements.test
@@ -0,0 +1,210 @@
+# Test for prepared statement instrumentation
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/no_protocol.inc
+
+CREATE DATABASE db;
+USE db;
+
+--let $psi_select = SELECT STATEMENT_NAME, SQL_TEXT, COUNT_REPREPARE, COUNT_EXECUTE, SUM_ROWS_SENT, SUM_SELECT_SCAN, SUM_NO_INDEX_USED FROM performance_schema.prepared_statements_instances ORDER BY STATEMENT_NAME, SQL_TEXT
+--let $psi_truncate = TRUNCATE TABLE performance_schema.prepared_statements_instances
+--let $eshl_select = SELECT EVENT_NAME, SQL_TEXT, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME FROM performance_schema.events_statements_history_long WHERE CURRENT_SCHEMA='db'
+--let $eshl_truncate = TRUNCATE TABLE performance_schema.events_statements_history_long
+
+--eval $psi_truncate
+--eval $eshl_truncate
+
+--source suite/perfschema/include/prepared_stmts_setup.inc
+
+--vertical_results
+--eval $psi_select
+--eval $eshl_select
+--horizontal_results
+
+--source suite/perfschema/include/prepared_stmts_execution.inc
+
+--vertical_results
+--eval $psi_select
+--eval $eshl_select
+--horizontal_results
+
+# Truncate to reset the statistics
+--eval $psi_truncate
+
+# check whether the statistics are reset
+--vertical_results
+--eval $psi_select
+--horizontal_results
+
+--source suite/perfschema/include/prepared_stmts_deallocation.inc
+
+--vertical_results
+# select query on prepared_statements_instances table must return empty set
+--eval $psi_select
+--eval $eshl_select
+--horizontal_results
+
+# truncate
+--eval $eshl_truncate
+
+#
+# Test to check the instrumentation of prepared statements
+# when all consumers in setup_consumers are disabled.
+#
+
+# Disable all consumers
+UPDATE performance_schema.setup_consumers SET ENABLED = 'NO';
+
+--source suite/perfschema/include/prepared_stmts_setup.inc
+
+--vertical_results
+--eval $psi_select
+--eval $eshl_select
+--horizontal_results
+
+--source suite/perfschema/include/prepared_stmts_execution.inc
+
+--vertical_results
+--eval $psi_select
+--eval $eshl_select
+--horizontal_results
+
+--source suite/perfschema/include/prepared_stmts_deallocation.inc
+
+--vertical_results
+--eval $psi_select
+--eval $eshl_select
+--horizontal_results
+
+# truncate
+--eval $eshl_truncate
+
+# restore the initial set-up of consumers table
+UPDATE performance_schema.setup_consumers SET ENABLED = 'YES';
+
+#
+# Aggregation
+#
+
+PREPARE st FROM 'SELECT SUM(1000 + ?) AS total';
+
+--vertical_results
+--eval $psi_select
+--horizontal_results
+
+SET @d=100;
+EXECUTE st USING @d;
+
+--vertical_results
+--eval $psi_select
+--horizontal_results
+
+let $i=5;
+while($i)
+{
+ SET @d = @d + 100;
+ EXECUTE st USING @d;
+ --vertical_results
+ --eval $psi_select
+ --horizontal_results
+ dec $i;
+}
+
+# truncate
+--eval $psi_truncate
+--vertical_results
+--eval $psi_select
+--horizontal_results
+
+#
+# check whether the instrumented prepared statement is removed from the
+# prepared_statement_instances table after de allocation of the prepared
+# statement even if instrumentation is disabled
+#
+
+# Disable prepared statement instrumentation
+UPDATE performance_schema.setup_instruments SET ENABLED = 'NO'
+ WHERE NAME like "statement/sql/execute%";
+
+SET @d=3274;
+# COUNT_EXECUTE should remain 0. No increment must be seen.
+EXECUTE st USING @d;
+--vertical_results
+--eval $psi_select
+--horizontal_results
+
+UPDATE performance_schema.setup_instruments SET ENABLED = 'NO'
+ WHERE NAME like "statement/sql/prepare%";
+
+DEALLOCATE PREPARE st;
+# should return empty set.
+--vertical_results
+--eval $psi_select
+--horizontal_results
+
+# Restore back teh initial set-up of setup_instruments table
+
+UPDATE performance_schema.setup_instruments SET ENABLED = 'YES'
+ WHERE NAME like "statement/sql/prepare%";
+UPDATE performance_schema.setup_instruments SET ENABLED = 'YES'
+ WHERE NAME like "statement/sql/execute%";
+
+
+# Reprepare
+
+CREATE TABLE tab(
+ Id INT,
+ name CHAR(10),
+ age INT
+);
+
+INSERT INTO tab VALUES(1,"Nakshatr",25),(2,"chanda",24),(3,"tejas",78);
+
+PREPARE st FROM 'SELECT * FROM tab';
+
+--vertical_results
+--eval $psi_select
+--horizontal_results
+
+EXECUTE st;
+
+--vertical_results
+--eval $psi_select
+--horizontal_results
+
+ALTER TABLE tab DROP COLUMN age;
+
+EXECUTE st;
+
+--vertical_results
+--eval $psi_select
+--horizontal_results
+
+ALTER TABLE tab ADD COLUMN age INT NULL;
+
+EXECUTE st;
+
+--vertical_results
+--eval $psi_select
+--horizontal_results
+
+# check if the statistics are reset
+--eval $psi_truncate
+--vertical_results
+--eval $psi_select
+--horizontal_results
+
+DEALLOCATE PREPARE st;
+
+--vertical_results
+--eval $psi_select
+--horizontal_results
+
+# clean up
+# truncate
+--eval $psi_truncate
+--eval $eshl_truncate
+
+DROP TABLE tab;
+DROP DATABASE db;
diff --git a/mysql-test/suite/perfschema/t/prepared_stmts_by_stored_programs.test b/mysql-test/suite/perfschema/t/prepared_stmts_by_stored_programs.test
new file mode 100644
index 00000000..bf81d036
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/prepared_stmts_by_stored_programs.test
@@ -0,0 +1,151 @@
+# Test to check instrumentation of prepared statements created by
+# stored programs. SQL prepared statements (PREPARE, EXECUTE, DEALLOCATE PREPARE)
+# can be used in stored procedures, but not stored functions or triggers.
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/no_protocol.inc
+
+--let $psi_select = SELECT STATEMENT_NAME, SQL_TEXT, COUNT_EXECUTE, COUNT_REPREPARE, OWNER_OBJECT_TYPE, OWNER_OBJECT_SCHEMA, OWNER_OBJECT_NAME FROM performance_schema.prepared_statements_instances
+TRUNCATE TABLE performance_schema.prepared_statements_instances;
+
+CREATE DATABASE db;
+USE db;
+
+CREATE TABLE t
+(
+ a INT,
+ b CHAR(10),
+ name CHAR(10)
+);
+SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
+INSERT INTO t VALUES (1,"kuchipudi","Vempati");
+INSERT INTO t VALUES (2,"odissi","Mohapatra");
+INSERT INTO t VALUES (3,"kathak","Maharaj");
+INSERT INTO t VALUES (4,"mohiyattam","Kalyanikutty");
+INSERT INTO t VALUES (5,"manipuri","Guru");
+INSERT INTO t VALUES (6,"kathakali","Manavedan");
+SET sql_mode= default;
+# Stored Procedure
+DELIMITER |;
+CREATE PROCEDURE p1()
+BEGIN
+ PREPARE st FROM 'SELECT * FROM t WHERE a<=?' ;
+ SET @a=3;
+ EXECUTE st using @a;
+END|
+
+CALL p1()|
+--eval $psi_select
+
+DEALLOCATE PREPARE st|
+--eval $psi_select
+
+CREATE PROCEDURE p2()
+BEGIN
+ PREPARE st1 FROM 'INSERT INTO t SELECT * FROM t WHERE a<=?' ;
+END|
+
+CALL p2()|
+--eval $psi_select
+
+SET @a=4|
+EXECUTE st1 using @a|
+--eval $psi_select
+
+CREATE PROCEDURE p3()
+BEGIN
+ SET @a=2;
+ EXECUTE st1 using @a;
+END|
+
+CALL p3()|
+--eval $psi_select
+
+DEALLOCATE PREPARE st1|
+--eval $psi_select
+
+PREPARE st2 FROM 'UPDATE t SET a=a+1 WHERE b=?'|
+--eval $psi_select
+
+CREATE PROCEDURE p4()
+BEGIN
+ SET @b='kuchipudi';
+ EXECUTE st2 USING @b;
+END|
+
+CALL p4()|
+--eval $psi_select
+
+ALTER TABLE t DROP COLUMN name;
+
+# COUNT_REPREPARE must be 1
+CALL p4()|
+--eval $psi_select
+
+DEALLOCATE PREPARE st2|
+--eval $psi_select
+
+CREATE PROCEDURE p5()
+BEGIN
+ SET @a=1;
+ SELECT @a;
+END|
+
+PREPARE st3 FROM 'CALL p5()'|
+--eval $psi_select
+EXECUTE st3|
+--eval $psi_select
+DEALLOCATE PREPARE st3|
+--eval $psi_select
+
+DELIMITER ;|
+
+# Events
+
+CREATE TABLE tab(a INT);
+
+SET GLOBAL event_scheduler=ON;
+
+DELIMITER |;
+CREATE EVENT e1 ON SCHEDULE EVERY 10 HOUR DO
+BEGIN
+ PREPARE st FROM 'INSERT INTO tab VALUES(?)';
+ SET @a=1;
+ EXECUTE st USING @a;
+END|
+
+DELIMITER ;|
+
+# Let e1 insert 1 records into the table tab
+
+--let $wait_condition= select count(*) >= 1 from tab
+--source include/wait_condition.inc
+SELECT * FROM tab LIMIT 1;
+
+# Wait till the above one execution of event is instrumented.
+
+--let $wait_condition= select count_star >= 1 from performance_schema.events_statements_summary_by_program where object_type='EVENT'
+--source include/wait_condition.inc
+
+SET GLOBAL event_scheduler=OFF;
+--source include/no_running_event_scheduler.inc
+
+# The following should return empty set as the instrumented prepared statement
+# row is removed as de allocation of the statement happens automatically as
+# event thread is cleaned up.
+--eval $psi_select
+
+# clean-up
+TRUNCATE TABLE performance_schema.prepared_statements_instances;
+TRUNCATE TABLE performance_schema.events_statements_history_long;
+
+DROP TABLE t;
+DROP TABLE tab;
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+DROP PROCEDURE p3;
+DROP PROCEDURE p4;
+DROP PROCEDURE p5;
+DROP EVENT IF EXISTS e1;
+DROP DATABASE db;
diff --git a/mysql-test/suite/perfschema/t/privilege.test b/mysql-test/suite/perfschema/t/privilege.test
new file mode 100644
index 00000000..06e7cdf0
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/privilege.test
@@ -0,0 +1,353 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+show grants;
+
+create user 'pfs_user_1'@localhost;
+create user 'pfs_user_2'@localhost;
+create user 'pfs_user_3'@localhost;
+grant SELECT,INSERT,UPDATE,DELETE,DROP,CREATE on test.* to 'pfs_user_1'@localhost;
+grant SELECT,INSERT,UPDATE,DELETE,DROP,CREATE on test.* to 'pfs_user_2'@localhost;
+grant SELECT,INSERT,UPDATE,DELETE,DROP,CREATE on test.* to 'pfs_user_3'@localhost;
+grant ALL on *.* to 'pfs_user_1'@localhost with GRANT OPTION;
+
+# Test denied privileges on performance_schema.*
+
+--error ER_DBACCESS_DENIED_ERROR
+grant ALL on performance_schema.* to 'pfs_user_2'@localhost
+ with GRANT OPTION;
+
+# will be ER_DBACCESS_DENIED_ERROR once .FRM are removed
+grant CREATE on performance_schema.* to 'pfs_user_2'@localhost;
+
+# will be ER_DBACCESS_DENIED_ERROR once .FRM are removed
+grant DROP on performance_schema.* to 'pfs_user_2'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant REFERENCES on performance_schema.* to 'pfs_user_2'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant INDEX on performance_schema.* to 'pfs_user_2'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant ALTER on performance_schema.* to 'pfs_user_2'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant CREATE TEMPORARY TABLES on performance_schema.* to 'pfs_user_2'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant EXECUTE on performance_schema.* to 'pfs_user_2'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant CREATE VIEW on performance_schema.* to 'pfs_user_2'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant SHOW VIEW on performance_schema.* to 'pfs_user_2'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant CREATE ROUTINE on performance_schema.* to 'pfs_user_2'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant ALTER ROUTINE on performance_schema.* to 'pfs_user_2'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant EVENT on performance_schema.* to 'pfs_user_2'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant TRIGGER on performance_schema.* to 'pfs_user_2'@localhost;
+
+# Test allowed privileges on performance_schema.*
+
+grant SELECT on performance_schema.* to 'pfs_user_2'@localhost;
+grant INSERT on performance_schema.* to 'pfs_user_2'@localhost;
+grant UPDATE on performance_schema.* to 'pfs_user_2'@localhost;
+grant DELETE on performance_schema.* to 'pfs_user_2'@localhost;
+grant LOCK TABLES on performance_schema.* to 'pfs_user_2'@localhost;
+
+# Test denied privileges on specific performance_schema tables.
+# setup_instrument : example of PFS_updatable_acl
+# events_waits_current : example of PFS_truncatable_acl
+# file_instances : example of PFS_readonly_acl
+
+--error ER_DBACCESS_DENIED_ERROR
+grant ALL on performance_schema.setup_instruments to 'pfs_user_3'@localhost
+ with GRANT OPTION;
+
+# will be ER_DBACCESS_DENIED_ERROR once .FRM are removed
+grant CREATE on performance_schema.setup_instruments to 'pfs_user_3'@localhost;
+
+# will be ER_DBACCESS_DENIED_ERROR once .FRM are removed
+grant DROP on performance_schema.setup_instruments to 'pfs_user_3'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant REFERENCES on performance_schema.setup_instruments to 'pfs_user_3'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant INDEX on performance_schema.setup_instruments to 'pfs_user_3'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant ALTER on performance_schema.setup_instruments to 'pfs_user_3'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant CREATE VIEW on performance_schema.setup_instruments to 'pfs_user_3'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant SHOW VIEW on performance_schema.setup_instruments to 'pfs_user_3'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant TRIGGER on performance_schema.setup_instruments to 'pfs_user_3'@localhost;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+grant INSERT on performance_schema.setup_instruments to 'pfs_user_3'@localhost;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+grant DELETE on performance_schema.setup_instruments to 'pfs_user_3'@localhost;
+
+grant SELECT on performance_schema.setup_instruments to 'pfs_user_3'@localhost
+ with GRANT OPTION;
+
+grant UPDATE on performance_schema.setup_instruments to 'pfs_user_3'@localhost
+ with GRANT OPTION;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant ALL on performance_schema.events_waits_current to 'pfs_user_3'@localhost
+ with GRANT OPTION;
+
+# will be ER_DBACCESS_DENIED_ERROR once .FRM are removed
+grant CREATE on performance_schema.events_waits_current to 'pfs_user_3'@localhost;
+
+# will be ER_DBACCESS_DENIED_ERROR once .FRM are removed
+grant DROP on performance_schema.events_waits_current to 'pfs_user_3'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant REFERENCES on performance_schema.events_waits_current to 'pfs_user_3'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant INDEX on performance_schema.events_waits_current to 'pfs_user_3'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant ALTER on performance_schema.events_waits_current to 'pfs_user_3'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant CREATE VIEW on performance_schema.events_waits_current to 'pfs_user_3'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant SHOW VIEW on performance_schema.events_waits_current to 'pfs_user_3'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant TRIGGER on performance_schema.events_waits_current to 'pfs_user_3'@localhost;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+grant INSERT on performance_schema.events_waits_current to 'pfs_user_3'@localhost;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+grant UPDATE on performance_schema.events_waits_current to 'pfs_user_3'@localhost;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+grant DELETE on performance_schema.events_waits_current to 'pfs_user_3'@localhost;
+
+grant SELECT on performance_schema.events_waits_current to 'pfs_user_3'@localhost
+ with GRANT OPTION;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant ALL on performance_schema.file_instances to 'pfs_user_3'@localhost
+ with GRANT OPTION;
+
+# will be ER_DBACCESS_DENIED_ERROR once .FRM are removed
+grant CREATE on performance_schema.file_instances to 'pfs_user_3'@localhost;
+
+# will be ER_DBACCESS_DENIED_ERROR once .FRM are removed
+grant DROP on performance_schema.file_instances to 'pfs_user_3'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant REFERENCES on performance_schema.file_instances to 'pfs_user_3'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant INDEX on performance_schema.file_instances to 'pfs_user_3'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant ALTER on performance_schema.file_instances to 'pfs_user_3'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant CREATE VIEW on performance_schema.file_instances to 'pfs_user_3'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant SHOW VIEW on performance_schema.file_instances to 'pfs_user_3'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+grant TRIGGER on performance_schema.file_instances to 'pfs_user_3'@localhost;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+grant INSERT on performance_schema.file_instances to 'pfs_user_3'@localhost;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+grant UPDATE on performance_schema.file_instances to 'pfs_user_3'@localhost;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+grant DELETE on performance_schema.file_instances to 'pfs_user_3'@localhost;
+
+grant SELECT on performance_schema.file_instances to 'pfs_user_3'@localhost
+ with GRANT OPTION;
+
+# See bug#45354 LOCK TABLES is not a TABLE privilege
+grant LOCK TABLES on performance_schema.* to 'pfs_user_3'@localhost
+ with GRANT OPTION;
+
+flush privileges;
+
+--source ../include/privilege.inc
+
+connect (con1, localhost, pfs_user_1, , );
+
+--source ../include/privilege.inc
+
+--disconnect con1
+
+connect (con2, localhost, pfs_user_2, , );
+
+--source ../include/privilege.inc
+
+--disconnect con2
+
+connect (con3, localhost, pfs_user_3, , );
+
+--source ../include/privilege.inc
+
+--disconnect con3
+
+--connection default
+
+revoke all privileges, grant option from 'pfs_user_1'@localhost;
+revoke all privileges, grant option from 'pfs_user_2'@localhost;
+revoke all privileges, grant option from 'pfs_user_3'@localhost;
+drop user 'pfs_user_1'@localhost;
+drop user 'pfs_user_2'@localhost;
+drop user 'pfs_user_3'@localhost;
+flush privileges;
+
+--echo # Test cases from WL#4818
+--echo # Setup user
+
+CREATE user pfs_user_4;
+--connect (pfs_user_4, localhost, pfs_user_4, ,"*NO-ONE*")
+
+--echo #
+--echo # WL#4818, NFS4: Normal user does not have access to view data
+--echo # without grants
+--echo #
+
+--connection pfs_user_4
+--echo # Select as pfs_user_4 should fail without grant
+
+--error ER_TABLEACCESS_DENIED_ERROR
+SELECT event_id FROM performance_schema.events_waits_history;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+SELECT event_id FROM performance_schema.events_waits_history_long;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+SELECT event_id FROM performance_schema.events_waits_current;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+SELECT event_name FROM performance_schema.events_waits_summary_by_instance;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+SELECT event_name FROM performance_schema.file_summary_by_instance;
+
+--echo #
+--echo # WL#4818, NFS3: Normal user does not have access to change what is
+--echo # instrumented without grants
+--echo #
+
+--connection pfs_user_4
+--echo # User pfs_user_4 should not be allowed to tweak instrumentation without
+--echo # explicit grant
+
+--error ER_TABLEACCESS_DENIED_ERROR
+UPDATE performance_schema.setup_instruments SET enabled = 'NO', timed = 'YES';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+UPDATE performance_schema.setup_instruments SET enabled = 'YES'
+WHERE name LIKE 'wait/synch/mutex/%'
+ OR name LIKE 'wait/synch/rwlock/%';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+UPDATE performance_schema.setup_consumers SET enabled = 'YES';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+UPDATE performance_schema.setup_timers SET timer_name = 'TICK';
+
+--error ER_TABLEACCESS_DENIED_ERROR
+TRUNCATE TABLE performance_schema.events_waits_history_long;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+TRUNCATE TABLE performance_schema.events_waits_history;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+TRUNCATE TABLE performance_schema.events_waits_current;
+
+--echo #
+--echo # WL#4814, NFS1: Can use grants to give normal user access
+--echo # to turn on and off instrumentation
+--echo #
+
+--connection default
+--echo # Grant access to change tables with the root account
+
+GRANT UPDATE ON performance_schema.setup_consumers TO pfs_user_4;
+GRANT UPDATE, SELECT ON performance_schema.setup_timers TO pfs_user_4;
+GRANT UPDATE, SELECT ON performance_schema.setup_instruments TO pfs_user_4;
+GRANT DROP ON performance_schema.events_waits_current TO pfs_user_4;
+GRANT DROP ON performance_schema.events_waits_history TO pfs_user_4;
+GRANT DROP ON performance_schema.events_waits_history_long TO pfs_user_4;
+
+--connection pfs_user_4
+--echo # User pfs_user_4 should now be allowed to tweak instrumentation
+
+UPDATE performance_schema.setup_instruments SET enabled = 'NO', timed = 'YES';
+
+UPDATE performance_schema.setup_instruments SET enabled = 'YES'
+WHERE name LIKE 'wait/synch/mutex/%'
+ OR name LIKE 'wait/synch/rwlock/%';
+
+UPDATE performance_schema.setup_consumers SET enabled = 'YES';
+
+# We do not touch "wait", to avoid restoring it at the end of the test,
+# as its default value initialized at server startup is ambiguous:
+# it can be CYCLE or NANOSECOND depending on platform
+
+UPDATE performance_schema.setup_timers SET timer_name = 'TICK' WHERE name <> "wait";
+
+TRUNCATE TABLE performance_schema.events_waits_history_long;
+TRUNCATE TABLE performance_schema.events_waits_history;
+TRUNCATE TABLE performance_schema.events_waits_current;
+
+--echo # Clean up
+--disconnect pfs_user_4
+--source include/wait_until_disconnected.inc
+--connection default
+REVOKE ALL PRIVILEGES, GRANT OPTION FROM pfs_user_4;
+DROP USER pfs_user_4;
+flush privileges;
+UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES';
+UPDATE performance_schema.setup_consumers SET enabled = 'YES';
+
+# Restore the default values for the timers that we changed.
+# Note, we did not touch "wait", see above.
+UPDATE performance_schema.setup_timers SET timer_name = 'MICROSECOND' where name="idle";
+UPDATE performance_schema.setup_timers SET timer_name = 'NANOSECOND' where name="stage";
+UPDATE performance_schema.setup_timers SET timer_name = 'NANOSECOND' where name="statement";
+
+--echo #
+--echo # WL#2284: Increase the length of a user name
+--echo #
+
+CREATE USER 'user_name_len_22_01234'@localhost;
+
+--error ER_DBACCESS_DENIED_ERROR
+GRANT ALL ON performance_schema.* TO 'user_name_len_22_01234'@localhost with GRANT OPTION;
+
+REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user_name_len_22_01234'@localhost;
+DROP USER 'user_name_len_22_01234'@localhost;
diff --git a/mysql-test/suite/perfschema/t/privilege_table_io.test b/mysql-test/suite/perfschema/t/privilege_table_io.test
new file mode 100644
index 00000000..1265b03b
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/privilege_table_io.test
@@ -0,0 +1,53 @@
+# Tests for PERFORMANCE_SCHEMA table io
+# This test makes a restart because without it, events_waits_history_long
+# sometimes contains duplicated entries of roles_mapping.
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/restart_mysqld.inc
+--source ../include/table_io_setup_helper.inc
+
+# Remove "deleted" records from mysql.db that may come from previous tests,
+# to avoid displaying spurious fetch.
+# There are two possible server reactions which are both ok.
+# Table Op Msg_type Msg_text
+# mysql.db optimize status OK
+# or
+# mysql.db optimize status Table is already up to date
+# Therefore we suppress the query_log here.
+--echo # We are forced to suppress here the server response.
+--disable_result_log
+optimize table mysql.user;
+optimize table mysql.db;
+optimize table mysql.proxies_priv;
+optimize table mysql.roles_mapping;
+optimize table mysql.tables_priv;
+optimize table mysql.procs_priv;
+optimize table mysql.servers;
+optimize table mysql.roles_mapping;
+--enable_result_log
+
+# Start recording events
+update performance_schema.setup_consumers set enabled='YES';
+update performance_schema.setup_objects set enabled='YES'
+ where object_type='TABLE' and object_schema= 'mysql';
+
+# Code to test
+
+flush privileges;
+# This will cause table io in mysql system security tables
+insert into test.marker set a = 1;
+# This will not, the ACL cache is already loaded
+insert into test.marker set a = 1;
+insert into test.marker set a = 1;
+show global variables like "performance_schema%";
+show global status like "performance_schema%";
+# Stop recording events + pull results
+let $schema_to_dump= "test", "mysql";
+--source ../include/table_io_result_helper.inc
+
+# Cleanup
+--source ../include/table_io_cleanup_helper.inc
+
+update performance_schema.setup_objects set enabled='NO'
+ where object_type='TABLE' and object_schema= 'mysql';
diff --git a/mysql-test/suite/perfschema/t/processlist-master.opt b/mysql-test/suite/perfschema/t/processlist-master.opt
new file mode 100644
index 00000000..f93413a6
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/processlist-master.opt
@@ -0,0 +1 @@
+--event-scheduler
diff --git a/mysql-test/suite/perfschema/t/processlist.test b/mysql-test/suite/perfschema/t/processlist.test
new file mode 100644
index 00000000..fed22153
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/processlist.test
@@ -0,0 +1,197 @@
+--echo ##
+--echo ## Test the Performance Schema-based implementation of SHOW PROCESSLIST.
+--echo ##
+--echo ## Test cases:
+--echo ## 1. Execute the new SHOW [FULL] PROCESSLIST and SELECT on performance_schema.processlist
+--echo ## 2. Execute the legacy SHOW [FULL] PROCESSLIST and SELECT on information_schema.processlist
+--echo ## 3. Verify that performance_schema_show_processlist = ON executes the new implementation
+--echo ## 4. Verify that performance_schema_show_processlist = OFF executes the legacy code path
+--echo ##
+--echo ## Results must be manually verified.
+
+--source include/no_protocol.inc
+--source include/have_debug.inc
+--source include/have_debug_sync.inc
+--source include/not_embedded.inc
+
+--echo
+--echo ### Setup ###
+--echo
+select @@global.performance_schema_show_processlist into @save_processlist;
+
+--echo
+create user user1@localhost, user2@localhost,
+ user3@localhost, user4@localhost;
+--echo
+grant ALL on *.* to user1@localhost;
+grant ALL on *.* to user2@localhost;
+grant ALL on *.* to user3@localhost;
+grant ALL on *.* to user4@localhost;
+--echo
+flush privileges;
+
+--echo
+use test;
+create table test.t1 (s1 int, s2 int, s3 int, s4 int);
+
+--echo
+--echo # Switch to (con0, localhost, root, , )
+connect (con0, localhost, root, , );
+--echo
+insert into test.t1 values(1, 1, 1, 1);
+insert into test.t1 values(2, 2, 2, 2);
+insert into test.t1 values(3, 3, 3, 3);
+insert into test.t1 values(4, 4, 4, 4);
+
+--echo
+--echo # Lock test.t1, insert/update/deletes will block
+lock tables t1 read;
+
+--echo
+--echo # Connect (con1, localhost, user1, , )
+connect (con1, localhost, user1, , );
+--send insert into test.t1 values (0, 0, 0, 0)
+
+--echo
+--echo # Connect (con2, localhost, user2, , )
+connect (con2, localhost, user2, , );
+# Create a query > 100 characters
+--send update test.t1 set s1 = s1 + 1, s2 = s2 + 2, s3 = s3 + 3, s4 = ((s4 + 4) * (s4 + 5)) + 12345 + 67890 + 11111 + 22222 + 33333 + 44444 + 55555 + 99999;
+--echo
+--echo # Connect (con3, localhost, user3, , )
+connect (con3, localhost, user3, , );
+--send delete from test.t1 where s1 = 3
+
+--echo
+--echo # Connect (con4, localhost, user4, , )
+connect (con4, localhost, user4, , );
+--send insert into test.t1 values (4, 4, 4, 4)
+
+--echo
+--echo # Connection default
+--connection default
+
+--echo
+--echo # Wait for queries to appear in the processlist table
+let $wait_condition = select count(*) >= 4 from information_schema.processlist
+ where state like '%metadata%';
+--source include/wait_condition.inc
+
+--echo
+--echo
+--echo ### Execute new SHOW [FULL] PROCESSLIST and SELECT on performance_schema.processlist
+--echo
+let $pfs_spl = on;
+--source ../include/processlist_set.inc
+--source ../include/processlist_load.inc
+
+--echo
+--echo
+--echo ### Execute legacy SHOW [FULL] PROCESSLIST and SELECT on information_schema.processlist
+--echo
+let $pfs_spl = off;
+--source ../include/processlist_set.inc
+--source ../include/processlist_load.inc
+
+--echo
+--echo
+--echo ### Verify feature code path
+--echo
+--echo # Enable SHOW PROCESSLIST via the Performance Schema
+let $pfs_spl = on;
+--source ../include/processlist_set.inc
+
+--echo
+--echo # Connection default, send SHOW PROCESSLIST
+--connection default
+SET DEBUG_SYNC='pfs_show_processlist_performance_schema SIGNAL pfs_processlist_pfs WAIT_FOR continue';
+--send SHOW FULL PROCESSLIST
+
+--echo
+--echo # Connection con0
+--connection con0
+SET DEBUG_SYNC='now WAIT_FOR pfs_processlist_pfs';
+SET DEBUG_SYNC='now SIGNAL continue';
+
+--echo
+--echo # Connection default, reap
+--connection default
+--replace_column 1 <Id> 3 <Host> 5 <Command> 6 <Time> 7 <State> 8 <Info>
+--sorted_result
+--reap
+
+--echo
+--echo
+--echo ### Verify legacy code path
+--echo
+--echo # Enable the legacy SHOW PROCESSLIST
+let $pfs_spl = off;
+--source ../include/processlist_set.inc
+
+--echo
+--echo # Connection default, send SHOW PROCESSLIST
+--connection default
+SET DEBUG_SYNC='RESET';
+SET DEBUG_SYNC='pfs_show_processlist_legacy SIGNAL pfs_processlist_legacy WAIT_FOR continue';
+--send SHOW FULL PROCESSLIST
+
+--echo
+--echo # Connection con0
+--connection con0
+SET DEBUG_SYNC='now WAIT_FOR pfs_processlist_legacy';
+SET DEBUG_SYNC='now SIGNAL continue';
+
+--echo
+--echo # Connection default, reap
+--connection default
+--replace_column 1 <Id> 3 <Host> 5 <Command> 6 <Time> 7 <State> 8 <Info>
+--sorted_result
+--reap
+
+--echo
+--echo
+--echo ### Clean up ###
+--echo
+
+--echo # Connection con0, unlock test.t1, disconnect
+--connection con0
+unlock tables;
+--disconnect con0
+
+--disable_query_log
+--disable_result_log
+--echo
+--echo # Connection con1, reap, disconnect
+--connection con1
+--reap
+--disconnect con1
+
+--echo # Connection con2, reap, disconnect
+--connection con2
+--reap
+--disconnect con2
+
+--echo # Connection con3, reap, disconnect
+--connection con3
+--reap
+--disconnect con3
+
+--echo # Connection con4, reap, disconnect
+--connection con4
+--reap
+--disconnect con4
+--enable_result_log
+--enable_query_log
+
+--echo
+--echo # Connection default
+--connection default
+
+--echo
+drop table test.t1;
+drop user user1@localhost;
+drop user user2@localhost;
+drop user user3@localhost;
+drop user user4@localhost;
+--echo
+set @@global.performance_schema_show_processlist = @save_processlist;
diff --git a/mysql-test/suite/perfschema/t/processlist_57.test b/mysql-test/suite/perfschema/t/processlist_57.test
new file mode 100644
index 00000000..748d8b74
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/processlist_57.test
@@ -0,0 +1,349 @@
+
+--source include/no_protocol.inc
+--source include/not_embedded.inc
+
+call mtr.add_suppression("Optional native table 'performance_schema'.'processlist' has the wrong structure or is missing.");
+call mtr.add_suppression("Column count of performance_schema.processlist is wrong. Expected 8, found 2. The table is probably corrupted");
+
+--echo ##
+--echo ## Verify fresh 5.7 instance
+--echo ##
+
+SELECT @@global.performance_schema_show_processlist;
+
+SHOW CREATE TABLE performance_schema.processlist;
+
+--echo ##
+--echo ## Simulate old 5.7 instance
+--echo ##
+
+DROP TABLE performance_schema.processlist;
+
+--error ER_NO_SUCH_TABLE
+SHOW CREATE TABLE performance_schema.processlist;
+
+let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
+--exec echo "wait" > $restart_file
+--echo ##
+--echo ## Server shutdown
+--echo ##
+--shutdown_server
+--source include/wait_until_disconnected.inc
+--echo ##
+--echo ### Server restart
+--echo ##
+--exec echo "restart:">$restart_file
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+--echo ##
+--echo ## Verify old 5.7 instance
+--echo ##
+
+SELECT @@global.performance_schema_show_processlist;
+
+--error ER_NO_SUCH_TABLE
+SHOW CREATE TABLE performance_schema.processlist;
+
+--error ER_NO_SUCH_TABLE
+SELECT * FROM performance_schema.processlist;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SHOW PROCESSLIST;
+
+SET GLOBAL performance_schema_show_processlist = 'ON';
+
+--error ER_NO_SUCH_TABLE
+SELECT * FROM performance_schema.processlist;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
+
+--error ER_NO_SUCH_TABLE
+SHOW PROCESSLIST;
+
+--echo ##
+--echo ## Perform broken upgrade (case 1)
+--echo ##
+
+CREATE TABLE performance_schema.processlist (a int, b int);
+
+SHOW CREATE TABLE performance_schema.processlist;
+
+SET GLOBAL performance_schema_show_processlist = 'OFF';
+
+SELECT * FROM performance_schema.processlist;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SHOW PROCESSLIST;
+
+SET GLOBAL performance_schema_show_processlist = 'ON';
+
+SELECT * FROM performance_schema.processlist;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
+
+--error ER_BAD_FIELD_ERROR
+SHOW PROCESSLIST;
+
+--exec echo "wait" > $restart_file
+--echo ##
+--echo ## Server shutdown
+--echo ##
+--shutdown_server
+--source include/wait_until_disconnected.inc
+--echo ##
+--echo ### Server restart
+--echo ##
+--exec echo "restart:">$restart_file
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+SHOW CREATE TABLE performance_schema.processlist;
+
+SET GLOBAL performance_schema_show_processlist = 'OFF';
+
+SELECT * FROM performance_schema.processlist;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SHOW PROCESSLIST;
+
+SET GLOBAL performance_schema_show_processlist = 'ON';
+
+SELECT * FROM performance_schema.processlist;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
+
+--error ER_BAD_FIELD_ERROR
+SHOW PROCESSLIST;
+
+--echo ##
+--echo ## Perform broken upgrade (case 2)
+--echo ##
+
+DROP TABLE performance_schema.processlist;
+CREATE TABLE performance_schema.processlist (
+ `ID` bigint(20) unsigned NOT NULL,
+ `USER` varchar(32) DEFAULT NULL,
+ `HOST` varchar(66) DEFAULT NULL,
+ `DB` varchar(64) DEFAULT NULL,
+ `COMMAND` varchar(16) DEFAULT NULL,
+ `TIME` bigint(20) DEFAULT NULL,
+ `STATE` varchar(64) DEFAULT NULL,
+ `INFO` longtext
+);
+
+SHOW CREATE TABLE performance_schema.processlist;
+
+SET GLOBAL performance_schema_show_processlist = 'OFF';
+
+SELECT * FROM performance_schema.processlist;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SHOW PROCESSLIST;
+
+SET GLOBAL performance_schema_show_processlist = 'ON';
+
+SELECT * FROM performance_schema.processlist;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
+
+# Works and returns no data, innodb table is empty.
+SHOW PROCESSLIST;
+
+--exec echo "wait" > $restart_file
+--echo ##
+--echo ## Server shutdown
+--echo ##
+--shutdown_server
+--source include/wait_until_disconnected.inc
+--echo ##
+--echo ### Server restart
+--echo ##
+--exec echo "restart:">$restart_file
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+SHOW CREATE TABLE performance_schema.processlist;
+
+SET GLOBAL performance_schema_show_processlist = 'OFF';
+
+SELECT * FROM performance_schema.processlist;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SHOW PROCESSLIST;
+
+SET GLOBAL performance_schema_show_processlist = 'ON';
+
+SELECT * FROM performance_schema.processlist;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
+
+# Works and returns no data, innodb table is empty.
+SHOW PROCESSLIST;
+
+--echo ##
+--echo ## Perform broken upgrade (case 3)
+--echo ##
+
+DROP TABLE performance_schema.processlist;
+CREATE TABLE performance_schema.processlist
+ LIKE INFORMATION_SCHEMA.PROCESSLIST;
+
+SHOW CREATE TABLE performance_schema.processlist;
+
+SET GLOBAL performance_schema_show_processlist = 'OFF';
+
+SELECT * FROM performance_schema.processlist;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SHOW PROCESSLIST;
+
+SET GLOBAL performance_schema_show_processlist = 'ON';
+
+SELECT * FROM performance_schema.processlist;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
+
+# Works and returns no data, innodb table is empty.
+SHOW PROCESSLIST;
+
+--exec echo "wait" > $restart_file
+--echo ##
+--echo ## Server shutdown
+--echo ##
+--shutdown_server
+--source include/wait_until_disconnected.inc
+--echo ##
+--echo ### Server restart
+--echo ##
+--exec echo "restart:">$restart_file
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+SHOW CREATE TABLE performance_schema.processlist;
+
+SET GLOBAL performance_schema_show_processlist = 'OFF';
+
+SELECT * FROM performance_schema.processlist;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SHOW PROCESSLIST;
+
+SET GLOBAL performance_schema_show_processlist = 'ON';
+
+SELECT * FROM performance_schema.processlist;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
+
+# Works and returns no data, innodb table is empty.
+SHOW PROCESSLIST;
+
+--echo ##
+--echo ## Perform correct upgrade
+--echo ##
+
+DROP TABLE performance_schema.processlist;
+CREATE TABLE performance_schema.processlist (
+ `ID` bigint(20) unsigned NOT NULL,
+ `USER` varchar(32) DEFAULT NULL,
+ `HOST` varchar(66) DEFAULT NULL,
+ `DB` varchar(64) DEFAULT NULL,
+ `COMMAND` varchar(16) DEFAULT NULL,
+ `TIME` bigint(20) DEFAULT NULL,
+ `STATE` varchar(64) DEFAULT NULL,
+ `INFO` longtext
+) ENGINE = 'PERFORMANCE_SCHEMA';
+
+SHOW CREATE TABLE performance_schema.processlist;
+
+SET GLOBAL performance_schema_show_processlist = 'OFF';
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SELECT * FROM performance_schema.processlist;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SHOW PROCESSLIST;
+
+SET GLOBAL performance_schema_show_processlist = 'ON';
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SELECT * FROM performance_schema.processlist;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SHOW PROCESSLIST;
+
+--exec echo "wait" > $restart_file
+--echo ##
+--echo ## Server shutdown
+--echo ##
+--shutdown_server
+--source include/wait_until_disconnected.inc
+--echo ##
+--echo ### Server restart
+--echo ##
+--exec echo "restart:">$restart_file
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+SHOW CREATE TABLE performance_schema.processlist;
+
+SET GLOBAL performance_schema_show_processlist = 'OFF';
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SELECT * FROM performance_schema.processlist;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SHOW PROCESSLIST;
+
+SET GLOBAL performance_schema_show_processlist = 'ON';
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SELECT * FROM performance_schema.processlist;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
+
+--replace_column 3 [HOST:PORT] 6 [TIME]
+SHOW PROCESSLIST;
+
+# Cleanup
+
+SET GLOBAL performance_schema_show_processlist = 'OFF';
+
diff --git a/mysql-test/suite/perfschema/t/processlist_acl-master.opt b/mysql-test/suite/perfschema/t/processlist_acl-master.opt
new file mode 100644
index 00000000..f93413a6
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/processlist_acl-master.opt
@@ -0,0 +1 @@
+--event-scheduler
diff --git a/mysql-test/suite/perfschema/t/processlist_acl.test b/mysql-test/suite/perfschema/t/processlist_acl.test
new file mode 100644
index 00000000..f0733865
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/processlist_acl.test
@@ -0,0 +1,196 @@
+--echo ##
+--echo ## Test the Performance Schema-based implementation of SHOW PROCESSLIST.
+--echo ##
+--echo ## Verify handling of the SELECT and PROCESS privileges.
+--echo ##
+--echo ## Test cases:
+--echo ## - Execute SHOW PROCESSLIST (new and legacy) with all privileges
+--echo ## - Execute SELECT on the performance_schema.processlist and information_schema.processlist with all privileges
+--echo ## - Execute SHOW PROCESSLIST (new and legacy) with no privileges
+--echo ## - Execute SELECT on the performance_schema.processlist and information_schema.processlist with no privileges
+--echo ##
+--echo ## Results must be manually verified.
+--echo
+
+--source include/no_protocol.inc
+--source include/not_embedded.inc
+
+--echo ### Setup ###
+--echo
+select @@global.performance_schema_show_processlist into @save_processlist;
+
+--echo
+--echo # Control users
+create user user_00@localhost, user_01@localhost;
+grant ALL on *.* to user_00@localhost;
+grant ALL on *.* to user_01@localhost;
+
+--echo
+--echo # Test users
+create user user_all@localhost, user_none@localhost;
+grant ALL on *.* to user_all@localhost;
+grant USAGE on *.* to user_none@localhost;
+--echo
+flush privileges;
+
+--echo
+show grants for user_all@localhost;
+--echo
+show grants for user_none@localhost;
+
+--echo
+use test;
+create table test.t1 (s1 int, s2 int, s3 int, s4 int);
+
+--echo
+--echo # Connect (con_00, localhost, user_00, , )
+connect (con_00, localhost, user_00, , );
+
+--echo # Connect (con_01, localhost, user_01, , )
+connect (con_01, localhost, user_01, , );
+--echo
+insert into test.t1 values(1, 1, 1, 1);
+insert into test.t1 values(2, 2, 2, 2);
+insert into test.t1 values(3, 3, 3, 3);
+insert into test.t1 values(4, 4, 4, 4);
+
+--echo
+--echo # Lock test.t1, insert/update/deletes will block
+lock tables t1 read;
+
+--echo
+--echo # Establish 2 connections for user_all
+--echo # Connect (con_all_1, localhost, user_all, , )
+connect (con_all_1, localhost, user_all, , );
+
+--echo # Connect (con_all_2, localhost, user_all, , )
+connect (con_all_2, localhost, user_all, , );
+--send insert into test.t1 values (0, 0, 0, 0)
+
+--echo
+--echo # Establish 4 connections for user_none
+--echo # Connect (con_none_1, localhost, user_none, , )
+connect (con_none_1, localhost, user_none, , );
+
+--echo # Connect (con_none_2, localhost, user_none, , )
+connect (con_none_2, localhost, user_none, , );
+
+--echo # Connect (con_none_3, localhost, user_none, , )
+connect (con_none_3, localhost, user_none, , );
+
+--echo # Connect (con_none_4, localhost, user_none, , )
+connect (con_none_4, localhost, user_none, , );
+--send update test.t1 set s1 = s1 + 1, s2 = s2 + 2;
+
+--echo
+--echo # Connection con_all_1
+--connection con_all_1
+
+# Note: When expecting processlist results for all users, the wait_condition
+# and subsequent execution of SHOW PROCESSLIST should be conducted from the
+# same connection to ensure consistent values in the Command and Info columns.
+
+--echo
+--echo # Wait for queries to appear in the processlist table
+let $wait_condition = select count(*) >= 2 from information_schema.processlist
+ where state like '%metadata%';
+--source include/wait_condition.inc
+
+--echo
+--echo ### Execute SHOW PROCESSLIST with all privileges
+--echo ### Expect all users
+--echo
+--echo # New SHOW PROCESSLIST
+let $pfs_spl = on;
+--source ../include/processlist_set.inc
+--source ../include/processlist_load.inc
+
+--echo
+--echo # Legacy SHOW PROCESSLIST
+let $pfs_spl = off;
+--source ../include/processlist_set.inc
+--source ../include/processlist_load.inc
+
+--echo
+--echo
+--echo ### Execute SHOW PROCESSLIST with no SELECT and no PROCESS privileges
+--echo ### Expect processes only from user_none
+--echo
+--echo # New SHOW PROCESSLIST
+let $pfs_spl = on;
+--source ../include/processlist_set.inc
+
+--echo
+--echo # Connection con_none_1
+--connection con_none_1
+--source ../include/processlist_load.inc
+
+--echo
+--echo # Confirm that only processes from user_none are visible
+--echo
+select count(*) as "Expect 0" from performance_schema.processlist
+ where user not in ('user_none');
+
+--echo
+--echo # Legacy SHOW PROCESSLIST
+--connection con_00
+let $pfs_spl = off;
+--source ../include/processlist_set.inc
+
+--echo
+--echo # Connection con_none_1
+--connection con_none_1
+--source ../include/processlist_load.inc
+
+--echo
+--echo
+--echo ### Clean up ###
+--echo
+
+--echo # Disconnect con_00
+--connection con_00
+--disconnect con_00
+
+--echo # Connection con_01, unlock test.t1, disconnect
+--connection con_01
+unlock tables;
+--disconnect con_01
+
+--echo # Disconnect con_all_1
+--connection con_all_1
+--disconnect con_all_1
+
+--echo # Reap con_all_2, disconnect
+--connection con_all_2
+--reap
+--disconnect con_all_2
+
+--echo # Disconnect con_none_1
+--connection con_none_1
+--disconnect con_none_1
+
+--echo # Disconnect con_none_2
+--connection con_none_2
+--disconnect con_none_2
+
+--echo # Disconnect con_none_3
+--connection con_none_3
+--disconnect con_none_3
+
+--echo # Reap con_none_4, disconnect
+--connection con_none_4
+--reap
+--disconnect con_none_4
+
+--echo
+--echo # Connection default
+--connection default
+
+--echo
+drop table test.t1;
+drop user user_00@localhost;
+drop user user_01@localhost;
+drop user user_all@localhost;
+drop user user_none@localhost;
+--echo
+set @@global.performance_schema_show_processlist = @save_processlist;
diff --git a/mysql-test/suite/perfschema/t/processlist_anonymous.test b/mysql-test/suite/perfschema/t/processlist_anonymous.test
new file mode 100644
index 00000000..4b8e7ec2
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/processlist_anonymous.test
@@ -0,0 +1,111 @@
+--echo ##
+--echo ## Test the Performance Schema-based implementation of SHOW PROCESSLIST.
+--echo ## Verify behavior for anonymous users and PROCESS_ACL.
+--echo ##
+
+--source include/no_protocol.inc
+--source include/not_embedded.inc
+
+SELECT @@global.performance_schema_show_processlist INTO @save_processlist;
+
+--source include/add_anonymous_users.inc
+
+SET @@global.performance_schema_show_processlist = OFF;
+
+connect (anon,localhost,test,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+
+SHOW GRANTS;
+
+# Empty
+SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
+
+# Empty
+SELECT * FROM performance_schema.processlist;
+
+--error ER_SPECIFIC_ACCESS_DENIED_ERROR
+SHOW PROCESSLIST;
+
+connection default;
+
+SET @@global.performance_schema_show_processlist = ON;
+
+connection anon;
+
+SHOW GRANTS;
+
+# Empty
+SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
+
+# Empty
+SELECT * FROM performance_schema.processlist;
+
+--error ER_SPECIFIC_ACCESS_DENIED_ERROR
+SHOW PROCESSLIST;
+
+disconnect anon;
+connection default;
+
+GRANT PROCESS ON *.* TO ''@'localhost';
+
+SET @@global.performance_schema_show_processlist = OFF;
+
+connect (anon2,localhost,test,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+
+SHOW GRANTS;
+
+# Full rows
+SELECT count(*) >= 2 FROM INFORMATION_SCHEMA.PROCESSLIST;
+
+# Full rows
+SELECT count(*) >= 2 FROM performance_schema.processlist;
+
+# Full rows
+--disable_result_log
+SHOW PROCESSLIST;
+--enable_result_log
+
+SELECT "Previous statement is now completed." as status;
+
+connection default;
+# Returns ROWS_SENT = 0 even when SHOW PROCESSLIST has rows
+SELECT EVENT_NAME, SQL_TEXT, ROWS_SENT as BROKEN_ROWS_SENT
+ FROM performance_schema.events_statements_history
+ WHERE SQL_TEXT = "SHOW PROCESSLIST";
+connection anon2;
+
+
+connection default;
+
+TRUNCATE TABLE performance_schema.events_statements_history;
+set @@global.performance_schema_show_processlist = ON;
+
+
+connection anon2;
+
+SHOW GRANTS;
+
+# Full rows
+SELECT count(*) >= 2 FROM INFORMATION_SCHEMA.PROCESSLIST;
+
+# Full rows
+SELECT count(*) >= 2 FROM performance_schema.processlist;
+
+# Full rows
+--disable_result_log
+SHOW PROCESSLIST;
+--enable_result_log
+
+SELECT "Previous statement is now completed." as status;
+
+connection default;
+SELECT EVENT_NAME, SQL_TEXT, ROWS_SENT >= 2
+ FROM performance_schema.events_statements_history
+ WHERE SQL_TEXT = "SHOW PROCESSLIST";
+
+disconnect anon2;
+connection default;
+
+--source include/delete_anonymous_users.inc
+
+SET @@global.performance_schema_show_processlist = @save_processlist;
+
diff --git a/mysql-test/suite/perfschema/t/processlist_no_pfs-master.opt b/mysql-test/suite/perfschema/t/processlist_no_pfs-master.opt
new file mode 100644
index 00000000..6fb075f6
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/processlist_no_pfs-master.opt
@@ -0,0 +1,2 @@
+--loose-disable-performance-schema
+--loose-performance-schema-show-processlist=ON
diff --git a/mysql-test/suite/perfschema/t/processlist_no_pfs.test b/mysql-test/suite/perfschema/t/processlist_no_pfs.test
new file mode 100644
index 00000000..273e180a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/processlist_no_pfs.test
@@ -0,0 +1,29 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+
+--source ../include/start_server_common.inc
+
+--echo
+select * from information_schema.engines
+ where engine = "PERFORMANCE_SCHEMA";
+
+--echo
+--echo # If the Performance Schema is disabled, then expect
+--echo # performance-schema-show-processlist = OFF
+--echo # regardless of its initial setting
+--echo
+select @@global.performance_schema_show_processlist;
+
+--echo
+--echo # If the Performance Schema is disabled, then setting
+--echo # performance-schema-show-processlist = ON
+--echo # succeeds, SHOW PROCESSLIST returns no data.
+--echo
+set @@global.performance_schema_show_processlist = ON;
+
+SHOW PROCESSLIST;
+
+--echo
+show global variables like "performance_schema";
+
diff --git a/mysql-test/suite/perfschema/t/processlist_port-master.opt b/mysql-test/suite/perfschema/t/processlist_port-master.opt
new file mode 100644
index 00000000..f93413a6
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/processlist_port-master.opt
@@ -0,0 +1 @@
+--event-scheduler
diff --git a/mysql-test/suite/perfschema/t/processlist_port.test b/mysql-test/suite/perfschema/t/processlist_port.test
new file mode 100644
index 00000000..8403b0c7
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/processlist_port.test
@@ -0,0 +1,162 @@
+--echo ##
+--echo ## Test the Performance Schema-based implementation of SHOW PROCESSLIST.
+--echo ##
+--echo ## Verify the Host field (hostname:port) against the legacy implementation.
+--echo ##
+
+--source include/no_protocol.inc
+--source include/not_embedded.inc
+
+--echo
+--echo ### Setup ###
+--echo
+select @@global.performance_schema_show_processlist into @save_processlist;
+
+--echo
+--echo # Control user
+create user user0@localhost;
+grant ALL on *.* to user0@localhost;
+
+--echo # Test users
+--echo
+create user user1@localhost, user2@localhost,
+ user3@localhost, user4@localhost;
+--echo
+# Grant no privileges to user1 to ensure only one process
+grant USAGE on *.* to user1@localhost;
+grant ALL on *.* to user2@localhost;
+grant ALL on *.* to user3@localhost;
+grant ALL on *.* to user4@localhost;
+--echo
+flush privileges;
+--echo
+show grants for user1@localhost;
+
+--echo
+--echo # Connect (con_user0, 127.0.0.1, user0, , , MASTER_MYPORT, )
+connect (con_user0, 127.0.0.1, user0, , , $MASTER_MYPORT, );
+--echo
+select connection_id() into @con_user0_id;
+
+--echo # Connect (con_user1, 127.0.0.1, user1, , , MASTER_MYPORT, )
+connect (con_user1, 127.0.0.1, user1, , , $MASTER_MYPORT, );
+
+--echo # Connect (con_user2, 127.0.0.1, user2, , , MASTER_MYPORT, )
+connect (con_user2, 127.0.0.1, user2, , , $MASTER_MYPORT, );
+
+--echo # Connect (con_user3, 127.0.0.1, user3, , , MASTER_MYPORT, )
+connect (con_user3, 127.0.0.1, user3, , , $MASTER_MYPORT, );
+
+--echo # Connect (con_user4, 127.0.0.1, user4, , , MASTER_MYPORT, )
+connect (con_user4, 127.0.0.1, user4, , , $MASTER_MYPORT, );
+
+--echo # Connection user0
+--connection con_user0
+let $wait_condition = select connection_id() = @con_user0_id;
+--source include/wait_condition.inc
+
+--echo
+--echo ### Compare the SHOW PROCESSLIST Host column between the new and old implementations
+--echo
+--echo ## New SHOW PROCESSLIST
+let $pfs_spl = on;
+--source ../include/processlist_set.inc
+--source ../include/processlist_load.inc
+
+--echo
+--echo # Connection user1
+--connection con_user1
+
+--echo # Get Host:Port, new
+let $host_new = query_get_value(SHOW FULL PROCESSLIST, Host, 1);
+
+--echo
+--echo ## Legacy SHOW PROCESSLIST
+--connection con_user0
+let $pfs_spl = off;
+--source ../include/processlist_set.inc
+--source ../include/processlist_load.inc
+
+--echo
+--echo # Connection user1
+--connection con_user1
+
+--echo # Get Host:Port, legacy
+let $host_old = query_get_value(SHOW FULL PROCESSLIST, Host, 1);
+
+--echo
+
+## DEBUG ONLY
+## --echo DEBUG: New: $host_new Old: $host_old
+
+if ($host_new == $host_old)
+{
+ --echo ***SUCCESS*** The SHOW PROCESSLIST Host fields match
+}
+
+if ($host_new != $host_old)
+{
+ --echo ***ERROR*** SHOW PROCESSLIST Host fields do not match. New: $host_new Old: $host_old
+}
+
+--echo
+--echo ### Compare the processlist Host column between Performance Schema and the Information Schema
+--echo
+--echo # Connection con_user0
+--connection con_user0
+let $count_new = `select count(*) from performance_schema.processlist`;
+let $count_old = `select count(*) from information_schema.processlist`;
+let $count_join = `select count(*) from performance_schema.processlist pspl
+ left join information_schema.processlist ispl on pspl.host = ispl.host and pspl.id = ispl.id`;
+
+--echo
+
+if ($count_old == $count_join)
+{
+ --echo ***SUCCESS*** The processlist Host fields match between the Performance Schema and the Information Schema
+}
+
+if ($count_old != $count_join)
+{
+ --echo ***ERROR*** The processlist Host fields do not match
+ --echo Count new: $count_new Count old: $count_old Count join: $count_join
+ --echo
+ select * from performance_schema.processlist order by host, id;
+ --echo
+ select * from information_schema.processlist order by host, id;
+ --echo
+ select * from performance_schema.processlist pspl
+ left join information_schema.processlist ispl on pspl.host = ispl.host and pspl.id = ispl.id;
+}
+
+--echo
+--echo
+--echo ### Clean up ###
+--echo
+
+--echo # Disconnect con_user0
+--connection con_user0
+--disconnect con_user0
+--echo # Disconnect con_user1
+--connection con_user1
+--disconnect con_user1
+--echo # Disconnect con_user2
+--connection con_user2
+--disconnect con_user2
+--echo # Disconnect con_user3
+--connection con_user3
+--disconnect con_user3
+--echo # Disconnect con_user4
+--connection con_user4
+--disconnect con_user4
+
+--echo # Connection default
+--connection default
+--echo
+drop user user0@localhost;
+drop user user1@localhost;
+drop user user2@localhost;
+drop user user3@localhost;
+drop user user4@localhost;
+--echo
+set @@global.performance_schema_show_processlist = @save_processlist;
diff --git a/mysql-test/suite/perfschema/t/processlist_reg_user.test b/mysql-test/suite/perfschema/t/processlist_reg_user.test
new file mode 100644
index 00000000..53dc8abf
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/processlist_reg_user.test
@@ -0,0 +1,134 @@
+--echo ##
+--echo ## Test the Performance Schema-based implementation of SHOW PROCESSLIST.
+--echo ## Verify behavior for regular users and PROCESS_ACL.
+--echo ##
+
+--source include/no_protocol.inc
+--source include/not_embedded.inc
+
+SELECT @@global.performance_schema_show_processlist INTO @save_processlist;
+
+--source include/add_anonymous_users.inc
+
+SET @@global.performance_schema_show_processlist = OFF;
+
+CREATE USER 'regular'@'localhost';
+
+connect (reg,localhost,regular,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+
+SHOW GRANTS;
+
+# Self rows only
+SELECT USER, INFO FROM INFORMATION_SCHEMA.PROCESSLIST;
+
+# Self rows only
+SELECT USER, INFO FROM performance_schema.processlist;
+
+# Self rows only
+--disable_result_log
+SHOW PROCESSLIST;
+--enable_result_log
+
+SELECT "Previous statement is now completed." as status;
+
+connection default;
+
+# Returns ROWS_SENT = 0 even when SHOW PROCESSLIST has rows
+SELECT EVENT_NAME, SQL_TEXT, ROWS_SENT as BROKEN_ROWS_SENT
+ FROM performance_schema.events_statements_history
+ WHERE SQL_TEXT = "SHOW PROCESSLIST";
+
+TRUNCATE TABLE performance_schema.events_statements_history;
+SET @@global.performance_schema_show_processlist = ON;
+
+connection reg;
+
+SHOW GRANTS;
+
+# Self rows only
+SELECT USER, INFO FROM INFORMATION_SCHEMA.PROCESSLIST;
+
+# Self rows only
+SELECT USER, INFO FROM performance_schema.processlist;
+
+# Self rows only
+--disable_result_log
+SHOW PROCESSLIST;
+--enable_result_log
+
+SELECT "Previous statement is now completed." as status;
+
+connection default;
+
+SELECT EVENT_NAME, SQL_TEXT, ROWS_SENT
+ FROM performance_schema.events_statements_history
+ WHERE SQL_TEXT = "SHOW PROCESSLIST";
+
+TRUNCATE TABLE performance_schema.events_statements_history;
+
+disconnect reg;
+
+GRANT PROCESS ON *.* TO 'regular'@'localhost';
+
+SET @@global.performance_schema_show_processlist = OFF;
+
+connect (reg2,localhost,regular,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+
+SHOW GRANTS;
+
+# Full rows
+SELECT count(*) >= 2 FROM INFORMATION_SCHEMA.PROCESSLIST;
+
+# Full rows
+SELECT count(*) >= 2 FROM performance_schema.processlist;
+
+# Full rows
+--disable_result_log
+SHOW PROCESSLIST;
+--enable_result_log
+
+SELECT "Previous statement is now completed." as status;
+
+connection default;
+
+# Returns ROWS_SENT = 0 even when SHOW PROCESSLIST has rows
+SELECT EVENT_NAME, SQL_TEXT, ROWS_SENT as BROKEN_ROWS_SENT
+ FROM performance_schema.events_statements_history
+ WHERE SQL_TEXT = "SHOW PROCESSLIST";
+
+TRUNCATE TABLE performance_schema.events_statements_history;
+SET @@global.performance_schema_show_processlist = ON;
+
+connection reg2;
+
+SHOW GRANTS;
+
+# Full rows
+SELECT count(*) >= 2 FROM INFORMATION_SCHEMA.PROCESSLIST;
+
+# Full rows
+SELECT count(*) >= 2 FROM performance_schema.processlist;
+
+# Full rows
+--disable_result_log
+SHOW PROCESSLIST;
+--enable_result_log
+
+SELECT "Previous statement is now completed." as status;
+
+connection default;
+
+SELECT EVENT_NAME, SQL_TEXT, ROWS_SENT >= 2
+ FROM performance_schema.events_statements_history
+ WHERE SQL_TEXT = "SHOW PROCESSLIST";
+
+TRUNCATE TABLE performance_schema.events_statements_history;
+
+disconnect reg2;
+
+--source include/delete_anonymous_users.inc
+
+SET @@global.performance_schema_show_processlist = @save_processlist;
+
+DROP USER 'regular'@'localhost';
+
diff --git a/mysql-test/suite/perfschema/t/query_cache-master.opt b/mysql-test/suite/perfschema/t/query_cache-master.opt
new file mode 100644
index 00000000..a00258bc
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/query_cache-master.opt
@@ -0,0 +1 @@
+--query_cache_type=1
diff --git a/mysql-test/suite/perfschema/t/query_cache.test b/mysql-test/suite/perfschema/t/query_cache.test
new file mode 100644
index 00000000..045c4628
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/query_cache.test
@@ -0,0 +1,61 @@
+# Tests for PERFORMANCE_SCHEMA
+
+# This test verifies that performance schema tables, because they contain
+# data that is volatile, are never cached in the query cache.
+
+--source include/have_query_cache.inc
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+set @save_query_cache_size=@@query_cache_size;
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 (a int not null);
+insert into t1 values (1), (2), (3);
+
+SET GLOBAL query_cache_size=1355776;
+
+flush query cache;
+reset query cache;
+flush status;
+
+--disable_ps2_protocol
+select * from t1;
+
+show global status like "Qcache_queries_in_cache";
+show global status like "Qcache_inserts";
+show global status like "Qcache_hits";
+
+select * from t1;
+
+show global status like "Qcache_queries_in_cache";
+show global status like "Qcache_inserts";
+show global status like "Qcache_hits";
+
+select spins from performance_schema.events_waits_current order by event_name limit 1;
+
+--replace_result CYCLE {CYCLE_OR_NANOSECOND} NANOSECOND {CYCLE_OR_NANOSECOND}
+select * from performance_schema.setup_timers where name='wait';
+
+show global status like "Qcache_queries_in_cache";
+show global status like "Qcache_inserts";
+show global status like "Qcache_hits";
+
+select spins from performance_schema.events_waits_current order by event_name limit 1;
+
+--replace_result CYCLE {CYCLE_OR_NANOSECOND} NANOSECOND {CYCLE_OR_NANOSECOND}
+select * from performance_schema.setup_timers where name='wait';
+--enable_ps2_protocol
+
+show global status like "Qcache_queries_in_cache";
+show global status like "Qcache_inserts";
+show global status like "Qcache_hits";
+
+SET GLOBAL query_cache_size=@save_query_cache_size;
+
+drop table t1;
+flush status;
+
diff --git a/mysql-test/suite/perfschema/t/read_only.test b/mysql-test/suite/perfschema/t/read_only.test
new file mode 100644
index 00000000..4cbaad0d
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/read_only.test
@@ -0,0 +1,77 @@
+# Tests for PERFORMANCE_SCHEMA
+#
+# Check that
+# - a regular user can not update setup_ tables under --read-only
+# - a user with SUPER privileges can
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--enable_connect_log
+
+use performance_schema;
+
+set @start_read_only= @@global.read_only;
+
+create user pfsuser@localhost;
+grant SELECT, UPDATE on performance_schema.* to pfsuser@localhost;
+flush privileges;
+
+connect (con1, localhost, pfsuser, ,"*NO-ONE*");
+
+connection default;
+
+set global read_only=0;
+
+connection con1;
+
+select @@global.read_only;
+show grants;
+--disable_result_log
+--echo # Update on perf_schema is allowed in read_only mode.
+select * from performance_schema.setup_instruments;
+update performance_schema.setup_instruments set enabled='NO';
+update performance_schema.setup_instruments set enabled='YES';
+--enable_result_log
+
+connection default;
+
+set global read_only=1;
+
+connection con1;
+
+select @@global.read_only;
+show grants;
+--disable_result_log
+select * from performance_schema.setup_instruments;
+--error ER_OPTION_PREVENTS_STATEMENT
+update performance_schema.setup_instruments set enabled='NO';
+--error ER_OPTION_PREVENTS_STATEMENT
+update performance_schema.setup_instruments set enabled='YES';
+--enable_result_log
+
+connection default;
+
+grant READ_ONLY ADMIN on *.* to pfsuser@localhost;
+flush privileges;
+
+disconnect con1;
+connect (con1, localhost, pfsuser, ,"*NO-ONE*");
+
+select @@global.read_only;
+show grants;
+--disable_result_log
+select * from performance_schema.setup_instruments;
+update performance_schema.setup_instruments set enabled='NO';
+update performance_schema.setup_instruments set enabled='YES';
+--enable_result_log
+
+disconnect con1;
+--source include/wait_until_disconnected.inc
+
+connection default;
+
+set global read_only= @start_read_only;
+
+drop user pfsuser@localhost;
+flush privileges;
+
diff --git a/mysql-test/suite/perfschema/t/relaylog.test b/mysql-test/suite/perfschema/t/relaylog.test
new file mode 100644
index 00000000..12fc96a8
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/relaylog.test
@@ -0,0 +1,180 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/have_log_bin.inc
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/master-slave.inc
+
+--disable_warnings
+drop table if exists test.t1;
+--sync_slave_with_master
+reset master;
+--enable_warnings
+
+create table test.t1(a int);
+drop table test.t1;
+
+--source include/show_binlog_events.inc
+
+# Notes
+#
+# The point of this test is to make sure code is properly instrumented,
+# where instruments have the proper key (binlog or relaylog),
+# it is not to dive into statistics for each instruments.
+# Different test execution sequence in different platforms do make the
+# results vary, making the test results very sensitive to changes.
+# To ensure robustness:
+# - log file rotation is limited to file .000001 and .000002
+# - statistics are normalized to "NONE" or "MANY"
+# - statistics on ::update_cond conditions are not collected,
+# since this is too much dependent on execution.
+# - statistics on COND_binlog_background_thread and COND_xid_list are not
+# collected, as they depend on exact timing for background binlog
+# checkpointing operations.
+#
+
+connection master;
+
+select
+ substring(file_name, locate("master-", file_name)) as FILE_NAME,
+ EVENT_NAME,
+ if (count_read > 0, "MANY", "NONE") as COUNT_READ,
+ if (count_write > 0,"MANY", "NONE") as COUNT_WRITE,
+ if (sum_number_of_bytes_read > 0, "MANY", "NONE") as SUM_NUMBER_OF_BYTES_READ,
+ if (sum_number_of_bytes_write > 0, "MANY", "NONE") as SUM_NUMBER_OF_BYTES_WRITE
+ from performance_schema.file_summary_by_instance
+ where file_name like "%master-%" order by file_name;
+
+select * from performance_schema.file_summary_by_instance
+ where file_name like "%slave-%" order by file_name;
+
+-- echo "Expect a master binlog + binlog_index"
+
+select
+ substring(file_name, locate("master-", file_name)) as FILE_NAME,
+ EVENT_NAME,
+ if (count_read > 0, "MANY", "NONE") as COUNT_READ,
+ if (count_write > 0,"MANY", "NONE") as COUNT_WRITE,
+ if (sum_number_of_bytes_read > 0, "MANY", "NONE") as SUM_NUMBER_OF_BYTES_READ,
+ if (sum_number_of_bytes_write > 0, "MANY", "NONE") as SUM_NUMBER_OF_BYTES_WRITE
+ from performance_schema.file_summary_by_instance
+ where event_name like "%binlog%" order by file_name;
+
+select
+ EVENT_NAME,
+ if (count_read > 0, "MANY", "NONE") as COUNT_READ,
+ if (count_write > 0,"MANY", "NONE") as COUNT_WRITE,
+ if (sum_number_of_bytes_read > 0, "MANY", "NONE") as SUM_NUMBER_OF_BYTES_READ,
+ if (sum_number_of_bytes_write > 0, "MANY", "NONE") as SUM_NUMBER_OF_BYTES_WRITE
+ from performance_schema.file_summary_by_event_name
+ where event_name like "%binlog%" order by event_name;
+
+select
+ EVENT_NAME,
+ if (count_star > 0, "MANY", "NONE") as COUNT_STAR
+ from performance_schema.events_waits_summary_global_by_event_name
+ where event_name like "%MYSQL_BIN_LOG%"
+ and event_name not like "%MYSQL_BIN_LOG::update_cond"
+ and event_name not like "%MYSQL_BIN_LOG::COND_binlog_background_thread%"
+ and event_name not like "%MYSQL_BIN_LOG::COND_xid_list"
+ order by event_name;
+
+-- echo "Expect no slave relay log"
+
+select * from performance_schema.file_summary_by_instance
+ where event_name like "%relaylog%" order by file_name;
+
+select * from performance_schema.file_summary_by_event_name
+ where event_name like "%relaylog%" order by event_name;
+
+select * from performance_schema.events_waits_summary_global_by_event_name
+ where event_name like "%MYSQL_RELAY_LOG%"
+ and event_name not like "%MYSQL_RELAY_LOG::update_cond"
+ order by event_name;
+
+sync_slave_with_master;
+-- echo "============ Performance schema on slave ============"
+
+select * from performance_schema.file_summary_by_instance
+ where file_name like "%master-%" order by file_name;
+
+select
+ substring(file_name, locate("slave-", file_name)) as FILE_NAME,
+ EVENT_NAME,
+ if (count_read > 0, "MANY", "NONE") as COUNT_READ,
+ if (count_write > 0,"MANY", "NONE") as COUNT_WRITE,
+ if (sum_number_of_bytes_read > 0, "MANY", "NONE") as SUM_NUMBER_OF_BYTES_READ,
+ if (sum_number_of_bytes_write > 0, "MANY", "NONE") as SUM_NUMBER_OF_BYTES_WRITE
+ from performance_schema.file_summary_by_instance
+ where file_name like "%slave-%"
+ and (file_name not like "%slave-relay-bin.0%"
+ or file_name like "%slave-relay-bin.000001"
+ or file_name like "%slave-relay-bin.000002")
+ order by file_name;
+
+-- echo "Expect a slave binlog + binlog_index"
+
+select
+ substring(file_name, locate("slave-", file_name)) as FILE_NAME,
+ EVENT_NAME,
+ if (count_read > 0, "MANY", "NONE") as COUNT_READ,
+ if (count_write > 0,"MANY", "NONE") as COUNT_WRITE,
+ if (sum_number_of_bytes_read > 0, "MANY", "NONE") as SUM_NUMBER_OF_BYTES_READ,
+ if (sum_number_of_bytes_write > 0, "MANY", "NONE") as SUM_NUMBER_OF_BYTES_WRITE
+ from performance_schema.file_summary_by_instance
+ where event_name like "%binlog%" order by file_name;
+
+select
+ EVENT_NAME,
+ if (count_read > 0, "MANY", "NONE") as COUNT_READ,
+ if (count_write > 0,"MANY", "NONE") as COUNT_WRITE,
+ if (sum_number_of_bytes_read > 0, "MANY", "NONE") as SUM_NUMBER_OF_BYTES_READ,
+ if (sum_number_of_bytes_write > 0, "MANY", "NONE") as SUM_NUMBER_OF_BYTES_WRITE
+ from performance_schema.file_summary_by_event_name
+ where event_name like "%binlog%" order by event_name;
+
+select
+ EVENT_NAME,
+ if (count_star > 0, "MANY", "NONE") as COUNT_STAR
+ from performance_schema.events_waits_summary_global_by_event_name
+ where event_name like "%MYSQL_BIN_LOG%"
+ and event_name not like "%MYSQL_BIN_LOG::update_cond"
+ and event_name not like "%MYSQL_BIN_LOG::COND_binlog_background_thread%"
+ and event_name not like "%MYSQL_BIN_LOG::COND_xid_list"
+ order by event_name;
+
+-- echo "Expect a slave relay log"
+
+select
+ substring(file_name, locate("slave-", file_name)) as FILE_NAME,
+ EVENT_NAME,
+ if (count_read > 0, "MANY", "NONE") as COUNT_READ,
+ if (count_write > 0,"MANY", "NONE") as COUNT_WRITE,
+ if (sum_number_of_bytes_read > 0, "MANY", "NONE") as SUM_NUMBER_OF_BYTES_READ,
+ if (sum_number_of_bytes_write > 0, "MANY", "NONE") as SUM_NUMBER_OF_BYTES_WRITE
+ from performance_schema.file_summary_by_instance
+ where event_name like "%relaylog%"
+ and (file_name not like "%slave-relay-bin.0%"
+ or file_name like "%slave-relay-bin.000001"
+ or file_name like "%slave-relay-bin.000002")
+ order by file_name;
+
+select
+ EVENT_NAME,
+ if (count_read > 0, "MANY", "NONE") as COUNT_READ,
+ if (count_write > 0,"MANY", "NONE") as COUNT_WRITE,
+ if (sum_number_of_bytes_read > 0, "MANY", "NONE") as SUM_NUMBER_OF_BYTES_READ,
+ if (sum_number_of_bytes_write > 0, "MANY", "NONE") as SUM_NUMBER_OF_BYTES_WRITE
+ from performance_schema.file_summary_by_event_name
+ where event_name like "%relaylog%" order by event_name;
+
+select
+ EVENT_NAME,
+ if (count_star > 0, "MANY", "NONE") as COUNT_STAR
+ from performance_schema.events_waits_summary_global_by_event_name
+ where event_name like "%MYSQL_RELAY_LOG%"
+ and event_name not like "%MYSQL_RELAY_LOG::update_cond"
+ order by event_name;
+
+--source include/stop_slave.inc
+
diff --git a/mysql-test/suite/perfschema/t/rollback_table_io.test b/mysql-test/suite/perfschema/t/rollback_table_io.test
new file mode 100644
index 00000000..67d7e4ca
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/rollback_table_io.test
@@ -0,0 +1,48 @@
+# Tests for PERFORMANCE_SCHEMA table io
+# Show the impact of a rollback in case of the transactional engine InnoDB
+
+# Setup
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/have_innodb.inc
+
+--disable_warnings
+drop table if exists test.t1;
+--enable_warnings
+
+let $engine_type= InnoDB;
+eval create table test.t1 (col1 bigint, col2 varchar(30)) engine = $engine_type;
+show create table test.t1;
+insert into test.t1 values(1,'One');
+eval set default_storage_engine=$engine_type;
+
+--source ../include/table_io_setup_helper.inc
+let $schema_to_dump= 'test';
+
+# Start recording of events
+update performance_schema.setup_consumers set enabled = 'YES';
+
+set autocommit = off;
+
+# Code to test
+
+delete from test.t1 where col1 = 1;
+insert into marker set a = 1;
+rollback;
+insert into marker set a = 1;
+update test.t1 set col2 = 'Updated' where col1 = 1;
+insert into marker set a = 1;
+rollback;
+insert into marker set a = 1;
+insert into test.t1 values(2,'Two');
+insert into marker set a = 1;
+rollback;
+
+# Stop recording of events + pull results
+--source ../include/table_io_result_helper.inc
+
+# Cleanup
+drop table test.t1;
+--source ../include/table_io_cleanup_helper.inc
+
diff --git a/mysql-test/suite/perfschema/t/rpl_group_member_stats.test b/mysql-test/suite/perfschema/t/rpl_group_member_stats.test
new file mode 100644
index 00000000..256c6a69
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/rpl_group_member_stats.test
@@ -0,0 +1,48 @@
+# WL#6839 - GCS Replication: P_S table to show DBSM stats
+#
+# This test proofs the existence of the replication_group_member_stats table
+# and all its fields. Since the table only returns values if the plugin is
+# loaded, all queries will return "No such row" or "0"
+#
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--let $member_id= query_get_value(SELECT Member_Id from performance_schema.replication_group_member_stats, Member_Id, 1)
+--let $assert_text= The value of member_id should not be present
+--let $assert_cond= "$member_id" = "No such row"
+--source include/assert.inc
+
+--let $view_id= query_get_value(SELECT View_Id from performance_schema.replication_group_member_stats, View_Id, 1)
+--let $assert_text= The value of view_id should not be present
+--let $assert_cond= "$View_Id" = "No such row"
+--source include/assert.inc
+
+--let $transaction_in_queue= query_get_value(SELECT Count_Transactions_in_queue from performance_schema.replication_group_member_stats, Count_Transactions_in_queue, 1)
+--let $assert_text= The value of Count_Transactions_in_queue should be 0
+--let $assert_cond= "$transaction_in_queue" = 0
+--source include/assert.inc
+
+--let $certified_transactions= query_get_value(SELECT Count_Transactions_checked from performance_schema.replication_group_member_stats, Count_Transactions_checked, 1)
+--let $assert_text= The value of Count_Transactions_checked should be 0
+--let $assert_cond= "$certified_transactions" = 0
+--source include/assert.inc
+
+--let $negatively_certified= query_get_value(SELECT Count_conflicts_detected from performance_schema.replication_group_member_stats, Count_conflicts_detected, 1)
+--let $assert_text= The value of Count_conflicts_detected should be 0
+--let $assert_cond= "$negatively_certified" = 0
+--source include/assert.inc
+
+--let $certification_db_size= query_get_value(SELECT Count_Transactions_rows_validating from performance_schema.replication_group_member_stats, Count_Transactions_rows_validating, 1)
+--let $assert_text= The value of Count_Transactions_rows_validating should be 0
+--let $assert_cond= "$certification_db_size" = 0
+--source include/assert.inc
+
+--let $stable_set= query_get_value(SELECT Transactions_Committed_all_members from performance_schema.replication_group_member_stats, Transactions_Committed_all_members, 1)
+--let $assert_text= The value of Transactions_Committed_all_members should be 0
+--let $assert_cond= "$stable_set" = 0
+--source include/assert.inc
+
+--let $last_certified_transaction= query_get_value(SELECT Last_conflict_free_transaction from performance_schema.replication_group_member_stats, Last_conflict_free_transaction, 1)
+--let $assert_text= The value of Last_conflict_free_transaction should not be present
+--let $assert_cond= "$last_certified_transaction" = "No such row"
+--source include/assert.inc
diff --git a/mysql-test/suite/perfschema/t/rpl_group_members.test b/mysql-test/suite/perfschema/t/rpl_group_members.test
new file mode 100644
index 00000000..e5dfde74
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/rpl_group_members.test
@@ -0,0 +1,33 @@
+# WL#6841 - GCS Replication: P_S table to show GCS kernel stats
+#
+# This test proofs the existence of the replication_connection_status table
+# and all its fields. Since the table only returns values if the plugin is
+# loaded, all queries will return "No such row" or "0"
+#
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--let $channel_name= query_get_value(SELECT Channel_Name from performance_schema.replication_group_members, Channel_Name, 1)
+--let $assert_text= The value of channel name should be empty
+--let $assert_cond= "$channel_name" = "No such row"
+--source include/assert.inc
+
+--let $member_id= query_get_value(SELECT Member_Id from performance_schema.replication_group_members, Member_Id, 1)
+--let $assert_text= The value of member_id should be empty
+--let $assert_cond= "$member_id" = "No such row"
+--source include/assert.inc
+
+--let $member_host= query_get_value(SELECT Member_Host from performance_schema.replication_group_members, Member_Host, 1)
+--let $assert_text= The value of member_host should be empty
+--let $assert_cond= "$member_host" = "No such row"
+--source include/assert.inc
+
+--let $member_port= query_get_value(SELECT Member_Port from performance_schema.replication_group_members, Member_Port, 1)
+--let $assert_text= The value of member_port should be empty
+--let $assert_cond= "$member_port" = "No such row"
+--source include/assert.inc
+
+--let $member_state= query_get_value(SELECT Member_State from performance_schema.replication_group_members, Member_State, 1)
+--let $assert_text= The value of member_state should be empty
+--let $assert_cond= "$member_state" = "No such row"
+--source include/assert.inc
diff --git a/mysql-test/suite/perfschema/t/rpl_gtid_func.test b/mysql-test/suite/perfschema/t/rpl_gtid_func.test
new file mode 100644
index 00000000..ffa58b27
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/rpl_gtid_func.test
@@ -0,0 +1,86 @@
+--source include/not_embedded.inc
+--source include/have_innodb.inc
+--source include/have_perfschema.inc
+--source include/no_protocol.inc
+
+-- source include/master-slave.inc
+
+connection master;
+
+--disable_warnings
+drop table if exists test.marker;
+--enable_warnings
+
+create table test.marker(a int) engine=innodb;
+insert into test.marker values (1);
+select * from test.marker;
+
+truncate table performance_schema.events_waits_history_long;
+truncate table performance_schema.events_statements_summary_by_digest;
+
+update performance_schema.setup_instruments
+ set enabled='YES', timed='YES';
+
+sync_slave_with_master;
+
+truncate table performance_schema.events_waits_history_long;
+truncate table performance_schema.events_statements_summary_by_digest;
+
+update performance_schema.setup_instruments
+ set enabled='YES', timed='NO';
+
+connection master;
+
+select * from performance_schema.setup_instruments
+ where timed='NO' and name not like "memory/%";
+
+select "This better be in the master" as in_master_digest;
+
+insert into performance_schema.setup_objects
+ values ('TABLE', 'master', 'foo', 'YES', 'YES');
+
+select * from performance_schema.setup_objects
+ order by object_type, object_schema, object_name;
+
+select digest_text, count_star
+ from performance_schema.events_statements_summary_by_digest
+ where digest_text like "%in_%_digest%";
+
+insert into test.marker values (2);
+
+sync_slave_with_master;
+
+select * from test.marker;
+
+select * from performance_schema.setup_instruments
+ where timed='YES';
+
+select "This better be in the slave" as in_slave_digest;
+
+insert into performance_schema.setup_objects
+ values ('TABLE', 'slave', 'foo', 'YES', 'YES');
+
+select * from performance_schema.setup_objects
+ order by object_type, object_schema, object_name;
+
+select digest_text, count_star
+ from performance_schema.events_statements_summary_by_digest
+ where digest_text like "%in_%_digest%";
+
+connection master;
+delete from performance_schema.setup_objects
+ where object_schema='master';
+sync_slave_with_master;
+
+delete from performance_schema.setup_objects
+ where object_schema='slave';
+select * from performance_schema.setup_objects;
+
+--disable_query_log
+--disable_warnings
+connection master;
+drop table test.marker;
+sync_slave_with_master;
+--enable_warnings
+--enable_query_log
+--source include/rpl_end.inc
diff --git a/mysql-test/suite/perfschema/t/rpl_statements.test b/mysql-test/suite/perfschema/t/rpl_statements.test
new file mode 100644
index 00000000..c97cd619
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/rpl_statements.test
@@ -0,0 +1,313 @@
+#
+# Check statement instrumentation of replicated statements
+#
+--source include/not_embedded.inc
+--source include/have_innodb.inc
+--source include/have_perfschema.inc
+--source include/no_protocol.inc
+--source include/have_binlog_format_mixed.inc
+--source include/master-slave.inc
+
+#==============================================================
+# Execute a variety of dml and ddl statements on the master.
+# Verify that the corresponding statement events are generated
+# on the slave.
+#
+# 1. Setup test files on master
+# 2. Replicate test files to slave
+# 3. Perform dml and ddl statements on master
+# 4. Copy statement events on master into a temporary table
+# 4. Replicate to slave
+# 5. Compare statement events on slave to those from the master
+# 6. Disable statement/abstract/relay_log on slave
+# 7. Update some tables on the master then replicate
+# 8. Verify that the updates were replicated but no statement
+# events were recorded
+#==============================================================
+
+#
+# UTILITY QUERIES
+#
+let $get_thread_id=
+ select thread_id into @my_thread_id
+ from performance_schema.threads
+ where processlist_id = connection_id();
+
+let $disable_instruments=
+ update performance_schema.setup_instruments
+ set enabled='no', timed='no'
+ where name like '%statement/%';
+
+let $enable_instruments= ../include
+ update performance_schema.setup_instruments
+ set enabled='yes', timed='yes'
+ where name like '%statement/%';
+
+let $column_list=
+ thread_id, event_id, rpad(event_name, 28, ' ') event_name, rpad(current_schema, 10, ' ') current_schema, rpad(digest_text, 72, ' ') digest_text, sql_text;
+
+# Define instrument name for enable/disable instruments
+let $pfs_instrument='%statement/%';
+
+--echo #
+--echo #
+--echo # STEP 1 - CREATE AND REPLICATE TEST TABLES
+--echo #
+
+connection master;
+
+--echo #
+--echo # *** Create test tables
+--echo #
+
+show global variables like 'binlog_format%';
+
+--disable_warnings
+drop table if exists test.marker;
+--enable_warnings
+
+eval $get_thread_id;
+
+create table test.marker(s1 int) engine=innodb;
+
+sync_slave_with_master;
+
+--echo #
+--echo # *** Clear statement events
+--source ../include/rpl_statements_truncate.inc
+
+--echo #
+--echo #
+--echo # STEP 2 - REPLICATE ONE ROW ON MASTER TO GET REPLICATION THREAD ID ON SLAVE
+--echo #
+
+connection master;
+
+--echo #
+insert into test.marker values (0);
+--echo #
+
+sync_slave_with_master;
+
+--echo #
+--echo # *** Verify row, get replication thread id, clear statement events
+--echo #
+
+# TODO: Get slave thread id from threads using thread/sql/slave_sql event name
+
+select thread_id into @slave_thread_id from performance_schema.events_statements_history
+ where sql_text like '%marker%';
+let $slave_thread_id= `select @slave_thread_id`;
+
+--echo # *** Verify row inserted on master was replicated
+select count(*) = 1 as 'Expect 1' from test.marker;
+
+--echo # *** Clear statement events
+--source ../include/rpl_statements_truncate.inc
+
+--echo #
+--echo #
+--echo # STEP 3 - PERFORM DML STATEMENTS ON MASTER
+--echo #
+
+connection master;
+
+--echo #
+show global variables like 'binlog_format%';
+
+--echo # *** Clear statement events
+--source ../include/rpl_statements_truncate.inc
+
+--echo #
+--echo # *** Create/drop table, create/drop database
+--echo #
+create database marker1_db;
+create database marker2_db;
+create table marker1_db.table1 (s1 int) engine=innodb;
+create table marker2_db.table1 (s1 int) engine=innodb;
+create table marker2_db.table2 (s1 int) engine=innodb;
+
+--echo #
+--echo # *** Transaction
+start transaction;
+insert into marker1_db.table1 values (1), (2), (3);
+insert into marker2_db.table1 values (1), (2), (3);
+commit;
+
+--echo #
+--echo # *** Alter
+alter table marker1_db.table1 add column (s2 varchar(32));
+
+--echo #
+--echo # *** Insert, Update
+start transaction;
+insert into marker1_db.table1 values (4, 'four'), (5, 'five'), (6, 'six');
+update marker1_db.table1 set s1 = s1 + 1;
+commit;
+
+--echo #
+--echo # *** Rollback
+start transaction;
+insert into marker1_db.table1 values (7, 'seven'), (8, 'eight'), (9, 'nine');
+rollback;
+
+--echo #
+--echo # *** Autocommit, Delete, Drop
+delete from marker1_db.table1 where s1 > 4;
+drop table marker2_db.table1;
+drop database marker2_db;
+
+--source ../include/disable_instruments.inc
+
+--echo #
+--echo # *** Examine statements events that will be compared on the slave
+--echo #
+
+--replace_column 1 [THREAD_ID] 2 [EVENT_ID]
+
+eval select $column_list from performance_schema.events_statements_history_long
+ where sql_text like '%marker%' order by event_id;
+
+--echo #
+--echo #
+--echo # STEP 4 - REPLICATE STATEMENT EVENTS ON MASTER TO SLAVE
+--echo #
+--echo #
+--echo # *** Store statement events in holding table, then replicate
+--echo #
+
+--source ../include/disable_instruments.inc
+
+--echo #
+--echo # Create table to hold statement events for later comparison on the slave
+--echo #
+
+create table test.master_events_statements_history_long as
+ (select thread_id, event_id, event_name, sql_text, digest, digest_text, current_schema, rows_affected
+ from performance_schema.events_statements_history_long
+ where (thread_id=@my_thread_id and digest_text like '%marker%'));
+
+--source ../include/enable_instruments.inc
+
+--echo #
+--echo #
+--echo # STEP 5 - VERIFY DML AND DDL STATEMENT EVENTS ON SLAVE
+--echo #
+
+sync_slave_with_master;
+
+--source ../include/disable_instruments.inc
+
+--echo #
+--echo # *** List statement events from master
+--echo #
+--replace_column 1 [THREAD_ID] 2 [EVENT_ID]
+eval select $column_list from master_events_statements_history_long order by event_id;
+
+--echo #
+--echo # *** List statement events on slave
+--echo #
+
+--replace_column 1 [THREAD_ID] 2 [EVENT_ID]
+
+eval select $column_list from performance_schema.events_statements_history_long
+ where thread_id = @slave_thread_id and sql_text like '%marker%' order by event_id;
+
+--echo #
+--echo # *** Compare master and slave events
+--echo #
+
+# Note: The statement digest provides a more robust comparison than the
+# event name. However, in some cases, e.g. DROP TABLE, the server generates
+# its own version of the statement which includes additional quotes and a
+# comment. A digest comparison is therefore impractical for server-generated
+# statements, so we use both methods to ensure coverage.
+
+--echo
+--echo # *** Event name comparison - expect 0 mismatches
+--echo
+
+select thread_id, event_id, event_name, digest_text, sql_text from performance_schema.events_statements_history_long t1
+ where t1.thread_id = @slave_thread_id and
+ sql_text like '%marker%' and
+ not exists (select * from master_events_statements_history_long t2 where t2.event_name = t1.event_name);
+
+--echo
+--echo # *** Statement digest comparison - expect 1 mismatch for DROP TABLE
+--echo
+
+--replace_column 1 [THREAD_ID] 2 [EVENT_ID] 4 [DIGEST]
+
+select thread_id, event_id, event_name, digest, digest_text, sql_text from performance_schema.events_statements_history_long t1
+ where t1.thread_id = @slave_thread_id and
+ sql_text like '%marker%' and
+ not exists (select * from master_events_statements_history_long t2 where t2.digest = t1.digest);
+
+--echo #
+--echo #
+--echo # STEP 6 - DISABLE REPLICATED STATEMENT EVENTS ON SLAVE
+--echo #
+--source ../include/rpl_statements_truncate.inc
+--source ../include/enable_instruments.inc
+
+update performance_schema.setup_instruments set enabled='no', timed='no'
+ where name like '%statement/abstract/relay_log%';
+
+select * from performance_schema.setup_instruments where name like '%statement/abstract/relay_log%';
+
+--echo #
+--echo #
+--echo # STEP 7 - UPDATE TABLES ON MASTER, REPLICATE
+--echo #
+
+connection master;
+
+--echo #
+--echo # *** Clear statement events
+--source ../include/rpl_statements_truncate.inc
+
+--echo # *** Update some tables, then replicate
+--echo #
+
+insert into marker1_db.table1 values (999, '999'), (998, '998'), (997, '997');
+
+--echo #
+--echo #
+--echo # STEP 8 - VERIFY TABLE UPDATES FROM MASTER, EXPECT NO STATEMENT EVENTS ON SLAVE
+--echo #
+
+sync_slave_with_master;
+
+--echo #
+--echo # *** Confirm rows were replicated
+--echo #
+
+select * from marker1_db.table1 where s1 > 900 order by s1;
+
+--echo #
+--echo # *** Confirm that are no statements events from the replication thread
+--echo #
+
+select * from performance_schema.events_statements_history_long
+ where thread_id = @slave_thread_id;
+
+--source ../include/enable_instruments.inc
+
+--echo #
+--echo #
+--echo # STEP 9 - CLEAN UP
+--echo #
+--echo #
+--disable_query_log
+--disable_warnings
+
+connection master;
+drop table test.marker;
+drop table test.master_events_statements_history_long;
+drop database marker1_db;
+
+sync_slave_with_master;
+
+--enable_warnings
+--enable_query_log
+--source include/rpl_end.inc
diff --git a/mysql-test/suite/perfschema/t/rpl_threads.test b/mysql-test/suite/perfschema/t/rpl_threads.test
new file mode 100644
index 00000000..a5ca51a9
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/rpl_threads.test
@@ -0,0 +1,85 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/have_log_bin.inc
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/master-slave.inc
+
+--disable_warnings
+drop table if exists test.t1;
+--sync_slave_with_master
+reset master;
+--enable_warnings
+
+create table test.t1(a int);
+drop table test.t1;
+
+--source include/show_binlog_events.inc
+
+# Notes
+#
+# The point of this test is to make sure code is properly instrumented,
+# for replication threads.
+# Each time an ID is assigned to a replication thread,
+# visible in the INFORMATION_SCHEMA.PROCESSLIST table,
+# the same PROCESSLIST_ID should be visible in table performance_schema.threads
+
+connection master;
+-- echo "============ Performance schema on master ============"
+
+# Read the ID of the binlog dump connection,
+# as exposed in PROCESSLIST.
+--enable_prepare_warnings
+select ID from INFORMATION_SCHEMA.PROCESSLIST
+ where COMMAND = "Binlog Dump"
+ into @master_dump_pid;
+--disable_prepare_warnings
+
+select COMMAND, STATE
+ from INFORMATION_SCHEMA.PROCESSLIST
+ where ID = @master_dump_pid;
+
+# Make sure the performance schema also knows this PROCESSLIST_ID
+select NAME, TYPE, PROCESSLIST_COMMAND, PROCESSLIST_STATE
+ from performance_schema.threads
+ where PROCESSLIST_ID = @master_dump_pid;
+
+sync_slave_with_master;
+-- echo "============ Performance schema on slave ============"
+
+# Read the ID of the SLAVE IO thread,
+# as exposed in PROCESSLIST.
+--enable_prepare_warnings
+select ID from INFORMATION_SCHEMA.PROCESSLIST
+ where STATE like "Waiting for master to send event%"
+ into @slave_io_pid;
+--disable_prepare_warnings
+
+select COMMAND, STATE
+ from INFORMATION_SCHEMA.PROCESSLIST
+ where ID = @slave_io_pid;
+
+# Make sure the performance schema also knows this PROCESSLIST_ID
+select NAME, TYPE, PROCESSLIST_COMMAND, PROCESSLIST_STATE
+ from performance_schema.threads
+ where PROCESSLIST_ID = @slave_io_pid;
+
+# Read the ID of the SLAVE SQL thread,
+# as exposed in PROCESSLIST.
+--enable_prepare_warnings
+select ID from INFORMATION_SCHEMA.PROCESSLIST
+ where STATE like "Slave has read all relay log%"
+ into @slave_sql_pid;
+--disable_prepare_warnings
+
+select COMMAND, STATE
+ from INFORMATION_SCHEMA.PROCESSLIST
+ where ID = @slave_sql_pid;
+
+# Make sure the performance schema also knows this PROCESSLIST_ID
+select NAME, TYPE, PROCESSLIST_COMMAND, PROCESSLIST_STATE
+ from performance_schema.threads
+ where PROCESSLIST_ID = @slave_sql_pid;
+
+--source include/rpl_end.inc
+
diff --git a/mysql-test/suite/perfschema/t/schema.test b/mysql-test/suite/perfschema/t/schema.test
new file mode 100644
index 00000000..d12ba2e2
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/schema.test
@@ -0,0 +1,7 @@
+# Tests for PERFORMANCE_SCHEMA
+# Show existing objects and information about their structure
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source ../include/schema.inc
+
diff --git a/mysql-test/suite/perfschema/t/selects-master.opt b/mysql-test/suite/perfschema/t/selects-master.opt
new file mode 100644
index 00000000..f93413a6
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/selects-master.opt
@@ -0,0 +1 @@
+--event-scheduler
diff --git a/mysql-test/suite/perfschema/t/selects.test b/mysql-test/suite/perfschema/t/selects.test
new file mode 100644
index 00000000..c67cb4b2
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/selects.test
@@ -0,0 +1,181 @@
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+#
+# WL#4814, 4.1.2 STORAGE ENGINE, FSE8: Selects
+#
+
+# Make some data that we can work on:
+
+UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES';
+
+# Disable ALL table IO, to avoid generating events from the selects
+# To be revised after WL#5342 PERFORMANCE SCHEMA SETUP OBJECTS
+
+UPDATE performance_schema.setup_instruments SET enabled = 'NO', timed = 'NO'
+ where NAME='wait/io/table/sql/handler';
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+CREATE TABLE t1 (id INT PRIMARY KEY, b CHAR(100) DEFAULT 'initial value')
+ENGINE=MyISAM;
+INSERT INTO t1 (id) VALUES (1), (2), (3), (4), (5), (6), (7), (8);
+
+# ORDER BY, GROUP BY and HAVING
+
+--replace_column 2 [NUM_BYTES]
+SELECT OPERATION, SUM(NUMBER_OF_BYTES) AS TOTAL
+FROM performance_schema.events_waits_history_long
+GROUP BY OPERATION
+HAVING TOTAL IS NOT NULL
+ORDER BY OPERATION
+LIMIT 1;
+
+# Sub SELECT
+--replace_column 1 [EVENT_ID]
+SELECT EVENT_ID FROM performance_schema.events_waits_current
+WHERE THREAD_ID IN
+ (SELECT THREAD_ID FROM performance_schema.threads)
+AND EVENT_NAME IN
+ (SELECT NAME FROM performance_schema.setup_instruments
+ WHERE NAME LIKE "wait/synch/%")
+LIMIT 1;
+
+# JOIN
+
+--replace_column 1 [EVENT_ID]
+SELECT DISTINCT EVENT_ID
+FROM performance_schema.events_waits_current
+JOIN performance_schema.events_waits_history USING (EVENT_ID)
+JOIN performance_schema.events_waits_history_long USING (EVENT_ID)
+ORDER BY EVENT_ID
+LIMIT 1;
+
+# Self JOIN
+
+--replace_column 1 [THREAD_ID] 2 [EVENT_ID] 3 [EVENT_NAME] 4 [TIMER_WAIT]
+SELECT t1.THREAD_ID, t2.EVENT_ID, t3.EVENT_NAME, t4.TIMER_WAIT
+FROM performance_schema.events_waits_history t1
+JOIN performance_schema.events_waits_history t2 USING (EVENT_ID)
+JOIN performance_schema.events_waits_history t3 ON (t2.THREAD_ID = t3.THREAD_ID)
+JOIN performance_schema.events_waits_history t4 ON (t3.EVENT_NAME = t4.EVENT_NAME)
+ORDER BY t1.EVENT_ID, t2.EVENT_ID
+LIMIT 5;
+
+# UNION
+--replace_column 1 [THREAD_ID] 2 [EVENT_ID]
+SELECT THREAD_ID, EVENT_ID FROM (
+SELECT THREAD_ID, EVENT_ID FROM performance_schema.events_waits_current
+UNION
+SELECT THREAD_ID, EVENT_ID FROM performance_schema.events_waits_history
+UNION
+SELECT THREAD_ID, EVENT_ID FROM performance_schema.events_waits_history_long
+) t1 ORDER BY THREAD_ID, EVENT_ID
+LIMIT 5;
+
+# EVENT
+
+# Check that the event_scheduler is really running
+--source include/running_event_scheduler.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t_event;
+DROP EVENT IF EXISTS t_ps_event;
+--enable_warnings
+CREATE TABLE t_event AS
+SELECT EVENT_ID FROM performance_schema.events_waits_current
+WHERE 1 = 2;
+CREATE EVENT t_ps_event
+ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND
+ON COMPLETION PRESERVE
+DO INSERT INTO t_event
+ SELECT DISTINCT EVENT_ID
+ FROM performance_schema.events_waits_current
+ JOIN performance_schema.events_waits_history USING (EVENT_ID)
+ ORDER BY EVENT_ID
+ LIMIT 1;
+
+# TRIGGER
+
+ALTER TABLE t1 ADD COLUMN c INT;
+
+--disable_warnings
+DROP TRIGGER IF EXISTS t_ps_trigger;
+--enable_warnings
+delimiter |;
+
+CREATE TRIGGER t_ps_trigger BEFORE INSERT ON t1
+ FOR EACH ROW BEGIN
+ SET NEW.c = (SELECT MAX(EVENT_ID)
+ FROM performance_schema.events_waits_current);
+ END;
+|
+
+delimiter ;|
+
+INSERT INTO t1 (id) VALUES (11), (12), (13);
+
+--replace_column 2 [EVENT_ID]
+SELECT id, c FROM t1 WHERE id > 10 ORDER BY c;
+
+DROP TRIGGER t_ps_trigger;
+
+# PROCEDURE
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS t_ps_proc;
+--enable_warnings
+--enable_prepare_warnings
+delimiter |;
+
+CREATE PROCEDURE t_ps_proc(IN conid INT, OUT pid INT)
+BEGIN
+ SELECT thread_id FROM performance_schema.threads
+ WHERE PROCESSLIST_ID = conid INTO pid;
+END;
+
+|
+
+delimiter ;|
+
+CALL t_ps_proc(connection_id(), @p_id);
+
+--disable_prepare_warnings
+# FUNCTION
+
+--disable_warnings
+DROP FUNCTION IF EXISTS t_ps_proc;
+--enable_warnings
+delimiter |;
+
+CREATE FUNCTION t_ps_func(conid INT) RETURNS int
+BEGIN
+ return (SELECT thread_id FROM performance_schema.threads
+ WHERE PROCESSLIST_ID = conid);
+END;
+
+|
+
+delimiter ;|
+
+SELECT t_ps_func(connection_id()) = @p_id;
+
+# We might reach this point too early which means the event scheduler has not
+# executed our "t_ps_event". Therefore we poll till the record was inserted
+# and run our test statement afterwards.
+let $wait_timeout= 20;
+let $wait_condition= SELECT COUNT(*) = 1 FROM t_event;
+--source include/wait_condition.inc
+--replace_column 1 [EVENT_ID]
+SELECT * FROM t_event;
+
+# Clean up
+DROP PROCEDURE t_ps_proc;
+DROP FUNCTION t_ps_func;
+DROP EVENT t_ps_event;
+DROP TABLE t1;
+DROP TABLE t_event;
+
+UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES';
+
diff --git a/mysql-test/suite/perfschema/t/server_init.test b/mysql-test/suite/perfschema/t/server_init.test
new file mode 100644
index 00000000..ae4f7ac9
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/server_init.test
@@ -0,0 +1,144 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+# This test verifies that the mysys and server instruments are properly
+# initialized and recorded by the performance schema during the bootstrap
+# sequence in mysqld main().
+# Note that some globals mutexes/rwlocks/conds that depend on #ifdef options
+# or runtime options are not tested here, to have a predictable result.
+
+use performance_schema;
+
+# Verify that these global mutexes have been properly initilized in mysys
+
+select count(name) from mutex_instances
+ where name like "wait/synch/mutex/mysys/THR_LOCK_malloc";
+
+select count(name) from mutex_instances
+ where name like "wait/synch/mutex/mysys/THR_LOCK_open";
+
+select count(name) from mutex_instances
+ where name like "wait/synch/mutex/mysys/THR_LOCK_myisam";
+
+select count(name) from mutex_instances
+ where name like "wait/synch/mutex/mysys/THR_LOCK_heap";
+
+select count(name) from mutex_instances
+ where name like "wait/synch/mutex/mysys/THR_LOCK_net";
+
+select count(name) from mutex_instances
+ where name like "wait/synch/mutex/mysys/THR_LOCK_charset";
+
+# There are no global rwlock in mysys
+
+# There are no global conditions in mysys
+# (THR_COND_threads is only present in debug builds
+
+# Verify that these global mutexes have been properly initilized in sql
+
+select count(name) from mutex_instances
+ where name like "wait/synch/mutex/sql/LOCK_thread_count";
+
+select count(name) from mutex_instances
+ where name like "wait/synch/mutex/sql/LOCK_log_throttle_qni";
+
+select count(name) from mutex_instances
+ where name like "wait/synch/mutex/sql/LOCK_status";
+
+select count(name) from mutex_instances
+ where name like "wait/synch/mutex/sql/LOCK_uuid_generator";
+
+select count(name) from mutex_instances
+ where name like "wait/synch/mutex/sql/LOCK_crypt";
+
+select count(name) from mutex_instances
+ where name like "wait/synch/mutex/sql/LOCK_active_mi";
+
+select count(name) from mutex_instances
+ where name like "wait/synch/mutex/sql/LOCK_manager";
+
+select count(name) from mutex_instances
+ where name like "wait/synch/mutex/sql/LOCK_global_system_variables";
+
+select count(name) from mutex_instances
+ where name like "wait/synch/mutex/sql/LOCK_user_conn";
+
+select count(name) from mutex_instances
+ where name like "wait/synch/mutex/sql/LOCK_prepared_stmt_count";
+
+select count(name) from mutex_instances
+ where name like "wait/synch/mutex/sql/LOCK_server_started";
+
+# LOG_INFO object are created on demand, and are not global.
+# select count(name) from mutex_instances
+# where name like "wait/synch/mutex/sql/LOG_INFO::lock";
+
+select count(name) from mutex_instances
+ where name like "wait/synch/mutex/sql/Query_cache::structure_guard_mutex";
+
+# The event scheduler may be disabled
+# select count(name) from mutex_instances
+# where name like "wait/synch/mutex/sql/Event_scheduler::LOCK_scheduler_state";
+
+select count(name) from mutex_instances
+ where name like "wait/synch/mutex/sql/LOCK_event_queue";
+
+select count(name) from mutex_instances
+ where name like "wait/synch/mutex/sql/LOCK_item_func_sleep";
+
+select count(name) from mutex_instances
+ where name like "wait/synch/mutex/sql/LOCK_audit_mask";
+
+select count(name) from mutex_instances
+ where name like "wait/synch/mutex/sql/LOCK_plugin";
+
+# Not a global variable, may be destroyed already.
+# select count(name) from mutex_instances
+# where name like "wait/synch/mutex/sql/LOCK_gdl";
+
+select count(name) from mutex_instances
+ where name like "wait/synch/mutex/sql/tz_LOCK";
+
+# Verify that these global rwlocks have been properly initilized in sql
+
+select count(name) from rwlock_instances
+ where name like "wait/synch/rwlock/sql/LOCK_sys_init_connect";
+
+select count(name) from rwlock_instances
+ where name like "wait/synch/rwlock/sql/LOCK_sys_init_slave";
+
+select count(name) from rwlock_instances
+ where name like "wait/synch/rwlock/sql/LOCK_system_variables_hash";
+
+# Verify that these global conditions have been properly initilized in sql
+
+select count(name) from cond_instances
+ where name like "wait/synch/cond/sql/COND_server_started";
+
+select count(name) from cond_instances
+ where name like "wait/synch/cond/sql/COND_refresh";
+
+select count(name) from cond_instances
+ where name like "wait/synch/cond/sql/COND_thread_count";
+
+select count(name) from cond_instances
+ where name like "wait/synch/cond/sql/COND_manager";
+
+select count(name) from cond_instances
+ where name like "wait/synch/cond/sql/COND_thread_cache";
+
+select count(name) from cond_instances
+ where name like "wait/synch/cond/sql/COND_flush_thread_cache";
+
+select count(name) from cond_instances
+ where name like "wait/synch/cond/sql/Query_cache::COND_cache_status_changed";
+
+# The event scheduler may be disabled
+# select count(name) from cond_instances
+# where name like "wait/synch/cond/sql/Event_scheduler::COND_state";
+
+select count(name) from cond_instances
+ where name like "wait/synch/cond/sql/COND_queue_state";
+
diff --git a/mysql-test/suite/perfschema/t/setup_actors.test b/mysql-test/suite/perfschema/t/setup_actors.test
new file mode 100644
index 00000000..9e9e0a4e
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/setup_actors.test
@@ -0,0 +1,230 @@
+# Check the impact of different entries in performance_schema.setup_actors
+# on when and how activity of users is recordeed in performance_schema.threads.
+# The checks for indirect activity caused by users, system threads etc.
+# are within setup_actors1.test.
+
+--source include/not_windows.inc
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+# The initial number of rows is 1. The initial row always looks like this:
+# mysql> select * from performance_schema.setup_actors;
+# +------+------+------+---------+---------+
+# | HOST | USER | ROLE | ENABLED | HISTORY |
+# +------+------+------+---------+---------+
+# | % | % | % | YES | YES |
+# +------+------+------+---------+---------+
+select * from performance_schema.setup_actors;
+
+truncate table performance_schema.setup_actors;
+
+insert into performance_schema.setup_actors
+values ('hosta', 'user1', '%', 'YES', 'YES');
+
+insert into performance_schema.setup_actors
+values ('%', 'user2', '%', 'YES', 'YES');
+
+insert into performance_schema.setup_actors
+values ('localhost', 'user3', '%', 'YES', 'YES');
+
+insert into performance_schema.setup_actors
+values ('hostb', '%', '%', 'YES', 'YES');
+
+select * from performance_schema.setup_actors
+order by USER, HOST, ROLE;
+
+create user user1@localhost;
+grant ALL on *.* to user1@localhost;
+create user user2@localhost;
+grant ALL on *.* to user2@localhost;
+create user user3@localhost;
+grant ALL on *.* to user3@localhost;
+create user user4@localhost;
+grant ALL on *.* to user4@localhost;
+create user user5@localhost;
+grant select on test.* to user5@localhost;
+
+flush privileges;
+
+connect (con1, localhost, user1, , );
+
+# INSTRUMENTED must be NO because there is no match in performance_schema.setup_actors
+select NAME, TYPE, INSTRUMENTED, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID = connection_id();
+let $con1_thread_id= `select THREAD_ID from performance_schema.threads
+ where PROCESSLIST_ID = connection_id()`;
+
+--connection default
+insert into performance_schema.setup_actors
+values ('%', 'user1', '%', 'YES', 'YES');
+
+--connection con1
+# INSTRUMENTED must be NO because there was no match in performance_schema.setup_actors
+# when our current session made its connect. Later changes in setup_actors have no
+# impact.
+select NAME, TYPE, INSTRUMENTED, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID = connection_id();
+
+--disconnect con1
+
+connect (con2, localhost, user2, , );
+
+# INSTRUMENTED must be YES because there is a match via
+# (HOST,USER,ROLE) = ('%', 'user2', '%') in performance_schema.setup_actors.
+select NAME, TYPE, INSTRUMENTED, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID=connection_id();
+let $con2_thread_id= `select THREAD_ID from performance_schema.threads
+ where PROCESSLIST_ID = connection_id()`;
+
+--disconnect con2
+
+--connection default
+# If a thread dies, we don't expect its THREAD_ID value will be re-used.
+if ($con2_thread_id <= $con1_thread_id)
+{
+ --echo ERROR: THREAD_ID of con2 is not bigger than THREAD_ID of con1
+ eval SELECT $con2_thread_id as THREAD_ID_con2, $con1_thread_id THREAD_ID_con1;
+}
+
+--disable_warnings
+drop table if exists test.t1;
+--enable_warnings
+create table test.t1 (col1 bigint);
+lock table test.t1 write;
+
+connect (con3, localhost, user3, , );
+
+# INSTRUMENTED must be YES because there is a match via
+# (HOST,USER,ROLE) = ('localhost', 'user3', '%') in performance_schema.setup_actors.
+select NAME, TYPE, INSTRUMENTED, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID = connection_id();
+
+# PROCESSLIST_ columns are:
+# (if name like '%OneConnection') all the same as what you'd get if you
+# run a select on INFORMATION_SCHEMA.PROCESSLIST for the corresponding thread.
+# Check at least once that this is fulfilled.
+# Note(mleich):
+# A join between INFORMATION_SCHEMA.PROCESSLIST and performance_schema.threads
+# Example:
+# select count(*) = 1
+# from performance_schema.threads T inner join information_schema.PROCESSLIST P
+# on T.PROCESSLIST_ID = P.ID and T.PROCESSLIST_USER = P.USER and
+# T.PROCESSLIST_HOST = P.HOST and T.PROCESSLIST_DB = P.DB and
+# T.PROCESSLIST_COMMAND = P.COMMAND and T.PROCESSLIST_INFO = P.INFO
+# where T.PROCESSLIST_ID = connection_id() and T.NAME = 'thread/sql/one_connection'
+# executed by the current connection looks like some of the most elegant solutions
+# for revealing this. But such a join suffers from sporadic differences like
+# column | observation
+# -------|-------------
+# state | "Sending data" vs. "executing"
+# time | 0 vs. 1 (high load on the testing box)
+# info | <full statement> vs. NULL (use of "--ps-protocol")
+# IMHO the differences are harmless.
+# Therefore we use here a different solution.
+#
+--echo # Send a statement to the server, but do not wait till the result
+--echo # comes back. We will pull this later.
+send
+insert into test.t1 set col1 = 1;
+connect (con4, localhost, user4, , );
+--echo # Poll till INFO is no more NULL and State = 'Waiting for table metadata lock'.
+let $wait_condition= select count(*) from information_schema.processlist
+ where user = 'user3' and info is not null
+ and state = 'Waiting for table metadata lock';
+--source include/wait_condition.inc
+# Expect to get 1 now
+select count(*) = 1
+from performance_schema.threads T inner join information_schema.PROCESSLIST P
+ on T.PROCESSLIST_ID = P.ID and T.PROCESSLIST_USER = P.USER and
+ T.PROCESSLIST_HOST = P.HOST and T.PROCESSLIST_DB = P.DB and
+ T.PROCESSLIST_COMMAND = P.COMMAND and T.PROCESSLIST_INFO = P.INFO
+where T.PROCESSLIST_USER = 'user3' and T.NAME = 'thread/sql/one_connection';
+
+# Resolve the situation + some cleanup
+--connection default
+unlock tables;
+--connection con3
+--echo # Reap the result of the no more blocked insert
+--reap
+--connection default
+drop table test.t1;
+--disconnect con3
+
+--connection con4
+# INSTRUMENTED must be NO because there is no match in performance_schema.setup_actors
+select NAME, TYPE, INSTRUMENTED, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID = connection_id();
+
+--disconnect con4
+
+--connection default
+
+insert into performance_schema.setup_actors
+values ('localhost', '%', '%', 'YES', 'YES');
+
+select * from performance_schema.setup_actors
+order by USER, HOST, ROLE;
+
+connect (con4b, localhost, user4, , );
+
+# INSTRUMENTED must be YES because there is a match via
+# (HOST,USER,ROLE) = ('localhost', '%', '%') in performance_schema.setup_actors.
+select NAME, TYPE, INSTRUMENTED, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID = connection_id();
+
+--disconnect con4b
+
+--connection default
+insert into performance_schema.setup_actors
+values ('%', 'user5', '%', 'YES', 'YES');
+
+create sql security definer view test.v1 as select NAME, TYPE, INSTRUMENTED, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID = connection_id();
+
+connect (con5, localhost, user5, , );
+
+--error ER_TABLEACCESS_DENIED_ERROR
+select * from performance_schema.threads;
+# 1. INSTRUMENTED must be YES because there are two matches
+# (HOST,USER,ROLE) = ('localhost', '%', '%')
+# (HOST,USER,ROLE) = ('%', 'user5', '%')
+# in performance_schema.setup_actors.
+# But the instrument will only count once which means we must get only one row.
+# 2. PROCESSLIST_USER refers to USER(), the user who connected,
+# not the user we might be temporarily acting as (with definer's rights).
+# Therefore PROCESSLIST_USER must be 'user5' though we run with right's of definer 'root'
+select * from test.v1;
+
+--disconnect con5
+--source include/wait_until_disconnected.inc
+
+
+--connection default
+
+drop view test.v1;
+revoke all privileges, grant option from user1@localhost;
+revoke all privileges, grant option from user2@localhost;
+revoke all privileges, grant option from user3@localhost;
+revoke all privileges, grant option from user4@localhost;
+revoke all privileges, grant option from user5@localhost;
+drop user user1@localhost;
+drop user user2@localhost;
+drop user user3@localhost;
+drop user user4@localhost;
+drop user user5@localhost;
+flush privileges;
+
+truncate table performance_schema.setup_actors;
+
+insert into performance_schema.setup_actors
+values ('%', '%', '%', 'YES', 'YES');
+
+select * from performance_schema.setup_actors;
+
diff --git a/mysql-test/suite/perfschema/t/setup_actors_enabled.test b/mysql-test/suite/perfschema/t/setup_actors_enabled.test
new file mode 100644
index 00000000..959c4d9c
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/setup_actors_enabled.test
@@ -0,0 +1,219 @@
+# Check the impact of changes done in ENABLED column in
+# performance_schema.setup_actors.
+
+--source include/not_windows.inc
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+# The initial number of rows is 1. The initial row always looks like this:
+# mysql> select * from performance_schema.setup_actors;
+# +------+------+------+---------+---------+
+# | HOST | USER | ROLE | ENABLED | HISTORY |
+# +------+------+------+---------+---------+
+# | % | % | % | YES | YES |
+# +------+------+------+---------+---------+
+select * from performance_schema.setup_actors;
+
+truncate table performance_schema.setup_actors;
+
+insert into performance_schema.setup_actors
+values ('localhost', 'user1', '%', 'YES', 'YES');
+
+insert into performance_schema.setup_actors
+values ('localhost', 'user2', '%', 'NO', 'NO');
+
+set @orig_sql_mode= @@sql_mode;
+set sql_mode= (select replace(@@sql_mode,'NO_AUTO_CREATE_USER',''));
+grant ALL on *.* to user1@localhost;
+grant ALL on *.* to user2@localhost;
+set sql_mode= @orig_sql_mode;
+
+flush privileges;
+
+--echo # Switch to (con1, localhost, user1, , )
+connect (con1, localhost, user1, , );
+
+# INSTRUMENTED must be YES because there is a match in
+# performance_schema.setup_actors and its ENABLED
+select NAME, TYPE, INSTRUMENTED, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID = connection_id();
+let $con1_thread_id= `select THREAD_ID from performance_schema.threads
+ where PROCESSLIST_ID = connection_id()`;
+
+--echo # Switch to (con2, localhost, user2, , )
+connect (con2, localhost, user2, , );
+
+# INSTRUMENTED must be NO because there is a match in
+# performance_schema.setup_actors but its DISABLED.
+select NAME, TYPE, INSTRUMENTED, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID = connection_id();
+let $con1_thread_id= `select THREAD_ID from performance_schema.threads
+ where PROCESSLIST_ID = connection_id()`;
+
+--echo # Switch to connection default
+--connection default
+update performance_schema.setup_actors set ENABLED='NO' where USER='user1';
+update performance_schema.setup_actors set ENABLED='YES' where USER='user2';
+
+--echo # Switch to connection con1
+--connection con1
+
+# INSTRUMENTED must still be YES because update to setup_actors doesn't affect
+# existing connetions.
+select NAME, TYPE, INSTRUMENTED, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID = connection_id();
+let $con1_thread_id= `select THREAD_ID from performance_schema.threads
+ where PROCESSLIST_ID = connection_id()`;
+
+--echo # Switch to connection con2
+--connection con2
+
+# INSTRUMENTED must still be NO because update to setup_actors doesn't affect
+# existing connetions.
+select NAME, TYPE, INSTRUMENTED, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID = connection_id();
+let $con1_thread_id= `select THREAD_ID from performance_schema.threads
+ where PROCESSLIST_ID = connection_id()`;
+
+--echo # Disconnect con1 and con2
+--disconnect con1
+--disconnect con2
+
+# Now reconnect
+--echo # Switch to (con1, localhost, user1, , )
+connect (con1, localhost, user1, , );
+
+# INSTRUMENTED must still be NO because update to setup_actors affects
+# new connetions.
+select NAME, TYPE, INSTRUMENTED, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID = connection_id();
+let $con1_thread_id= `select THREAD_ID from performance_schema.threads
+ where PROCESSLIST_ID = connection_id()`;
+
+--echo # Switch to (con2 localhost, user2, , )
+connect (con2, localhost, user2, , );
+
+# INSTRUMENTED must still be YES because update to setup_actors affects
+# new connetions.
+select NAME, TYPE, INSTRUMENTED, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID = connection_id();
+let $con1_thread_id= `select THREAD_ID from performance_schema.threads
+ where PROCESSLIST_ID = connection_id()`;
+
+--echo # Disconnect con1 and con2
+--disconnect con1
+--disconnect con2
+
+--echo # Switch to connection default
+--connection default
+
+# Checking if update is allowed on performance_schema.setup_actors ENABLED
+# column after revoke update privilege
+
+revoke update on *.* from 'user2'@'localhost';
+
+flush privileges;
+
+--echo # Switch to (con2 localhost, user2, , )
+connect (con2, localhost, user2, , );
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.setup_actors
+ set ENABLED='NO';
+
+--disconnect con2
+--connection default
+
+# Checking for Rules Order
+# 1. a match for 'U1' and 'H1'.
+# 2. then for 'U1' and '%'.
+# 3. then for '%' and 'H1'.
+# 4. then for '%' and '%'.
+
+insert into performance_schema.setup_actors
+values ('%', 'user1', '%', 'YES', 'YES');
+
+
+insert into performance_schema.setup_actors
+values ('localhost', '%', '%', 'NO', 'NO');
+
+insert into performance_schema.setup_actors
+values ('%', '%', '%', 'YES', 'YES');
+
+
+--echo # Switch to (con1, localhost, user1, , )
+connect (con1, localhost, user1, , );
+
+# INSTRUMENTED must still be NO as it will match rule1
+# new connetions.
+select NAME, TYPE, INSTRUMENTED, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID = connection_id();
+
+--disconnect con1
+--connection default
+
+delete from performance_schema.setup_actors where
+HOST='localhost' and USER='user1';
+
+--echo # Switch to (con1, localhost, user1, , )
+connect (con1, localhost, user1, , );
+
+# INSTRUMENTED must still be YES as it will match rule2
+# new connetions.
+select NAME, TYPE, INSTRUMENTED, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID = connection_id();
+
+
+--disconnect con1
+--connection default
+
+delete from performance_schema.setup_actors where
+HOST='%' and USER='user1';
+
+--echo # Switch to (con1, localhost, user1, , )
+connect (con1, localhost, user1, , );
+
+# INSTRUMENTED must still be NO as it will match rule3
+# new connetions.
+select NAME, TYPE, INSTRUMENTED, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID = connection_id();
+
+--disconnect con1
+--connection default
+
+delete from performance_schema.setup_actors where
+HOST='localhost' and USER='%';
+
+--echo # Switch to (con1, localhost, user1, , )
+connect (con1, localhost, user1, , );
+
+# INSTRUMENTED must still be YES as it will match rule4
+# new connetions.
+select NAME, TYPE, INSTRUMENTED, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID = connection_id();
+
+--disconnect con1
+--connection default
+
+revoke all privileges, grant option from user1@localhost;
+revoke all privileges, grant option from user2@localhost;
+drop user user1@localhost;
+drop user user2@localhost;
+flush privileges;
+
+truncate table performance_schema.setup_actors;
+
+insert into performance_schema.setup_actors
+values ('%', '%', '%', 'YES', 'YES');
+
+select * from performance_schema.setup_actors;
+
diff --git a/mysql-test/suite/perfschema/t/setup_actors_history.test b/mysql-test/suite/perfschema/t/setup_actors_history.test
new file mode 100644
index 00000000..ecb3324a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/setup_actors_history.test
@@ -0,0 +1,177 @@
+# Check the impact of changes done in HISTORY column in
+# performance_schema.setup_actors.
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+# The initial number of rows is 1. The initial row always looks like this:
+# mysql> select * from performance_schema.setup_actors;
+# +------+------+------+---------+---------+
+# | HOST | USER | ROLE | ENABLED | HISTORY |
+# +------+------+------+---------+---------+
+# | % | % | % | YES | YES |
+# +------+------+------+---------+---------+
+select * from performance_schema.setup_actors;
+
+truncate table performance_schema.setup_actors;
+
+insert into performance_schema.setup_actors
+values ('localhost', 'user1', '%', 'YES', 'YES');
+
+insert into performance_schema.setup_actors
+values ('localhost', 'user2', '%', 'YES', 'NO');
+
+insert into performance_schema.setup_actors
+values ('localhost', 'user3', '%', 'NO', 'YES');
+
+insert into performance_schema.setup_actors
+values ('localhost', 'user4', '%', 'NO', 'NO');
+
+create user user1@localhost;
+create user user2@localhost;
+create user user3@localhost;
+create user user4@localhost;
+
+grant ALL on *.* to user1@localhost;
+grant ALL on *.* to user2@localhost;
+grant ALL on *.* to user3@localhost;
+grant ALL on *.* to user4@localhost;
+
+flush privileges;
+
+--echo # Switch to (con1, localhost, user1, , )
+connect (con1, localhost, user1, , );
+
+# Expecting INSTRUMENTED=YES, HISTORY=YES
+select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID = connection_id();
+
+--echo # Switch to (con2, localhost, user2, , )
+connect (con2, localhost, user2, , );
+
+# Expecting INSTRUMENTED=YES, HISTORY=NO
+select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID = connection_id();
+
+--echo # Switch to (con3, localhost, user3, , )
+connect (con3, localhost, user3, , );
+
+# Expecting INSTRUMENTED=NO, HISTORY=YES
+select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID = connection_id();
+
+--echo # Switch to (con4, localhost, user4, , )
+connect (con4, localhost, user4, , );
+
+# Expecting INSTRUMENTED=NO, HISTORY=NO
+select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID = connection_id();
+
+--echo # Switch to connection default
+--connection default
+update performance_schema.setup_actors
+ set HISTORY='NO' where USER in ('user1', 'user3');
+update performance_schema.setup_actors
+ set HISTORY='YES' where USER in ('user2', 'user4');
+
+--echo # Switch to connection con1
+--connection con1
+
+# Expecting INSTRUMENTED=YES, HISTORY=YES
+select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID = connection_id();
+
+--echo # Switch to connection con2
+--connection con2
+
+# Expecting INSTRUMENTED=YES, HISTORY=NO
+select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID = connection_id();
+
+--echo # Switch to connection con3
+--connection con3
+
+# Expecting INSTRUMENTED=NO, HISTORY=YES
+select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID = connection_id();
+
+--echo # Switch to connection con4
+--connection con4
+
+# Expecting INSTRUMENTED=NO, HISTORY=NO
+select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID = connection_id();
+
+--echo # Disconnect all con
+--disconnect con1
+--disconnect con2
+--disconnect con3
+--disconnect con4
+
+# Now reconnect
+--echo # Switch to (con1, localhost, user1, , )
+connect (con1, localhost, user1, , );
+
+# Expecting INSTRUMENTED=YES, HISTORY=NO
+select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID = connection_id();
+
+--echo # Switch to (con2 localhost, user2, , )
+connect (con2, localhost, user2, , );
+
+# Expecting INSTRUMENTED=YES, HISTORY=YES
+select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID = connection_id();
+
+--echo # Switch to (con3, localhost, user3, , )
+connect (con3, localhost, user3, , );
+
+# Expecting INSTRUMENTED=NO, HISTORY=NO
+select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID = connection_id();
+
+--echo # Switch to (con4 localhost, user4, , )
+connect (con4, localhost, user4, , );
+
+# Expecting INSTRUMENTED=NO, HISTORY=YES
+select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
+from performance_schema.threads
+where PROCESSLIST_ID = connection_id();
+
+--echo # Disconnect all con
+--disconnect con1
+--disconnect con2
+--disconnect con3
+--disconnect con4
+
+--echo # Switch to connection default
+--connection default
+
+revoke all privileges, grant option from user1@localhost;
+revoke all privileges, grant option from user2@localhost;
+revoke all privileges, grant option from user3@localhost;
+revoke all privileges, grant option from user4@localhost;
+drop user user1@localhost;
+drop user user2@localhost;
+drop user user3@localhost;
+drop user user4@localhost;
+flush privileges;
+
+truncate table performance_schema.setup_actors;
+
+insert into performance_schema.setup_actors
+values ('%', '%', '%', 'YES', 'YES');
+
+select * from performance_schema.setup_actors;
+
diff --git a/mysql-test/suite/perfschema/t/setup_consumers_defaults-master.opt b/mysql-test/suite/perfschema/t/setup_consumers_defaults-master.opt
new file mode 100644
index 00000000..db53957b
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/setup_consumers_defaults-master.opt
@@ -0,0 +1,18 @@
+--loose-performance-schema-consumer-events-stages-current=OFF
+--loose-performance-schema-consumer-events-stages-history=ON
+--loose-performance-schema-consumer-events-stages-history-long=OFF
+
+--loose-performance-schema-consumer-events-statements-current=ON
+--loose-performance-schema-consumer-events-statements-history=OFF
+--loose-performance-schema-consumer-events-statements-history-long=ON
+
+--loose-performance-schema-consumer-events-transactions-current=ON
+--loose-performance-schema-consumer-events-transactions-history=OFF
+--loose-performance-schema-consumer-events-transactions-history-long=ON
+
+--loose-performance-schema-consumer-events-waits-current=OFF
+--loose-performance-schema-consumer-events-waits-history=ON
+--loose-performance-schema-consumer-events-waits-history-long=OFF
+
+--loose-performance-schema-consumer-global-instrumentation=ON
+--loose-performance-schema-consumer-thread-instrumentation=ON
diff --git a/mysql-test/suite/perfschema/t/setup_consumers_defaults.test b/mysql-test/suite/perfschema/t/setup_consumers_defaults.test
new file mode 100644
index 00000000..d8aa52a1
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/setup_consumers_defaults.test
@@ -0,0 +1,18 @@
+
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+SELECT * FROM performance_schema.setup_consumers ORDER BY name;
+
+#
+# Verify that the consumer option settings cannot be changed or seen
+#
+--error ER_UNKNOWN_SYSTEM_VARIABLE
+SELECT @@performance_schema_consumer_events_stages_current;
+
+--error ER_UNKNOWN_SYSTEM_VARIABLE
+SET @@performance_schema_consumer_events_stages_current=0;
+
+SHOW GLOBAL VARIABLES LIKE "performance_schema_consumer%";
diff --git a/mysql-test/suite/perfschema/t/setup_instruments_defaults-master.opt b/mysql-test/suite/perfschema/t/setup_instruments_defaults-master.opt
new file mode 100644
index 00000000..dd2aa078
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/setup_instruments_defaults-master.opt
@@ -0,0 +1,28 @@
+--log-error=0
+--loose-performance-schema-instrument='%=ON'
+--loose-performance-schema-instrument=''
+--loose-performance-schema-instrument=' wait/synch/mutex/sql/% = OFF ''
+--loose-performance-schema-instrument='//wait/synch/mutex/sql/% = 'OFF ''
+--loose-performance-schema-instrument=' wait/synch/mutex/sql/% = OFF '
+--loose-performance-schema-instrument='''''
+--loose-performance-schema-instrument=' / '
+--loose-performance-schema-instrument=' wait/synch/mutex/sql/% = OFF '
+--loose-performance-schema-instrument='wait/synch/mutex/sql/% = OFF '
+--loose-performance-schema-instrument='wait/synch/mutex/sql/LOCK% = ON'
+--loose-performance-schema-instrument='wait/synch/mutex/sql/LOCK_thd_count=OFF'
+--loose-performance-schema-instrument=' wait/synch/mutex/sql/LOCK_user_conn = COUNTED'
+--loose-performance-schema-instrument='wait%/synch/mutex/sql/LOCK_uu%_genera%/= COUNTED'
+--loose-performance-schema-instrument='%%wait/synch/mutex/sql/LOCK_plugin=COUNTED'
+--loose-performance-schema-instrument='%=FOO'
+--loose-performance-schema-instrument='%=%'
+--loose-performance-schema-instrument='%'
+--loose-performance-schema-instrument=' unknown%instrument/event/name with blanks = YES'
+--loose-performance-schema-instrument='unknown/instrument/event/name = TRUE'
+--loose-performance-schema-instrument='stage/sql/creating table = COUNTED'
+--loose-performance-schema-instrument='wait/synch/mutex/sql/LOG_INFO::lock = 1'
+--loose-performance-schema-instrument='wait/synch/mutex/sql/THD::LOCK_thd_data= TRUE'
+--loose-performance-schema-instrument='wait/synch/mutex/sql/hash_filo::lock =FALSE'
+--loose-performance-schema-instrument='wait/synch/mutex/sql/TABLE_SHARE::LOCK_ha_data= NO'
+--loose-performance-schema-instrument='memory/%=ON'
+--loose-performance-schema-instrument='memory/performance_schema/%=OFF'
+
diff --git a/mysql-test/suite/perfschema/t/setup_instruments_defaults.test b/mysql-test/suite/perfschema/t/setup_instruments_defaults.test
new file mode 100644
index 00000000..ea59cd4f
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/setup_instruments_defaults.test
@@ -0,0 +1,100 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+# Verify that the configuration options were applied correctly to the
+# performance_schema.setup_instruments table. These instruments that are known to persist across
+# platforms and the various compile options.
+
+--echo #
+--echo # Verify that the configuration file defaults were processed correctly
+--echo #
+
+SELECT * FROM performance_schema.setup_instruments
+WHERE name IN (
+ 'wait/synch/mutex/sql/LOCK_user_conn',
+ 'wait/synch/mutex/sql/LOCK_uuid_generator',
+ 'wait/synch/mutex/sql/LOCK_plugin',
+ 'stage/sql/creating table')
+AND enabled = 'yes' AND timed = 'no'
+ORDER BY name;
+
+SELECT * FROM performance_schema.setup_instruments
+WHERE name = 'wait/synch/mutex/sql/LOCK_thd_list'
+AND enabled = 'no' AND timed = 'no';
+
+SELECT * FROM performance_schema.setup_instruments
+WHERE name IN (
+ 'wait/synch/mutex/sql/LOG_INFO::lock',
+ 'wait/synch/mutex/sql/THD::LOCK_thd_list')
+AND enabled = 'yes' AND timed = 'yes'
+ORDER BY name;
+
+SELECT * FROM performance_schema.setup_instruments
+WHERE name = 'wait/synch/mutex/sql/hash_filo::lock'
+AND enabled = 'no' AND timed = 'no'
+ORDER BY name;
+
+--echo #
+--echo # Verify that the memory instruments are never timed
+--echo #
+SELECT * FROM performance_schema.setup_instruments
+WHERE name like 'memory/%'
+AND timed = 'YES';
+
+--echo #
+--echo # Verify that the memory/performance_schema instruments are never disabled
+--echo #
+SELECT * FROM performance_schema.setup_instruments
+WHERE name like 'memory/performance_schema/%'
+AND enabled = 'NO';
+
+
+--echo #
+--echo # Verify that the instrument startup settings are not not visible.
+--echo #
+SHOW VARIABLES LIKE "%/wait/synch/mutex%";
+
+--echo #
+--echo # Verify command line options are processed correctly
+--echo #
+
+# The instrument wait/io/table/sql/handler should be enabled and timed. We will
+# restart the server with the instrument disabled from the command line.
+--echo #
+--echo # Verify that wait/io/table/sql/handler is enabled and timed
+--echo #
+SELECT * FROM performance_schema.setup_instruments
+WHERE name like "%wait/io/table/sql/handler%";
+
+# Write file to make mysql-test-run.pl wait for the server to stop
+--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+
+# Restart the server
+--echo #
+--echo # Stop server
+--send_shutdown
+--source include/wait_until_disconnected.inc
+
+--echo # Restart server with wait/io/table/sql/handler disabled
+
+--exec echo "restart:--loose-performance-schema-instrument=%wait/io/table/sql/%=off" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+
+# Turn on reconnect
+--echo # Enable reconnect
+--enable_reconnect
+
+# Wait for server to be back online again
+--echo # Wait until connected again
+--source include/wait_until_connected_again.inc
+
+# Turn off reconnect again
+--echo # Disable reconnect
+--disable_reconnect
+
+--echo #
+--echo # Verify that wait/io/table is disabled
+--echo #
+SELECT * FROM performance_schema.setup_instruments
+WHERE name like "%wait/io/table/sql/handler%";
diff --git a/mysql-test/suite/perfschema/t/setup_object_table_lock_io.test b/mysql-test/suite/perfschema/t/setup_object_table_lock_io.test
new file mode 100644
index 00000000..aaa17fa7
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/setup_object_table_lock_io.test
@@ -0,0 +1,107 @@
+# Test for Performance Schema.
+# To test the effect of disabling/enabling instrumentation for a table
+# in setup_objects table.
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_warnings
+drop table if exists test.setup_objects;
+--enable_warnings
+
+# Make sure only table io / table lock is instrumented and timed
+update performance_schema.setup_instruments set enabled='NO';
+update performance_schema.setup_instruments set enabled='YES', timed='YES'
+ where name in ('wait/io/table/sql/handler', 'wait/lock/table/sql/handler');
+
+# Remove noise from previous tests
+truncate table performance_schema.table_io_waits_summary_by_table;
+truncate table performance_schema.table_lock_waits_summary_by_table;
+
+# Save the setup
+create table test.setup_objects as select * from performance_schema.setup_objects;
+truncate table performance_schema.setup_objects;
+select * from performance_schema.setup_objects;
+
+insert into performance_schema.setup_objects
+ values ('TABLE', 'db1', 't1', 'YES', 'YES');
+
+insert into performance_schema.setup_objects
+ values ('TABLE', 'db1', 't2', 'YES', 'YES');
+
+select * from performance_schema.setup_objects
+ order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME;
+SET sql_mode = default;
+
+--disable_warnings
+drop database if exists db1;
+--enable_warnings
+
+create database db1;
+create table db1.t1 (a int, b char(10) default 'default', unique key uidx(a));
+create table db1.t2 (a int, b char(10) default 'default');
+
+# Insert some values in tables.
+insert into db1.t1 values('11', 'db1.t1');
+insert into db1.t1 values('12', 'db1.t1');
+insert into db1.t1 values('13', 'db1.t1');
+insert into db1.t2 values('21', 'db1.t2');
+insert into db1.t2 values('22', 'db1.t2');
+insert into db1.t2 values('23', 'db1.t2');
+
+# Query P_S tables. Stats should be updated.
+select OBJECT_SCHEMA, OBJECT_NAME, COUNT_STAR, COUNT_READ, COUNT_WRITE
+ from performance_schema.table_lock_waits_summary_by_table
+ where OBJECT_SCHEMA='db1';
+select OBJECT_SCHEMA, OBJECT_NAME, COUNT_STAR, COUNT_READ, COUNT_WRITE
+ from performance_schema.table_io_waits_summary_by_table
+ where OBJECT_SCHEMA='db1';
+
+truncate table db1.t1;
+truncate table db1.t2;
+
+# Query P_S tables. Stats should be updated.
+select OBJECT_SCHEMA, OBJECT_NAME, COUNT_STAR, COUNT_READ, COUNT_WRITE
+ from performance_schema.table_lock_waits_summary_by_table
+ where OBJECT_SCHEMA='db1';
+select OBJECT_SCHEMA, OBJECT_NAME, COUNT_STAR, COUNT_READ, COUNT_WRITE
+ from performance_schema.table_io_waits_summary_by_table
+ where OBJECT_SCHEMA='db1';
+
+# Disable instrumentation for db1.t1
+update performance_schema.setup_objects
+ set ENABLED='NO' where OBJECT_SCHEMA = 'db1' and OBJECT_NAME='t1';
+
+# Query P_S tables. Stats for db1.t1 should have been removed while for db1.t2 it should have been preserved.
+select OBJECT_SCHEMA, OBJECT_NAME, COUNT_STAR, COUNT_READ, COUNT_WRITE
+ from performance_schema.table_lock_waits_summary_by_table
+ where OBJECT_SCHEMA='db1';
+select OBJECT_SCHEMA, OBJECT_NAME, COUNT_STAR, COUNT_READ, COUNT_WRITE
+ from performance_schema.table_io_waits_summary_by_table
+ where OBJECT_SCHEMA='db1';
+
+# Enable instrumentation for db1.t1
+update performance_schema.setup_objects
+ set ENABLED='YES' where OBJECT_SCHEMA = 'db1' and OBJECT_NAME='t1';
+
+# Query P_S tables. Stats for db1.t1 should have been reset while for db1.t2 it should have been preserved.
+select OBJECT_SCHEMA, OBJECT_NAME, COUNT_STAR, COUNT_READ, COUNT_WRITE
+ from performance_schema.table_lock_waits_summary_by_table
+ where OBJECT_SCHEMA='db1';
+select OBJECT_SCHEMA, OBJECT_NAME, COUNT_STAR, COUNT_READ, COUNT_WRITE
+ from performance_schema.table_io_waits_summary_by_table
+ where OBJECT_SCHEMA='db1';
+
+truncate table performance_schema.setup_objects;
+
+select count(*) from performance_schema.setup_objects;
+
+drop database db1;
+
+# Restore the setup
+truncate table performance_schema.setup_objects;
+insert into performance_schema.setup_objects select * from test.setup_objects;
+drop table test.setup_objects;
+
+update performance_schema.setup_instruments set enabled='YES', timed='YES';
+
diff --git a/mysql-test/suite/perfschema/t/setup_objects.test b/mysql-test/suite/perfschema/t/setup_objects.test
new file mode 100644
index 00000000..604b35b0
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/setup_objects.test
@@ -0,0 +1,197 @@
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_warnings
+drop table if exists test.setup_objects;
+--enable_warnings
+
+# Make sure only table io / table lock is instrumented and timed
+update performance_schema.setup_instruments set enabled='NO';
+update performance_schema.setup_instruments set enabled='YES', timed='YES'
+ where name in ('wait/io/table/sql/handler', 'wait/lock/table/sql/handler');
+
+# Remove noise from previous tests
+truncate table performance_schema.events_waits_history_long;
+
+# Save the setup
+create table test.setup_objects as select * from performance_schema.setup_objects;
+truncate table performance_schema.setup_objects;
+
+insert into performance_schema.setup_objects
+ values ('TABLE', 'db1', 't1', 'YES', 'YES');
+
+insert into performance_schema.setup_objects
+ values ('TABLE', 'db1', 't2', 'YES', 'NO');
+
+insert into performance_schema.setup_objects
+ values ('TABLE', 'db1', '%', 'YES', 'YES');
+
+insert into performance_schema.setup_objects
+ values ('TABLE', 'db2', 't1', 'YES', 'YES');
+
+insert into performance_schema.setup_objects
+ values ('TABLE', 'db2', 't2', 'YES', 'NO');
+
+insert into performance_schema.setup_objects
+ values ('TABLE', 'db3', 't1', 'YES', 'YES');
+
+insert into performance_schema.setup_objects
+ values ('TABLE', 'db3', 't2', 'NO', 'NO');
+
+insert into performance_schema.setup_objects
+ values ('TABLE', 'db3', '%', 'NO', 'YES');
+
+insert into performance_schema.setup_objects
+ values ('TABLE', 'db4', 't1', 'NO', 'YES');
+
+insert into performance_schema.setup_objects
+ values ('TABLE', 'db4', '%', 'YES', 'NO');
+
+# Also test insert of invalid enum values
+SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
+--error ER_NO_REFERENCED_ROW_2
+insert into performance_schema.setup_objects
+ values ('SOMETHING', 'bad1', 'bad1', 'YES', 'NO');
+show warnings;
+
+--error ER_NO_REFERENCED_ROW_2
+insert into performance_schema.setup_objects
+ values ('TABLE', 'bad2', 'bad2', 'MAYBE', 'NO');
+show warnings;
+
+--error ER_NO_REFERENCED_ROW_2
+insert into performance_schema.setup_objects
+ values ('TABLE', 'bad3', 'bad3', 'YES', 'MAYBE NOT');
+show warnings;
+
+select * from performance_schema.setup_objects
+ order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME;
+
+# Also test update of invalid enum values
+# Note: do not use SHOW WARNINGS in the test,
+# because error messages such as:
+# "Data truncated for column 'OBJECT_TYPE' at row <N>"
+# do not always use the same row number <N>.
+
+# ER_WRONG_PERFSCHEMA_USAGE because of privileges, expected.
+--error ER_WRONG_PERFSCHEMA_USAGE
+update performance_schema.setup_objects
+ set OBJECT_TYPE='SOMETHING' where OBJECT_SCHEMA='db1' and OBJECT_NAME='t1';
+
+--error ER_NO_REFERENCED_ROW_2
+update performance_schema.setup_objects
+ set ENABLED='MAYBE' where OBJECT_SCHEMA='db1' and OBJECT_NAME='t1';
+
+--error ER_NO_REFERENCED_ROW_2
+update performance_schema.setup_objects
+ set TIMED='MAYBE NOT' where OBJECT_SCHEMA='db1' and OBJECT_NAME='t1';
+
+select * from performance_schema.setup_objects
+ order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME;
+SET sql_mode = default;
+--disable_warnings
+drop database if exists db1;
+drop database if exists db2;
+drop database if exists db3;
+drop database if exists db4;
+drop database if exists db5;
+--enable_warnings
+
+create database db1;
+create database db2;
+create database db3;
+create database db4;
+create database db5;
+
+create table db1.t1(a int);
+create table db1.t2(a int);
+create table db1.t3(a int);
+create table db1.t4(a int);
+create table db1.t5(a int);
+
+create table db2.t1(a int);
+create table db2.t2(a int);
+create table db2.t3(a int);
+create table db2.t4(a int);
+create table db2.t5(a int);
+
+create table db3.t1(a int);
+create table db3.t2(a int);
+create table db3.t3(a int);
+create table db3.t4(a int);
+create table db3.t5(a int);
+
+create table db4.t1(a int);
+create table db4.t2(a int);
+create table db4.t3(a int);
+create table db4.t4(a int);
+create table db4.t5(a int);
+
+create table db5.t1(a int);
+
+select * from db1.t1;
+select * from db1.t2;
+select * from db1.t3;
+select * from db1.t4;
+select * from db1.t5;
+
+select * from db2.t1;
+select * from db2.t2;
+select * from db2.t3;
+select * from db2.t4;
+select * from db2.t5;
+
+select * from db3.t1;
+select * from db3.t2;
+select * from db3.t3;
+select * from db3.t4;
+select * from db3.t5;
+
+select * from db4.t1;
+select * from db4.t2;
+select * from db4.t3;
+select * from db4.t4;
+select * from db4.t5;
+
+select * from db5.t1;
+
+create table db5.t2(a int);
+select * from db3.t2;
+
+# Verify what is instrumented
+select distinct OBJECT_TYPE, OBJECT_NAME, OBJECT_SCHEMA
+ from performance_schema.events_waits_history_long
+ where OBJECT_SCHEMA like "db%"
+ group by OBJECT_TYPE, OBJECT_NAME, OBJECT_SCHEMA
+ order by OBJECT_TYPE, OBJECT_NAME, OBJECT_SCHEMA;
+
+# Verify what is instrumented and timed
+select distinct OBJECT_TYPE, OBJECT_NAME, OBJECT_SCHEMA
+ from performance_schema.events_waits_history_long
+ where OBJECT_SCHEMA like "db%" and TIMER_END is not NULL
+ group by OBJECT_TYPE, OBJECT_NAME, OBJECT_SCHEMA
+ order by OBJECT_TYPE, OBJECT_NAME, OBJECT_SCHEMA;
+
+update performance_schema.setup_objects
+ set timed='YES' where OBJECT_SCHEMA = '%';
+
+create table db5.t3(a int);
+select * from db3.t3;
+
+truncate table performance_schema.setup_objects;
+
+select count(*) from performance_schema.setup_objects;
+
+drop database db1;
+drop database db2;
+drop database db3;
+drop database db4;
+drop database db5;
+
+# Restore the setup
+truncate table performance_schema.setup_objects;
+insert into performance_schema.setup_objects select * from test.setup_objects;
+drop table test.setup_objects;
+
+update performance_schema.setup_instruments set enabled='YES', timed='YES';
+
diff --git a/mysql-test/suite/perfschema/t/short_option_1-master.opt b/mysql-test/suite/perfschema/t/short_option_1-master.opt
new file mode 100644
index 00000000..13005cd1
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/short_option_1-master.opt
@@ -0,0 +1 @@
+-a -Cutf8 -W1
diff --git a/mysql-test/suite/perfschema/t/short_option_1.test b/mysql-test/suite/perfschema/t/short_option_1.test
new file mode 100644
index 00000000..31ba0245
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/short_option_1.test
@@ -0,0 +1,16 @@
+# Work around MDEV-29508
+
+# Tests for PERFORMANCE_SCHEMA
+# Check server start for short server start options
+
+select 'Ok, the server started' as result;
+
+# See the associated -master.opt file.
+
+select @@SQL_MODE;
+show global variables like 'sql_mode';
+
+select @@character_set_server;
+show global variables like 'character_set_system';
+
+show global variables like 'log_warnings';
diff --git a/mysql-test/suite/perfschema/t/short_option_2-master.opt b/mysql-test/suite/perfschema/t/short_option_2-master.opt
new file mode 100644
index 00000000..5d45b9ec
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/short_option_2-master.opt
@@ -0,0 +1 @@
+-aW2
diff --git a/mysql-test/suite/perfschema/t/short_option_2.test b/mysql-test/suite/perfschema/t/short_option_2.test
new file mode 100644
index 00000000..0921849c
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/short_option_2.test
@@ -0,0 +1,14 @@
+# Tests for PERFORMANCE_SCHEMA
+# Check server start for short server start options
+
+select 'Ok, the server started' as result;
+
+# See the associated -master.opt file.
+# -aW2 should be parsed as -a -W2, which are two separate short options
+# stuffed inside a single argv[i] argument.
+
+# Should contain ANSI, since we started the server with -a (stands for --ansi)
+select @@SQL_MODE;
+
+# Should be 2, since we started the server with -W2
+select @@log_warnings;
diff --git a/mysql-test/suite/perfschema/t/show_aggregate.test b/mysql-test/suite/perfschema/t/show_aggregate.test
new file mode 100644
index 00000000..c84e99f6
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/show_aggregate.test
@@ -0,0 +1,301 @@
+################# suite/perfschema/t/show_aggregate.test #######################
+# #
+# This test verifies: #
+# 1. Status variable values are consistent with corresponding server events. #
+# 2. Status variable values are consistent across session, thread, account, #
+# host, user and global tables. #
+# 3. Status totals for user, host and account are retained after related #
+# threads disconnect. #
+################################################################################
+
+--source include/have_perfschema.inc
+--source include/have_innodb.inc
+--source include/not_embedded.inc
+--source include/no_protocol.inc
+--source include/maybe_pool_of_threads.inc
+--source include/wait_for_pfs_thread_count.inc
+
+--echo #
+--echo # ================================================================================
+--echo # SETUP
+--echo # ================================================================================
+SET @@session.sql_log_bin=OFF;
+--echo #
+--echo # CREATE 3 CLIENTS, 3 CONNECTIONS, RESULTS TABLE
+connection default;
+USE test;
+
+flush status;
+
+--echo #
+--echo # Create results table
+CREATE TABLE test.status_results
+ (variable_name VARCHAR(64), start INT DEFAULT 0, stop INT DEFAULT 0, delta INT DEFAULT 0,
+ t1 INT DEFAULT 0, t2 INT DEFAULT 0, t3 INT DEFAULT 0, thread INT DEFAULT 0,
+ u1 INT DEFAULT 0, u2 INT DEFAULT 0, u3 INT DEFAULT 0, user INT DEFAULT 0,
+ h1 INT DEFAULT 0, h2 INT DEFAULT 0, h3 INT DEFAULT 0, host INT DEFAULT 0,
+ a1 INT DEFAULT 0, a2 INT DEFAULT 0, a3 INT DEFAULT 0, acct INT DEFAULT 0);
+
+INSERT INTO test.status_results (variable_name, start)
+ SELECT sg.variable_name, sg.variable_value+0 FROM performance_schema.global_status sg
+ WHERE variable_name IN ('handler_delete', 'handler_rollback');
+
+--echo
+--echo # Create test tables
+CREATE TABLE t1 (s1 int) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1), (2), (2), (3), (3), (3);
+CREATE TABLE t2 (s1 int) ENGINE=InnoDB;
+CREATE TABLE t3 (s1 int) ENGINE=InnoDB;
+--echo #
+set @orig_sql_mode= @@sql_mode;
+set sql_mode= (select replace(@@sql_mode,'NO_AUTO_CREATE_USER',''));
+GRANT ALL ON *.* to 'user1'@localhost;
+GRANT ALL ON *.* to 'user2'@localhost;
+GRANT ALL ON *.* to 'user3'@localhost;
+set sql_mode= @orig_sql_mode;
+
+--echo #
+--echo # ================================================================================
+--echo # CONNECTION 1: DELETE 1, ROLLBACK x 1
+--echo # ================================================================================
+connect(con1, localhost, user1,,);
+SET @@session.sql_log_bin=OFF;
+DELETE FROM t1 WHERE s1 = 1;
+START TRANSACTION;
+INSERT INTO t1 VALUES (1);
+ROLLBACK;
+
+--echo #
+--echo # ================================================================================
+--echo # CONNECTION 2: DELETE 2, ROLLBACK x 2
+--echo # ================================================================================
+connect(con2, localhost, user2,,);
+SET @@session.sql_log_bin=OFF;
+DELETE FROM t1 WHERE s1 = 2;
+--echo #
+START TRANSACTION;
+INSERT INTO t1 VALUES (2);
+ROLLBACK;
+--echo #
+START TRANSACTION;
+INSERT INTO t1 VALUES (2);
+ROLLBACK;
+
+--echo #
+--echo # ================================================================================
+--echo # CONNECTION 3: DELETE 3, ROLLBACK x 3
+--echo # ================================================================================
+connect(con3, localhost, user3,,);
+SET @@session.sql_log_bin=OFF;
+DELETE FROM t1 WHERE s1 = 3;
+--echo #
+START TRANSACTION;
+INSERT INTO t1 VALUES (3);
+ROLLBACK;
+--echo #
+START TRANSACTION;
+INSERT INTO t1 VALUES (3);
+ROLLBACK;
+--echo #
+START TRANSACTION;
+INSERT INTO t1 VALUES (3);
+ROLLBACK;
+
+--echo #
+--echo # ================================================================================
+--echo # CONNECTION DEFAULT: Gather results, compare session and global status counts
+--echo # ================================================================================
+connection default;
+--echo # Get thread ids for each connection.
+USE performance_schema;
+SELECT thread_id INTO @con1_id FROM threads WHERE processlist_user IN ('user1') and processlist_id;
+SELECT thread_id INTO @con2_id FROM threads WHERE processlist_user IN ('user2') and processlist_id;
+SELECT thread_id INTO @con3_id FROM threads WHERE processlist_user IN ('user3') and processlist_id;
+
+--source ../include/show_aggregate.inc
+
+#--echo DEBUG
+#USE test;
+#SELECT * FROM test.status_results;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 1: STATUS_BY_THREAD: Verify expected status counts per thread (1,2,3)
+--echo # ================================================================================
+--echo #
+--echo # Review per-thread status counts
+--echo #
+USE performance_schema;
+
+--echo #
+--echo # Verify expected counts for 'handler_delete' per thread
+--echo #
+--replace_column 1 con_1
+SELECT *, IF (variable_value = 1,'OK1','ERROR1') AS Expected FROM status_by_thread WHERE thread_id = @con1_id AND variable_name IN ('handler_delete', 'handler_rollback');
+--echo #
+--replace_column 1 con_2
+SELECT *, IF (variable_value = 2,'OK2','ERROR2') AS Expected FROM status_by_thread WHERE thread_id = @con2_id AND variable_name IN ('handler_delete', 'handler_rollback');
+--echo #
+--replace_column 1 con_3
+SELECT *, IF (variable_value = 3,'OK3','ERROR3') AS Expected FROM status_by_thread WHERE thread_id = @con3_id AND variable_name IN ('handler_delete', 'handler_rollback');
+
+--echo #
+--echo # STATUS_BY_THREAD vs. GLOBAL_STATUS
+--echo #
+SELECT variable_name, t1, t2, t3, delta, thread, IF(thread=delta,'OK4','ERROR4') Expected
+FROM test.status_results
+ORDER BY variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 2: STATUS_BY_USER: Verify expected status counts per user (1,2,3)
+--echo # ================================================================================
+SELECT *, IF (variable_value = 1,'OK5','ERROR5') AS Expected FROM status_by_user WHERE user IN ('user1') AND variable_name IN ('handler_delete');
+--echo #
+SELECT *, IF (variable_value = 2,'OK6','ERROR6') AS Expected FROM status_by_user WHERE user IN ('user2') AND variable_name IN ('handler_delete');
+--echo #
+SELECT *, IF (variable_value = 3,'OK7','ERROR7') AS Expected FROM status_by_user WHERE user IN ('user3') AND variable_name IN ('handler_delete');
+
+--echo #
+--echo # STATUS_BY_USER vs. GLOBAL_STATUS
+--echo #
+SELECT variable_name, u1, u2, u3, delta, user, IF(user=delta,'OK8','ERROR8') Expected
+FROM test.status_results
+ORDER BY variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 3: STATUS_BY_ACCOUNT: Verify expected status counts per user, host (1,2,3)
+--echo # ================================================================================
+SELECT *, IF (variable_value = 1,'OK9','ERROR9') AS Expected FROM status_by_account WHERE user IN ('user1') AND variable_name IN ('handler_delete');
+--echo #
+SELECT *, IF (variable_value = 2,'OKa','ERRORa') AS Expected FROM status_by_account WHERE user IN ('user2') AND variable_name IN ('handler_delete');
+--echo #
+SELECT *, IF (variable_value = 3,'OKb','ERRORb') AS Expected FROM status_by_account WHERE user IN ('user3') AND variable_name IN ('handler_delete');
+
+--echo #
+--echo # STATUS_BY_ACCOUNT vs. GLOBAL_STATUS
+--echo #
+SELECT variable_name, a1, a2, a3, delta, acct, IF(acct=delta,'OKc','ERRORc') Expected
+FROM test.status_results
+ORDER BY variable_name;
+
+--echo # ================================================================================
+--echo # TEST 4: STATUS_BY_HOST: Verify expected status counts per host (6)
+--echo # ================================================================================
+SELECT *, IF (variable_value = 6,'OKd','ERRORd') AS Expected FROM status_by_host WHERE host IN ('localhost') AND variable_name IN ('handler_delete');
+
+--echo #
+--echo # STATUS_BY_HOST vs. GLOBAL_STATUS
+--echo #
+--echo # Special case: No way to isolate pre-existing 'localhost' activity, so
+--echo # just check global totals = sum(status_by_host).
+--echo #
+SELECT variable_name, h1, h2, h3, delta, host, IF(host=delta,'OKe','ERRORe') Expected
+FROM test.status_results
+ORDER BY variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # DISCONNECT ALL USERS AND RUN THE TESTS AGAIN. RESULTS SHOULD NOT CHANGE.
+--echo # ================================================================================
+disconnect con1;
+disconnect con2;
+disconnect con3;
+
+--echo #
+USE test;
+--echo #
+--echo # Clear results table, leave initial global_status counts
+UPDATE test.status_results
+ SET stop=0, delta=0,
+ t1=0, t2=0, t3=0, thread=0,
+ u1=0, u2=0, u3=0, user=0,
+ h1=0, h2=0, h3=0, host=0,
+ a1=0, a2=0, a3=0, acct=0;
+
+let $wait_condition= select count(*) = 0 from performance_schema.threads where processlist_user like 'user%' and processlist_id;
+--source include/wait_condition.inc
+
+#--echo DEBUG
+#SELECT * FROM test.status_results;
+--echo #
+--source ../include/show_aggregate.inc
+
+USE performance_schema;
+--echo #
+--echo # ================================================================================
+--echo # TEST X: STATUS_BY_THREAD: Connections are gone--nothing to verify.
+--echo # ================================================================================
+--echo #
+--echo # ================================================================================
+--echo # TEST 5: STATUS_BY_USER: Verify expected status counts per user (1,2,3)
+--echo # ================================================================================
+SELECT *, IF (variable_value = 1,'OKf','ERRORf') AS Expected FROM status_by_user WHERE user IN ('user1') AND variable_name IN ('handler_delete');
+--echo #
+SELECT *, IF (variable_value = 2,'OKg','ERRORg') AS Expected FROM status_by_user WHERE user IN ('user2') AND variable_name IN ('handler_delete');
+--echo #
+SELECT *, IF (variable_value = 3,'OKh','ERRORh') AS Expected FROM status_by_user WHERE user IN ('user3') AND variable_name IN ('handler_delete');
+
+--echo #
+--echo # STATUS_BY_USER vs. GLOBAL_STATUS
+--echo #
+SELECT variable_name, u1, u2, u3, delta, user, IF(user=delta,'OKi','ERRORi') Expected
+FROM test.status_results
+ORDER BY variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 6: STATUS_BY_ACCOUNT: Verify expected status counts per user:host (1,2,3)
+--echo # ================================================================================
+SELECT *, IF (variable_value = 1,'OKj','ERRORj') AS Expected FROM status_by_account WHERE user IN ('user1') AND variable_name IN ('handler_delete');
+--echo #
+SELECT *, IF (variable_value = 2,'OKk','ERRORk') AS Expected FROM status_by_account WHERE user IN ('user2') AND variable_name IN ('handler_delete');
+--echo #
+SELECT *, IF (variable_value = 3,'OKl','ERRORl') AS Expected FROM status_by_account WHERE user IN ('user3') AND variable_name IN ('handler_delete');
+
+--echo #
+--echo # STATUS_BY_ACCOUNT vs. GLOBAL_STATUS
+--echo #
+SELECT variable_name, a1, a2, a3, delta, acct, IF(acct=delta,'OKn','ERRORn') Expected
+FROM test.status_results
+ORDER BY variable_name;
+
+--echo # ================================================================================
+--echo # TEST 7: STATUS_BY_HOST: Verify expected status counts per host (6)
+--echo # ================================================================================
+SELECT *, IF (variable_value = 6,'OKo','ERRORo') AS Expected FROM status_by_host WHERE host IN ('localhost') AND variable_name IN ('handler_delete');
+
+--echo #
+--echo # STATUS_BY_HOST vs. GLOBAL_STATUS
+--echo #
+--echo # Special case: No way to isolate pre-existing 'localhost' activity, so
+--echo # just check global totals = sum(status_by_host).
+--echo #
+SELECT variable_name, h1, h2, h3, delta, host, IF(host=delta,'OKp','ERRORp') Expected
+FROM test.status_results
+ORDER BY variable_name;
+
+--echo # ================================================================================
+--echo # TEST 8: FLUSH STATUS should clear account, host and user status
+--echo # ================================================================================
+--echo #
+FLUSH STATUS;
+--echo #
+SELECT * FROM status_by_account WHERE user IN ('user1', 'user2', 'user3') AND variable_name IN ('handler_delete');
+--echo #
+SELECT * FROM status_by_host WHERE host IN ('localhost') AND variable_name IN ('handler_delete');
+--echo #
+SELECT * FROM status_by_user WHERE user IN ('user1', 'user2', 'user3') AND variable_name IN ('handler_delete');
+
+--echo # ================================================================================
+--echo # CLEANUP
+--echo # ================================================================================
+DROP TABLE test.t1;
+DROP TABLE test.t2;
+DROP TABLE test.t3;
+DROP TABLE test.status_results;
+DROP USER 'user1'@localhost;
+DROP USER 'user2'@localhost;
+DROP USER 'user3'@localhost;
+--echo #
diff --git a/mysql-test/suite/perfschema/t/show_coverage.test b/mysql-test/suite/perfschema/t/show_coverage.test
new file mode 100644
index 00000000..6a8d90d6
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/show_coverage.test
@@ -0,0 +1,186 @@
+################### suite/perfschema/t/show_coverage.test ######################
+# #
+# Testcases to increase DGCOV coverage of the status and system variable #
+# implementation in the Performance Schema. #
+# #
+################################################################################
+--source include/have_perfschema.inc
+--source include/not_embedded.inc
+--source include/no_protocol.inc
+--source include/count_sessions.inc
+
+--echo #
+--echo # TEST 1
+--echo # Handling of SHOW STATUS/VARIABLES ... WHERE
+--echo #
+SHOW STATUS WHERE VARIABLE_NAME LIKE "foo";
+--echo #
+SHOW GLOBAL STATUS WHERE VARIABLE_NAME LIKE "foo";
+--echo #
+SHOW SESSION STATUS WHERE VARIABLE_NAME LIKE "foo";
+--echo #
+SHOW VARIABLES WHERE VARIABLE_NAME LIKE "foo";
+--echo #
+SHOW GLOBAL VARIABLES WHERE VARIABLE_NAME LIKE "foo";
+--echo #
+SHOW SESSION VARIABLES WHERE VARIABLE_NAME LIKE "foo";
+
+--echo #
+--echo # TEST 2
+--echo # CREATE..SELECT -- Expect correct ER_WARN_DEPRECATED_SYNTAX
+--echo #
+USE test;
+CREATE TABLE t0 SELECT * FROM information_schema.global_status WHERE variable_name = 'COM_SELECT';
+DROP TABLE t0;
+
+--echo #
+--echo # TEST 3
+--echo # Select status and system variable tables using ORDER BY to exercise the
+--echo # rnd_pos() method
+--echo #
+use performance_schema;
+--disable_result_log
+select * from global_variables order by variable_name;
+select * from variables_by_thread order by variable_name;
+select * from session_variables order by variable_name;
+select * from global_status order by variable_name;
+select * from session_status order by variable_name;
+select * from status_by_thread order by variable_name;
+select * from status_by_user order by variable_name;
+select * from status_by_host order by variable_name;
+select * from status_by_account order by variable_name;
+--enable_result_log
+
+--echo #
+--echo # TEST 4
+--echo # Handling of SHOW STATUS/VARIABLES ... WHERE
+--echo #
+SHOW STATUS WHERE VARIABLE_NAME LIKE "foo";
+--echo #
+SHOW GLOBAL STATUS WHERE VARIABLE_NAME LIKE "foo";
+--echo #
+SHOW SESSION STATUS WHERE VARIABLE_NAME LIKE "foo";
+--echo #
+SHOW VARIABLES WHERE VARIABLE_NAME LIKE "foo";
+--echo #
+SHOW GLOBAL VARIABLES WHERE VARIABLE_NAME LIKE "foo";
+--echo #
+SHOW SESSION VARIABLES WHERE VARIABLE_NAME LIKE "foo";
+
+--echo #
+--echo # TEST 5
+--echo # Confirm FLUSH STATUS resets counters for all threads.
+--echo #
+--echo #
+--echo # Create a new connection
+--connect(con1, localhost, root,,)
+--echo #
+--echo # Record thread id
+let $thread_id= `SELECT THREAD_ID FROM performance_schema.threads WHERE PROCESSLIST_ID = CONNECTION_ID()`;
+--echo #
+--echo # Increase bytes_received for new connection
+USE test;
+SHOW TABLES;
+--connection default
+USE performance_schema;
+--disable_query_log
+eval SELECT $thread_id INTO @thread_id;
+--enable_query_log
+
+--echo #
+--echo # Record bytes_received for other connection
+SELECT variable_value FROM status_by_thread
+ WHERE variable_name = "bytes_received" and thread_id = @thread_id INTO @bytes_before;
+--echo #
+--echo # Reset status counters
+FLUSH STATUS;
+--echo #
+--echo # Record bytes_received after reset
+SELECT variable_value FROM status_by_thread
+ WHERE variable_name = "bytes_received" and thread_id = @thread_id INTO @bytes_after;
+--echo #
+--echo # Expect bytes_before > bytes_after
+SELECT @bytes_before > @bytes_after AS 'Expect 1';
+--echo #
+--echo # Expect bytes_after is zero
+SELECT @bytes_after AS 'Expect 0';
+
+disconnect con1;
+--source include/wait_until_count_sessions.inc
+
+
+--echo #
+--echo # TEST 6
+--echo #
+--echo # Bug#28291258 FLUSH STATUS ADDS TWICE TO GLOBAL VALUES
+--echo #
+
+--echo #
+--echo # Default connection
+--let $initial_global_value = query_get_value(SHOW GLOBAL STATUS LIKE 'Slow_queries', Value, 1)
+
+--source include/count_sessions.inc
+
+--echo #
+--echo # First connection
+--connect (con1, localhost, root,,)
+
+## Global value requested from the first session must not change
+--let $current_global_value = query_get_value(SHOW GLOBAL STATUS LIKE 'Slow_queries', Value, 1)
+--let $assert_cond = $current_global_value - $initial_global_value = 0
+--let $assert_text = Global value requested from the first session must not change
+--source include/assert.inc
+
+--echo #
+--echo # Generate a slow query
+--echo #
+SET long_query_time = 2;
+SELECT SLEEP(4);
+SET long_query_time = @@global.long_query_time;
+--echo #
+
+## Global value requested from the first session after SLEEP() must increase by 1
+--let $current_global_value = query_get_value(SHOW GLOBAL STATUS LIKE 'Slow_queries', Value, 1)
+--let $first_session_value = query_get_value(SHOW SESSION STATUS LIKE 'Slow_queries', Value, 1)
+--let $assert_cond = $current_global_value - $initial_global_value = 1
+--let $assert_text = Global value requested from the first session after SLEEP() must increase by 1
+--source include/assert.inc
+--let $assert_cond = $first_session_value = 1
+--let $assert_text = First session value must increase by 1
+--source include/assert.inc
+
+--connection default
+--disconnect con1
+--source include/wait_until_count_sessions.inc
+
+--echo #
+--echo # Default connection
+--connection default
+
+## Global value requested from the default session after DISCONNECT must remain the same
+--let $current_global_value = query_get_value(SHOW GLOBAL STATUS LIKE 'Slow_queries', Value, 1)
+--let $default_session_value = query_get_value(SHOW SESSION STATUS LIKE 'Slow_queries', Value, 1)
+--let $assert_cond = $current_global_value - $initial_global_value = 1
+--let $assert_text = Global value requested from the default session after DISCONNECT must remain the same
+--source include/assert.inc
+
+## Default session value must remain zero
+--let $assert_cond = $default_session_value = 0
+--let $assert_text = Default session value must remain zero
+--source include/assert.inc
+
+--echo #
+FLUSH STATUS;
+--echo #
+
+## Global value requested from the default session after FLUSH must remain the same
+--let $current_global_value = query_get_value(SHOW GLOBAL STATUS LIKE 'Slow_queries', Value, 1)
+--let $default_session_value = query_get_value(SHOW SESSION STATUS LIKE 'Slow_queries', Value, 1)
+--let $assert_cond = $current_global_value - $initial_global_value = 1
+--let $assert_text = Global value requested from the default session after FLUSH must remain the same
+--source include/assert.inc
+
+## Default session value after FLUSH must remain zero
+--let $assert_cond = $default_session_value = 0
+--let $assert_text = Default session value after FLUSH must remain zero
+--source include/assert.inc
diff --git a/mysql-test/suite/perfschema/t/show_misc.test b/mysql-test/suite/perfschema/t/show_misc.test
new file mode 100644
index 00000000..e557ef31
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/show_misc.test
@@ -0,0 +1,64 @@
+--source include/have_perfschema.inc
+--source include/not_embedded.inc
+--source include/no_protocol.inc
+
+select 1;
+SHOW STATUS LIKE 'Last_query_partial_plans';
+select 2;
+SHOW STATUS LIKE 'Last_query_cost';
+
+flush status;
+SHOW STATUS LIKE 'Created_tmp_tables';
+
+--echo #
+--echo # ================================================================================
+--echo # Bug#21789221 SHOW STATUS FAILS WITH LOCK TABLES AND SHOW_COMPATIBILITY_56=OFF
+--echo # ================================================================================
+--echo # Verify that SHOW STATUS and SHOW VARIABLES works under LOCK TABLES mode
+--echo #
+CREATE TABLE test.t1 (s1 INT);
+LOCK TABLE test.t1 READ;
+--echo #
+SHOW GLOBAL STATUS WHERE VARIABLE_NAME LIKE "foo";
+--echo #
+SHOW SESSION STATUS WHERE VARIABLE_NAME LIKE "foo";
+--echo #
+SHOW GLOBAL VARIABLES WHERE VARIABLE_NAME LIKE "foo";
+--echo #
+SHOW SESSION VARIABLES WHERE VARIABLE_NAME LIKE "foo";
+--echo #
+UNLOCK TABLES;
+--echo #
+LOCK TABLE test.t1 WRITE;
+--echo #
+SHOW GLOBAL STATUS WHERE VARIABLE_NAME LIKE "foo";
+--echo #
+SHOW SESSION STATUS WHERE VARIABLE_NAME LIKE "foo";
+--echo #
+SHOW GLOBAL VARIABLES WHERE VARIABLE_NAME LIKE "foo";
+--echo #
+SHOW SESSION VARIABLES WHERE VARIABLE_NAME LIKE "foo";
+--echo #
+UNLOCK TABLES;
+
+DROP TABLE test.t1;
+
+
+--echo #
+--echo # ================================================================================
+--echo # Bug#28515475 BOGUS DATA WHEN ORDERING RESULTS FROM VARIABLES_BY_THREAD
+--echo # ================================================================================
+--echo # Verify the results from "WHERE variable_name IN(...)", particularly for those
+--echo # variables that are listed after the deprecated variable gtid_executed.
+--echo # The ORDER BY also forces an additional code path through rnd_pos().
+--echo #
+
+SELECT variable_name FROM performance_schema.variables_by_thread
+ WHERE variable_name IN ('interactive_timeout','net_read_timeout','net_write_timeout','wait_timeout')
+ ORDER BY variable_name;
+
+
+--echo #
+--echo # ================================================================================
+--echo # CLEAN UP
+--echo # ================================================================================
diff --git a/mysql-test/suite/perfschema/t/show_plugin.test b/mysql-test/suite/perfschema/t/show_plugin.test
new file mode 100644
index 00000000..7109c314
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/show_plugin.test
@@ -0,0 +1,321 @@
+################# suite/perfschema/t/show_plugin.test ##########################
+# #
+# MySQL plugins can define their own status variables and system variables. #
+# This test exercises SHOW STATUS, SHOW VARIABLES and the status and system #
+# variable tables while the EXAMPLE plugin is loaded and unloaded. #
+# #
+# The EXAMPLE plugin defines the following system and status variables: #
+# Global system variables: #
+# example_double_thdvar #
+# example_double_var #
+# example_enum_var #
+# example_ulong_var #
+# #
+# Session variables: #
+# example_double_thdvar - Local and/or global #
+# #
+# Global status: #
+# example_func_example - Status function #
+# #
+################################################################################
+
+--source include/have_perfschema.inc
+--source include/not_embedded.inc
+--source include/not_windows_embedded.inc
+--source include/have_example_plugin.inc
+--source include/have_innodb.inc
+--source include/have_debug_sync.inc
+
+--enable_connect_log
+
+--echo #
+--echo # ================================================================================
+--echo # SETUP
+--echo # ================================================================================
+--echo # Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+--echo #
+--echo # Verify EXAMPLE plugin is not loaded
+SELECT COUNT(*) = 0 AS "Expect 1" FROM information_schema.plugins WHERE plugin_name = "EXAMPLE";
+--echo #
+--echo # Create one session to force local and global system variables
+--connect(con0, localhost, root,,)
+--connection default
+--echo #
+--echo # ================================================================================
+--echo # TEST 1- NO PLUGIN VARS
+--echo # ================================================================================
+--source ../include/show_plugin_verifier.inc
+--echo #
+
+--echo # ================================================================================
+--echo # TEST 2 - PLUGIN LOAD, UNLOAD, RELOAD
+--echo # ================================================================================
+--echo # ================================================================================
+--echo # 2.1 - INSTALL PLUGIN
+--echo # ================================================================================
+INSTALL PLUGIN example SONAME 'ha_example';
+
+--echo #
+--echo # ================================================================================
+--echo # 2.1a - FORCE SYNC OF LOCAL AND GLOBAL SYSTEM VARS
+--echo # ================================================================================
+--source ../include/show_plugin_verifier.inc
+
+--disconnect con0
+
+--echo #
+--echo # ================================================================================
+--echo # 2.2 - SET PLUGIN VARS
+--echo # ================================================================================
+--echo # GLOBAL
+SET GLOBAL example_ulong_var = 100;
+SET GLOBAL example_enum_var = e1;
+SET GLOBAL example_double_var = 100.9990;
+SET GLOBAL example_double_thdvar = 101.9991;
+--echo # SESSION
+SET SESSION example_double_thdvar = 102.9992;
+
+--echo #
+--echo # ================================================================================
+--echo # 2.3 - VERIFY UPDATED PLUGIN VARS
+--echo # ================================================================================
+--source ../include/show_plugin_verifier.inc
+
+--echo #
+--echo # ================================================================================
+--echo # 2.4 - UNINSTALL PLUGIN
+--echo # ================================================================================
+UNINSTALL PLUGIN example;
+
+--echo #
+--echo # ================================================================================
+--echo # 2.5 - VERIFY NO PLUGIN VARS
+--echo # ================================================================================
+--source ../include/show_plugin_verifier.inc
+
+--echo #
+--echo # ================================================================================
+--echo # 2.6 - REINSTALL PLUGIN
+--echo # ================================================================================
+--echo # Reinstall EXAMPLE plugin
+INSTALL PLUGIN example SONAME 'ha_example';
+
+--echo #
+--echo # ================================================================================
+--echo # 2.7 - SET PLUGIN VARS AGAIN
+--echo # ================================================================================
+--echo # GLOBAL
+SET GLOBAL example_ulong_var = 200;
+SET GLOBAL example_enum_var = e2;
+SET GLOBAL example_double_var = 200.8880;
+SET GLOBAL example_double_thdvar = 201.8881;
+--echo # SESSION
+SET SESSION example_double_thdvar = 202.8882;
+
+--echo #
+--echo # ================================================================================
+--echo # 2.8 - VERIFY PLUGIN VARS
+--echo # ================================================================================
+--source ../include/show_plugin_verifier.inc
+
+--echo #
+--echo # ================================================================================
+--echo # 2.9 - UNINSTALL PLUGIN
+--echo # ================================================================================
+UNINSTALL PLUGIN example;
+
+--echo #
+--echo # ================================================================================
+--echo # 2.10 - VERIFY NO PLUGIN VARS
+--echo # ================================================================================
+--source ../include/show_plugin_verifier.inc
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 3 - SESSION PLUGIN VARS ON MULTIPLE CONNECTIONS
+--echo # ================================================================================
+--echo #
+--echo # ================================================================================
+--echo # 3.1 - INSTALL PLUGIN
+--echo # ================================================================================
+INSTALL PLUGIN example SONAME 'ha_example';
+
+--echo #
+--echo # ================================================================================
+--echo # 3.2 - SET GLOBAL AND DEFAULT CONNECTION VARS
+--echo # ================================================================================
+--connection default
+SET GLOBAL example_ulong_var = 300;
+SET GLOBAL example_enum_var = e1;
+SET GLOBAL example_double_var = 301.0000;
+SET GLOBAL example_double_thdvar = 302.0000;
+SET SESSION example_double_thdvar = 300.0000;
+
+--echo #
+--echo # ================================================================================
+--echo # 3.3 - CONNECT 3 CLIENTS, SET LOCAL PLUGIN VARS
+--echo # ================================================================================
+--connect(con1, localhost, root,,)
+SET SESSION example_double_thdvar = 300.1111;
+--echo #
+--connect(con2, localhost, root,,)
+SET SESSION example_double_thdvar = 300.2222;
+--echo #
+--connect(con3, localhost, root,,)
+SET SESSION example_double_thdvar = 300.3333;
+--echo #
+--connection default
+
+--echo #
+--echo # ================================================================================
+--echo # 3.4 - VERIFY GLOBAL AND SESSION PLUGIN VARS
+--echo # ================================================================================
+--source ../include/show_plugin_verifier.inc
+--echo #
+--echo # Variables by thread
+SELECT variable_name, variable_value FROM performance_schema.variables_by_thread
+WHERE variable_name LIKE "example_%" ORDER BY variable_value;
+
+--echo #
+--echo # ================================================================================
+--echo # 3.5 - DISCONNECT CLIENTS
+--echo # ================================================================================
+--connection con1
+--disconnect con1
+--source include/wait_until_disconnected.inc
+
+--connection con2
+--disconnect con2
+--source include/wait_until_disconnected.inc
+
+--connection con3
+--disconnect con3
+--source include/wait_until_disconnected.inc
+
+--connection default
+
+--echo #
+--echo # ================================================================================
+--echo # 3.6 - VERIFY SESSION VARS ARE REMOVED
+--echo # ================================================================================
+--source ../include/show_plugin_verifier.inc
+--echo #
+--echo # Variables by thread
+SELECT variable_name, variable_value FROM performance_schema.variables_by_thread
+WHERE variable_name LIKE "example_%" ORDER BY variable_value;
+
+--echo #
+--echo # ================================================================================
+--echo # 3.7 - RECONNECT 3 CLIENTS, SET SESSION VARS FOR EACH
+--echo # ================================================================================
+--connect(con1, localhost, root,,)
+SET SESSION example_double_thdvar = 311.1111;
+--echo #
+--connect(con2, localhost, root,,)
+SET SESSION example_double_thdvar = 322.2222;
+--echo #
+--connect(con3, localhost, root,,)
+SET SESSION example_double_thdvar = 333.3333;
+--echo #
+--connection default
+
+--echo #
+--echo # ================================================================================
+--echo # 3.8 - VERIFY GLOBAL AND SESSION VARS
+--echo # ================================================================================
+--source ../include/show_plugin_verifier.inc
+--echo #
+--echo # Variables by thread
+SELECT variable_name, variable_value FROM performance_schema.variables_by_thread
+WHERE variable_name LIKE "example_%" ORDER BY variable_value;
+
+--echo #
+--echo # ================================================================================
+--echo # 3.9 - UNINSTALL PLUGIN, LEAVE CLIENTS CONNECTED
+--echo # ================================================================================
+UNINSTALL PLUGIN example;
+
+--echo #
+--echo # ================================================================================
+--echo # 3.10 - VERIFY SESSION VARS ARE REMOVED
+--echo # ================================================================================
+--source ../include/show_plugin_verifier.inc
+--echo #
+--echo # VARIABLES BY THREAD
+SELECT variable_name, variable_value FROM performance_schema.variables_by_thread
+WHERE variable_name LIKE "example_%" ORDER BY variable_value;
+
+--echo #
+--echo # ================================================================================
+--echo # 3.11 - DISCONNECT CLIENTS
+--echo # ================================================================================
+--connection con1
+--disconnect con1
+--source include/wait_until_disconnected.inc
+
+--connection con2
+--disconnect con2
+--source include/wait_until_disconnected.inc
+
+--connection con3
+--disconnect con3
+--source include/wait_until_disconnected.inc
+
+--connection default
+
+--echo #
+--echo # ================================================================================
+--echo # 3.12 - VERIFY CLIENTS ARE REMOVED
+--echo # ================================================================================
+--source ../include/show_plugin_verifier.inc
+--echo #
+--echo # VARIABLES BY THREAD
+SELECT variable_name, variable_value FROM performance_schema.variables_by_thread
+WHERE variable_name LIKE "example_%" ORDER BY variable_value;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 4 - BUG#18008907: DEADLOCK WITH CHANGE_USER, SHOW VARIABLES, INSTALL PLUGIN
+--echo # ================================================================================
+--echo #
+--echo #
+--echo # ================================================================================
+--echo # TEST 5 - BUG#22225549 MYSQL_CHANGE_USER/MYSQL_RESET_CONNECTION + SET INNODB...
+--echo Update to plugin-defined session variable triggers resync with global
+--echo variables and deadlocks on THD::LOCK_thd_sysvar.
+--echo # ================================================================================
+#
+# The deadlock occurs when plugin-defined session variables are resynced with the global
+# variables. To force a resync, change the user and update a session variable from a
+# plugin, in this case InnoDB.
+#
+select @@session.innodb_strict_mode;
+let $innodb_strict_mode_save = `select @@session.innodb_strict_mode`;
+select user(), current_user();
+--echo # change_user root
+--change_user root
+--echo #
+--echo # Trigger a resync of session variables with global variables.
+--echo #
+set @@session.innodb_strict_mode=off;
+
+--echo #
+--echo # Restore
+--echo #
+eval set @@session.innodb_strict_mode=$innodb_strict_mode_save;
+select @@session.innodb_strict_mode;
+
+--echo #
+--echo # ================================================================================
+--echo # CLEAN UP
+--echo # ================================================================================
+--connection default
+--echo #
+
+--echo #
+--disable_connect_log
+
+--echo #
+--echo # Wait till we reached the initial number of concurrent sessions
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/suite/perfschema/t/show_sanity.test b/mysql-test/suite/perfschema/t/show_sanity.test
new file mode 100644
index 00000000..3ca88b55
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/show_sanity.test
@@ -0,0 +1,1831 @@
+################# suite/perfschema/t/show_sanity.test ##########################
+# #
+# Compare global/session status and system variables in the Information Schema #
+# to those in Performance Schema. Do this once with SHOW_COMPATIBILITY_56 = ON #
+# again with SHOW_COMPATIBILITY_56 = OFF. #
+# #
+# Status and system variables may have a scope of: #
+# #
+# GLOBAL - System level only. #
+# SESSION - Applies at both the global and session level. #
+# Status variables with SESSION scope are totaled across all #
+# threads for global queries such as SHOW GLOBAL STATUS. #
+# System variables with SESSION scope have a global default #
+# that can be changed at the session level. #
+# SESSION-ONLY - Client connection level only. #
+# #
+#==============================================================================#
+# This test consists of two phases: #
+# #
+# COLLECTION - Gather results from SHOW commands and SELECTs on the I_S/P_S #
+# tables into a single table. Tag each variable with the source (SHOW, SELECT, #
+# P_S, I_S) and compatibility mode setting (OFF, ON). #
+# #
+# VERIFICATION - Compare and cross-reference the results between and across #
+# sources and compatibility modes, factoring in the known variances. #
+# #
+# The verification phase assumes that there will be no variation between the #
+# 5.6 and 5.7 results as long as known discrepancies in scope handling are #
+# accounted for. Expected variations are tagged as "JUNK" and filtered from #
+# the comparisons. #
+# #
+# The expected scope for each variable was initially determined from the MySQL #
+# system and status variable documentation and then further verified by the #
+# actual implementation. #
+# #
+# The difference between how 5.6 and 5.7 manage query scope vs. variable scope #
+# are summarized as follows: #
+# #
+# *** SHOW_COMPATIBILITY_56 = ON *** #
+# #
+# SHOW GLOBAL STATUS / I_S.GLOBAL_STATUS #
+# GLOBAL - Yes #
+# SESSION - Yes, totaled across all threads #
+# SESSION-ONLY - Yes, current session #
+# #
+# SHOW SESSION STATUS / I_S.SESSION_STATUS #
+# GLOBAL - Yes #
+# SESSION - Yes, current session #
+# SESSION-ONLY - Yes #
+# #
+# SHOW GLOBAL VARIABLES / I_S.GLOBAL_VARIABLES #
+# GLOBAL - Yes #
+# SESSION - Yes #
+# SESSION-ONLY - No #
+# #
+# SHOW SESSION VARIABLES / I_S.SESSION_VARIABLES #
+# GLOBAL - Yes #
+# SESSION - Yes, current session #
+# SESSION-ONLY - Yes #
+# #
+# *** SHOW_COMPATIBILITY_56 = OFF *** #
+# #
+# Information Schema status and system tables are disabled #
+# (ER_FEATURE_DISABLED_SEE_DOC). #
+# #
+# SHOW GLOBAL STATUS / P_S.GLOBAL_STATUS #
+# GLOBAL - Yes #
+# SESSION - Yes (totaled across all threads for SHOW STATUS) #
+# SESSION-ONLY - No #
+# #
+# SHOW SESSION STATUS / P_S.SESSION_STATUS, STATUS_BY_THREAD #
+# GLOBAL - No #
+# SESSION - Yes #
+# SESSION-ONLY - Yes #
+# #
+# P_S.STATUS_BY_USER / HOST / ACCOUNT #
+# GLOBAL - No #
+# SESSION - Yes (totaled across all related threads) #
+# SESSION-ONLY - No #
+# #
+# SHOW GLOBAL VARIABLES / P_S.GLOBAL_VARIABLES #
+# GLOBAL - Yes #
+# SESSION - No #
+# SESSION-ONLY - No #
+# #
+# SHOW SESSION VARIABLES / P_S.SESSION_VARIABLES, VARIABLES_BY_THREAD #
+# GLOBAL - No #
+# SESSION - Yes #
+# SESSION-ONLY - Yes #
+# #
+# In addition to the differences in how variable scope is handled, comparisons #
+# between 5.6 and 5.7 must also account for differences in how variables are #
+# represented based upon the variable type or meaning. For example, #
+# SESSION-ONLY variables such as "Last Query Cost" have no meaning when #
+# aggregated by user, account or host. #
+# #
+# These additional differences are summarized as follows: #
+# #
+# I_S.GLOBAL_STATUS vs. P_S.GLOBAL_STATUS #
+# - Remove SESSION-ONLY #
+# - Remove SLAVE-ONLY #
+# #
+# I_S.SESSION_STATUS vs. P_S.SESSION_STATUS #
+# - Remove GLOBAL-only vars #
+# - Remove SLAVE-ONLY #
+# #
+# P_S.SESSION_STATUS vs. P_S.STATUS_BY_USER/HOST/ACCOUNT #
+# - Remove SESSION-ONLY #
+# - Remove non-aggregatable #
+# #
+################################################################################
+--source include/have_perfschema.inc
+--source include/not_embedded.inc
+--source include/no_protocol.inc
+
+create table test.sanity(
+ `SHOW_MODE` varchar(48) NOT NULL,
+ `SOURCE` varchar(64) NOT NULL,
+ `VARIABLE_NAME` varchar(64) NOT NULL);
+
+select thread_id from performance_schema.threads
+ where processlist_id = connection_id()
+ into @my_tid;
+
+select @@global.show_compatibility_56 into @show_compatibility_56_save;
+
+set @my_user='root';
+set @my_host='localhost';
+
+# Debug
+# select connection_id(), @my_tid, @my_user, @my_host;
+# show plugins
+--echo #
+--echo # ================================================================================
+--echo # SHOW_COMPATIBILITY_56 = ON
+--echo # ================================================================================
+set global show_compatibility_56 = on;
+
+--echo #
+--echo # STEP 1-1
+insert into test.sanity
+ select "5.6", "I_S.GLOBAL_VARIABLES", variable_name
+ from information_schema.global_variables;
+
+--echo #
+--echo # STEP 1-2
+insert into test.sanity
+ select "5.6", "I_S.SESSION_VARIABLES", variable_name
+ from information_schema.session_variables;
+
+--echo #
+--echo # STEP 1-3
+insert into test.sanity
+ select "5.6", "P_S.GLOBAL_VARIABLES", variable_name
+ from performance_schema.global_variables;
+
+--echo #
+--echo # STEP 1-4
+insert into test.sanity
+ select "5.6", "P_S.VARIABLES_BY_THREAD", variable_name
+ from performance_schema.variables_by_thread
+ where thread_id = @my_tid;
+
+--echo #
+--echo # STEP 1-5
+insert into test.sanity
+ select "5.6", "P_S.SESSION_VARIABLES", variable_name
+ from performance_schema.session_variables;
+
+--echo #
+--echo # STEP 1-6
+insert into test.sanity
+ select "5.6", "I_S.GLOBAL_STATUS", variable_name
+ from information_schema.global_status;
+
+--echo #
+--echo # STEP 1-7
+insert into test.sanity
+ select "5.6", "I_S.SESSION_STATUS", variable_name
+ from information_schema.session_status;
+
+--echo #
+--echo # STEP 1-8
+insert into test.sanity
+ select "5.6", "P_S.GLOBAL_STATUS", variable_name
+ from performance_schema.global_status;
+
+--echo #
+--echo # STEP 1-9
+--echo # EMPTY, NO WARNINGS (not available in 5.6 mode)
+select *
+ from performance_schema.status_by_thread;
+
+--echo #
+--echo # STEP 1-10
+insert into test.sanity
+ select "5.6", "P_S.SESSION_STATUS", variable_name
+ from performance_schema.session_status;
+
+--echo #
+--echo # STEP 1-11
+--echo # EMPTY, NO WARNINGS (not available in 5.6 mode)
+select *
+ from performance_schema.status_by_account;
+
+--echo #
+--echo # STEP 1-12
+--echo # EMPTY, NO WARNINGS (not available in 5.6 mode)
+select *
+ from performance_schema.status_by_user;
+
+--echo #
+--echo # STEP 1-13
+--echo # EMPTY, NO WARNINGS (not available in 5.6 mode)
+select *
+ from performance_schema.status_by_host;
+
+--echo #
+--echo # ================================================================================
+--echo # SHOW_COMPATIBILITY_56 = OFF
+--echo # ================================================================================
+set global show_compatibility_56 = off;
+
+--echo #
+--echo # STEP 2-1
+--echo # FAILS WITH ERROR
+--error ER_FEATURE_DISABLED_SEE_DOC
+select *
+ from information_schema.global_variables;
+
+--echo #
+--echo # STEP 2-2
+--echo # FAILS WITH ERROR
+--error ER_FEATURE_DISABLED_SEE_DOC
+select *
+ from information_schema.session_variables;
+
+--echo #
+--echo # STEP 2-3
+insert into test.sanity
+ select "5.7", "P_S.GLOBAL_VARIABLES", variable_name
+ from performance_schema.global_variables;
+
+--echo #
+--echo # STEP 2-4
+insert into test.sanity
+ select "5.7", "P_S.VARIABLES_BY_THREAD", variable_name
+ from performance_schema.variables_by_thread
+ where thread_id = @my_tid;
+
+--echo #
+--echo # STEP 2-5
+insert into test.sanity
+ select "5.7", "P_S.SESSION_VARIABLES", variable_name
+ from performance_schema.session_variables;
+
+--echo #
+--echo # STEP 2-6
+--echo # FAILS WITH ERROR
+--error ER_FEATURE_DISABLED_SEE_DOC
+select *
+ from information_schema.global_status;
+
+--echo #
+--echo # STEP 2-7
+--echo # FAILS WITH ERROR
+--error ER_FEATURE_DISABLED_SEE_DOC
+select *
+ from information_schema.session_status;
+
+--echo #
+--echo # STEP 2-8
+insert into test.sanity
+ select "5.7", "P_S.GLOBAL_STATUS", variable_name
+ from performance_schema.global_status;
+
+--echo #
+--echo # STEP 2-9
+insert into test.sanity
+ select "5.7", "P_S.STATUS_BY_THREAD", variable_name
+ from performance_schema.status_by_thread
+ where thread_id = @my_tid;
+
+--echo #
+--echo # STEP 2-10
+insert into test.sanity
+ select "5.7", "P_S.SESSION_STATUS", variable_name
+ from performance_schema.session_status;
+
+--echo #
+--echo # STEP 2-11
+insert into test.sanity
+ select "5.7", "P_S.STATUS_BY_ACCOUNT", variable_name
+ from performance_schema.status_by_account
+ where `user` = @my_user and `host` = @my_host;
+
+--echo #
+--echo # STEP 2-12
+insert into test.sanity
+ select "5.7", "P_S.STATUS_BY_USER", variable_name
+ from performance_schema.status_by_user
+ where `user` = @my_user;
+
+--echo #
+--echo # STEP 2-13
+insert into test.sanity
+ select "5.7", "P_S.STATUS_BY_HOST", variable_name
+ from performance_schema.status_by_host
+ where `host` = @my_host;
+
+--echo #
+--echo # STEP 2-14
+--echo # Known global variables in 5.6 that should not display in session queries.
+--echo # These should be global-only system variables.
+--disable_query_log
+insert into test.sanity values
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "AUTO_GENERATE_CERTS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "AUTOMATIC_SP_PRIVILEGES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "AVOID_TEMPORAL_UPGRADE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "BACK_LOG"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "BASEDIR"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "BIND_ADDRESS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "BINLOGGING_IMPOSSIBLE_MODE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "BINLOG_CACHE_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "BINLOG_CHECKSUM"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "BINLOG_ERROR_ACTION"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "BINLOG_GROUP_COMMIT_SYNC_DELAY"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "BINLOG_GROUP_COMMIT_SYNC_NO_DELAY_COUNT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "BINLOG_GTID_SIMPLE_RECOVERY"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "BINLOG_MAX_FLUSH_QUEUE_TIME"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "BINLOG_ORDER_COMMITS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "BINLOG_STMT_CACHE_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "CHARACTER_SETS_DIR"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "CHARACTER_SET_SYSTEM"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "CHECK_PROXY_USERS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "CONCURRENT_INSERT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "CONNECT_TIMEOUT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "CORE_FILE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "DATADIR"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "DATETIME_FORMAT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "DATE_FORMAT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "DEFAULT_AUTHENTICATION_PLUGIN"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "DEFAULT_PASSWORD_LIFETIME"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "DELAYED_INSERT_LIMIT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "DELAYED_INSERT_TIMEOUT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "DELAYED_QUEUE_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "DELAY_KEY_WRITE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "DISABLED_STORAGE_ENGINES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "DISCONNECT_ON_EXPIRED_PASSWORD"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "ENFORCE_GTID_CONSISTENCY"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "EVENT_SCHEDULER"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "EXECUTED_GTIDS_COMPRESSION_PERIOD"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "EXPIRE_LOGS_DAYS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "FLUSH"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "FLUSH_TIME"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "FT_BOOLEAN_SYNTAX"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "FT_MAX_WORD_LEN"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "FT_MIN_WORD_LEN"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "FT_QUERY_EXPANSION_LIMIT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "FT_STOPWORD_FILE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "GENERAL_LOG"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "GENERAL_LOG_FILE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "GTID_EXECUTED_COMPRESSION_PERIOD"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "GTID_MODE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "GTID_PURGED"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "HAVE_COMPRESS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "HAVE_CRYPT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "HAVE_DYNAMIC_LOADING"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "HAVE_GEOMETRY"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "HAVE_OPENSSL"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "HAVE_PROFILING"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "HAVE_QUERY_CACHE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "HAVE_RTREE_KEYS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "HAVE_SSL"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "HAVE_STATEMENT_TIMEOUT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "HAVE_SYMLINK"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "HOSTNAME"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "HOST_CACHE_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "IGNORE_BUILTIN_INNODB"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "IGNORE_DB_DIRS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INIT_CONNECT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INIT_FILE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INIT_SLAVE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_ADAPTIVE_FLUSHING"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_ADAPTIVE_FLUSHING_LWM"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_FLUSH_SYNC"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_ADAPTIVE_HASH_INDEX"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_ADAPTIVE_HASH_INDEX_PARTS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_AUTOEXTEND_INCREMENT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_AUTOINC_LOCK_MODE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_BACKGROUND_DROP_LIST_EMPTY"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_BUFFER_POOL_CHUNK_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_BUFFER_POOL_DUMP_AT_SHUTDOWN"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_BUFFER_POOL_DUMP_NOW"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_BUFFER_POOL_DUMP_PCT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_BUFFER_POOL_EVICT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_BUFFER_POOL_FILENAME"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_BUFFER_POOL_LOAD_ABORT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_BUFFER_POOL_LOAD_AT_STARTUP"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_BUFFER_POOL_LOAD_NOW"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_BUFFER_POOL_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_BUF_FLUSH_LIST_NOW"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_CHANGE_BUFFERING"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_CHANGE_BUFFERING_DEBUG"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_CHANGE_BUFFER_MAX_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_CHECKSUM_ALGORITHM"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_CMP_PER_INDEX_ENABLED"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_COMPRESS_DEBUG"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_COMPRESSION_FAILURE_THRESHOLD_PCT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_COMPRESSION_LEVEL"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_COMPRESSION_PAD_PCT_MAX"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_DATA_FILE_PATH"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_DATA_HOME_DIR"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_DEFAULT_ROW_FORMAT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_DISABLE_BACKGROUND_MERGE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_DISABLE_SORT_FILE_CACHE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_DOUBLEWRITE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_FAST_SHUTDOWN"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_FILE_PER_TABLE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_FILL_FACTOR"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_FIL_MAKE_PAGE_DIRTY_DEBUG"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_FLUSHING_AVG_LOOPS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_FLUSH_LOG_AT_TIMEOUT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_FLUSH_LOG_AT_TRX_COMMIT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_FLUSH_METHOD"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_FLUSH_NEIGHBORS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_FORCE_LOAD_CORRUPTED"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_FORCE_RECOVERY"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_FT_AUX_TABLE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_FT_CACHE_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_FT_ENABLE_DIAG_PRINT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_FT_MAX_TOKEN_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_FT_MIN_TOKEN_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_FT_NUM_WORD_OPTIMIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_FT_RESULT_CACHE_LIMIT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_FT_SERVER_STOPWORD_TABLE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_FT_SORT_PLL_DEGREE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_FT_TOTAL_CACHE_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_IO_CAPACITY"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_IO_CAPACITY_MAX"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_LARGE_PREFIX"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_LIMIT_OPTIMISTIC_INSERT_DEBUG"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_LOCKS_UNSAFE_FOR_BINLOG"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_LOG_BUFFER_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_LOG_CHECKPOINT_NOW"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_LOG_FILE_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_LOG_GROUP_HOME_DIR"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_LOG_WRITE_AHEAD_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_LRU_SCAN_DEPTH"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_MAX_DIRTY_PAGES_PCT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_MAX_DIRTY_PAGES_PCT_LWM"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_MAX_PURGE_LAG"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_MAX_PURGE_LAG_DELAY"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_MAX_UNDO_LOG_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_MERGE_THRESHOLD_SET_ALL_DEBUG"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_MONITOR_DISABLE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_MONITOR_ENABLE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_MONITOR_RESET"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_MONITOR_RESET_ALL"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_NUMA_INTERLEAVE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_OLD_BLOCKS_PCT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_OLD_BLOCKS_TIME"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_ONLINE_ALTER_LOG_MAX_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_OPEN_FILES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_OPTIMIZE_FULLTEXT_ONLY"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_PAGE_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_PRINT_ALL_DEADLOCKS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_PURGE_BATCH_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_PURGE_RSEG_TRUNCATE_FREQUENCY"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_PURGE_THREADS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_RANDOM_READ_AHEAD"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_READ_AHEAD_THRESHOLD"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_READ_IO_THREADS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_READ_ONLY"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_ROLLBACK_ON_TIMEOUT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_ROLLBACK_SEGMENTS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_SAVED_PAGE_NUMBER_DEBUG"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_SEMAPHORE_WAIT_TIMEOUT_DEBUG"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_SORT_BUFFER_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_SPIN_WAIT_DELAY"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_STATS_AUTO_RECALC"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_STATS_METHOD"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_STATS_ON_METADATA"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_STATS_PERSISTENT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_STATS_PERSISTENT_SAMPLE_PAGES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_STATS_SAMPLE_PAGES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_STATS_TRANSIENT_SAMPLE_PAGES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_STATUS_OUTPUT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_STATUS_OUTPUT_LOCKS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_SYNC_ARRAY_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_SYNC_SPIN_LOOPS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_TEMP_DATA_FILE_PATH"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_TRX_PURGE_VIEW_UPDATE_ONLY_DEBUG"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_TRX_RSEG_N_SLOTS_DEBUG"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_UNDO_DIRECTORY"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_UNDO_LOG_TRUNCATE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_UNDO_TABLESPACES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_USE_NATIVE_AIO"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INNODB_WRITE_IO_THREADS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "INTERNAL_TMP_DISK_STORAGE_ENGINE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "KEY_BUFFER_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "KEY_CACHE_AGE_THRESHOLD"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "KEY_CACHE_BLOCK_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "KEY_CACHE_DIVISION_LIMIT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LARGE_FILES_SUPPORT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LARGE_PAGES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LARGE_PAGE_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LC_MESSAGES_DIR"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LICENSE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LOCAL_INFILE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LOCKED_IN_MEMORY"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LOG_BIN"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LOG_BIN_BASENAME"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LOG_BIN_INDEX"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LOG_BIN_TRUST_FUNCTION_CREATORS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LOG_BIN_USE_V1_ROW_EVENTS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LOG_BUILTIN_AS_IDENTIFIED_BY_PASSWORD"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LOG_ERROR"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LOG_ERROR_VERBOSITY"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LOG_OUTPUT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LOG_QUERIES_NOT_USING_INDEXES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LOG_SLAVE_UPDATES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LOG_SLOW_ADMIN_STATEMENTS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LOG_SLOW_SLAVE_STATEMENTS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LOG_SYSLOG"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LOG_SYSLOG_FACILITY"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LOG_SYSLOG_INCLUDE_PID"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LOG_SYSLOG_TAG"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LOG_THROTTLE_QUERIES_NOT_USING_INDEXES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LOG_TIMESTAMPS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LOG_WARNINGS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LOWER_CASE_FILE_SYSTEM"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "LOWER_CASE_TABLE_NAMES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "MASTER_INFO_REPOSITORY"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "MASTER_VERIFY_CHECKSUM"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "MAX_BINLOG_CACHE_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "MAX_BINLOG_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "MAX_BINLOG_STMT_CACHE_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "MAX_CONNECTIONS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "MAX_CONNECT_ERRORS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "MAX_DIGEST_LENGTH"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "MAX_PREPARED_STMT_COUNT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "MAX_RELAY_LOG_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "MAX_WRITE_LOCK_COUNT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "METADATA_LOCKS_CACHE_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "METADATA_LOCKS_HASH_INSTANCES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "MYISAM_DATA_POINTER_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "MYISAM_MAX_SORT_FILE_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "MYISAM_MMAP_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "MYISAM_RECOVER_OPTIONS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "MYISAM_USE_MMAP"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "MYSQL_NATIVE_PASSWORD_PROXY_USERS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "NAMED_PIPE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "NAMED_PIPE_FULL_ACCESS_GROUP"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "NDBINFO_DATABASE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "NDBINFO_OFFLINE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "NDBINFO_TABLE_PREFIX"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "NDBINFO_VERSION"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "NGRAM_TOKEN_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "OFFLINE_MODE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "OLD"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "OPEN_FILES_LIMIT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_ACCOUNTS_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_DIGESTS_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_EVENTS_STAGES_HISTORY_LONG_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_EVENTS_STAGES_HISTORY_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_EVENTS_STATEMENTS_HISTORY_LONG_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_EVENTS_STATEMENTS_HISTORY_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_EVENTS_TRANSACTIONS_HISTORY_LONG_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_EVENTS_TRANSACTIONS_HISTORY_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_EVENTS_WAITS_HISTORY_LONG_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_EVENTS_WAITS_HISTORY_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_HOSTS_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_MAX_COND_CLASSES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_MAX_COND_INSTANCES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_MAX_DIGEST_LENGTH"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_MAX_FILE_CLASSES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_MAX_FILE_HANDLES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_MAX_FILE_INSTANCES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_MAX_INDEX_STAT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_MAX_MEMORY_CLASSES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_MAX_METADATA_LOCKS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_MAX_MUTEX_CLASSES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_MAX_MUTEX_INSTANCES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_MAX_PREPARED_STATEMENTS_INSTANCES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_MAX_PROGRAM_INSTANCES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_MAX_RWLOCK_CLASSES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_MAX_RWLOCK_INSTANCES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_MAX_SOCKET_CLASSES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_MAX_SOCKET_INSTANCES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_MAX_SQL_TEXT_LENGTH"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_MAX_STAGE_CLASSES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_MAX_STATEMENT_CLASSES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_MAX_STATEMENT_STACK"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_MAX_TABLE_HANDLES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_MAX_TABLE_INSTANCES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_MAX_TABLE_LOCK_STAT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_MAX_THREAD_CLASSES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_MAX_THREAD_INSTANCES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_SESSION_CONNECT_ATTRS_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_SETUP_ACTORS_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_SETUP_OBJECTS_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PERFORMANCE_SCHEMA_USERS_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PID_FILE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PLUGIN_DIR"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PORT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "PROTOCOL_VERSION"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "QUERY_CACHE_LIMIT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "QUERY_CACHE_MIN_RES_UNIT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "QUERY_CACHE_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "READ_ONLY"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "RELAY_LOG"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "RELAY_LOG_BASENAME"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "RELAY_LOG_INDEX"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "RELAY_LOG_INFO_FILE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "RELAY_LOG_INFO_REPOSITORY"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "RELAY_LOG_PURGE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "RELAY_LOG_RECOVERY"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "RELAY_LOG_SPACE_LIMIT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "REPORT_HOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "REPORT_PASSWORD"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "REPORT_PORT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "REPORT_USER"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "RPL_STOP_SLAVE_TIMEOUT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SECURE_AUTH"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SECURE_FILE_PRIV"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SERVER_ID"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SERVER_ID_BITS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SERVER_UUID"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SHA256_PASSWORD_AUTO_GENERATE_RSA_KEYS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SHA256_PASSWORD_PRIVATE_KEY_PATH"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SHA256_PASSWORD_PUBLIC_KEY_PATH"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SHARED_MEMORY"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SHARED_MEMORY_BASE_NAME"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SHA256_PASSWORD_PROXY_USERS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SHOW_COMPATIBILITY_56"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SIMPLIFIED_BINLOG_GTID_RECOVERY"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SKIP_EXTERNAL_LOCKING"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SKIP_NAME_RESOLVE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SKIP_NETWORKING"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SKIP_SHOW_DATABASE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SLAVE_ALLOW_BATCHING"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SLAVE_CHECKPOINT_GROUP"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SLAVE_CHECKPOINT_PERIOD"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SLAVE_COMPRESSED_PROTOCOL"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SLAVE_EXEC_MODE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SLAVE_LOAD_TMPDIR"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SLAVE_MAX_ALLOWED_PACKET"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SLAVE_NET_TIMEOUT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SLAVE_PARALLEL_TYPE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SLAVE_PARALLEL_WORKERS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SLAVE_PENDING_JOBS_SIZE_MAX"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SLAVE_PRESERVE_COMMIT_ORDER"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SLAVE_ROWS_SEARCH_ALGORITHMS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SLAVE_SKIP_ERRORS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SLAVE_SQL_VERIFY_CHECKSUM"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SLAVE_TRANSACTION_RETRIES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SLAVE_TYPE_CONVERSIONS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SLOW_LAUNCH_TIME"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SLOW_QUERY_LOG"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SLOW_QUERY_LOG_FILE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SOCKET"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SQL_SLAVE_SKIP_COUNTER"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SSL_CA"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SSL_CAPATH"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SSL_CERT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SSL_CIPHER"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SSL_CRL"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SSL_CRLPATH"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SSL_KEY"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SUPER_READ_ONLY"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "STORED_PROGRAM_CACHE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SYNC_BINLOG"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SYNC_FRM"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SYNC_MASTER_INFO"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SYNC_RELAY_LOG"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SYNC_RELAY_LOG_INFO"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "SYSTEM_TIME_ZONE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "TABLE_DEFINITION_CACHE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "TABLE_OPEN_CACHE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "TABLE_OPEN_CACHE_INSTANCES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "THREAD_CACHE_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "THREAD_HANDLING"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "THREAD_STACK"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "TIME_FORMAT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "TMPDIR"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "VERSION"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "VERSION_COMMENT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "VERSION_COMPILE_MACHINE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "VERSION_COMPILE_OS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_VARIABLES", "REQUIRE_SECURE_TRANSPORT")
+;
+--enable_query_log
+
+--echo #
+--echo # STEP 2-15
+--echo # Known global status in 5.6 that should not exist in session queries.
+--echo # These should be global-only status variables.
+--disable_query_log
+insert into test.sanity values
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "ABORTED_CLIENTS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "ABORTED_CONNECTS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "BINLOG_CACHE_DISK_USE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "BINLOG_CACHE_USE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "BINLOG_STMT_CACHE_DISK_USE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "BINLOG_STMT_CACHE_USE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "CONNECTIONS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "CONNECTION_ERRORS_ACCEPT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "CONNECTION_ERRORS_INTERNAL"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "CONNECTION_ERRORS_MAX_CONNECTIONS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "CONNECTION_ERRORS_PEER_ADDRESS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "CONNECTION_ERRORS_SELECT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "CONNECTION_ERRORS_TCPWRAP"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "CREATED_TMP_FILES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "DELAYED_ERRORS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "DELAYED_INSERT_THREADS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "DELAYED_WRITES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "FLUSH_COMMANDS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_AHI_DROP_LOOKUPS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_AVAILABLE_UNDO_LOGS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_BUFFER_POOL_BYTES_DATA"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_BUFFER_POOL_BYTES_DIRTY"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_BUFFER_POOL_DUMP_STATUS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_BUFFER_POOL_LOAD_STATUS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_BUFFER_POOL_PAGES_DATA"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_BUFFER_POOL_PAGES_DIRTY"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_BUFFER_POOL_PAGES_FLUSHED"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_BUFFER_POOL_PAGES_FREE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_BUFFER_POOL_PAGES_LATCHED"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_BUFFER_POOL_PAGES_MISC"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_BUFFER_POOL_PAGES_TOTAL"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_BUFFER_POOL_READS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_BUFFER_POOL_READ_AHEAD"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_BUFFER_POOL_READ_AHEAD_EVICTED"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_BUFFER_POOL_READ_AHEAD_RND"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_BUFFER_POOL_READ_REQUESTS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_BUFFER_POOL_RESIZE_STATUS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_BUFFER_POOL_WAIT_FREE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_BUFFER_POOL_WRITE_REQUESTS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_DATA_FSYNCS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_DATA_PENDING_FSYNCS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_DATA_PENDING_READS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_DATA_PENDING_WRITES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_DATA_READ"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_DATA_READS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_DATA_WRITES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_DATA_WRITTEN"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_DBLWR_PAGES_WRITTEN"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_DBLWR_WRITES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_HAVE_ATOMIC_BUILTINS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_LOG_WAITS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_LOG_WRITES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_LOG_WRITE_REQUESTS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_NUM_OPEN_FILES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_OS_LOG_FSYNCS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_OS_LOG_PENDING_FSYNCS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_OS_LOG_PENDING_WRITES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_OS_LOG_WRITTEN"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_PAGES_CREATED"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_PAGES_READ"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_PAGES_WRITTEN"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_PAGE_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_PURGE_TRX_ID_AGE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_PURGE_VIEW_TRX_ID_AGE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_ROWS_DELETED"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_ROWS_INSERTED"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_ROWS_READ"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_ROWS_UPDATED"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_ROW_LOCK_CURRENT_WAITS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_ROW_LOCK_TIME"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_ROW_LOCK_TIME_AVG"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_ROW_LOCK_TIME_MAX"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_ROW_LOCK_WAITS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "INNODB_TRUNCATED_STATUS_WRITES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "KEY_BLOCKS_NOT_FLUSHED"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "KEY_BLOCKS_UNUSED"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "KEY_BLOCKS_USED"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "KEY_READS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "KEY_READ_REQUESTS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "KEY_WRITES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "KEY_WRITE_REQUESTS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "LOCKED_CONNECTS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "MAX_USED_CONNECTIONS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "MAX_USED_CONNECTIONS_TIME"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "NOT_FLUSHED_DELAYED_ROWS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "OPENED_FILES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "OPEN_FILES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "OPEN_STREAMS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "OPEN_TABLE_DEFINITIONS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "ONGOING_ANONYMOUS_GTID_VIOLATING_TRANSACTION_COUNT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "ONGOING_ANONYMOUS_TRANSACTION_COUNT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "ONGOING_AUTOMATIC_GTID_VIOLATING_TRANSACTION_COUNT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_ACCOUNTS_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_COND_CLASSES_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_COND_INSTANCES_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_DIGEST_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_FILE_CLASSES_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_FILE_HANDLES_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_FILE_INSTANCES_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_INDEX_STAT_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_HOSTS_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_LOCKER_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_MEMORY_CLASSES_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_METADATA_LOCK_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_MUTEX_CLASSES_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_MUTEX_INSTANCES_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_NESTED_STATEMENT_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_PREPARED_STATEMENTS_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_PROGRAM_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_RWLOCK_CLASSES_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_RWLOCK_INSTANCES_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_SESSION_CONNECT_ATTRS_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_SOCKET_CLASSES_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_SOCKET_INSTANCES_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_STAGE_CLASSES_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_STATEMENT_CLASSES_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_TABLE_HANDLES_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_TABLE_INSTANCES_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_TABLE_LOCK_STAT_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_THREAD_CLASSES_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_THREAD_INSTANCES_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PERFORMANCE_SCHEMA_USERS_LOST"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "PREPARED_STMT_COUNT"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "QCACHE_FREE_BLOCKS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "QCACHE_FREE_MEMORY"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "QCACHE_HITS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "QCACHE_INSERTS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "QCACHE_LOWMEM_PRUNES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "QCACHE_NOT_CACHED"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "QCACHE_QUERIES_IN_CACHE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "QCACHE_TOTAL_BLOCKS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "RSA_PUBLIC_KEY"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "SLAVE_OPEN_TEMP_TABLES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "SLAVE_ROWS_LAST_SEARCH_ALGORITHM_USED"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "SSL_ACCEPTS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "SSL_ACCEPT_RENEGOTIATES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "SSL_CALLBACK_CACHE_HITS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "SSL_CLIENT_CONNECTS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "SSL_CONNECT_RENEGOTIATES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "SSL_CTX_VERIFY_DEPTH"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "SSL_CTX_VERIFY_MODE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "SSL_FINISHED_ACCEPTS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "SSL_FINISHED_CONNECTS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "SSL_SESSION_CACHE_HITS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "SSL_SESSION_CACHE_MISSES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "SSL_SESSION_CACHE_MODE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "SSL_SESSION_CACHE_OVERFLOWS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "SSL_SESSION_CACHE_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "SSL_SESSION_CACHE_TIMEOUTS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "SSL_USED_SESSION_CACHE_ENTRIES"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "TABLE_LOCKS_IMMEDIATE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "TABLE_LOCKS_WAITED"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "TC_LOG_MAX_PAGES_USED"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "TC_LOG_PAGE_SIZE"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "TC_LOG_PAGE_WAITS"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "THREADS_CACHED"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "THREADS_CONNECTED"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "THREADS_CREATED"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "THREADS_RUNNING"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "UPTIME"),
+ ("JUNK: GLOBAL-ONLY", "I_S.SESSION_STATUS", "UPTIME_SINCE_FLUSH_STATUS")
+;
+--enable_query_log
+
+--echo #
+--echo # STEP 2-15A
+--echo # COM counters appear in I_S.SESSION_STATUS, but not in P_S.SESSION_STATUS
+--disable_query_log
+insert into test.sanity values
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_ADMIN_COMMANDS"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_ALTER_DB"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_ALTER_DB_UPGRADE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_ALTER_EVENT"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_ALTER_FUNCTION"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_ALTER_INSTANCE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_ALTER_PROCEDURE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_ALTER_SERVER"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_ALTER_TABLE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_ALTER_TABLESPACE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_ALTER_USER"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_ANALYZE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_ASSIGN_TO_KEYCACHE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_BEGIN"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_BINLOG"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_CALL_PROCEDURE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_CHANGE_DB"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_CHANGE_MASTER"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_CHANGE_REPL_FILTER"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_CHECK"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_CHECKSUM"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_COMMIT"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_CREATE_DB"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_CREATE_EVENT"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_CREATE_FUNCTION"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_CREATE_INDEX"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_CREATE_PROCEDURE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_CREATE_SERVER"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_CREATE_TABLE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_CREATE_TRIGGER"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_CREATE_UDF"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_CREATE_USER"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_CREATE_VIEW"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_DEALLOC_SQL"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_DELETE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_DELETE_MULTI"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_DO"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_DROP_DB"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_DROP_EVENT"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_DROP_FUNCTION"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_DROP_INDEX"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_DROP_PROCEDURE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_DROP_SERVER"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_DROP_TABLE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_DROP_TRIGGER"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_DROP_USER"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_DROP_VIEW"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_EMPTY_QUERY"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_EXECUTE_SQL"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_EXPLAIN_OTHER"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_FLUSH"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_GET_DIAGNOSTICS"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_GROUP_REPLICATION_START"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_GROUP_REPLICATION_STOP"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_GRANT"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_HA_CLOSE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_HA_OPEN"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_HA_READ"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_HELP"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_INSERT"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_INSERT_SELECT"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_INSTALL_PLUGIN"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_KILL"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_LOAD"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_LOCK_TABLES"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_OPTIMIZE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_PRELOAD_KEYS"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_PREPARE_SQL"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_PURGE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_PURGE_BEFORE_DATE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_RELEASE_SAVEPOINT"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_RENAME_TABLE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_RENAME_USER"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_REPAIR"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_REPLACE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_REPLACE_SELECT"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_RESET"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_RESIGNAL"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_REVOKE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_REVOKE_ALL"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_ROLLBACK"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_ROLLBACK_TO_SAVEPOINT"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SAVEPOINT"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SELECT"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SET_OPTION"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_BINLOGS"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_BINLOG_EVENTS"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_CHARSETS"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_COLLATIONS"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_CREATE_DB"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_CREATE_EVENT"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_CREATE_FUNC"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_CREATE_PROC"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_CREATE_TABLE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_CREATE_TRIGGER"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_CREATE_USER"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_DATABASES"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_ENGINE_LOGS"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_ENGINE_MUTEX"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_ENGINE_STATUS"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_ERRORS"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_EVENTS"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_FIELDS"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_FUNCTION_CODE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_FUNCTION_STATUS"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_GRANTS"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_KEYS"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_MASTER_STATUS"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_OPEN_TABLES"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_PLUGINS"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_PRIVILEGES"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_PROCEDURE_CODE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_PROCEDURE_STATUS"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_PROCESSLIST"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_PROFILE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_PROFILES"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_RELAYLOG_EVENTS"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_SLAVE_HOSTS"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_SLAVE_STATUS"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_SLAVE_STATUS_NONBLOCKING"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_STATUS"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_STORAGE_ENGINES"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_TABLES"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_TABLE_STATUS"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_TRIGGERS"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_VARIABLES"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SHOW_WARNINGS"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SIGNAL"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SLAVE_START"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_SLAVE_STOP"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_STMT_CLOSE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_STMT_EXECUTE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_STMT_FETCH"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_STMT_PREPARE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_STMT_RESET"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_STMT_SEND_LONG_DATA"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_TRUNCATE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_UNINSTALL_PLUGIN"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_UNLOCK_TABLES"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_UPDATE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_UPDATE_MULTI"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_XA_COMMIT"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_XA_END"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_XA_PREPARE"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_XA_RECOVER"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_XA_ROLLBACK"),
+ ("JUNK: COM COUNTER", "I_S.SESSION_STATUS", "COM_XA_START")
+;
+
+--enable_query_log
+
+--echo #
+--echo # STEP 2-15B
+--echo # These slave status counters appear in I_S.SESSION_STATUS, but not in P_S.SESSION_STATUS
+insert into test.sanity values
+ ("JUNK: SLAVE-ONLY", "I_S.SESSION_STATUS", "SLAVE_HEARTBEAT_PERIOD"),
+ ("JUNK: SLAVE-ONLY", "I_S.SESSION_STATUS", "SLAVE_LAST_HEARTBEAT"),
+ ("JUNK: SLAVE-ONLY", "I_S.SESSION_STATUS", "SLAVE_RECEIVED_HEARTBEATS"),
+ ("JUNK: SLAVE-ONLY", "I_S.SESSION_STATUS", "SLAVE_RETRIED_TRANSACTIONS"),
+ ("JUNK: SLAVE-ONLY", "I_S.SESSION_STATUS", "SLAVE_RUNNING")
+;
+
+--echo #
+--echo # STEP 2-16
+--echo # Known session-only status in 5.6 that should not exist in global queries.
+insert into test.sanity values
+ ("JUNK: SESSION-ONLY", "I_S.GLOBAL_STATUS", "COMPRESSION"),
+ ("JUNK: SESSION-ONLY", "I_S.GLOBAL_STATUS", "LAST_QUERY_COST"),
+ ("JUNK: SESSION-ONLY", "I_S.GLOBAL_STATUS", "LAST_QUERY_PARTIAL_PLANS")
+;
+
+--echo #
+--echo # STEP 2-16A
+--echo # COM counters appear in I_S.GLOBAL_STATUS but not in P_S.GLOBAL_STATUS
+--disable_query_log
+insert into test.sanity values
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_ADMIN_COMMANDS"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_ALTER_DB"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_ALTER_DB_UPGRADE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_ALTER_EVENT"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_ALTER_FUNCTION"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_ALTER_INSTANCE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_ALTER_PROCEDURE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_ALTER_SERVER"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_ALTER_TABLE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_ALTER_TABLESPACE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_ALTER_USER"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_ANALYZE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_ASSIGN_TO_KEYCACHE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_BEGIN"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_BINLOG"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_CALL_PROCEDURE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_CHANGE_DB"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_CHANGE_MASTER"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_CHANGE_REPL_FILTER"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_CHECK"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_CHECKSUM"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_COMMIT"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_CREATE_DB"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_CREATE_EVENT"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_CREATE_FUNCTION"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_CREATE_INDEX"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_CREATE_PROCEDURE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_CREATE_SERVER"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_CREATE_TABLE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_CREATE_TRIGGER"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_CREATE_UDF"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_CREATE_USER"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_CREATE_VIEW"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_DEALLOC_SQL"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_DELETE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_DELETE_MULTI"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_DO"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_DROP_DB"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_DROP_EVENT"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_DROP_FUNCTION"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_DROP_INDEX"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_DROP_PROCEDURE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_DROP_SERVER"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_DROP_TABLE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_DROP_TRIGGER"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_DROP_USER"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_DROP_VIEW"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_EMPTY_QUERY"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_EXECUTE_SQL"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_EXPLAIN_OTHER"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_FLUSH"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_GET_DIAGNOSTICS"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_GRANT"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_GROUP_REPLICATION_START"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_GROUP_REPLICATION_STOP"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_HA_CLOSE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_HA_OPEN"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_HA_READ"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_HELP"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_INSERT"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_INSERT_SELECT"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_INSTALL_PLUGIN"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_KILL"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_LOAD"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_LOCK_TABLES"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_OPTIMIZE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_PRELOAD_KEYS"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_PREPARE_SQL"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_PURGE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_PURGE_BEFORE_DATE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_RELEASE_SAVEPOINT"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_RENAME_TABLE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_RENAME_USER"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_REPAIR"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_REPLACE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_REPLACE_SELECT"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_RESET"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_RESIGNAL"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_REVOKE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_REVOKE_ALL"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_ROLLBACK"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_ROLLBACK_TO_SAVEPOINT"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SAVEPOINT"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SELECT"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SET_OPTION"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_BINLOGS"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_BINLOG_EVENTS"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_CHARSETS"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_COLLATIONS"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_CREATE_DB"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_CREATE_EVENT"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_CREATE_FUNC"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_CREATE_PROC"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_CREATE_TABLE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_CREATE_TRIGGER"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_CREATE_USER"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_DATABASES"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_ENGINE_LOGS"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_ENGINE_MUTEX"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_ENGINE_STATUS"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_ERRORS"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_EVENTS"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_FIELDS"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_FUNCTION_CODE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_FUNCTION_STATUS"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_GRANTS"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_KEYS"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_MASTER_STATUS"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_OPEN_TABLES"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_PLUGINS"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_PRIVILEGES"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_PROCEDURE_CODE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_PROCEDURE_STATUS"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_PROCESSLIST"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_PROFILE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_PROFILES"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_RELAYLOG_EVENTS"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_SLAVE_HOSTS"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_SLAVE_STATUS"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_SLAVE_STATUS_NONBLOCKING"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_STATUS"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_STORAGE_ENGINES"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_TABLES"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_TABLE_STATUS"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_TRIGGERS"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_VARIABLES"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SHOW_WARNINGS"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SIGNAL"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SLAVE_START"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_SLAVE_STOP"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_STMT_CLOSE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_STMT_EXECUTE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_STMT_FETCH"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_STMT_PREPARE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_STMT_RESET"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_STMT_SEND_LONG_DATA"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_TRUNCATE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_UNINSTALL_PLUGIN"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_UNLOCK_TABLES"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_UPDATE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_UPDATE_MULTI"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_XA_COMMIT"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_XA_END"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_XA_PREPARE"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_XA_RECOVER"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_XA_ROLLBACK"),
+ ("JUNK: COM COUNTER", "I_S.GLOBAL_STATUS", "COM_XA_START")
+ ;
+
+--enable_query_log
+
+--echo #
+--echo # STEP 2-16B
+--echo # These slave status counters appear in I_S.GLOBAL_STATUS, but not in P_S.GLOBAL_STATUS
+insert into test.sanity values
+ ("JUNK: SLAVE-ONLY", "I_S.GLOBAL_STATUS", "SLAVE_HEARTBEAT_PERIOD"),
+ ("JUNK: SLAVE-ONLY", "I_S.GLOBAL_STATUS", "SLAVE_LAST_HEARTBEAT"),
+ ("JUNK: SLAVE-ONLY", "I_S.GLOBAL_STATUS", "SLAVE_RECEIVED_HEARTBEATS"),
+ ("JUNK: SLAVE-ONLY", "I_S.GLOBAL_STATUS", "SLAVE_RETRIED_TRANSACTIONS"),
+ ("JUNK: SLAVE-ONLY", "I_S.GLOBAL_STATUS", "SLAVE_RUNNING")
+;
+
+--echo #
+--echo # STEP 2-17
+--echo # Status variables that should not exist in queries that aggregate across threads.
+--echo # Criteria: Session-only OR non-aggregatable.
+insert into test.sanity values
+ ("JUNK", "NO AGGREGATE", "COMPRESSION"),
+ ("JUNK", "NO AGGREGATE", "LAST_QUERY_COST"),
+ ("JUNK", "NO AGGREGATE", "LAST_QUERY_PARTIAL_PLANS"),
+ ("JUNK", "NO AGGREGATE", "OPEN_TABLES"),
+ ("JUNK", "NO AGGREGATE", "QUERIES"),
+ ("JUNK", "NO AGGREGATE", "SLOW_LAUNCH_THREADS"),
+ ("JUNK", "NO AGGREGATE", "SSL_CIPHER"),
+ ("JUNK", "NO AGGREGATE", "SSL_CIPHER_LIST"),
+ ("JUNK", "NO AGGREGATE", "SSL_DEFAULT_TIMEOUT"),
+ ("JUNK", "NO AGGREGATE", "SSL_SERVER_NOT_AFTER"),
+ ("JUNK", "NO AGGREGATE", "SSL_SERVER_NOT_BEFORE"),
+ ("JUNK", "NO AGGREGATE", "SSL_SESSIONS_REUSED"),
+ ("JUNK", "NO AGGREGATE", "SSL_VERIFY_DEPTH"),
+ ("JUNK", "NO AGGREGATE", "SSL_VERIFY_MODE"),
+ ("JUNK", "NO AGGREGATE", "SSL_VERSION")
+;
+
+#Debug
+#select * from test.sanity order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 1A
+--echo # Present in 5.6 P_S.GLOBAL_VARIABLES (1-3)
+--echo # Missing in 5.6 I_S.GLOBAL_VARIABLES (1-1)
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.6"
+ and source = "P_S.GLOBAL_VARIABLES"
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.6"
+ and source = "I_S.GLOBAL_VARIABLES")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 1B
+--echo # Present in 5.7 P_S.GLOBAL_VARIABLES (2-3)
+--echo # Missing in 5.6 I_S.GLOBAL_VARIABLES (1-1)
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.GLOBAL_VARIABLES"
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.6"
+ and source = "I_S.GLOBAL_VARIABLES")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 2A
+--echo # Present in 5.6 I_S.GLOBAL_VARIABLES (1-1)
+--echo # Missing in 5.6 P_S.GLOBAL_VARIABLES (1-3)
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.6"
+ and source = "I_S.GLOBAL_VARIABLES"
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.6"
+ and source = "P_S.GLOBAL_VARIABLES")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 2B
+--echo # Present in 5.6 I_S.GLOBAL_VARIABLES (1-1)
+--echo # Missing in 5.7 P_S.GLOBAL_VARIABLES (2-3)
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.6"
+ and source = "I_S.GLOBAL_VARIABLES"
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.GLOBAL_VARIABLES")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 3A
+--echo # Present in 5.6 P_S.SESSION_VARIABLES (1-5)
+--echo # Missing in 5.6 I_S.SESSION_VARIABLES (1-2)
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.6"
+ and source = "P_S.SESSION_VARIABLES"
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.6"
+ and source = "I_S.SESSION_VARIABLES")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 3B
+--echo # Present in 5.7 P_S.SESSION_VARIABLES (2-5)
+--echo # Missing in 5.6 I_S.SESSION_VARIABLES (1-2)
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.SESSION_VARIABLES"
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.6"
+ and source = "I_S.SESSION_VARIABLES")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 4A
+--echo # Present in 5.6 I_S.SESSION_VARIABLES (1-2)
+--echo # Missing in 5.6 P_S.SESSION_VARIABLES (1-5)
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.6"
+ and source = "I_S.SESSION_VARIABLES"
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.6"
+ and source = "P_S.SESSION_VARIABLES")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 4B
+--echo # Present in 5.6 I_S.SESSION_VARIABLES (1-2)
+--echo # Missing in 5.7 P_S.SESSION_VARIABLES (2-5)
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.6"
+ and source = "I_S.SESSION_VARIABLES"
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.SESSION_VARIABLES")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 5A
+--echo # Present in 5.6 P_S.VARIABLES_BY_THREAD (1-4)
+--echo # Missing in 5.6 I_S.SESSION_VARIABLES (1-2)
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.6"
+ and source = "P_S.VARIABLES_BY_THREAD"
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.6"
+ and source = "I_S.SESSION_VARIABLES")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 5B
+--echo # Present in 5.7 P_S.VARIABLES_BY_THREAD (2-4)
+--echo # Missing in 5.6 I_S.SESSION_VARIABLES (1-2)
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.VARIABLES_BY_THREAD"
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.6"
+ and source = "I_S.SESSION_VARIABLES")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 5C
+--echo # Present in 5.6 I_S.SESSION_VARIABLES (1-2)
+--echo # Missing in 5.6 P_S.VARIABLES_BY_THREAD (1-4)
+--echo # EXPECT NOTHING BESIDE KNOWN GLOBAL VARIABLES (2-14)
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.6"
+ and source = "I_S.SESSION_VARIABLES"
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.6"
+ and source = "P_S.VARIABLES_BY_THREAD")
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "JUNK: GLOBAL-ONLY"
+ and source = "I_S.SESSION_VARIABLES")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 5D
+--echo # Present in 5.6 I_S.SESSION_VARIABLES (1-2)
+--echo # Missing in 5.7 P_S.VARIABLES_BY_THREAD (2-5)
+--echo # EXPECT NOTHING BESIDE KNOWN GLOBAL VARIABLES (2-14)
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.6"
+ and source = "I_S.SESSION_VARIABLES"
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.VARIABLES_BY_THREAD")
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "JUNK: GLOBAL-ONLY"
+ and source = "I_S.SESSION_VARIABLES")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 5E
+--echo # KNOWN GLOBAL VARIABLES (2-14)
+--echo # Expect missing in 5.6 P_S.VARIABLES_BY_THREAD (1-4)
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "JUNK: GLOBAL-ONLY"
+ and source = "I_S.SESSION_VARIABLES"
+ and upper(variable_name) in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.6"
+ and source = "P_S.VARIABLES_BY_THREAD")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 5F
+--echo # KNOWN GLOBAL VARIABLES (2-14)
+--echo # Expect missing in 5.7 P_S.VARIABLES_BY_THREAD (2-5)
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "JUNK: GLOBAL-ONLY"
+ and source = "I_S.SESSION_VARIABLES"
+ and upper(variable_name) in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.VARIABLES_BY_THREAD")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 6A
+--echo # Present in 5.7 P_S.GLOBAL_STATUS (2-8)
+--echo # Missing in 5.6 I_S.GLOBAL_STATUS (1-6)
+--echo # EXPECT NOTHING
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.GLOBAL_STATUS"
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.6"
+ and source = "I_S.GLOBAL_STATUS")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 6B
+--echo # Present in 5.7 P_S.GLOBAL_STATUS (2-8)
+--echo # Missing in 5.6 P_S.GLOBAL_STATUS (1-8)
+--echo # EXPECT NOTHING
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.GLOBAL_STATUS"
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.6"
+ and source = "P_S.GLOBAL_STATUS")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 6C
+--echo # Present in 5.6 P_S.GLOBAL_STATUS (1-8)
+--echo # Missing in 5.7 P_S.GLOBAL_STATUS (2-8)
+--echo # EXPECT NOTHING
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.6"
+ and source = "P_S.GLOBAL_STATUS"
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.GLOBAL_STATUS")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 7
+--echo # Present in 5.6 I_S.GLOBAL_STATUS (1-6)
+--echo # Missing in 5.7 P_S.GLOBAL_STATUS (2-8)
+--echo # EXPECT NOTHING AFTER REMOVING KNOWN SESSION-ONLY, COM COUNTERS AND SLAVE-ONLY (2-16 & 2-16A & 2-16B)
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.6"
+ and source = "I_S.GLOBAL_STATUS"
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where (show_mode = "JUNK: SESSION-ONLY" or show_mode = "JUNK: COM COUNTER" or show_mode = "JUNK: SLAVE-ONLY")
+ and source = "I_S.GLOBAL_STATUS")
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.GLOBAL_STATUS")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 8
+--echo # KNOWN SESSION-ONLY (2-16)
+--echo # KNOWN COM COUNTERS (2-16A)
+--echo # KNOWN SLAVE-ONLY (2-16B)
+--echo # Status variables that should NOT be present in 5.7 P_S.GLOBAL_STATUS (2-8)
+--echo # EXPECT NOTHING
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.GLOBAL_STATUS"
+ and upper(variable_name) in (
+ select upper(variable_name) from test.sanity
+ where (show_mode = "JUNK: SESSION-ONLY" or show_mode = "JUNK: COM COUNTER" or show_mode = "JUNK: SLAVE-ONLY")
+ and source = "I_S.GLOBAL_STATUS")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 9A
+--echo # Present in 5.7 P_S.SESSION_STATUS (2-10)
+--echo # Missing in 5.6 I_S.SESSION_STATUS (1-7)
+--echo # EXPECT NOTHING
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.SESSION_STATUS"
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.6"
+ and source = "I_S.SESSION_STATUS")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 9B
+--echo # Present in 5.7 P_S.SESSION_STATUS (2-10)
+--echo # Missing in 5.6 P_S.SESSION_STATUS (1-10)
+--echo # EXPECT NOTHING
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.SESSION_STATUS"
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.6"
+ and source = "P_S.SESSION_STATUS")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 9C
+--echo # Present in 5.6 P_S.SESSION_STATUS (1-10)
+--echo # Missing in 5.7 P_S.SESSION_STATUS (2-10)
+--echo # EXPECT NOTHING
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.6"
+ and source = "P_S.SESSION_STATUS"
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.SESSION_STATUS")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 10
+--echo # Present in 5.6 I_S.SESSION_STATUS (1-7)
+--echo # Missing in 5.7 P_S.SESSION_STATUS (2-10)
+--echo # EXPECT NOTHING AFTER REMOVING KNOWN COM COUNTERS AND SLAVE-ONLY (2-15A & 2-15B)
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.6"
+ and source = "I_S.SESSION_STATUS"
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where (show_mode = "JUNK: COM COUNTER" or show_mode = "JUNK: SLAVE-ONLY")
+ and source = "I_S.SESSION_STATUS")
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.SESSION_STATUS")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 11
+--echo # KNOWN COM COUNTERS (2-15A)
+--echo # KNOWN SLAVE-ONLY (2-15B)
+--echo # Status variables that should NOT be present in 5.7 P_S.SESSION_STATUS (2-10)
+--echo # EXPECT NOTHING
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.SESSION_STATUS"
+ and upper(variable_name) in (
+ select upper(variable_name) from test.sanity
+ where (show_mode = "JUNK: COM COUNTER" or show_mode = "JUNK: SLAVE-ONLY")
+ and source = "I_S.SESSION_STATUS")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 12
+--echo # Present in 5.7 P_S.SESSION_STATUS (2-10)
+--echo # Missing in 5.7 P_S.STATUS_BY_THREAD
+--echo # EXPECT NOTHING AFTER REMOVING KNOWN GLOBAL-ONLY (2-15)
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.SESSION_STATUS"
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.STATUS_BY_THREAD")
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where (show_mode = "JUNK: GLOBAL-ONLY")
+ and source = "I_S.SESSION_STATUS")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 13
+--echo # Present in 5.7 P_S.STATUS_BY_THREAD
+--echo # Missing in 5.7 P_S.SESSION_STATUS (2-10)
+--echo # EXPECT NOTHING
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.STATUS_BY_THREAD"
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.SESSION_STATUS")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 14
+--echo # Present in 5.7 P_S.SESSION_STATUS (2-10)
+--echo # Missing in 5.7 P_S.STATUS_BY_ACCOUNT
+--echo # EXPECT NOTHING AFTER REMOVING
+--echo # - KNOWN GLOBAL-ONLY (2-15)
+--echo # - STATUS VARS THAT CAN'T BE AGGREGATED (2-17)
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.SESSION_STATUS"
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "JUNK"
+ and source = "NO AGGREGATE")
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where (show_mode = "JUNK: GLOBAL-ONLY")
+ and source = "I_S.SESSION_STATUS")
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.STATUS_BY_ACCOUNT")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 15
+--echo # Present in 5.7 P_S.STATUS_BY_ACCOUNT
+--echo # Missing in 5.7 P_S.SESSION_STATUS (2-10)
+--echo # EXPECT NOTHING
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.STATUS_BY_ACCOUNT"
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.SESSION_STATUS")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 16
+--echo # KNOWN STATUS VARS THAT CAN'T BE AGGREGATED (2-17)
+--echo # Status variables that should NOT be present in 5.7 P_S.STATUS_BY_ACCOUNT
+--echo # ================================================================================
+select * from performance_schema.status_by_account
+ where upper(variable_name) in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "JUNK"
+ and source = "NO AGGREGATE")
+ order by variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 17
+--echo # Present in 5.7 P_S.SESSION_STATUS (2-10)
+--echo # Missing in 5.7 P_S.STATUS_BY_USER
+--echo # EXPECT NOTHING AFTER REMOVING
+--echo # - KNOWN GLOBAL-ONLY (2-15)
+--echo # - STATUS VARS THAT CAN'T BE AGGREGATED (2-17)
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.SESSION_STATUS"
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "JUNK"
+ and source = "NO AGGREGATE")
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where (show_mode = "JUNK: GLOBAL-ONLY")
+ and source = "I_S.SESSION_STATUS")
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.STATUS_BY_USER")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 18
+--echo # Present in 5.7 P_S.STATUS_BY_USER
+--echo # Missing in 5.7 P_S.SESSION_STATUS (2-10)
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.STATUS_BY_USER"
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.SESSION_STATUS")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 19
+--echo # KNOWN STATUS VARS THAT CAN'T BE AGGREGATED (2-17)
+--echo # Status variables that should NOT be present in 5.7 P_S.STATUS_BY_USER
+--echo # ================================================================================
+select * from performance_schema.status_by_user
+ where upper(variable_name) in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "JUNK"
+ and source = "NO AGGREGATE")
+ order by variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 20
+--echo # Present in 5.7 P_S.SESSION_STATUS (2-10)
+--echo # Missing in 5.7 P_S.STATUS_BY_HOST
+--echo # EXPECT NOTHING AFTER REMOVING
+--echo # - KNOWN GLOBAL-ONLY (2-15)
+--echo # - STATUS VARS THAT CAN'T BE AGGREGATED (2-17)
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.SESSION_STATUS"
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "JUNK"
+ and source = "NO AGGREGATE")
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where (show_mode = "JUNK: GLOBAL-ONLY")
+ and source = "I_S.SESSION_STATUS")
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.STATUS_BY_HOST")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 21
+--echo # Present in 5.7 P_S.STATUS_BY_HOST
+--echo # Missing in 5.7 P_S.SESSION_STATUS (2-10)
+--echo # ================================================================================
+select * from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.STATUS_BY_HOST"
+ and upper(variable_name) not in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "5.7"
+ and source = "P_S.SESSION_STATUS")
+ order by show_mode, source, variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # TEST 22
+--echo # KNOWN STATUS VARS THAT CAN'T BE AGGREGATED (2-17)
+--echo # Status variables that should NOT be present in 5.7 P_S.STATUS_BY_HOST
+--echo # ================================================================================
+select * from performance_schema.status_by_host
+ where upper(variable_name) in (
+ select upper(variable_name) from test.sanity
+ where show_mode = "JUNK"
+ and source = "NO AGGREGATE")
+ order by variable_name;
+
+--echo #
+--echo # ================================================================================
+--echo # CLEAN UP
+--echo # ================================================================================
+set @@global.show_compatibility_56 = @show_compatibility_56_save;
+drop table test.sanity;
+
+
diff --git a/mysql-test/suite/perfschema/t/socket_connect.test b/mysql-test/suite/perfschema/t/socket_connect.test
new file mode 100644
index 00000000..8290e289
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/socket_connect.test
@@ -0,0 +1,293 @@
+#
+# Check the handling of TCP/IP connections in the performance_schema socket
+# instance tables
+#
+#==============================================================================
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source ../include/wait_for_pfs_thread_count.inc
+
+# Set this to enable debugging output
+let $my_socket_debug_dbug=0;
+
+--echo #==============================================================================
+--echo # Establish the level of IPV6 support
+--echo #==============================================================================
+--source ../include/socket_ipv6.inc
+
+--echo #==============================================================================
+--echo # Get hostname, port number
+--echo #==============================================================================
+SELECT @@hostname INTO @MY_HOSTNAME;
+SELECT @@port INTO @MY_MASTER_PORT;
+
+if ($my_socket_debug)
+{
+ SELECT @MY_HOSTNAME AS 'Hostname';
+ SELECT @MY_MASTER_PORT AS 'Master Port';
+}
+#==============================================================================
+# Utility queries
+#==============================================================================
+let $count_client_connections=
+ SELECT COUNT(*) INTO @my_client_connections
+ FROM performance_schema.socket_instances
+ WHERE EVENT_NAME LIKE "%client_connection%";
+
+let $get_thread_id=
+ SELECT THREAD_ID INTO @my_thread_id
+ FROM performance_schema.threads
+ WHERE PROCESSLIST_ID = CONNECTION_ID();
+
+let $get_object_instance_begin=
+ SELECT OBJECT_INSTANCE_BEGIN INTO @my_object_instance_begin
+ FROM performance_schema.socket_instances
+ WHERE THREAD_ID = @my_thread_id;
+
+let $get_port=
+ SELECT PORT INTO @my_port
+ FROM performance_schema.socket_instances
+ WHERE THREAD_ID = @my_thread_id;
+
+let $ip_localhost=
+ (IP LIKE '%127.0.0.1' OR IP LIKE '%::1');
+
+--echo #==============================================================================
+--echo # 1.0 Get the default connection object_instance_begin, thread id and verify
+--echo # the expected number of client connections.
+--echo #==============================================================================
+--echo #
+--echo # 1.1 Confirm only one client connection
+--echo #
+eval $count_client_connections;
+
+if (`SELECT @my_client_connections != 1`)
+{
+ --echo # There should be one client connection
+ SELECT * FROM performance_schema.socket_instances;
+ --echo # abort
+ exit;
+}
+
+--echo #
+--echo # 1.2 Get the default THREAD_ID;
+--echo #
+eval $get_thread_id;
+let $default_thread_id= `SELECT @my_thread_id`;
+
+--echo #
+--echo # 1.3 Get the default OBJECT_INSTANCE_BEGIN
+--echo #
+eval $get_object_instance_begin;
+let $default_object_instance_begin= `SELECT @my_object_instance_begin`;
+--disable_query_log
+SELECT @my_object_instance_begin INTO @default_object_instance_begin;
+--enable_query_log
+
+if ($my_socket_debug)
+{
+ --echo # Default object instance begin = $default_object_instance_begin
+ --echo # Default thread id = $default_thread_id
+}
+
+--echo #==============================================================================
+--echo # 2.0 ESTABLISH TCP/IP CONNECTION 1
+--echo # Connect with IP = localhost (127.0.0.1 or ::1)
+--echo #==============================================================================
+--disable_query_log
+--connect (con1,$my_localhost,root,,test,,$MASTER_MYPORT)
+--enable_query_log
+
+--echo #
+--echo # 2.1 Get the connection thread id
+--echo #
+eval $get_thread_id;
+
+--echo #
+--echo # 2.2 Get the connection object instance begin
+--echo #
+eval $get_object_instance_begin;
+
+--echo #
+--echo # 2.3 Get the connection port
+--echo #
+eval $get_port;
+
+--disable_query_log
+SELECT @my_thread_id INTO @con1_thread_id;
+SELECT @my_port INTO @con1_port;
+SELECT @my_object_instance_begin INTO @con1_object_id;
+let $con1_thread_id= `SELECT @con1_thread_id`;
+let $con1_port= `SELECT @con1_port`;
+let $con1_object_id= `SELECT @con1_object_id`;
+let $con1_name1= "127.0.0.1:$con1_port";
+let $con1_name2= "::1:$con1_port";
+--enable_query_log
+
+if ($my_socket_debug)
+{
+ --echo # Con1 thread id = $con1_thread_id
+ --echo # Con1 object_id = $con1_object_id
+ --echo # Con1 port = $con1_port
+ --echo # Con1 name1 = $con1_name1
+ --echo # Con1 name2 = $con1_name2
+}
+
+--echo #
+--echo # 2.4 Verify that the connection is 127.0.0.1 or ::1
+--echo #
+eval SELECT COUNT(*) = 1 AS 'Expect 1'
+FROM performance_schema.socket_instances
+WHERE EVENT_NAME LIKE '%client_connection%'
+ AND $ip_localhost
+ AND PORT= @con1_port
+ AND OBJECT_INSTANCE_BEGIN= @con1_object_id;
+
+--echo #
+--echo # 2.5 Verify that the same connection is in the summary instance table
+--echo #
+eval SELECT COUNT(*) = 1 AS 'Expect 1'
+FROM performance_schema.socket_summary_by_instance
+WHERE EVENT_NAME LIKE '%client_connection%'
+ AND OBJECT_INSTANCE_BEGIN= @con1_object_id;
+
+--echo #
+--echo # Switch to connection default
+--echo #
+--connection default
+
+--echo #==============================================================================
+--echo # 3.0 ESTABLISH TCP/IP CONNECTION 2
+--echo # Connect with IP = localhost (127.0.0.1 or ::1)
+--echo #==============================================================================
+--disable_query_log
+--connect (con2,$my_localhost,root,,test,,$MASTER_MYPORT)
+--enable_query_log
+
+--echo #
+--echo # 3.1 Get the connection thread id
+--echo #
+eval $get_thread_id;
+
+--echo #
+--echo # 3.2 Get the connection object instance begin
+--echo #
+eval $get_object_instance_begin;
+
+--echo #
+--echo # 3.3 Get the connection port
+--echo #
+eval $get_port;
+
+--disable_query_log
+SELECT @my_thread_id INTO @con2_thread_id;
+SELECT @my_port INTO @con2_port;
+SELECT @my_object_instance_begin INTO @con2_object_id;
+let $con2_thread_id= `SELECT @con2_thread_id`;
+let $con2_port= `SELECT @con2_port`;
+let $con2_object_id= `SELECT @con2_object_id`;
+let $con2_name1= "127.0.0.1:$con2_port";
+let $con2_name2= "::1:$con2_port";
+--enable_query_log
+
+if ($my_socket_debug)
+{
+ --echo # con2 thread id = $con2_thread_id
+ --echo # con2 object_id = $con2_object_id
+ --echo # con2 port = $con2_port
+ --echo # con2 name1 = $con2_name1
+ --echo # con2 name2 = $con2_name2
+}
+
+--echo #
+--echo # 3.4 Verify that the connection is 127.0.0.1 or ::1
+--echo #
+
+eval SELECT COUNT(*) = 1 AS 'Expect 1'
+FROM performance_schema.socket_instances
+WHERE EVENT_NAME LIKE '%client_connection%'
+ AND $ip_localhost
+ AND PORT= @con2_port
+ AND OBJECT_INSTANCE_BEGIN= @con2_object_id;
+
+--echo #
+--echo # 3.5 Verify that the same connection is in the summary instance table
+--echo #
+eval SELECT COUNT(*) = 1 AS 'Expect 1'
+FROM performance_schema.socket_summary_by_instance
+WHERE EVENT_NAME LIKE '%client_connection%'
+ AND OBJECT_INSTANCE_BEGIN= @con2_object_id;
+
+--echo #
+--echo # 3.6 Verify that the connection is 127.0.0.1 or ::1
+--echo #
+eval SELECT COUNT(*) = 1 AS 'Expect 1'
+FROM performance_schema.socket_instances
+WHERE EVENT_NAME LIKE '%client_connection%'
+ AND $ip_localhost
+ AND PORT= @con2_port
+ AND OBJECT_INSTANCE_BEGIN= @con2_object_id;
+
+--echo #==============================================================================
+--echo # 4.0 Verify both connections exist in the instance tables
+--echo #==============================================================================
+--connection default
+
+--echo #
+--echo # 4.1 Verify that there are two TCP/IP connections in the socket instance table
+--echo #
+eval SELECT COUNT(*) = 2 AS 'Expect 2'
+FROM performance_schema.socket_instances
+WHERE EVENT_NAME LIKE '%client_connection%'
+ AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND $ip_localhost;
+
+--echo #
+--echo # 4.2 Verify that there are two TCP/IP connections in the summary instance table
+--echo #
+eval SELECT COUNT(*) = 2 AS 'Expect 2'
+FROM performance_schema.socket_summary_by_instance
+WHERE EVENT_NAME LIKE '%client_connection%'
+ AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin;
+
+--echo #==============================================================================
+--echo # 5.0 Drop the client connections
+--echo #==============================================================================
+
+--echo # 5.1 Disconnect con1
+--connection con1
+--disconnect con1
+--source include/wait_until_disconnected.inc
+
+--echo # 5.2 Disconnect con2
+--connection con2
+--disconnect con2
+--source include/wait_until_disconnected.inc
+--connection default
+
+--echo #==============================================================================
+--echo # 6.0 Verify sockets were removed from the instance tables
+--echo #==============================================================================
+
+--echo #
+--echo # 6.1 Verify that there are no TCP/IP connections in the socket instance table
+--echo #
+let $wait_condition=
+SELECT COUNT(*) = 0 AS 'Expect 0'
+FROM performance_schema.socket_instances
+WHERE EVENT_NAME LIKE '%client_connection%'
+ AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND $ip_localhost;
+--source include/wait_condition.inc
+
+--echo #
+--echo # 6.2 Verify that there are no TCP/IP connections in the summary instance table
+--echo #
+let $wait_condition=
+SELECT COUNT(*) = 0 AS 'Expect 0'
+FROM performance_schema.socket_summary_by_instance
+WHERE EVENT_NAME LIKE '%client_connection%'
+ AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin;
+--source include/wait_condition.inc
+exit;
diff --git a/mysql-test/suite/perfschema/t/socket_instances_func-master.opt b/mysql-test/suite/perfschema/t/socket_instances_func-master.opt
new file mode 100644
index 00000000..b12a8b3b
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/socket_instances_func-master.opt
@@ -0,0 +1 @@
+--skip-name-resolve --bind-address=*
diff --git a/mysql-test/suite/perfschema/t/socket_instances_func.test b/mysql-test/suite/perfschema/t/socket_instances_func.test
new file mode 100644
index 00000000..7e8dfe51
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/socket_instances_func.test
@@ -0,0 +1,443 @@
+#
+# Some functional checks for the content of performance_schema.socket_instances.
+#
+
+--source include/not_embedded.inc
+--source include/not_windows.inc
+--source include/have_perfschema.inc
+
+# Set this to enable debugging output
+let $my_socket_debug_dbug= 0;
+
+#
+# Set IP address defaults with respect to IPV6 support
+#
+
+# Determine if IPV6 supported
+let $check_ipv6_just_check= 1;
+--source include/check_ipv6.inc
+
+# Determine if IPV4 mapped to IPV6 supported
+let $check_ipv4_mapped_just_check= 1;
+--source include/have_ipv4_mapped.inc
+
+let $my_localhost= 127.0.0.1;
+
+if($check_ipv6_supported)
+{
+ let $my_localhost= ::1;
+}
+
+if($check_ipv4_mapped_supported)
+{
+ let $my_localhost= ::ffff:127.0.0.1;
+}
+
+if($my_socket_debug)
+{
+ --echo IPV6=$check_ipv6_supported, IPV4_MAPPED=$check_ipv4_mapped_supported, LOCALHOST=$my_localhost
+}
+
+# This test only runs when IPv6 is supported (see include/check_ipv6.inc), so
+# the server will listen on both IPv4 and IPv6 wildcard addresses. That's why
+# the expected number of TCP/IP listeners is always 2.
+
+#
+# Preserve the current state of SOCKET_INSTANCES
+#
+
+--echo # Take a snapshot of SOCKET_INSTANCES
+CREATE TEMPORARY TABLE my_socket_instances AS
+SELECT * FROM performance_schema.socket_instances;
+
+--echo # Get thread id of the default connection
+SELECT THREAD_ID INTO @thread_id
+FROM performance_schema.threads
+WHERE PROCESSLIST_ID = CONNECTION_ID();
+
+let $con0_thread_id= `SELECT @thread_id`;
+
+#
+# ESTABLISH TCP/IP CONNECTION 1
+#
+# Start connection with IP = localhost (127.0.0.1 or ::1)
+
+--connect (con1,$my_localhost,root,,test,,$MASTER_MYPORT)
+
+if($my_socket_debug)
+{
+# --replace_result '::ffff:127.0.0.1' <LOCALHOST> '127.0.0.1' <LOCALHOST> '::1' <LOCALHOST> '::' <BINDADDR> '0.0.0.0' <BINDADDR>
+ SELECT * FROM performance_schema.socket_instances;
+}
+
+--echo # Store the thread id of connection 1 (tcp/ip)
+SELECT THREAD_ID INTO @thread_id
+FROM performance_schema.threads
+WHERE PROCESSLIST_ID = CONNECTION_ID();
+
+--echo # Store the port of connection 1 (tcp/ip)
+eval SELECT PORT INTO @port
+FROM performance_schema.socket_instances
+WHERE THREAD_ID = @thread_id;
+
+let $con1_thread_id= `SELECT @thread_id`;
+let $con1_port= `SELECT @port`;
+
+--connection default
+
+#
+# ESTABLISH TCP/IP CONNECTION 2
+#
+# Start a second connection with IP = localhost (127.0.0.1 or ::1)
+
+--connect (con2,$my_localhost,root,,test,,$MASTER_MYPORT)
+
+if($my_socket_debug)
+{
+# --replace_result '::ffff:127.0.0.1' <LOCALHOST> '127.0.0.1' <LOCALHOST> '::1' <LOCALHOST> '::' <BINDADDR> '0.0.0.0' <BINDADDR>
+ SELECT * FROM performance_schema.socket_instances;
+}
+
+--echo # Store the thread_id of connection 2 (tcp/ip)
+SELECT THREAD_ID INTO @thread_id
+FROM performance_schema.threads
+WHERE PROCESSLIST_ID = CONNECTION_ID();
+
+--echo # Store the port of connection 2 (tcp/ip)
+eval SELECT PORT INTO @port
+FROM performance_schema.socket_instances
+WHERE THREAD_ID = @thread_id;
+
+let $con2_thread_id= `SELECT @thread_id`;
+let $con2_port= `SELECT @port`;
+
+--connection default
+
+#
+# ESTABLISH LOCAL UNIX DOMAIN CONNECTION
+#
+# Connect via mysql sock file
+
+--connect(con3,localhost,root,,test,,)
+
+if($my_socket_debug)
+{
+# --replace_result '::ffff:127.0.0.1' <LOCALHOST> '127.0.0.1' <LOCALHOST> '::1' <LOCALHOST> '::' <BINDADDR> '0.0.0.0' <BINDADDR>
+ SELECT * FROM performance_schema.socket_instances;
+}
+
+--echo # Store the thread id of connection 3 (unix domain)
+SELECT THREAD_ID INTO @thread_id
+FROM performance_schema.threads
+WHERE PROCESSLIST_ID = CONNECTION_ID();
+
+--echo # Store the port of connection 3 (unix domain)
+eval SELECT PORT INTO @port
+FROM performance_schema.socket_instances
+WHERE THREAD_ID = @thread_id;
+
+let $con3_port= `SELECT @port`;
+let $con3_thread_id= `SELECT @thread_id`;
+
+--connection default
+
+#
+# VERIFY EVENT NAMES
+#
+
+--echo # EVENT_NAME is the "wait/io/socket/*" instrument identifier.
+
+SELECT COUNT(*) = 0 AS "Expect 1"
+FROM performance_schema.socket_instances
+WHERE EVENT_NAME NOT LIKE 'wait/io/socket/%';
+
+#
+# VERIFY UNIQUE EVENT IDs
+#
+
+--echo # OBJECT_INSTANCE_BEGIN is an arbitrary identifier, guaranteed to be unique.
+
+SELECT COUNT(*) = COUNT(DISTINCT OBJECT_INSTANCE_BEGIN) AS "Expect 1"
+FROM performance_schema.socket_instances;
+
+#
+# VERIFY UNIQUE SOCKET ID
+#
+
+--echo # SOCKET_ID is the internal file handle assigned to the socket.
+
+SELECT COUNT(*) = COUNT(DISTINCT SOCKET_ID) AS "Expect 1"
+FROM performance_schema.socket_instances;
+
+#
+# VERIFY UNIQUE THREAD IDs
+#
+
+--echo # Characteristics per our thread
+--echo # There must be only one entry with our thread_id
+
+--disable_query_log ONCE
+eval SET @thread_id= $con0_thread_id;
+
+eval SELECT COUNT(*) = 1 AS 'Expect 1'
+FROM performance_schema.socket_instances
+WHERE THREAD_ID = @thread_id;
+
+#
+# VERIFY UNIQUE PORT NUMBERS FOR TCP/IP CLIENTS
+#
+
+--echo # TCP/IP connections should have a unique port number
+--disable_query_log ONCE
+eval SET @port= $con1_port;
+
+--echo # Connection 1 (tcp/ip)
+eval SELECT COUNT(*) = 1 AS 'Expect 1'
+FROM performance_schema.socket_instances
+WHERE PORT = @port;
+
+--disable_query_log ONCE
+eval SET @port= $con2_port;
+
+--echo # Connection 2 (tcp/ip)
+eval SELECT COUNT(*) = 1 AS 'Expect 1'
+FROM performance_schema.socket_instances
+WHERE PORT = @port;
+
+#
+# VERIFY CONNECTION DETAILS FOR THE DEFAULT CONNECTION
+#
+
+--echo # Check the content for the default connection (unix domain)
+# EVENT_NAME OBJECT_INSTANCE_BEGIN THREAD_ID SOCKET_ID IP PORT STATE
+# wait/io/socket/sql/client_connection 139799531958280 16 37 0 ACTIVE
+
+--disable_query_log ONCE
+eval SET @thread_id = $con0_thread_id;
+
+SELECT COUNT(*) = 1 as 'Expect 1'
+FROM performance_schema.socket_instances
+WHERE EVENT_NAME = 'wait/io/socket/sql/client_connection'
+AND PORT = 0 AND THREAD_ID = @thread_id;
+
+#
+# VERIFY SERVER LISTENING SOCKET, TCP/IP
+#
+
+--echo # Characteristics of 'server_tcpip_socket' entry
+--echo # Server listening socket, TCP/IP
+--echo # There are two entries with 'wait/io/socket/sql/server_tcpip_socket',
+--echo # for [::] and for 0.0.0.0.
+--echo # They share the same thread id with 'wait/io/socket/sql/server_unix_socket'.
+
+SELECT COUNT(*) = 2 AS 'Expect 2'
+FROM performance_schema.socket_instances
+WHERE EVENT_NAME = 'wait/io/socket/sql/server_tcpip_socket';
+
+# Store the thread id of server_tcpip_socket
+--echo # Get the 'server_tcpip_socket' thread id
+
+SELECT DISTINCT THREAD_ID INTO @thread_id
+FROM performance_schema.socket_instances
+WHERE EVENT_NAME = 'wait/io/socket/sql/server_tcpip_socket';
+
+let $server_tcpip_thread_id= `SELECT @thread_id`;
+
+--echo # Check the content.
+--disable_query_log ONCE
+eval SET @port = $MASTER_MYPORT;
+
+eval SELECT THREAD_ID = @thread_id
+ AND (IP = '0.0.0.0' OR IP = '::')
+ AND PORT = @port
+ AND STATE = 'ACTIVE' AS 'Expect 1'
+FROM performance_schema.socket_instances
+WHERE EVENT_NAME = 'wait/io/socket/sql/server_tcpip_socket';
+
+#
+# VERIFY SERVER LISTENING SOCKET, UNIX DOMAIN
+#
+
+--echo # Characteristics of 'server_unix_socket' entry
+--echo # Server listening socket, unix domain (socket file)
+--echo # There is only one entry with 'wait/io/socket/sql/server_unix_socket'.
+--echo # It shares the same thread id as 'wait/io/socket/sql/server_tcpip_socket'.
+
+SELECT COUNT(*) = 1 AS 'Expect 1'
+FROM performance_schema.socket_instances
+WHERE EVENT_NAME = 'wait/io/socket/sql/server_unix_socket';
+
+# Store the thread id of 'server_unix_socket'
+--echo # Get the 'server_unix_socket' thread id
+
+SELECT THREAD_ID INTO @thread_id
+FROM performance_schema.socket_instances
+WHERE EVENT_NAME = 'wait/io/socket/sql/server_unix_socket';
+
+let $server_unix_thread_id= `SELECT @thread_id`;
+
+--echo # Check the content.
+eval SELECT THREAD_ID = @thread_id
+ AND IP = ''
+ AND PORT = 0
+ AND STATE = 'ACTIVE' AS 'Expect 1'
+FROM performance_schema.socket_instances
+WHERE EVENT_NAME = 'wait/io/socket/sql/server_unix_socket';
+
+#
+# VERIFY SERVER LISTENING SOCKET THREAD IDs
+#
+
+--echo # Server listening sockets (TCP and Unix) are handled on the same thread
+
+--disable_query_log ONCE
+eval SET @thread_id = $server_tcpip_thread_id;
+
+eval SELECT COUNT(*) = 3 AS 'Expect 3'
+FROM performance_schema.socket_instances
+WHERE THREAD_ID = @thread_id;
+
+--disable_query_log ONCE
+eval SET @thread_id = $server_unix_thread_id;
+
+eval SELECT COUNT(*) = 3 AS 'Expect 3'
+FROM performance_schema.socket_instances
+WHERE THREAD_ID = @thread_id;
+
+--echo #Compare server listener socket thread ids
+--disable_query_log ONCE
+eval SELECT ($server_tcpip_thread_id = $server_unix_thread_id) into @match_thread_id;
+
+select @match_thread_id;
+
+#
+# VERIFY TCP/IP CLIENT CONNECTION 1
+#
+
+# EVENT_NAME OBJECT_INSTANCE_BEGIN THREAD_ID SOCKET_ID IP PORT STATE
+# wait/io/socket/sql/client_connection 140707865187120 18 59 127.0.0.1 59298 IDLE or ACTIVE
+
+--echo # Check content for client connection 1 (tcpip)
+
+--disable_query_log
+eval SET @port = $con1_port;
+eval SET @thread_id = $con1_thread_id;
+eval SET @addr = '$my_localhost';
+--enable_query_log
+
+eval SELECT EVENT_NAME = 'wait/io/socket/sql/client_connection'
+ AND (IP LIKE '%127.0.0.1' OR IP = '::1')
+ AND PORT = @port
+AS 'Expect 1'
+FROM performance_schema.socket_instances
+WHERE THREAD_ID = @thread_id;
+
+--echo # Characteristics of entries with THREAD_ID of con1
+--echo # There is only one entry with this id.
+
+eval SELECT COUNT(*) = 1 AS 'Expect 1'
+FROM performance_schema.socket_instances
+WHERE THREAD_ID = @thread_id;
+
+#
+# VERIFY TCP/IP CLIENT CONNECTION 2
+#
+
+# EVENT_NAME OBJECT_INSTANCE_BEGIN THREAD_ID SOCKET_ID IP PORT STATE
+# wait/io/socket/sql/client_connection 140707865187120 18 59 127.0.0.1 59298 IDLE or ACTIVE
+
+--echo # Check content for client connection 2 (tcpip)
+
+--disable_query_log
+eval SET @port = $con2_port;
+eval SET @thread_id = $con2_thread_id;
+eval SET @addr = '$my_localhost';
+--enable_query_log
+
+eval SELECT EVENT_NAME = 'wait/io/socket/sql/client_connection'
+ AND (IP LIKE '%127.0.0.1' OR IP = '::1')
+ AND PORT = @port
+AS 'Expect 1'
+FROM performance_schema.socket_instances
+WHERE THREAD_ID = @thread_id;
+
+--echo # Characteristics of entries with THREAD_ID of con2
+--echo # There is only one entry with this id.
+
+eval SELECT COUNT(*) = 1 AS 'Expect 1'
+FROM performance_schema.socket_instances
+WHERE THREAD_ID = @thread_id;
+
+#
+# VERIFY LOCAL CONNECTION, UNIX DOMAIN
+#
+
+# EVENT_NAME OBJECT_INSTANCE_BEGIN THREAD_ID SOCKET_ID IP PORT STATE
+# wait/io/socket/sql/client_connection 139799531958280 16 37 0 IDLE or ACTIVE
+
+--echo # Check the content for client connection 3 (unix domain).
+
+--disable_query_log ONCE
+eval SET @thread_id = $con3_thread_id;
+
+eval SELECT EVENT_NAME = 'wait/io/socket/sql/client_connection'
+ AND IP = ''
+ AND PORT = 0
+AS 'Expect 1'
+FROM performance_schema.socket_instances
+WHERE THREAD_ID = @thread_id;
+
+--echo # Characteristics of entries with THREAD_ID of con3
+--echo # There is only one entry with this id.
+
+eval SELECT COUNT(*) = 1 AS 'Expect 1'
+FROM performance_schema.socket_instances
+WHERE THREAD_ID = @thread_id;
+
+#
+# LIST CLIENT CONNECTIONS
+#
+
+--echo # Show differences to socket_instances before con1, con2 and con3 connecting
+let $part=
+FROM performance_schema.socket_instances
+WHERE (EVENT_NAME,OBJECT_INSTANCE_BEGIN,THREAD_ID,SOCKET_ID,IP,PORT,STATE)
+NOT IN (SELECT EVENT_NAME,OBJECT_INSTANCE_BEGIN,THREAD_ID,SOCKET_ID,IP,PORT,STATE
+ FROM my_socket_instances)
+ORDER BY THREAD_ID;
+--replace_result '::ffff:127.0.0.1' <LOCALHOST> '127.0.0.1' <LOCALHOST> '::1' <LOCALHOST> '::' <BINDADDR> '0.0.0.0' <BINDADDR>
+eval
+SELECT EVENT_NAME, IP
+$part;
+
+--connection default
+
+#
+# DROP CLIENT CONNECTIONS
+#
+
+--connection con1
+--disconnect con1
+--source include/wait_until_disconnected.inc
+--connection con2
+--disconnect con2
+--source include/wait_until_disconnected.inc
+--connection con3
+--disconnect con3
+--source include/wait_until_disconnected.inc
+--connection default
+
+#
+# VERIFY CONNECTIONS DROPPED
+#
+
+--echo # After waiting a bit we should have no differences to socket_instances
+--echo # before con1, con2, con3 connecting.
+let $wait_timeout= 10;
+let $wait_condition= SELECT COUNT(*) = 0 $part;
+--source include/wait_condition.inc
+#
+eval
+SELECT *
+$part;
+
diff --git a/mysql-test/suite/perfschema/t/socket_instances_func_win-master.opt b/mysql-test/suite/perfschema/t/socket_instances_func_win-master.opt
new file mode 100644
index 00000000..ab6ca173
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/socket_instances_func_win-master.opt
@@ -0,0 +1 @@
+--skip-name-resolve
diff --git a/mysql-test/suite/perfschema/t/socket_instances_func_win.test b/mysql-test/suite/perfschema/t/socket_instances_func_win.test
new file mode 100644
index 00000000..5faf0d24
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/socket_instances_func_win.test
@@ -0,0 +1,339 @@
+#
+# Some functional checks for the content of performance_schema.socket_instances.
+#
+
+--source include/not_embedded.inc
+--source include/windows.inc
+--source include/have_perfschema.inc
+
+# Set this to enable debugging output
+let $my_socket_debug_dbug= 0;
+
+#
+# Set IP address defaults with respect to IPV6 support
+#
+
+# Determine if IPV6 supported
+let $check_ipv6_just_check= 1;
+--source include/check_ipv6.inc
+
+# Determine if IPV4 mapped to IPV6 supported
+let $check_ipv4_mapped_just_check= 1;
+--source include/have_ipv4_mapped.inc
+
+let $my_localhost= 127.0.0.1;
+
+if($check_ipv6_supported)
+{
+ let $my_localhost= ::1;
+}
+
+if($check_ipv4_mapped_supported)
+{
+ let $my_localhost= ::ffff:127.0.0.1;
+}
+
+if($my_socket_debug)
+{
+ --echo IPV6=$check_ipv6_supported, IPV4_MAPPED=$check_ipv4_mapped_supported, LOCALHOST=$my_localhost
+}
+
+#
+# Preserve the current state of SOCKET_INSTANCES
+#
+
+--echo # Take a snapshot of SOCKET_INSTANCES
+CREATE TEMPORARY TABLE my_socket_instances AS
+SELECT * FROM performance_schema.socket_instances;
+
+--echo # Get thread id of the default connection
+SELECT THREAD_ID INTO @thread_id
+FROM performance_schema.threads
+WHERE PROCESSLIST_ID = CONNECTION_ID();
+
+let $con0_thread_id= `SELECT @thread_id`;
+
+#
+# ESTABLISH TCP/IP CONNECTION 1
+#
+# Start connection with IP = localhost (127.0.0.1 or ::1)
+
+--echo # Establish local TCP/IP connection (con1,localhost,root,,test,,)
+--disable_query_log
+--connect (con1,$my_localhost,root,,test,,$MASTER_MYPORT)
+--enable_query_log
+
+if($my_socket_debug)
+{
+# --replace_result '::ffff:127.0.0.1' <LOCALHOST> '127.0.0.1' <LOCALHOST> '::1' <LOCALHOST> '::' <BINDADDR> '0.0.0.0' <BINDADDR>
+ SELECT * FROM performance_schema.socket_instances;
+}
+
+--echo # Store the thread id of connection 1 (tcp/ip)
+SELECT THREAD_ID INTO @thread_id
+FROM performance_schema.threads
+WHERE PROCESSLIST_ID = CONNECTION_ID();
+
+--echo # Store the port of connection 1 (tcp/ip)
+eval SELECT PORT INTO @port
+FROM performance_schema.socket_instances
+WHERE THREAD_ID = @thread_id;
+
+let $con1_thread_id= `SELECT @thread_id`;
+let $con1_port= `SELECT @port`;
+
+--echo # Switch to connection default
+--connection default
+
+#
+# ESTABLISH TCP/IP CONNECTION 2
+#
+# Start a second connection with IP = localhost (127.0.0.1 or ::1)
+
+--echo # Establish second local TCP/IP connection (con1,localhost,root,,test,,)
+--disable_query_log
+--connect (con2,$my_localhost,root,,test,,$MASTER_MYPORT)
+--enable_query_log
+
+if($my_socket_debug)
+{
+# --replace_result '::ffff:127.0.0.1' <LOCALHOST> '127.0.0.1' <LOCALHOST> '::1' <LOCALHOST> '::' <BINDADDR> '0.0.0.0' <BINDADDR>
+ SELECT * FROM performance_schema.socket_instances;
+}
+
+--echo # Store the thread_id of connection 2 (tcp/ip)
+SELECT THREAD_ID INTO @thread_id
+FROM performance_schema.threads
+WHERE PROCESSLIST_ID = CONNECTION_ID();
+
+--echo # Store the port of connection 2 (tcp/ip)
+eval SELECT PORT INTO @port
+FROM performance_schema.socket_instances
+WHERE THREAD_ID = @thread_id;
+
+let $con2_thread_id= `SELECT @thread_id`;
+let $con2_port = `SELECT @port`;
+
+--echo # Switch to connection default
+--connection default
+
+#
+# VERIFY EVENT NAMES
+#
+
+--echo # EVENT_NAME is the "wait/io/socket/*" instrument identifier.
+
+SELECT COUNT(*) = 0 AS "Expect 1"
+FROM performance_schema.socket_instances
+WHERE EVENT_NAME NOT LIKE 'wait/io/socket/%';
+
+#
+# VERIFY UNIQUE EVENT IDs
+#
+
+--echo # OBJECT_INSTANCE_BEGIN is an arbitrary identifier, guaranteed to be unique.
+
+SELECT COUNT(*) = COUNT(DISTINCT OBJECT_INSTANCE_BEGIN) AS "Expect 1"
+FROM performance_schema.socket_instances;
+
+#
+# VERIFY UNIQUE SOCKET ID
+#
+
+--echo # SOCKET_ID is the internal file handle assigned to the socket.
+
+SELECT COUNT(*) = COUNT(DISTINCT SOCKET_ID) AS "Expect 1"
+FROM performance_schema.socket_instances;
+
+#
+# VERIFY UNIQUE THREAD IDs
+#
+
+--echo # Characteristics per our thread
+--echo # There must be only one entry with our thread_id
+
+--disable_query_log
+eval SET @thread_id= $con0_thread_id;
+--enable_query_log
+
+eval SELECT COUNT(*) = 1 AS 'Expect 1'
+FROM performance_schema.socket_instances
+WHERE THREAD_ID = @thread_id;
+
+#
+# VERIFY UNIQUE PORT NUMBERS FOR TCP/IP CLIENTS
+#
+
+--echo # TCP/IP connections should have a unique port number
+--disable_query_log
+eval SET @port= $con1_port;
+--enable_query_log
+
+--echo # Connection 1 (tcp/ip)
+eval SELECT COUNT(*) = 1 AS 'Expect 1'
+FROM performance_schema.socket_instances
+WHERE PORT = @port;
+
+--disable_query_log
+eval SET @port= $con2_port;
+--enable_query_log
+
+--echo # Connection 2 (tcp/ip)
+eval SELECT COUNT(*) = 1 AS 'Expect 1'
+FROM performance_schema.socket_instances
+WHERE PORT = @port;
+
+#
+# VERIFY CONNECTION DETAILS FOR THE DEFAULT CONNECTION
+#
+
+--echo # Check the content for the default connection (tcpip)
+# EVENT_NAME OBJECT_INSTANCE_BEGIN THREAD_ID SOCKET_ID IP PORT STATE
+# wait/io/socket/sql/client_connection 26139912 16 907296 127.0.0.1 2631 ACTIVE
+
+--disable_query_log
+eval SET @thread_id = $con0_thread_id;
+--enable_query_log
+
+SELECT EVENT_NAME = 'wait/io/socket/sql/client_connection'
+ AND (IP LIKE '%127.0.0.1' OR IP = '::1') AS 'Expect 1'
+FROM performance_schema.socket_instances
+WHERE THREAD_ID = @thread_id;
+
+#
+# VERIFY SERVER LISTENING SOCKET, TCP/IP
+#
+
+--echo # Characteristics of 'server_tcpip_socket' entry
+--echo # Server listening socket, TCP/IP
+--echo # There is only one entry with 'wait/io/socket/sql/server_tcpip_socket'.
+--echo # It shares the same thread id as 'wait/io/socket/sql/server_unix_socket'.
+
+SELECT COUNT(*) = 1 AS 'Expect 1'
+FROM performance_schema.socket_instances
+WHERE EVENT_NAME = 'wait/io/socket/sql/server_tcpip_socket';
+
+# Store the thread id of server_tcpip_socket
+--echo # Get the 'server_tcpip_socket' thread id
+
+SELECT THREAD_ID INTO @thread_id
+FROM performance_schema.socket_instances
+WHERE EVENT_NAME = 'wait/io/socket/sql/server_tcpip_socket';
+
+let $server_tcpip_thread_id= `SELECT @thread_id`;
+
+--echo # Check the content.
+--disable_query_log
+eval SET @port = $MASTER_MYPORT;
+--enable_query_log
+
+eval SELECT THREAD_ID = @thread_id
+ AND (IP = '0.0.0.0' OR IP = '::')
+ AND PORT = @port
+ AND STATE = 'ACTIVE' AS 'Expect 1'
+FROM performance_schema.socket_instances
+WHERE EVENT_NAME = 'wait/io/socket/sql/server_tcpip_socket';
+
+#
+# VERIFY TCP/IP CLIENT CONNECTION 1
+#
+
+# EVENT_NAME OBJECT_INSTANCE_BEGIN THREAD_ID SOCKET_ID IP PORT STATE
+# wait/io/socket/sql/client_connection 140707865187120 18 59 127.0.0.1 59298 IDLE or ACTIVE
+
+--echo # Check content for client connection 1 (tcpip)
+
+--disable_query_log
+eval SET @port = $con1_port;
+eval SET @thread_id = $con1_thread_id;
+eval SET @addr = '$my_localhost';
+--enable_query_log
+
+eval SELECT EVENT_NAME = 'wait/io/socket/sql/client_connection'
+ AND (IP LIKE '%127.0.0.1' OR IP = '::1')
+ AND PORT = @port
+AS 'Expect 1'
+FROM performance_schema.socket_instances
+WHERE THREAD_ID = @thread_id;
+
+--echo # Characteristics of entries with THREAD_ID of con1
+--echo # There is only one entry with this id.
+
+eval SELECT COUNT(*) = 1 AS 'Expect 1'
+FROM performance_schema.socket_instances
+WHERE THREAD_ID = @thread_id;
+
+#
+# VERIFY TCP/IP CLIENT CONNECTION 2
+#
+
+# EVENT_NAME OBJECT_INSTANCE_BEGIN THREAD_ID SOCKET_ID IP PORT STATE
+# wait/io/socket/sql/client_connection 140707865187120 18 59 127.0.0.1 59298 IDLE or ACTIVE
+
+--echo # Check content for client connection 2 (tcpip)
+
+--disable_query_log
+eval SET @port = $con2_port;
+eval SET @thread_id = $con2_thread_id;
+eval SET @addr = '$my_localhost';
+--enable_query_log
+
+eval SELECT EVENT_NAME = 'wait/io/socket/sql/client_connection'
+ AND (IP LIKE '%127.0.0.1' OR IP = '::1')
+ AND PORT = @port
+AS 'Expect 1'
+FROM performance_schema.socket_instances
+WHERE THREAD_ID = @thread_id;
+
+--echo # Characteristics of entries with THREAD_ID of con2
+--echo # There is only one entry with this id.
+
+eval SELECT COUNT(*) = 1 AS 'Expect 1'
+FROM performance_schema.socket_instances
+WHERE THREAD_ID = @thread_id;
+
+#
+# LIST CLIENT CONNECTIONS
+#
+
+--echo # Show differences to socket_instances before con1, con2 and con3 connecting
+let $part=
+FROM performance_schema.socket_instances
+WHERE (EVENT_NAME,OBJECT_INSTANCE_BEGIN,THREAD_ID,SOCKET_ID,IP,PORT,STATE)
+NOT IN (SELECT EVENT_NAME,OBJECT_INSTANCE_BEGIN,THREAD_ID,SOCKET_ID,IP,PORT,STATE
+ FROM my_socket_instances)
+ORDER BY THREAD_ID;
+--replace_result '::ffff:127.0.0.1' <LOCALHOST> '127.0.0.1' <LOCALHOST> '::1' <LOCALHOST> '::' <BINDADDR> '0.0.0.0' <BINDADDR>
+eval
+SELECT EVENT_NAME, IP
+$part;
+
+--connection default
+
+#
+# DROP CLIENT CONNECTIONS
+#
+
+--echo # Disconnect con1 and con2
+--connection con1
+--disconnect con1
+--source include/wait_until_disconnected.inc
+--connection con2
+--disconnect con2
+--source include/wait_until_disconnected.inc
+--connection default
+
+#
+# VERIFY CONNECTIONS DROPPED
+#
+
+--echo # After waiting a bit we should have no differences to socket_instances
+--echo # before con1, con2 connecting.
+let $wait_timeout= 10;
+let $wait_condition= SELECT COUNT(*) = 0 $part;
+--source include/wait_condition.inc
+#
+eval
+SELECT *
+$part;
+
diff --git a/mysql-test/suite/perfschema/t/socket_summary_by_event_name_func.test b/mysql-test/suite/perfschema/t/socket_summary_by_event_name_func.test
new file mode 100644
index 00000000..4a6ee2b6
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/socket_summary_by_event_name_func.test
@@ -0,0 +1,337 @@
+#
+# Some functional checks for the content of the performance_schema table
+# socket_summary_by_event_name.
+#
+# Created: cpowers 2011-08-18
+#==============================================================================
+#
+# Performance schema table socket_summary_by_event_name holds statistics
+# aggreagated by event name. Table socket_summary_by_instances maintains statistics
+# per socket instance.
+#
+# This test verifies that the statistics in socket_summary_by_event_name
+# are consistent with those in socket_summary_by_instance.
+#
+#==============================================================================
+# Embedded server does not support the performance_schema.
+--source include/not_embedded.inc
+
+# Not much can happen without the performance schema
+--source include/have_perfschema.inc
+
+# Wait for any clients from previous tests to disconnect
+--source ../include/wait_for_pfs_thread_count.inc
+
+# The values in the performance_schema tables depend on how much communication
+# happens per SQL statement within our MTR tests. And there is a significant
+# difference between standard statement execution and execution via
+# prepared statement.
+--source include/no_protocol.inc
+
+#--source include/turn_off_only_full_group_by.inc
+
+# Set this to enable debugging output
+let $my_socket_debug_dbug= 0;
+
+--echo #==============================================================================
+--echo # Establish the level of IPV6 support
+--echo #==============================================================================
+--source ../include/socket_ipv6.inc
+
+--echo #==============================================================================
+--echo # Get hostname, port number
+--echo #==============================================================================
+SELECT @@hostname INTO @MY_HOSTNAME;
+SELECT @@port INTO @MY_MASTER_PORT;
+
+if ($my_socket_debug)
+{
+ SELECT @MY_HOSTNAME AS 'Hostname';
+ SELECT @MY_MASTER_PORT AS 'Master Port';
+ --echo MASTER_MYPORT=$MASTER_MYPORT
+}
+#==============================================================================
+# Utility queries
+#==============================================================================
+let $count_client_connections=
+ SELECT COUNT(*) INTO @my_client_connections
+ FROM performance_schema.socket_instances
+ WHERE EVENT_NAME LIKE "%client_connection%";
+
+let $get_thread_id=
+ SELECT THREAD_ID INTO @my_thread_id
+ FROM performance_schema.threads
+ WHERE PROCESSLIST_ID = CONNECTION_ID();
+
+let $get_object_instance_begin=
+ SELECT OBJECT_INSTANCE_BEGIN INTO @my_object_instance_begin
+ FROM performance_schema.socket_instances
+ WHERE THREAD_ID = @my_thread_id;
+
+let $get_port=
+ SELECT PORT INTO @my_port
+ FROM performance_schema.socket_instances
+ WHERE THREAD_ID = @my_thread_id;
+
+let $get_write_count=
+SELECT sum(SUM_NUMBER_OF_BYTES_WRITE) INTO @my_write_count
+ FROM performance_schema.socket_summary_by_instance;
+#==============================================================================
+# Testcase queries
+#==============================================================================
+let $insert_totals=
+ INSERT INTO mysqltest.my_socket_summary SELECT EVENT_NAME,
+ SUM(t1.COUNT_STAR), SUM(t1.SUM_TIMER_WAIT), SUM(t1.MIN_TIMER_WAIT), SUM(t1.AVG_TIMER_WAIT), SUM(t1.MAX_TIMER_WAIT),
+ SUM(t1.COUNT_READ), SUM(t1.SUM_TIMER_READ), SUM(t1.MIN_TIMER_READ), SUM(t1.AVG_TIMER_READ), SUM(t1.MAX_TIMER_READ), SUM(t1.SUM_NUMBER_OF_BYTES_READ),
+ SUM(t1.COUNT_WRITE), SUM(t1.SUM_TIMER_WRITE), SUM(t1.MIN_TIMER_WRITE), SUM(t1.AVG_TIMER_WRITE), SUM(t1.MAX_TIMER_WRITE), SUM(t1.SUM_NUMBER_OF_BYTES_WRITE),
+ SUM(t1.COUNT_MISC), SUM(t1.SUM_TIMER_MISC), SUM(t1.MIN_TIMER_MISC), SUM(t1.AVG_TIMER_MISC), SUM(t1.MAX_TIMER_MISC), NULL
+ FROM performance_schema.socket_summary_by_instance AS t1
+ WHERE EVENT_NAME LIKE '%client_connection%' GROUP BY EVENT_NAME;
+
+let $compare_tables_and_print=
+SELECT EVENT_NAME,
+ (SUM(t_inst.COUNT_STAR) = t_name.COUNT_STAR) AS CNT_STAR,
+ (SUM(t_inst.SUM_TIMER_WAIT) = t_name.SUM_TIMER_WAIT) AS SUM_WAIT,
+ (MAX(t_inst.MAX_TIMER_WAIT) = t_name.MAX_TIMER_WAIT) AS MAX_WAIT,
+# (MIN(t_inst.MIN_TIMER_WAIT) = t_name.MIN_TIMER_WAIT) AS MIN_WAIT,
+ (SUM(t_inst.COUNT_READ) = t_name.COUNT_READ) AS CNT_READ,
+ (SUM(t_inst.SUM_TIMER_READ) = t_name.SUM_TIMER_READ) AS SUM_READ,
+ (MAX(t_inst.MAX_TIMER_READ) = t_name.MAX_TIMER_READ) AS MAX_READ,
+# (MIN(t_inst.MIN_TIMER_READ) = t_name.MIN_TIMER_READ) AS MIN_READ,
+ (SUM(t_inst.SUM_NUMBER_OF_BYTES_READ) = t_name.SUM_NUMBER_OF_BYTES_READ) AS BYTES_READ,
+ (SUM(t_inst.COUNT_WRITE) = t_name.COUNT_WRITE) AS CNT_WRITE,
+ (SUM(t_inst.SUM_TIMER_WRITE) = t_name.SUM_TIMER_WRITE) AS SUM_WRITE,
+ (MAX(t_inst.MAX_TIMER_WRITE) = t_name.MAX_TIMER_WRITE) AS MAX_WRITE,
+# (MIN(t_inst.MIN_TIMER_WRITE) = t_name.MIN_TIMER_WRITE) AS MIN_WRITE,
+ (SUM(t_inst.SUM_NUMBER_OF_BYTES_WRITE) = t_name.SUM_NUMBER_OF_BYTES_WRITE) AS BYTES_WRITE,
+ (SUM(t_inst.COUNT_MISC) = t_name.COUNT_MISC) AS CNT_MISC,
+ (SUM(t_inst.SUM_TIMER_MISC) = t_name.SUM_TIMER_MISC) AS SUM_MISC
+FROM performance_schema.socket_summary_by_instance t_inst
+JOIN performance_schema.socket_summary_by_event_name t_name
+USING (EVENT_NAME)
+WHERE t_inst.event_name LIKE '%client%'
+ AND t_inst.object_instance_begin <> @default_object_instance_begin;
+
+let $compare_tables_and_verify=
+SELECT (
+ (SUM(t_inst.COUNT_STAR) = t_name.COUNT_STAR) AND
+ (SUM(t_inst.SUM_TIMER_WAIT) = t_name.SUM_TIMER_WAIT) AND
+ (MAX(t_inst.MAX_TIMER_WAIT) = t_name.MAX_TIMER_WAIT) AND
+# (MIN(t_inst.MIN_TIMER_WAIT) = t_name.MIN_TIMER_WAIT) AND
+ (SUM(t_inst.COUNT_READ) = t_name.COUNT_READ) AND
+ (SUM(t_inst.SUM_TIMER_READ) = t_name.SUM_TIMER_READ) AND
+ (MAX(t_inst.MAX_TIMER_READ) = t_name.MAX_TIMER_READ) AND
+# (MIN(t_inst.MIN_TIMER_READ) = t_name.MIN_TIMER_READ) AND
+ (SUM(t_inst.SUM_NUMBER_OF_BYTES_READ) = t_name.SUM_NUMBER_OF_BYTES_READ) AND
+ (SUM(t_inst.COUNT_WRITE) = t_name.COUNT_WRITE) AND
+ (SUM(t_inst.SUM_TIMER_WRITE) = t_name.SUM_TIMER_WRITE) AND
+ (MAX(t_inst.MAX_TIMER_WRITE) = t_name.MAX_TIMER_WRITE) AND
+# (MIN(t_inst.MIN_TIMER_WRITE) = t_name.MIN_TIMER_WRITE) AND
+ (SUM(t_inst.SUM_NUMBER_OF_BYTES_WRITE) = t_name.SUM_NUMBER_OF_BYTES_WRITE) AND
+ (SUM(t_inst.COUNT_MISC) = t_name.COUNT_MISC) AND
+ (SUM(t_inst.SUM_TIMER_MISC) = t_name.SUM_TIMER_MISC) ) = 1 INTO @tables_match
+FROM performance_schema.socket_summary_by_instance t_inst
+JOIN performance_schema.socket_summary_by_event_name t_name
+USING (EVENT_NAME)
+WHERE t_inst.event_name LIKE '%client%'
+ AND t_inst.object_instance_begin <> @default_object_instance_begin;
+
+--echo #==============================================================================
+--echo # 1.0 TEST INITIALIZATION
+--echo #==============================================================================
+--echo #
+--echo # 1.1 Disable instrumentation of the default (this) connection
+--echo #
+--connection default
+UPDATE performance_schema.threads
+ SET INSTRUMENTED='NO' WHERE PROCESSLIST_ID = CONNECTION_ID();
+
+--echo #
+--echo # 1.2 Get the default THREAD_ID;
+--echo #
+eval $get_thread_id;
+let $default_thread_id= `SELECT @my_thread_id`;
+
+--echo #
+--echo # 1.3 Get the default OBJECT_INSTANCE_BEGIN
+--echo #
+eval $get_object_instance_begin;
+let $default_object_instance_begin= `SELECT @my_object_instance_begin`;
+
+--disable_query_log
+SELECT @my_object_instance_begin INTO @default_object_instance_begin;
+--enable_query_log
+
+if ($my_socket_debug)
+{
+ --echo # Default object instance begin = $default_object_instance_begin
+ --echo # Default thread id = $default_thread_id
+}
+
+--echo #
+--echo # 1.4 Create a test database
+--echo #
+CREATE SCHEMA mysqltest;
+
+--echo #
+--echo # 1.5 Create a table to store summary values from socket_summary_by_instance
+--echo and socket_summary_by_event_name
+--echo #
+CREATE TABLE mysqltest.my_socket_summary AS
+ SELECT * FROM performance_schema.socket_summary_by_instance
+ WHERE 1 = 0;
+
+--echo #
+--echo # 1.6 Drop object_instance_begin from my_socket_summary
+--echo #
+ALTER TABLE mysqltest.my_socket_summary
+ DROP COLUMN OBJECT_INSTANCE_BEGIN;
+
+--echo #
+--echo # 1.7 Add an auto_inc column to my_socket_summary
+--echo #
+ALTER TABLE mysqltest.my_socket_summary
+ ADD COLUMN (n INT AUTO_INCREMENT, PRIMARY KEY(n));
+
+--echo #
+--echo # 1.8 Create test tables
+--echo #
+CREATE TABLE mysqltest.t1 (n INT AUTO_INCREMENT, s1 VARCHAR(1024), PRIMARY KEY(n));
+CREATE TABLE mysqltest.t2 (n INT AUTO_INCREMENT, s1 VARCHAR(1024), PRIMARY KEY(n));
+
+--echo #==============================================================================
+--echo # 2.0 ESTABLISH CLIENT CONNECTIONS
+--echo #==============================================================================
+--echo #
+--echo # 2.1 Connection 1 (tcp/ip, 127.0.0.1 or ::1)
+--echo #
+--disable_query_log
+--connect (con1,$my_localhost,root,,,,$MASTER_MYPORT)
+--enable_query_log
+
+--echo #
+--echo # 2.2 Connection 2 (localhost or unix domain socket)
+--echo #
+--disable_query_log
+--connect (con2,localhost,root,,,,)
+--enable_query_log
+
+--echo #==============================================================================
+--echo # 3.0 RUN THE TESTS
+--echo #==============================================================================
+--echo #
+--echo # 3.1 Clear performance schema tables
+--echo #
+TRUNCATE performance_schema.socket_summary_by_instance;
+TRUNCATE performance_schema.socket_summary_by_event_name;
+
+--echo #
+--echo # 3.2 Get the 'before' sum of bytes written from socket_summary_by_instance
+--echo for later comparison to the 'after' byte count as a simple confirmation
+--echo that the table was updated.
+--echo #
+--connection default
+eval $get_write_count;
+let $my_count_before= `SELECT @my_write_count`;
+
+--echo #
+--echo # 3.3 From connection 1, insert one a 1K row of data into t1
+--echo #
+--connection con1
+USE mysqltest;
+INSERT INTO t1 (s1) VALUES (REPEAT('a', 1024));
+INSERT INTO t1 (s1) SELECT s1 FROM t1;
+
+--echo #
+--echo # 3.4 From connection 2, insert one a 1K row of data into t2
+--echo #
+--connection con2
+USE mysqltest;
+INSERT INTO t2 (s1) VALUES (REPEAT('a', 1024));
+INSERT INTO t2 (s1) SELECT s1 FROM t2;
+
+--echo #
+--echo # 3.5 Get the 'after' sum of bytes written from socket_summary_by_instance
+--echo #
+--connection default
+eval $get_write_count;
+let $my_count_after= `SELECT @my_write_count`;
+
+--echo #
+--echo # 3.6 Verify that SUM_NUMBER_OF_BYTES_WRITE increased
+--echo #
+
+if ($my_count_before >= $my_count_after)
+{
+ --echo
+ --echo # ERROR: Write count did not increaase
+ --echo # Before = $my_count_before
+ --echo # After = $my_count_after
+ --echo
+ SELECT * FROM performance_schema.socket_summary_by_instance ORDER BY EVENT_NAME;
+ --echo
+ --echo # Abort
+ exit;
+}
+
+--echo #
+--echo # socket_summary_by_instance was updated
+--echo #
+
+--echo #==============================================================================
+--echo # 4.0 VERIFY RESULTS
+--echo #==============================================================================
+--echo #
+--echo # 4.1 Verify that the totals in socket_summary_by_event_name are
+--echo consistent with totals in socket_summary_by_instance
+--echo #
+
+--disable_query_log
+eval $compare_tables_and_verify;
+
+if (`SELECT @tables_match = 0`)
+{
+ --echo
+ --echo # ERROR: Socket summary tables do not match
+ --echo # Column comparison results:
+ --echo
+ eval $compare_tables_and_print;
+ --enable_query_log
+ --echo
+ SELECT * FROM performance_schema.socket_summary_by_instance ORDER BY EVENT_NAME;
+ --echo
+ SELECT * FROM performance_schema.socket_summary_by_event_name ORDER BY EVENT_NAME;
+ --echo
+ --echo # Abort
+ exit;
+}
+--enable_query_log
+
+--echo #==============================================================================
+--echo # 5.0 Clean up
+--echo #==============================================================================
+
+--echo #
+--echo # 5.1 Disconnect con1
+--echo #
+--connection con1
+--disconnect con1
+--source include/wait_until_disconnected.inc
+
+--echo #
+--echo # 5.2 Disconnect con2
+--echo #
+--connection con2
+--disconnect con2
+--source include/wait_until_disconnected.inc
+
+--echo #
+--echo # 5.3 Drop mysqltest
+--echo #
+--connection default
+DROP DATABASE mysqltest;
+
+#--source include/restore_sql_mode_after_turn_off_only_full_group_by.inc
+
+exit;
+
diff --git a/mysql-test/suite/perfschema/t/socket_summary_by_instance_func.test b/mysql-test/suite/perfschema/t/socket_summary_by_instance_func.test
new file mode 100644
index 00000000..fc848922
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/socket_summary_by_instance_func.test
@@ -0,0 +1,1713 @@
+# Some functional checks for the content of the performance_schema table
+# socket_summary_by_instance.
+#
+# Created: mleich 2011-07-01
+#
+# Rough description of "What is when tested"
+# 1. Impact of successful connect
+# A new row with EVENT_NAME "client_connection" shows up
+# is tested in 0 and 4.5.
+# 2. Impact of disconnect
+# A row with EVENT_NAME "client_connection" disappears
+# is tested in 0. and 2.
+# 3. Disabling the instrumentation for some thread causes that the
+# counter for this thread become static is tested in 4.3.
+# Nearby the beginning of this test and somewhere in the middle.
+# 4. TRUNCATE table resets the counters is tested in 5.
+# 5. Consistency within a row like MIN_* <= AVG_* <= MAX_*
+# -> include/socket_summary_check.inc which is called at
+# various places
+# 6. Consistency of the instances mentioned in socket_summary_by_event
+# and socket_summary_by_instance is checked per call of
+# include/socket_summary_check.inc
+# 7. Check if changes in counters of instances caused by actions
+# are reasonable is tested for
+# - Connects+SQL statements in 4.1 and 4.2
+# - SQL statements in 4.4
+# - Connects in 4.5
+#
+
+# Embedded server does not supprt the performance_schema.
+--source include/not_embedded.inc
+--source include/not_windows.inc
+--source include/no_valgrind_without_big.inc
+--source include/have_perfschema.inc
+
+# The values in the performance_schema tables depend on how much communication
+# happens per SQL statement within our MTR tests. And there is a significant
+# difference between standard statement execution and execution via
+# prepared statement.
+--source include/no_protocol.inc
+
+#===================================
+# Set IP address defaults with respect to IPV6 support
+#
+# Set this to enable debugging output
+let $my_socket_debug_dbug= 0;
+#
+# Determine if IPV6 supported
+#
+let $check_ipv6_just_check= 1;
+--source include/have_ipv4_mapped.inc
+#
+# Determine if IPV4 mapped to IPV6 supported
+#
+let $check_ipv4_mapped_just_check= 1;
+--source include/have_ipv4_mapped.inc
+#
+# Set the localhost IP default to use when establishing connections
+let $my_localhost=127.0.0.1;
+if($check_ipv6_supported)
+{
+ let $my_localhost=::1;
+}
+if($check_ipv4_mapped_supported)
+{
+ let $my_localhost=::ffff:127.0.0.1;
+}
+#
+let $my_socket_debug_dbug= 0;
+if($my_socket_debug)
+{
+ --echo IPV6=$check_ipv6_supported, IPV4_MAPPED = $check_ipv4_mapped_supported, LOCALHOST = $my_localhost
+}
+#===================================
+
+--echo # The logging of commands and result sets is mostly disabled.
+--echo # There are some messages which help to observe the progress of the test.
+--echo # In case some check fails
+--echo # - a message about this will be printed
+--echo # - some SQL commands which show the unexpected state will be executed
+--echo # (logging enabled)
+--echo # - the test might abort
+--echo #
+
+--disable_query_log
+
+--echo # 0. Check, build or set prequisites
+#==========================================
+# Set $print_details to 1 in case you want that the exact diffs caused
+# by the execution of a statement get printed.
+# Disadvantage of printing details:
+# Even minor legimitate changes of the client - server communication can
+# cause that the test needs maintenance.
+# Advantage:
+# More thorough checks.
+# If any of the checks detects some suspicious/unexpected state than
+# $print_details will be automatically switched to 1.
+#
+let $print_details= 0;
+
+#
+# Number of attempts within the test checking the stability of counter changes.
+#
+let $loop_rounds= 10;
+
+# This test of PERFORMANCE_SCHEMA functionality is very vulnerable.
+# Ensure that we have in the moment exact one
+# - connection
+# - instance with EVENT_NAME LIKE '%client_connection'
+# - instance with EVENT_NAME LIKE '%server_tcpip_socket'
+# - instance with EVENT_NAME LIKE '%server_unix_socket'
+#=======================================================
+let $my_rules= COUNT(*) = 1;
+let $part=
+FROM performance_schema.threads
+WHERE NAME LIKE '%one_connection';
+let $wait_condition=
+SELECT $my_rules $part;
+let $wait_timeout= 5;
+--source include/wait_condition.inc
+--enable_query_log
+if(!$success)
+{
+ --echo # ERROR: There must be only one user connection
+ eval
+ SELECT * $part;
+ --echo # abort
+ exit;
+}
+let $part=
+FROM performance_schema.socket_summary_by_instance
+WHERE EVENT_NAME LIKE '%client_connection';
+let $wait_condition=
+SELECT $my_rules $part;
+let $wait_timeout= 5;
+--source include/wait_condition.inc
+if(!$success)
+{
+ --echo # ERROR: There must be only one instance with this EVENT_NAME.
+ eval
+ SELECT * $part;
+ --echo # abort
+ exit;
+}
+let $part=
+FROM performance_schema.socket_summary_by_instance
+WHERE EVENT_NAME LIKE '%server_unix_socket';
+let $wait_condition=
+SELECT $my_rules $part;
+let $wait_timeout= 5;
+--source include/wait_condition.inc
+if(!$success)
+{
+ --echo # ERROR: There must be only one instance with this EVENT_NAME.
+ eval
+ SELECT * $part;
+ --echo # abort
+ exit;
+}
+let $part=
+FROM performance_schema.socket_summary_by_instance
+WHERE EVENT_NAME LIKE '%server_tcpip_socket';
+let $wait_condition=
+SELECT $my_rules $part;
+let $wait_timeout= 5;
+--source include/wait_condition.inc
+if(!$success)
+{
+ --echo # ERROR: There must be only one instance with this EVENT_NAME.
+ eval
+ SELECT * $part;
+ --echo # abort
+ exit;
+}
+
+--disable_query_log
+
+#
+# Lower the resolution of the wait timer from the default 'CYCLE'
+# to 'NANOSECOND'.
+# Hint: The timer columns contains values in picoseconds independent
+# of the timer resolution.
+# The timer resolution has an impact on the precision of the value.
+# This should prevent the failures seen on some suspicious PB boxes where
+# - calculations exceeded the BIGINT UNSIGNED (data type of the counter columns)
+# value range.
+# - we have reached from whatever reason 20 digit values
+# The consequence for the current test is the following:
+# The common sense rule
+# In case COUNT_<A> increases than SUM_TIMER_<A> must also increase
+# is no more valid because some action might need less time than the
+# timer resolution.
+#
+let $wait_timer= `SELECT TIMER_NAME FROM performance_schema.setup_timers
+ WHERE NAME = 'wait'`;
+UPDATE performance_schema.setup_timers
+SET TIMER_NAME = 'NANOSECOND'
+WHERE NAME = 'wait';
+
+#
+# Additional SCHEMA used for
+# - detection of our "worker" session within the PROCESSLIST.
+# No other connection should use this schema as default schema.
+# - easy cleanup because auxiliary objects are stored there
+#
+CREATE SCHEMA mysqltest;
+CREATE SCHEMA mysqlsupertest;
+
+#
+# Clear summary tables of previous entries
+#
+TRUNCATE performance_schema.socket_summary_by_instance;
+TRUNCATE performance_schema.socket_summary_by_event_name;
+# Disable instrumenting of the current default session.
+# Required for check 1.1
+UPDATE performance_schema.threads
+SET INSTRUMENTED='NO' WHERE PROCESSLIST_ID = CONNECTION_ID();
+
+#
+# Auxiliary tables for storing current values at certain points of time.
+# We store states of performance_schema.socket_summary_by_instance here
+# in order
+# - to have initial values from before some action
+# - to minimize the impact of statements used for the checks on results.
+# CREATE TEMPORARY TABLE my_socket_summary_by_instance AS
+# would be nice but some statements are not supported for temporary tables.
+#
+# DECIMAL(60,0) is used instead of BIGINT UNSIGNED. The goal is to prevent
+# errors during calculations
+# Example:
+# - A and B UNSIGNED BIGINT
+# - A < B
+# - A - B ---> Error
+# though the columns in all queries are orderd to avoid this too.
+#
+CREATE TABLE mysqltest.my_socket_summary_by_instance (
+ EVENT_NAME varchar(128) NOT NULL,
+ OBJECT_INSTANCE_BEGIN bigint(20) unsigned NOT NULL,
+ COUNT_STAR DECIMAL(60,0) NOT NULL,
+ SUM_TIMER_WAIT DECIMAL(60,0) NOT NULL,
+ MIN_TIMER_WAIT DECIMAL(60,0) NOT NULL,
+ AVG_TIMER_WAIT DECIMAL(60,0) NOT NULL,
+ MAX_TIMER_WAIT DECIMAL(60,0) NOT NULL,
+ COUNT_READ DECIMAL(60,0) NOT NULL,
+ SUM_TIMER_READ DECIMAL(60,0) NOT NULL,
+ MIN_TIMER_READ DECIMAL(60,0) NOT NULL,
+ AVG_TIMER_READ DECIMAL(60,0) NOT NULL,
+ MAX_TIMER_READ DECIMAL(60,0) NOT NULL,
+ SUM_NUMBER_OF_BYTES_READ DECIMAL(60,0) NOT NULL,
+ COUNT_WRITE DECIMAL(60,0) NOT NULL,
+ SUM_TIMER_WRITE DECIMAL(60,0) NOT NULL,
+ MIN_TIMER_WRITE DECIMAL(60,0) NOT NULL,
+ AVG_TIMER_WRITE DECIMAL(60,0) NOT NULL,
+ MAX_TIMER_WRITE DECIMAL(60,0) NOT NULL,
+ SUM_NUMBER_OF_BYTES_WRITE DECIMAL(60,0) NOT NULL,
+ COUNT_MISC DECIMAL(60,0) NOT NULL,
+ SUM_TIMER_MISC DECIMAL(60,0) NOT NULL,
+ MIN_TIMER_MISC DECIMAL(60,0) NOT NULL,
+ AVG_TIMER_MISC DECIMAL(60,0) NOT NULL,
+ MAX_TIMER_MISC DECIMAL(60,0) NOT NULL,
+ pk VARCHAR(20),
+ PRIMARY KEY(pk, EVENT_NAME, OBJECT_INSTANCE_BEGIN)
+) DEFAULT CHARSET=utf8;
+
+
+# The CAST(... AS DECIMAL(60,0)) prevents errors which might show up in case
+# we run with the original data type UNSIGNED BIGINT.
+CREATE TABLE mysqltest.socket_summary_by_instance_detail (
+ EVENT_NAME varchar(128) NOT NULL,
+ OBJECT_INSTANCE_BEGIN bigint(20) unsigned NOT NULL,
+ COUNT_READ DECIMAL(60,0) NOT NULL,
+ SUM_TIMER_READ DECIMAL(60,0) NOT NULL,
+ SUM_NUMBER_OF_BYTES_READ DECIMAL(60,0) NOT NULL,
+ COUNT_WRITE DECIMAL(60,0) NOT NULL,
+ SUM_TIMER_WRITE DECIMAL(60,0) NOT NULL,
+ SUM_NUMBER_OF_BYTES_WRITE DECIMAL(60,0) NOT NULL,
+ COUNT_MISC DECIMAL(60,0) NOT NULL,
+ SUM_TIMER_MISC DECIMAL(60,0) NOT NULL,
+ statement VARCHAR(500),
+ run INTEGER
+) DEFAULT CHARSET=utf8;
+
+#
+# Auxiliary SQL functions used to shorten some commands.
+#
+CREATE FUNCTION mysqltest.min_of_triple
+ (f1 DECIMAL(60,0), f2 DECIMAL(60,0), f3 DECIMAL(60,0))
+ RETURNS DECIMAL(60,0)
+ RETURN IF(IF(f1 < f2,f1,f2) < f3,IF(f1 < f2,f1,f2), f3);
+CREATE FUNCTION mysqltest.max_of_triple
+ (f1 DECIMAL(60,0), f2 DECIMAL(60,0), f3 DECIMAL(60,0))
+ RETURNS DECIMAL(60,0)
+ RETURN IF(IF(f1 > f2,f1,f2) > f3,IF(f1 > f2,f1,f2), f3);
+
+#
+# Auxiliary table for experiments with SELECTs earning different result sets.
+#
+CREATE TABLE mysqltest.my_aux (col1 INTEGER, col2 VARCHAR(1024), PRIMARY KEY(col1));
+INSERT INTO mysqltest.my_aux SET col1 = 0, col2 = REPEAT('a',0);
+INSERT INTO mysqltest.my_aux SET col1 = 1, col2 = REPEAT('a',0);
+INSERT INTO mysqltest.my_aux SET col1 = 2, col2 = REPEAT('a',1);
+INSERT INTO mysqltest.my_aux SET col1 = 3, col2 = REPEAT('a',1024);
+
+#
+# Auxiliary mysqltest variables used to shorten commands and to ensure
+# that we run all time the right operation.
+#
+let $truncate=
+TRUNCATE TABLE mysqltest.my_socket_summary_by_instance;
+#
+let $insert_before=
+INSERT INTO mysqltest.my_socket_summary_by_instance
+SELECT *,'Before' FROM performance_schema.socket_summary_by_instance;
+#
+let $insert_after=
+INSERT INTO mysqltest.my_socket_summary_by_instance
+SELECT *,'After' FROM performance_schema.socket_summary_by_instance;
+#
+let $insert_pseudo_before=
+INSERT INTO mysqltest.my_socket_summary_by_instance
+(EVENT_NAME, OBJECT_INSTANCE_BEGIN,
+COUNT_STAR, SUM_TIMER_WAIT, MIN_TIMER_WAIT, AVG_TIMER_WAIT, MAX_TIMER_WAIT,
+COUNT_READ, SUM_TIMER_READ, MIN_TIMER_READ, AVG_TIMER_READ, MAX_TIMER_READ,
+SUM_NUMBER_OF_BYTES_READ,
+COUNT_WRITE, SUM_TIMER_WRITE, MIN_TIMER_WRITE, AVG_TIMER_WRITE, MAX_TIMER_WRITE,
+SUM_NUMBER_OF_BYTES_WRITE,
+COUNT_MISC, SUM_TIMER_MISC, MIN_TIMER_MISC, AVG_TIMER_MISC, MAX_TIMER_MISC,
+pk)
+SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN,
+0, 0, 0, 0, 0,
+0, 0, 0, 0, 0,
+0,
+0, 0, 0, 0, 0,
+0,
+0, 0, 0, 0, 0,
+'Pseudo_Before'
+FROM mysqltest.my_socket_summary_by_instance t1
+WHERE OBJECT_INSTANCE_BEGIN NOT IN
+ (SELECT OBJECT_INSTANCE_BEGIN
+ FROM mysqltest.my_socket_summary_by_instance t2
+ WHERE pk = 'Before');
+#
+let $insert_delta=
+INSERT INTO mysqltest.socket_summary_by_instance_detail
+ (EVENT_NAME,OBJECT_INSTANCE_BEGIN,
+ COUNT_READ, SUM_TIMER_READ, SUM_NUMBER_OF_BYTES_READ,
+ COUNT_WRITE,SUM_TIMER_WRITE,SUM_NUMBER_OF_BYTES_WRITE,
+ COUNT_MISC, SUM_TIMER_MISC, statement,run)
+SELECT EVENT_NAME,OBJECT_INSTANCE_BEGIN,
+ t1.COUNT_READ - t2.COUNT_READ,
+ t1.SUM_TIMER_READ - t2.SUM_TIMER_READ,
+ t1.SUM_NUMBER_OF_BYTES_READ - t2.SUM_NUMBER_OF_BYTES_READ,
+ t1.COUNT_WRITE - t2.COUNT_WRITE,
+ t1.SUM_TIMER_WRITE - t2.SUM_TIMER_WRITE,
+ t1.SUM_NUMBER_OF_BYTES_WRITE - t2.SUM_NUMBER_OF_BYTES_WRITE,
+ t1.COUNT_MISC - t2.COUNT_MISC,
+ t1.SUM_TIMER_MISC - t2.SUM_TIMER_MISC,
+ NULL,NULL
+FROM mysqltest.my_socket_summary_by_instance t1
+JOIN mysqltest.my_socket_summary_by_instance t2
+USING (EVENT_NAME,OBJECT_INSTANCE_BEGIN)
+WHERE t1.pk = 'After' AND t2.pk LIKE '%Before';
+#
+let $get_object_instance_begin=
+SELECT OBJECT_INSTANCE_BEGIN INTO @con1_object_instance_begin
+FROM performance_schema.socket_summary_by_instance AS t1
+WHERE (EVENT_NAME,OBJECT_INSTANCE_BEGIN)
+ NOT IN (SELECT EVENT_NAME,OBJECT_INSTANCE_BEGIN
+ FROM mysqltest.my_socket_summary_by_instance AS t2
+ WHERE pk = 'Before');
+
+# Use this whenever you print data.
+let $column_list=
+RPAD(EVENT_NAME, 38, ' ') AS EVENT_NAME,
+LPAD(OBJECT_INSTANCE_BEGIN, 20, ' ') AS OBJECT_INSTANCE,
+LPAD(COUNT_READ, 7, ' ') AS CREAD,
+LPAD(SUM_TIMER_READ, 12, ' ') AS TREAD,
+LPAD(SUM_NUMBER_OF_BYTES_READ, 7, ' ') AS BREAD,
+LPAD(COUNT_WRITE, 7, ' ') AS CWRITE,
+LPAD(SUM_TIMER_WRITE, 12, ' ') AS TWRITE,
+LPAD(SUM_NUMBER_OF_BYTES_WRITE, 7, ' ') AS BWRITE,
+LPAD(COUNT_MISC, 7, ' ') AS CMISC,
+LPAD(SUM_TIMER_MISC, 13, ' ') AS TMISC,
+RPAD(STATEMENT, 50, ' ') AS STATEMENT,
+LPAD(RUN, 5, ' ') AS RUN;
+
+# Determine OBJECT_INSTANCE_BEGIN of the connection default
+# which acts as the observer
+eval $truncate;
+eval $insert_before;
+--disconnect default
+--connect (default,localhost,root,,,,)
+# --echo ########### Disconnect/Connect
+# --enable_query_log
+eval $insert_after;
+eval $get_object_instance_begin;
+SET @default_object_instance_begin = @con1_object_instance_begin;
+
+# Wait till the old default connection has disappeared
+let $wait_timeout= 5;
+let $wait_condition=
+SELECT COUNT(*) = 1
+FROM performance_schema.threads
+WHERE processlist_user = 'root';
+--source include/wait_condition.inc
+--enable_query_log
+if (!$success)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # Error: The disconnect of the old default connection
+ --echo # (user = 'root') failed. We expect to have only one connection
+ --echo # with user = 'root'. And this is our current connection.
+ SELECT * FROM performance_schema.threads
+ WHERE processlist_user = 'root';
+ --echo # abort
+ exit;
+}
+
+# Disable instrumenting of the current default session.
+# Required for check 1.2
+UPDATE performance_schema.threads
+SET INSTRUMENTED='NO' WHERE PROCESSLIST_ID = CONNECTION_ID();
+
+--echo # 1. Basic checks
+--echo # 1.1 Check that the entry of the disconnected old default session really
+--echo # disappeared from performance_schema.socket_summary_by_instance.
+#===============================================================================
+# This failed at some point in history when the instrumenting for the
+# session to be disconnected was disabled.
+if(`SELECT COUNT(*) FROM performance_schema.socket_summary_by_instance
+WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND EVENT_NAME LIKE '%client_connection'`)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # Error: The disconnected old default session did not disappear from
+ --echo # socket_summary_by_instance.
+ SELECT * FROM performance_schema.socket_summary_by_instance
+ WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND EVENT_NAME LIKE '%client_connection';
+}
+
+TRUNCATE TABLE performance_schema.socket_summary_by_instance;
+
+--echo # 1.2 Check the base line
+#===============================
+eval $truncate;
+--source ../include/socket_summary_check.inc
+
+# --disable_query_log
+# --disable_query_log
+
+--echo # 2. Variations on Connect
+let $is_connect= 1;
+--echo # 2.1 Connect fails because the user is unknown
+--echo # length of user name = 4 character
+--echo # length of default db = 9 character
+#========================================================================
+let $connect_host= localhost;
+let $connect_db= mysqltest;
+let $connect_user= boot;
+--source ../include/socket_event.inc
+
+--echo # 2.2 Connect fails because the user is unknown
+--echo # length of user name = 14 character (10 more than in 2.1)
+--echo # length of default db = 9 character
+#========================================================================
+let $connect_host= localhost;
+let $connect_db= mysqltest;
+let $connect_user= boot0123456789;
+--source ../include/socket_event.inc
+
+--echo # 2.3 Connect should pass, host = localhost
+--echo # length of user name = 4 character
+--echo # length of default db = 9 character
+#========================================================================
+let $connect_host= localhost;
+let $connect_db= mysqltest;
+let $connect_user= root;
+--source ../include/socket_event.inc
+
+--echo # 2.4 Connect should pass, host = localhost
+--echo # length of user name = 4 character
+--echo # length of default db = 14 character (5 more than 2.3)
+#========================================================================
+let $connect_host= localhost;
+let $connect_db= mysqlsupertest;
+let $connect_user= root;
+--source ../include/socket_event.inc
+
+--echo # 2.5 Connect should pass, host = localhost
+--echo # length of user name = 10 character
+--echo # length of default db = 9 character
+#========================================================================
+CREATE USER 'root012345'@'localhost';
+GRANT ALL PRIVILEGES ON *.* TO 'root012345'@'localhost';
+let $connect_host= localhost;
+let $connect_db= mysqltest;
+let $connect_user= root012345;
+--source ../include/socket_event.inc
+DROP USER 'root012345'@'localhost';
+
+--echo # 2.6 Connect should pass, host = localhost
+--echo # length of user name = 14 character
+--echo # length of default db = 9 character
+#========================================================================
+CREATE USER 'root0123456789'@'localhost';
+GRANT ALL PRIVILEGES ON *.* to 'root0123456789'@'localhost';
+let $connect_host= localhost;
+let $connect_db= mysqltest;
+let $connect_user= root0123456789;
+--source ../include/socket_event.inc
+DROP USER 'root0123456789'@'localhost';
+
+--echo # 2.7 Connect should pass, host = my_localhost
+--echo # length of user name = 4 character
+--echo # length of default db = 9 character
+--echo # connection runs through server_tcpip_socket !
+#========================================================================
+let $connect_host= $my_localhost;
+let $connect_db= mysqltest;
+let $connect_user= root;
+--source ../include/socket_event.inc
+
+#========================================================================
+--connect (con1,localhost,root,,mysqltest,,)
+# Experiments showed some unexpected result in the counter difference
+# which got con1 for the next statement (see 3.1).
+# The measured diff was too high and was probably caused by some
+# too much delayed counter maintenance for the connect.
+# We run here just some SQL statement because counter maintenance
+# for SQL statements is more fast and reliable than far Connect.
+DO 1;
+--connection default
+--source ../include/wait_till_sleep.inc
+--disable_query_log
+
+--echo # 3 Variations on SELECT
+# Attention: Don't use
+# - any double quotes within the statements because sourced scripts
+# already "decorate" $variables with double quotes
+# - UNION because this leads to result set related byte write
+# counters which cannot good compared to select without union
+let $is_connect= 0;
+eval $get_object_instance_begin;
+--echo # 3.1 Check a SELECT ending with server sending an error message.
+--echo # Error message is short (unknown table).
+#========================================================================
+let $statement= SELECT col2 FROM does_not_exist;
+--source ../include/socket_event.inc
+
+--echo # 3.2 SELECT ending with server sending an error message.
+--echo # Now the statement is a bit longer but the error message
+--echo # length does again not depend on statement.
+#=======================================================================
+let $statement= SELECT col2 FROM does_not_exist WHERE col1 = 0;
+--source ../include/socket_event.inc
+
+--echo # 3.3 SELECT ending with server sending an error message.
+--echo # The statement has the same length like in 3.2 but the error
+--echo # message is now different and much longer.
+#=======================================================================
+let $statement= SELECT col2 FROM does_not_exist WHERE col1 A 0;
+--source ../include/socket_event.inc
+
+--echo # 3.4 SELECT ending with server sending an error message.
+--echo # Statement and error message are a bit longer than in 3.1
+--echo # because the table name is longer.
+#=======================================================================
+let $statement= SELECT col2 FROM does_not_exist0123;
+--source ../include/socket_event.inc
+
+--echo # 3.5 SELECT earning an empty result set.
+#=======================================================
+let $statement= SELECT col2 FROM mysqltest.my_aux WHERE col1 = -1;
+--source ../include/socket_event.inc
+
+--echo # 3.6 SELECT earning an empty result set.
+--echo # Short column name is replaced by longer alias.
+#==========================================================
+let $statement= SELECT col2 AS my_super_col FROM mysqltest.my_aux WHERE col1 = -1;
+--source ../include/socket_event.inc
+
+--echo # 3.7 SELECT earning one row with an empty string.
+#================================================================
+let $statement= SELECT col2 FROM mysqltest.my_aux WHERE col1 = 1;
+--source ../include/socket_event.inc
+
+--echo # 3.8 SELECT earning one row with one string one char long.
+#=========================================================================
+let $statement= SELECT col2 FROM mysqltest.my_aux WHERE col1 = 2;
+--source ../include/socket_event.inc
+
+--echo # 3.9 SELECT earning one row with one string 1024 char long.
+#==========================================================================
+let $statement= SELECT col2 FROM mysqltest.my_aux WHERE col1 = 3;
+--source ../include/socket_event.inc
+
+--echo # 3.10 SELECT earning two rows with an empty string
+#==========================================================================
+let $statement= SELECT col2 FROM mysqltest.my_aux WHERE col1 < 2;
+--source ../include/socket_event.inc
+
+--echo # 3.11 Check that the preceding Connects/SQL command runs have not
+--echo # caused some unexpected state.
+#==========================================================================
+let $my_rules= COUNT(*) = 2;
+let $part=
+FROM performance_schema.threads
+WHERE NAME LIKE '%one_connection';
+if(`SELECT NOT ( $my_rules ) $part `)
+{
+ --echo # ERROR: There must be only two user connections
+ eval
+ SELECT * $part;
+ --echo # abort
+ exit;
+}
+let $part=
+FROM performance_schema.socket_summary_by_instance
+WHERE EVENT_NAME LIKE '%client_connection';
+if(`SELECT NOT ( $my_rules ) $part `)
+{
+ --echo # ERROR: There must be only two instances with this EVENT_NAME.
+ eval
+ SELECT * $part;
+ --echo # abort
+ exit;
+}
+let $my_rules= COUNT(*) = 1;
+let $part=
+FROM performance_schema.socket_summary_by_instance
+WHERE EVENT_NAME LIKE '%server_unix_socket';
+if(`SELECT NOT ( $my_rules ) $part `)
+{
+ --echo # ERROR: There must be only one instance with this EVENT_NAME.
+ eval
+ SELECT * $part;
+ --echo # abort
+ exit;
+}
+let $part=
+FROM performance_schema.socket_summary_by_instance
+WHERE EVENT_NAME LIKE '%server_tcpip_socket';
+if(`SELECT NOT ( $my_rules ) $part `)
+{
+ --echo # ERROR: There must be only one instance with this EVENT_NAME.
+ eval
+ SELECT * $part;
+ --echo # abort
+ exit;
+}
+
+--echo # 4. Check delta (value_after_action - value_before_action) details
+# 4.0 . Negative deltas cannot have happened because the counter columns within
+# socket_summary_by_instance_detail are defined as UNSIGNED BIGINT.
+# = The INSERT which computes the diff would have been failed.
+--echo # 4.1 Check that
+--echo # - no change in COUNT_* leads to no change in
+--echo # SUM_TIMER_* and no change in SUM_NUMBER_OF_BYTES_*
+--echo # - increased COUNT_READ leads to increased
+--echo # SUM_NUMBER_OF_BYTES_READ
+--echo # - increased COUNT_WRITE leads to increased
+--echo # SUM_NUMBER_OF_BYTES_WRITE
+--echo # Attention:
+--echo # The time required for some action might be below timer resolution.
+--echo # Therefore some increased COUNT_* does not need to lead to an
+--echo # increased SUM_TIMER_*.
+#==========================================================================
+# Enable the following lines for debugging the check.
+# Attention: socket_summary_by_instance_detail is after that rotten.
+if(0)
+{
+ --enable_info
+ UPDATE mysqltest.socket_summary_by_instance_detail
+ SET SUM_TIMER_MISC = 13, COUNT_MISC = 0
+ WHERE statement LIKE '%WHERE col1 = 3'
+ AND EVENT_NAME LIKE '%client_connection'
+ AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ LIMIT 1;
+ --disable_info
+}
+
+let $my_rules=
+((COUNT_READ = 0 AND SUM_TIMER_READ = 0 AND SUM_NUMBER_OF_BYTES_READ = 0)
+ OR
+ (COUNT_READ > 0 AND SUM_NUMBER_OF_BYTES_READ > 0))
+AND
+((COUNT_WRITE = 0 AND SUM_TIMER_WRITE = 0 AND SUM_NUMBER_OF_BYTES_WRITE = 0)
+ OR
+ (COUNT_WRITE > 0 AND SUM_NUMBER_OF_BYTES_WRITE > 0))
+AND
+((COUNT_MISC = 0 AND SUM_TIMER_MISC = 0)
+ OR
+(COUNT_MISC > 0));
+if(`SELECT COUNT(*) FROM mysqltest.socket_summary_by_instance_detail
+ WHERE NOT ( $my_rules ) `)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo #
+ eval
+ SELECT
+ $column_list
+ FROM mysqltest.socket_summary_by_instance_detail
+ WHERE NOT ( $my_rules )
+ ORDER BY EVENT_NAME, OBJECT_INSTANCE, STATEMENT, RUN;
+ let $print_details= 1;
+}
+
+--echo # 4.2 Results must be stable
+#==========================================================================
+# Enable the following lines for debugging the check.
+# Attention: socket_summary_by_instance_detail is after that rotten.
+if(0)
+{
+ --enable_info
+ UPDATE mysqltest.socket_summary_by_instance_detail
+ SET COUNT_WRITE = 13
+ WHERE statement LIKE '%WHERE col1 = 3'
+ AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND EVENT_NAME LIKE '%client_connection'
+ LIMIT 1;
+ --disable_info
+}
+
+# eval
+# SELECT
+# $column_list
+# FROM mysqltest.socket_summary_by_instance_detail
+# WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+# ORDER BY EVENT_NAME, statement,run;
+
+# In case we are able to wait all time till perfschema has finished the
+# maintenance of counters than the following must be valid.
+let $my_rules=
+COUNT(DISTINCT SUM_NUMBER_OF_BYTES_READ) = 1 AND
+COUNT(DISTINCT COUNT_WRITE) = 1 AND
+COUNT(DISTINCT SUM_NUMBER_OF_BYTES_WRITE) = 1;
+
+# In case we do not get the results somehow deterministic than we
+# we should go with the less strict check based on CV.
+#
+# Compute coefficient of variation (CV) to detect 'notable' variances in the
+# byte count and operation counts. The acceptable range for the CV is purely
+# subjective, however, the CV is a dimensionless quantity therefore valid
+# across platforms.
+# let $my_rules=
+# STD(COUNT_READ)/AVG(COUNT_READ) <= 0.2 AND
+# STD(SUM_NUMBER_OF_BYTES_READ)/AVG(SUM_NUMBER_OF_BYTES_READ) <= 0.2 AND
+# STD(COUNT_WRITE)/AVG(COUNT_WRITE) <= 0.2 AND
+# STD(SUM_NUMBER_OF_BYTES_WRITE)/AVG(SUM_NUMBER_OF_BYTES_WRITE) <= 0.2 AND
+# STD(COUNT_MISC)/AVG(COUNT_MISC) <= 0.4;
+
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail
+WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+GROUP BY EVENT_NAME, statement
+HAVING NOT ($my_rules) ;
+if(`SELECT COUNT(statement) $part`)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo # for GROUP BY EVENT_NAME, statement
+ eval
+ SELECT $column_list
+ FROM mysqltest.socket_summary_by_instance_detail
+ WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND (EVENT_NAME, statement)
+ IN (SELECT EVENT_NAME, statement
+ $part)
+ ORDER BY EVENT_NAME, statement, run, OBJECT_INSTANCE_BEGIN;
+ let $print_details= 1;
+}
+
+--echo # 4.3 Counters must be 0 in client_connection for the default session
+--echo # Instrumenting is disabled since a long time and the counter were
+--echo # reset via TRUNCATE just after the disabling.
+#==========================================================================
+let $my_rules=
+COUNT_STAR = 0 AND SUM_TIMER_WAIT = 0
+AND
+COUNT_READ = 0 AND SUM_TIMER_READ = 0 AND SUM_NUMBER_OF_BYTES_READ = 0
+AND
+COUNT_WRITE = 0 AND SUM_TIMER_WRITE = 0 AND SUM_NUMBER_OF_BYTES_WRITE = 0
+AND
+COUNT_MISC = 0 AND SUM_TIMER_MISC = 0;
+if(`SELECT COUNT(*) FROM performance_schema.socket_summary_by_instance
+ WHERE NOT ( $my_rules )
+ AND OBJECT_INSTANCE_BEGIN = @default_object_instance_begin`)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo #
+ # Attention: We use here performance_schema.socket_summary_by_instance
+ # and not mysqltest.socket_summary_by_instance_detail.
+ # Therefore the convenient $column_list cannot be used.
+ eval
+ SELECT
+ COUNT_STAR, SUM_TIMER_WAIT,
+ COUNT_READ,SUM_TIMER_READ,SUM_NUMBER_OF_BYTES_READ,
+ COUNT_WRITE,SUM_TIMER_WRITE,SUM_NUMBER_OF_BYTES_WRITE,
+ COUNT_MISC,SUM_TIMER_MISC
+ FROM performance_schema.socket_summary_by_instance
+ WHERE OBJECT_INSTANCE_BEGIN = @default_object_instance_begin;
+ let $print_details= 1;
+}
+
+#---------------------------------------------------------------------------
+
+--echo # 4.4 Check the differences caused by SQL statements
+--echo # 4.4.1 There must be no changes in counters of instances
+--echo # NOT LIKE '%client_connection' because everything gets charged
+--echo # into client_connection of the acting connection.
+#===========================================================================
+# Enable the following lines for debugging the check.
+# Attention: socket_summary_by_instance_detail is after that rotten.
+if(0)
+{
+ --enable_info
+ UPDATE mysqltest.socket_summary_by_instance_detail
+ SET COUNT_WRITE = 13
+ WHERE statement LIKE '%WHERE col1 = 3'
+ AND EVENT_NAME NOT LIKE '%client_connection'
+ LIMIT 1;
+ --disable_info
+}
+
+let $my_rules=
+COUNT_READ = 0 AND SUM_TIMER_READ = 0 AND SUM_NUMBER_OF_BYTES_READ = 0
+AND
+COUNT_WRITE = 0 AND SUM_TIMER_WRITE = 0 AND SUM_NUMBER_OF_BYTES_WRITE = 0
+AND
+COUNT_MISC = 0 AND SUM_TIMER_MISC = 0;
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail
+ WHERE NOT ( $my_rules )
+ AND EVENT_NAME NOT LIKE '%client_connection'
+ AND statement NOT LIKE 'Connect%';
+if(`SELECT COUNT(*) $part`)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo #
+ eval
+ SELECT
+ $column_list
+ $part
+ ORDER BY EVENT_NAME, OBJECT_INSTANCE_BEGIN, statement, run;
+ let $print_details= 1;
+}
+
+--echo # 4.4.2 In case of SELECT and our scenarios even COUNT_READ and COUNT_MISC
+--echo # are stable.
+#===========================================================================
+# Enable the following lines for debugging the check.
+# Attention: socket_summary_by_instance_detail is after that rotten.
+if(0)
+{
+ --enable_info
+ UPDATE mysqltest.socket_summary_by_instance_detail
+ SET COUNT_READ = 13
+ WHERE statement LIKE '%WHERE col1 = 3'
+ LIMIT 1;
+ --disable_info
+}
+
+let $my_rules=
+COUNT(DISTINCT COUNT_READ) = 1 AND
+COUNT(DISTINCT COUNT_MISC) = 1;
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail
+WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND statement NOT LIKE '%Connect%'
+GROUP BY EVENT_NAME, statement
+HAVING NOT ($my_rules) ;
+if(`SELECT COUNT(statement) $part`)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo # for GROUP BY EVENT_NAME, statement
+ eval
+ SELECT $column_list
+ FROM mysqltest.socket_summary_by_instance_detail
+ WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND (EVENT_NAME, statement)
+ IN (SELECT EVENT_NAME, statement
+ $part)
+ ORDER BY EVENT_NAME, statement, run, OBJECT_INSTANCE_BEGIN;
+ let $print_details= 1;
+}
+
+--echo # 4.4.3 In our testing scenarios we get for the client_connection entry
+--echo # of the acting connection
+--echo # -> OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+--echo # COUNT_MISC = 0 AND SUM_TIMER_MISC = 0
+#===========================================================================
+# Enable the following lines for debugging the check.
+# Attention: socket_summary_by_instance_detail is after that rotten.
+if(0)
+{
+ --enable_info
+ UPDATE mysqltest.socket_summary_by_instance_detail
+ SET COUNT_MISC = 13
+ WHERE statement LIKE '%WHERE col1 = 3'
+ AND EVENT_NAME LIKE '%client_connection'
+ AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ LIMIT 1;
+ --disable_info
+}
+
+let $my_rules=
+COUNT_MISC = 0 AND SUM_TIMER_MISC = 0;
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail
+WHERE NOT ( $my_rules )
+ AND EVENT_NAME LIKE '%client_connection'
+ AND statement NOT LIKE 'Connect%'
+ AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin;
+if(`SELECT COUNT(*) $part`)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo #
+ eval
+ SELECT
+ $column_list
+ $part
+ ORDER BY EVENT_NAME, OBJECT_INSTANCE_BEGIN, statement, run;
+ let $print_details= 1;
+}
+
+# Initialize variables
+let $my_rules= my_rules_not_set;
+let $stmt1= stmt1_not_set;
+let $stmt2= stmt2_not_set;
+# $title_prefix is used for the generation of titles
+let $title_prefix= 4.4;
+# $check_num is used for the generation of titles and gets incremented after
+# every call of the current script.
+let $check_num= 4;
+# $column_list is used for the generation of error information and valid for
+# every sub test.
+let $diff_column_list=
+t2.COUNT_READ - t1.COUNT_READ AS D_COUNT_READ,
+t2.COUNT_READ AS S2_COUNT_READ,
+t1.COUNT_READ AS S1_COUNT_READ,
+t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ AS D_SUM_NUMBER_OF_BYTES_READ,
+t2.SUM_NUMBER_OF_BYTES_READ AS S2_SUM_NUMBER_OF_BYTES_READ,
+t1.SUM_NUMBER_OF_BYTES_READ AS S1_SUM_NUMBER_OF_BYTES_READ,
+t2.COUNT_WRITE - t1.COUNT_WRITE AS D_COUNT_WRITE,
+t2.COUNT_WRITE AS S2_COUNT_WRITE,
+t1.COUNT_WRITE AS S1_COUNT_WRITE,
+t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE AS D_SUM_NUMBER_OF_BYTES_WRITE,
+t2.SUM_NUMBER_OF_BYTES_WRITE AS S2_SUM_NUMBER_OF_BYTES_WRITE,
+t1.SUM_NUMBER_OF_BYTES_WRITE AS S1_SUM_NUMBER_OF_BYTES_WRITE,
+t2.COUNT_MISC - t1.COUNT_MISC AS D_COUNT_MISC,
+t2.COUNT_MISC AS S2_COUNT_MISC,
+t1.COUNT_MISC AS S1_COUNT_MISC;
+# $part is used for the generation of "check" statements + error information
+# and valid for every sub test.
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail t1
+JOIN mysqltest.socket_summary_by_instance_detail t2
+USING (EVENT_NAME, OBJECT_INSTANCE_BEGIN, run)
+WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND EVENT_NAME LIKE ('%client_connection')
+ AND run = 1;
+
+--echo # Check the differences between changes caused by SQL statements
+--echo # These differences must correspond to parameters like
+--echo # - statement, table name or column name length
+--echo # - number of rows in result set, size of rows in result set etc.
+# --> Statement NOT LIKE '%Connect%'
+
+let stmt1= SELECT col2 FROM does_not_exist;
+let stmt2= SELECT col2 FROM does_not_exist WHERE col1 = 0;
+#
+# CNT_READ BYTES_READ CNT_WRITE BYTES_WRITE CNT_MISC statement
+# 3 36 1 59 1 SELECT col2 FROM does_not_exist
+# 3 51 1 59 1 SELECT col2 FROM does_not_exist WHERE col1 = 0
+# The string of the statement gets charged into SUM_NUMBER_OF_BYTES_READ.
+# The server error message gets charged into SUM_NUMBER_OF_BYTES_WRITE.
+let $msg=
+# One statement is longer than the other.
+# Both statements fail with the same error message (table does not exist);
+#
+let $my_rules=
+t2.COUNT_READ - t1.COUNT_READ = 0 AND
+t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt2') - LENGTH('$stmt1') AND
+t2.COUNT_WRITE - t1.COUNT_WRITE = 0 AND
+t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE = 0 AND
+t2.COUNT_MISC - t1.COUNT_MISC = 0;
+--source ../include/socket_check1.inc
+
+let $stmt1= SELECT col2 FROM does_not_exist WHERE col1 = 0;
+let $stmt2= SELECT col2 FROM does_not_exist WHERE col1 A 0;
+#
+# CNT_READ BYTES_READ CNT_WRITE BYTES_WRITE CNT_MISC statement
+# 3 51 1 59 1 SELECT col2 FROM does_not_exist WHERE col1 = 0
+# 3 51 1 162 1 SELECT col2 FROM does_not_exist WHERE col1 A 0
+let $msg=
+# Both statements have the same length and fail.
+# The length of the error messages differs.;
+let $my_rules=
+t2.COUNT_READ - t1.COUNT_READ = 0 AND
+t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt2') - LENGTH('$stmt1') AND
+t2.COUNT_WRITE - t1.COUNT_WRITE = 0 AND
+t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE > 0 AND
+t2.COUNT_MISC - t1.COUNT_MISC = 0;
+--source ../include/socket_check1.inc
+
+let $stmt1= SELECT col2 FROM does_not_exist;
+let $stmt2= SELECT col2 FROM does_not_exist0123;
+# CNT_READ BYTES_READ CNT_WRITE BYTES_WRITE CNT_MISC statement
+# 3 36 1 59 1 SELECT col2 FROM does_not_exist
+# 3 40 1 63 1 SELECT col2 FROM does_not_exist0123
+let $msg=
+# Both statements fail (table does not exist).
+# The length of the statement and the length of the error messages differs.
+# Reason for both differences is the length of the table name.;
+let $my_rules=
+t2.COUNT_READ - t1.COUNT_READ = 0 AND
+t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt2') - LENGTH('$stmt1') AND
+t2.COUNT_WRITE - t1.COUNT_WRITE = 0 AND
+t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE = LENGTH('$stmt2') - LENGTH('$stmt1') AND
+t2.COUNT_MISC - t1.COUNT_MISC = 0;
+--source ../include/socket_check1.inc
+
+# Assuming that some new check should be added.
+# How to enforce that a lot info is printed so that it becomes easy to derive
+# the right value for $my_rules?
+#----------------------------------------------------------------------------
+# let $my_rules= 0;
+# This will cause that suite/perfschema/include/socket_check1.inc concludes that
+# the check via $my_rules failed and it will print debug information.
+# let $stmt1= SELECT col2 FROM does_not_exist WHERE col1 = 0;
+# let $stmt2= SELECT col2 FROM does_not_exist WHERE col1 A 0;
+# let $my_rules= 0;
+# --source ../include/socket_check1.inc
+
+let $stmt2= SELECT col2 AS my_super_col FROM mysqltest.my_aux WHERE col1 = -1;
+let $stmt1= SELECT col2 FROM mysqltest.my_aux WHERE col1 = -1;
+#
+# CNT_READ BYTES_READ CNT_WRITE BYTES_WRITE CNT_MISC statement
+# 3 54 1 78 1 SELECT col2 FROM mysqltest.my_aux WHERE col1 = -1
+# 3 70 1 86 1 SELECT col2 AS my_super_col FROM mysqltest.my_aux WHERE col1 = -1
+let $msg=
+# Both statements get an empty result set.
+# The length of the statements and the length of the result sets differs.
+# Reason for both differences is the length of the some column name.;
+let $my_rules=
+t2.COUNT_READ - t1.COUNT_READ = 0 AND
+t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt2') - LENGTH('$stmt1') AND
+t2.COUNT_WRITE - t1.COUNT_WRITE = 0 AND
+t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE = LENGTH('my_super_col') - LENGTH('col2') AND
+t2.COUNT_MISC - t1.COUNT_MISC = 0;
+--source ../include/socket_check1.inc
+
+let $stmt2= SELECT col2 FROM mysqltest.my_aux WHERE col1 = 1;
+let $stmt1= SELECT col2 FROM mysqltest.my_aux WHERE col1 = -1;
+#
+# CNT_READ BYTES_READ CNT_WRITE BYTES_WRITE CNT_MISC statement
+# t1 3 54 1 78 1 SELECT col2 FROM mysqltest.my_aux WHERE col1 = -1
+# t2 3 53 1 83 1 SELECT col2 FROM mysqltest.my_aux WHERE col1 = 1
+let $msg=
+# Both statements differ in the statement length.
+# One statement earns an empty result set.
+# The other statement earns one row containing an empty string.;
+let $my_rules=
+t2.COUNT_READ - t1.COUNT_READ = 0 AND
+t1.SUM_NUMBER_OF_BYTES_READ - t2.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt1') - LENGTH('$stmt2') AND
+t2.COUNT_WRITE - t1.COUNT_WRITE = 0 AND
+t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE > 0 AND
+t2.COUNT_MISC - t1.COUNT_MISC = 0;
+--source ../include/socket_check1.inc
+
+let $stmt2= SELECT col2 FROM mysqltest.my_aux WHERE col1 = 2;
+let $stmt1= SELECT col2 FROM mysqltest.my_aux WHERE col1 = 1;
+#
+# CNT_READ BYTES_READ CNT_WRITE BYTES_WRITE CNT_MISC statement
+# 3 53 1 83 1 SELECT col2 FROM mysqltest.my_aux WHERE col1 = 1
+# 3 53 1 84 1 SELECT col2 FROM mysqltest.my_aux WHERE col1 = 2
+let $msg=
+# Both statements have the same length.
+# One statement earns an one row containing an empty string.
+# The other statement earns one row containing a string 1 byte long.;
+let $my_rules=
+t2.COUNT_READ - t1.COUNT_READ = 0 AND
+t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt2') - LENGTH('$stmt1') AND
+t2.COUNT_WRITE - t1.COUNT_WRITE = 0 AND
+t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE = 1 AND
+t2.COUNT_MISC - t1.COUNT_MISC = 0;
+--source ../include/socket_check1.inc
+
+let $stmt2= SELECT col2 FROM mysqltest.my_aux WHERE col1 = 3;
+let $stmt1= SELECT col2 FROM mysqltest.my_aux WHERE col1 = 1;
+#
+# CNT_READ BYTES_READ CNT_WRITE BYTES_WRITE CNT_MISC statement
+# 3 53 1 83 1 SELECT col2 FROM mysqltest.my_aux WHERE col1 = 1
+# 3 53 1 1109 1 SELECT col2 FROM mysqltest.my_aux WHERE col1 = 3
+let $msg=
+# Both statements have the same length.
+# One statement earns an one row containing an empty string.
+# The other statement earns one row containing a string 1024 byte long.;
+let $my_rules=
+t2.COUNT_READ - t1.COUNT_READ = 0 AND
+t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt2') - LENGTH('$stmt1') AND
+t2.COUNT_WRITE - t1.COUNT_WRITE = 0 AND
+t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE >= 1024 AND
+t2.COUNT_MISC - t1.COUNT_MISC = 0;
+--source ../include/socket_check1.inc
+
+let $stmt2= SELECT col2 FROM mysqltest.my_aux WHERE col1 < 2;
+let $stmt1= SELECT col2 FROM mysqltest.my_aux WHERE col1 = 1;
+#
+# CNT_READ BYTES_READ CNT_WRITE BYTES_WRITE CNT_MISC statement
+# t1 3 53 1 83 1 SELECT col2 FROM mysqltest.my_aux WHERE col1 = 1
+# t2 3 53 1 88 1 SELECT col2 FROM mysqltest.my_aux WHERE col1 < 2
+let $msg=
+# Both statements have the same length.
+# One statement earns an one row containing an empty string.
+# The other statement earns two rows containing an empty string.;
+let $my_rules=
+t2.COUNT_READ - t1.COUNT_READ = 0 AND
+t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt2') - LENGTH('$stmt1') AND
+t2.COUNT_WRITE - t1.COUNT_WRITE = 0 AND
+t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE > 0 AND
+t2.COUNT_MISC - t1.COUNT_MISC = 0;
+--source ../include/socket_check1.inc
+
+--echo # 4.5 Check the differences caused by Connects
+--echo # Attention: Succesful Connects run an additional "DO 1".
+--echo # 4.5.1 Connects do not charge anything into READ or WRITE counters
+--echo # of the instance with EVENT_NAME NOT LIKE ('%client_connection%').
+--echo # This mean all these counters must be 0.
+let $my_rules=
+COUNT_READ = 0 AND SUM_TIMER_READ = 0 AND SUM_NUMBER_OF_BYTES_READ = 0 AND
+COUNT_WRITE = 0 AND SUM_TIMER_WRITE = 0 AND SUM_NUMBER_OF_BYTES_WRITE = 0;
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail
+WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND statement LIKE ('%Connect%')
+ AND EVENT_NAME NOT LIKE ('%client_connection%')
+ AND NOT ( $my_rules );
+if(`SELECT COUNT(*) $part `)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo #
+ eval
+ SELECT
+ $column_list
+ $part;
+ let $print_details= 1;
+}
+
+--echo # 4.5.2 Connects using for host the value 'localhost'
+--echo # 4.5.2.1 For the instance with EVENT_NAME LIKE '%server_tcpip_socket'
+--echo # COUNT_MISC = 0 AND SUM_TIMER_MISC = 0 must be valid
+--echo # because we run through server_unix_socket.
+#===========================================================================
+# Enable the following lines for debugging the check.
+# Attention: socket_summary_by_instance_detail is after that rotten.
+if(0)
+{
+ --enable_info
+ UPDATE mysqltest.socket_summary_by_instance_detail
+ SET COUNT_MISC = 13
+ WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND statement LIKE ('%Connect%localhost%')
+ AND EVENT_NAME LIKE ('%server_tcpip_socket%')
+ LIMIT 1;
+ --disable_info
+}
+
+let $my_rules=
+COUNT_MISC = 0 AND SUM_TIMER_MISC = 0;
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail
+WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND statement LIKE ('%Connect%localhost%')
+ AND EVENT_NAME LIKE ('%server_tcpip_socket%')
+ AND NOT ( $my_rules );
+if(`SELECT COUNT(*) $part `)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo #
+ eval
+ SELECT
+ $column_list
+ $part;
+ let $print_details= 1;
+}
+
+--echo # 4.5.2.2 For the instance with EVENT_NAME LIKE '%server_unix_socket'
+--echo # COUNT_MISC > 0 must be valid.
+#===========================================================================
+# Enable the following lines for debugging the check.
+# Attention: socket_summary_by_instance_detail is after that rotten.
+if(0)
+{
+ --enable_info
+ UPDATE mysqltest.socket_summary_by_instance_detail
+ SET COUNT_MISC = 0
+ WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND statement LIKE ('%Connect%localhost%')
+ AND EVENT_NAME LIKE ('%server_unix_socket%')
+ LIMIT 1;
+ --disable_info
+}
+
+let $my_rules=
+COUNT_MISC > 0;
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail
+WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND statement LIKE ('%Connect%localhost%')
+ AND EVENT_NAME LIKE ('%server_unix_socket%')
+ AND NOT ( $my_rules );
+if(`SELECT COUNT(*) $part `)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo #
+ eval
+ SELECT
+ $column_list
+ $part;
+ let $print_details= 1;
+}
+
+--echo # 4.5.3 Connects using for host a value <> 'localhost'
+--echo # 4.5.3.1 For the instance with EVENT_NAME LIKE '%server_unix_socket'
+--echo # COUNT_MISC = 0 AND SUM_TIMER_MISC = 0 must be valid
+--echo # because we run through server_tcpip_socket.
+#===========================================================================
+# Enable the following lines for debugging the check.
+# Attention: socket_summary_by_instance_detail is after that rotten.
+if(0)
+{
+ --enable_info
+ eval
+ UPDATE mysqltest.socket_summary_by_instance_detail
+ SET COUNT_MISC = 13
+ WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND EVENT_NAME LIKE ('%server_unix_socket%')
+ AND statement LIKE ('%Connect%$my_localhost%')
+ LIMIT 1;
+ --disable_info
+}
+
+let $my_rules=
+COUNT_MISC = 0 AND SUM_TIMER_MISC = 0;
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail
+WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND statement LIKE ('%Connect%$my_localhost%')
+ AND EVENT_NAME LIKE ('%server_unix_socket%')
+ AND NOT ( $my_rules );
+if(`SELECT COUNT(*) $part `)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo #
+ eval
+ SELECT
+ $column_list
+ $part;
+ let $print_details= 1;
+}
+
+--echo # 4.5.3.2 For the instance with EVENT_NAME LIKE '%server_tcpip_socket'
+--echo # COUNT_MISC > 0 must be valid.
+#===========================================================================
+# Enable the following lines for debugging the check.
+# Attention: socket_summary_by_instance_detail is after that rotten.
+if(0)
+{
+ --enable_info
+ eval
+ UPDATE mysqltest.socket_summary_by_instance_detail
+ SET COUNT_MISC = 0
+ WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND statement LIKE ('%Connect%$my_localhost%')
+ AND EVENT_NAME LIKE ('%server_tcpip_socket%')
+ LIMIT 1;
+ --disable_info
+}
+
+let $my_rules=
+COUNT_MISC > 0;
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail
+WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND statement LIKE ('%Connect%$my_localhost%')
+ AND EVENT_NAME LIKE ('%server_tcpip_socket%')
+ AND NOT ( $my_rules );
+if(`SELECT COUNT(*) $part `)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo #
+ eval
+ SELECT
+ $column_list
+ $part;
+ let $print_details= 1;
+}
+
+--echo # 4.5.4 Failing Connects do not cause any row with EVENT_NAME
+--echo # LIKE '%client_connection'
+#===========================================================================
+# Enable the following lines for debugging the check.
+# Attention: socket_summary_by_instance_detail is after that rotten.
+if(0)
+{
+ --enable_info
+ eval
+ UPDATE mysqltest.socket_summary_by_instance_detail
+ SET statement = 'Connect boot '
+ WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND statement LIKE ('Connect%root%')
+ AND EVENT_NAME LIKE ('%client_connection')
+ LIMIT 1;
+ --disable_info
+}
+
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail
+WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND statement LIKE ('Connect%boot%')
+ AND EVENT_NAME LIKE ('%client_connection');
+if(`SELECT COUNT(*) $part`)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect that there are no rows because
+ --echo # - failing connects do not cause a row with "client_connection"
+ --echo # - all failing connects contain a user name LIKE '%boot%'
+ eval
+ SELECT
+ $column_list
+ $part;
+ let $print_details= 1;
+}
+
+--echo # 4.5.5 Successful Connects cause a new instance with EVENT_NAME
+--echo # LIKE '%client_connection'
+#===========================================================================
+# Enable the following lines for debugging the check.
+# Attention: socket_summary_by_instance_detail is after that rotten.
+if(0)
+{
+ --enable_info
+ DELETE
+ FROM mysqltest.socket_summary_by_instance_detail
+ WHERE EVENT_NAME LIKE ('%client_connection')
+ AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND statement LIKE ('Connect%root%')
+ LIMIT 1;
+ --disable_info
+}
+
+# - connects which should be successful have statement LIKE ('Connect%root%').
+# - We try every type of Connect $loop_rounds times.
+# Therefore we should find $loop_rounds rows with
+# - EVENT_NAME LIKE ('%client_connection')
+# AND
+# - OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+# We do not want to count the entry of belonging to the default connection.
+# AND
+# - statement LIKE ('Connect%root%')
+# The connects which should be successful.
+#
+let $my_rules=
+COUNT(*) = $loop_rounds;
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail
+WHERE EVENT_NAME LIKE ('%client_connection')
+ AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND statement LIKE ('Connect%root%')
+GROUP BY statement
+HAVING NOT ( $my_rules );
+
+if(`SELECT COUNT(*) $part`)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo # for GROUP BY statement
+ --echo #
+ eval
+ SELECT
+ $column_list
+ FROM mysqltest.socket_summary_by_instance_detail
+ WHERE EVENT_NAME LIKE ('%client_connection')
+ AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND statement IN
+ (SELECT statement
+ $part);
+ let $print_details= 1;
+}
+
+--echo # 4.6 Check the differences caused by Connects
+--echo # - INSTANCES with an EVENT_NAME like server_tcpip_socket or
+--echo # server_unix_socket are already checked
+--echo # - the stability of results is already checked
+--echo # So we con go with the results of the first run.
+
+# Typical content of mysqltest.socket_summary_by_instance_detail
+#
+# eval
+# SELECT $column_list
+# FROM mysqltest.socket_summary_by_instance_detail
+# WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+# AND EVENT_NAME LIKE ('%client_connection')
+# AND statement LIKE ('Connect%')
+# AND run = 1
+# ORDER BY event_name,statement, run;
+# CREAD TREAD BREAD CWRITE TWRITE BWRITE CMISC TMISC STATEMENT
+# 4 6149616 79 3 34008480 117 3 38914128 Connect (con*,::ffff:127.0.0.1,root,,mysqltest,,)
+# 4 7012368 84 3 10112256 117 2 43067376 Connect (con*,localhost,root,,mysqlsupertest,,)
+# 4 7172880 79 3 10247688 117 2 40128000 Connect (con*,localhost,root,,mysqltest,,)
+# 4 6706392 85 3 15509472 117 2 34851168 Connect (con*,localhost,root012345,,mysqltest,,)
+# 4 10543632 89 3 10578744 117 2 39460872 Connect (con*,localhost,root0123456789,,mysqltest,,)
+
+--echo # 4.6.1 The SUM_OF_BYTES_WRITE value depends on length of database
+--echo # since the database name is written in OK packet.
+--echo # Hence the value 2.
+#========================================================================
+let $my_rules= COUNT(DISTINCT SUM_NUMBER_OF_BYTES_WRITE) = 2;
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail
+WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND EVENT_NAME LIKE ('%client_connection')
+ AND statement LIKE ('Connect%')
+ AND run = 1;
+if(`SELECT NOT ( $my_rules) $part`)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo # for all Connects
+ --echo #
+ eval
+ SELECT
+ statement, SUM_NUMBER_OF_BYTES_WRITE
+ $part;
+ let $print_details= 1;
+}
+
+--echo # 4.6.2 The SUM_OF_BYTES_WRITE value hast to be > 100.
+#============================================================
+let $my_rules= SUM_NUMBER_OF_BYTES_WRITE > 100;
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail
+WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND EVENT_NAME LIKE ('%client_connection')
+ AND statement LIKE ('Connect%')
+ AND NOT ( $my_rules )
+ AND run = 1;
+if(`SELECT COUNT(*) $part`)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo # for all Connects
+ --echo #
+ eval
+ SELECT
+ statement, SUM_NUMBER_OF_BYTES_WRITE
+ $part;
+ let $print_details= 1;
+}
+
+--echo # 4.6.3 COUNT_READ, COUNT_WRITE and COUNT_MISC have to be to be > 0
+#=========================================================================
+let $my_rules=
+COUNT_READ > 0 AND COUNT_WRITE > 0 AND COUNT_MISC > 0;
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail
+WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND EVENT_NAME LIKE ('%client_connection')
+ AND statement LIKE ('Connect%')
+ AND NOT ( $my_rules )
+ AND run = 1;
+if(`SELECT COUNT(*) $part`)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo # for all Connects
+ --echo #
+ eval
+ SELECT
+ statement, COUNT_READ, COUNT_WRITE, COUNT_MISC
+ $part;
+ let $print_details= 1;
+}
+
+--echo # 4.6.4 Checks based on comparison of results for connects
+let $part0=
+FROM mysqltest.socket_summary_by_instance_detail t1
+JOIN mysqltest.socket_summary_by_instance_detail t2
+USING (EVENT_NAME, run)
+WHERE EVENT_NAME LIKE ('%client_connection')
+ AND run = 1
+ AND t2.OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND t1.OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin;
+let $part1=
+SELECT RPAD(statement,55,' ') AS STATEMENT,
+ LENGTH(statement), SUM_NUMBER_OF_BYTES_READ
+FROM mysqltest.socket_summary_by_instance_detail
+WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND EVENT_NAME LIKE ('%client_connection')
+ AND run = 1;
+
+
+--echo # 4.6.4 The user name length affects the SUM_OF_BYTES_READ value
+#======================================================================
+# CREAD TREAD BREAD CWRITE TWRITE BWRITE CMISC TMISC STATEMENT
+# 4 6706392 85 3 15509472 117 2 34851168 Connect (con*,localhost,root012345,,mysqltest,,)
+# 4 10543632 89 3 10578744 117 2 39460872 Connect (con*,localhost,root0123456789,,mysqltest,,)
+let $stmt2= Connect (con*,localhost,root0123456789,,mysqltest,,);
+let $stmt1= Connect (con*,localhost,root012345,,mysqltest,,);
+let $my_rules=
+t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt2') - LENGTH('$stmt1');
+if(`SELECT NOT ($my_rules)
+ $part0
+ AND t2.statement = '$stmt2'
+ AND t1.statement = '$stmt1'`)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo #
+ eval
+ $part1
+ AND statement IN('$stmt2','$stmt1');
+ let $print_details= 1;
+}
+
+--echo # 4.6.5 The database name length affects the SUM_OF_BYTES_READ value
+#==========================================================================
+# CREAD TREAD BREAD CWRITE TWRITE BWRITE CMISC TMISC STATEMENT
+# 4 7012368 84 3 10112256 117 2 43067376 Connect (con*,localhost,root,,mysqlsupertest,,)
+# 4 7172880 79 3 10247688 117 2 40128000 Connect (con*,localhost,root,,mysqltest,,)
+let $stmt2= Connect (con*,localhost,root,,mysqlsupertest,,);
+let $stmt1= Connect (con*,localhost,root,,mysqltest,,);
+let $my_rules=
+t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt2') - LENGTH('$stmt1');
+if(`SELECT NOT ($my_rules)
+ $part0
+ AND t2.statement = '$stmt2'
+ AND t1.statement = '$stmt1'`)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo #
+ eval
+ $part1
+ AND statement IN('$stmt2','$stmt1');
+ let $print_details= 1;
+}
+
+--echo # 5. Check the impact of TRUNCATE on socket_summary_by_instance.
+--echo # It must reset all counters.
+#=======================================================================
+# We do not need to check if the majority of counters is <> 0 because if
+# we ever hit such a bad state than a lot of the preceding checks would
+# have already failed and reported this.
+TRUNCATE TABLE performance_schema.socket_summary_by_instance;
+let $my_rules=
+COUNT_STAR = 0 AND SUM_TIMER_WAIT = 0
+AND
+COUNT_READ = 0 AND SUM_TIMER_READ = 0 AND SUM_NUMBER_OF_BYTES_READ = 0
+AND
+COUNT_WRITE = 0 AND SUM_TIMER_WRITE = 0 AND SUM_NUMBER_OF_BYTES_WRITE = 0
+AND
+COUNT_MISC = 0 AND SUM_TIMER_MISC = 0;
+if(`SELECT COUNT(*) FROM performance_schema.socket_summary_by_instance
+ WHERE NOT ( $my_rules )
+ AND OBJECT_INSTANCE_BEGIN = @default_object_instance_begin`)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo #
+ eval
+ SELECT
+ COUNT_STAR, SUM_TIMER_WAIT,
+ COUNT_READ,SUM_TIMER_READ,SUM_NUMBER_OF_BYTES_READ,
+ COUNT_WRITE,SUM_TIMER_WRITE,SUM_NUMBER_OF_BYTES_WRITE,
+ COUNT_MISC,SUM_TIMER_MISC
+ FROM performance_schema.socket_summary_by_instance
+ WHERE OBJECT_INSTANCE_BEGIN = @default_object_instance_begin;
+}
+
+
+if($print_details)
+{
+ --enable_query_log
+ --enable_result_log
+ --horizontal_results
+ --echo # Dump detailed differences after - before statement execution
+ --echo # 1. The statement executing connection and hopefully no one else
+ SELECT @default_object_instance_begin;
+ SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN,
+ COUNT_READ, SUM_NUMBER_OF_BYTES_READ,
+ COUNT_WRITE, SUM_NUMBER_OF_BYTES_WRITE,
+ COUNT_MISC, statement
+ FROM mysqltest.socket_summary_by_instance_detail
+ WHERE EVENT_NAME LIKE '%client_connection%'
+ AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ ORDER BY statement, run;
+ --echo # 2. The connection default
+ SELECT EVENT_NAME,
+ COUNT_READ, SUM_NUMBER_OF_BYTES_READ,
+ COUNT_WRITE, SUM_NUMBER_OF_BYTES_WRITE,
+ COUNT_MISC, statement
+ FROM mysqltest.socket_summary_by_instance_detail
+ WHERE OBJECT_INSTANCE_BEGIN = @default_object_instance_begin
+ ORDER BY statement,run;
+ --echo # 3. The "server_unix_socket"
+ # WHERE OBJECT_INSTANCE_BEGIN = @default_object_instance_begin
+ SELECT EVENT_NAME,
+ COUNT_READ, SUM_NUMBER_OF_BYTES_READ,
+ COUNT_WRITE, SUM_NUMBER_OF_BYTES_WRITE,
+ COUNT_MISC, statement
+ FROM mysqltest.socket_summary_by_instance_detail
+ WHERE EVENT_NAME LIKE '%server_unix_socket%'
+ ORDER BY statement,run;
+ --echo # 4. The "server_tcpip_socket"
+ SELECT EVENT_NAME,
+ COUNT_READ, SUM_NUMBER_OF_BYTES_READ,
+ COUNT_WRITE, SUM_NUMBER_OF_BYTES_WRITE,
+ COUNT_MISC, statement
+ FROM mysqltest.socket_summary_by_instance_detail
+ WHERE EVENT_NAME LIKE '%server_tcpip_socket%'
+ ORDER BY statement,run;
+ --echo # 5. mysqltest.my_socket_summary_by_instance
+ --vertical_results
+ SELECT * FROM mysqltest.my_socket_summary_by_instance;
+ --horizontal_results
+}
+
+--echo # 6. Cleanup
+#==================
+# Cleanup
+--disable_query_log
+eval
+UPDATE performance_schema.setup_timers
+SET TIMER_NAME = '$wait_timer'
+WHERE NAME = 'wait';
+DROP SCHEMA mysqltest;
+DROP SCHEMA mysqlsupertest;
+--connection con1
+--disconnect con1
+--source include/wait_until_disconnected.inc
+--connection default
+--enable_query_log
diff --git a/mysql-test/suite/perfschema/t/socket_summary_by_instance_func_win.test b/mysql-test/suite/perfschema/t/socket_summary_by_instance_func_win.test
new file mode 100644
index 00000000..2c6a375b
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/socket_summary_by_instance_func_win.test
@@ -0,0 +1,1730 @@
+# Some functional checks for the content of the performance_schema table
+# socket_summary_by_instance.
+#
+# Created: mleich 2011-07-01
+#
+# Rough description of "What is when tested"
+# 1. Impact of successful connect
+# A new row with EVENT_NAME "client_connection" shows up
+# is tested in 0 and 4.5.
+# 2. Impact of disconnect
+# A row with EVENT_NAME "client_connection" disappears
+# is tested in 0. and 2.
+# 3. Disabling the instrumentation for some thread causes that the
+# counter for this thread become static is tested in 4.3.
+# Nearby the beginning of this test and somewhere in the middle.
+# 4. TRUNCATE table resets the counters is tested in 5.
+# 5. Consistency within a row like MIN_* <= AVG_* <= MAX_*
+# -> include/socket_summary_check.inc which is called at
+# various places
+# 6. Consistency of the instances mentioned in socket_summary_by_event
+# and socket_summary_by_instance is checked per call of
+# include/socket_summary_check.inc
+# 7. Check if changes in counters of instances caused by actions
+# are reasonable is tested for
+# - Connects+SQL statements in 4.1 and 4.2
+# - SQL statements in 4.4
+# - Connects in 4.5
+#
+
+# Embedded server does not support the performance_schema.
+--source include/not_embedded.inc
+
+# Windows platforms only
+--source include/windows.inc
+--source include/have_perfschema.inc
+
+# The values in the performance_schema tables depend on how much communication
+# happens per SQL statement within our MTR tests. And there is a significant
+# difference between standard statement execution and execution via
+# prepared statement.
+--source include/no_protocol.inc
+
+
+#===================================
+# Set IP address defaults with respect to IPV6 support
+#
+# Set this to enable debugging output
+let $my_socket_debug_dbug= 0;
+#
+# Determine if IPV6 supported
+#
+let $check_ipv6_just_check= 1;
+--source include/check_ipv6.inc
+#
+# Determine if IPV4 mapped to IPV6 supported
+#
+let $check_ipv4_mapped_just_check= 1;
+--source include/have_ipv4_mapped.inc
+#
+# Set the localhost IP default to use when establishing connections
+let $my_localhost=127.0.0.1;
+if($check_ipv6_supported)
+{
+ let $my_localhost=::1;
+}
+if($check_ipv4_mapped_supported)
+{
+ let $my_localhost=::ffff:127.0.0.1;
+}
+#
+let $my_socket_debug_dbug= 0;
+if($my_socket_debug)
+{
+ --echo IPV6=$check_ipv6_supported, IPV4_MAPPED = $check_ipv4_mapped_supported, LOCALHOST = $my_localhost
+}
+#===================================
+
+--echo # The logging of commands and result sets is mostly disabled.
+--echo # There are some messages which help to observe the progress of the test.
+--echo # In case some check fails
+--echo # - a message about this will be printed
+--echo # - some SQL commands which show the unexpected state will be executed
+--echo # (logging enabled)
+--echo # - the test might abort
+--echo #
+
+--disable_query_log
+
+--echo # 0. Check, build or set prequisites
+#==========================================
+# Set $print_details to 1 in case you want that the exact diffs caused
+# by the execution of a statement get printed.
+# Disadvantage of printing details:
+# Even minor legimitate changes of the client - server communication can
+# cause that the test needs maintenance.
+# Advantage:
+# More thorough checks.
+# If any of the checks detects some suspicious/unexpected state than
+# $print_details will be automatically switched to 1.
+#
+let $print_details= 0;
+
+#
+# Number of attempts within the test checking the stability of counter changes.
+#
+let $loop_rounds= 10;
+
+# This test of PERFORMANCE_SCHEMA functionality is very vulnerable.
+# Ensure that we have in the moment exact one
+# - connection
+# - instance with EVENT_NAME LIKE '%client_connection'
+# - instance with EVENT_NAME LIKE '%server_tcpip_socket'
+# - instance with EVENT_NAME LIKE '%server_unix_socket'
+#=======================================================
+let $my_rules= COUNT(*) = 1;
+let $part=
+FROM performance_schema.threads
+WHERE NAME LIKE '%one_connection';
+let $wait_condition=
+SELECT $my_rules $part;
+let $wait_timeout= 5;
+--source include/wait_condition.inc
+if(!$success)
+{
+ --echo # ERROR: There must be only one user connection
+ eval
+ SELECT * $part;
+ --echo # abort
+ die;
+}
+let $part=
+FROM performance_schema.socket_summary_by_instance
+WHERE EVENT_NAME LIKE '%client_connection';
+let $wait_condition=
+SELECT $my_rules $part;
+let $wait_timeout= 5;
+--source include/wait_condition.inc
+if(!$success)
+{
+ --echo # ERROR: There must be only one instance with this EVENT_NAME.
+ eval
+ SELECT * $part;
+ --echo # abort
+ die;
+}
+# DISABLED FOR WINDOWS
+let $part=
+FROM performance_schema.socket_summary_by_instance
+WHERE EVENT_NAME LIKE '%server_unix_socket';
+let $wait_condition=
+SELECT $my_rules $part;
+let $wait_timeout= 5;
+#--source include/wait_condition.inc
+#if(!$success)
+#{
+# --echo # ERROR: There must be only one instance with this EVENT_NAME.
+# eval
+# SELECT * $part;
+# --echo # abort
+# die;
+#}
+let $part=
+FROM performance_schema.socket_summary_by_instance
+WHERE EVENT_NAME LIKE '%server_tcpip_socket';
+let $wait_condition=
+SELECT $my_rules $part;
+let $wait_timeout= 5;
+--source include/wait_condition.inc
+if(!$success)
+{
+ --echo # ERROR: There must be only one instance with this EVENT_NAME.
+ eval
+ SELECT * $part;
+ --echo # abort
+ die;
+}
+
+--disable_query_log
+
+#
+# Lower the resolution of the wait timer from the default 'CYCLE'
+# to 'NANOSECOND'.
+# Hint: The timer columns contains values in picoseconds independent
+# of the timer resolution.
+# The timer resolution has an impact on the precision of the value.
+# This should prevent the failures seen on some suspicious PB boxes where
+# - calculations exceeded the BIGINT UNSIGNED (data type of the counter columns)
+# value range.
+# - we have reached from whatever reason 20 digit values
+# The consequence for the current test is the following:
+# The common sense rule
+# In case COUNT_<A> increases than SUM_TIMER_<A> must also increase
+# is no more valid because some action might need less time than the
+# timer resolution.
+#
+let $wait_timer= `SELECT TIMER_NAME FROM performance_schema.setup_timers
+ WHERE NAME = 'wait'`;
+UPDATE performance_schema.setup_timers
+SET TIMER_NAME = 'NANOSECOND'
+WHERE NAME = 'wait';
+
+#
+# Additional SCHEMA used for
+# - detection of our "worker" session within the PROCESSLIST.
+# No other connection should use this schema as default schema.
+# - easy cleanup because auxiliary objects are stored there
+#
+CREATE SCHEMA mysqltest;
+CREATE SCHEMA mysqlsupertest;
+
+#
+# Clear summary tables of previous entries
+#
+TRUNCATE performance_schema.socket_summary_by_instance;
+TRUNCATE performance_schema.socket_summary_by_event_name;
+# Disable instrumenting of the current default session.
+# Required for check 1.1
+UPDATE performance_schema.threads
+SET INSTRUMENTED='NO' WHERE PROCESSLIST_ID = CONNECTION_ID();
+
+#
+# Auxiliary tables for storing current values at certain points of time.
+# We store states of performance_schema.socket_summary_by_instance here
+# in order
+# - to have initial values from before some action
+# - to minimize the impact of statements used for the checks on results.
+# CREATE TEMPORARY TABLE my_socket_summary_by_instance AS
+# would be nice but some statements are not supported for temporary tables.
+#
+# DECIMAL(60,0) is used instead of BIGINT UNSIGNED. The goal is to prevent
+# errors during calculations
+# Example:
+# - A and B UNSIGNED BIGINT
+# - A < B
+# - A - B ---> Error
+# though the columns in all queries are orderd to avoid this too.
+#
+CREATE TABLE mysqltest.my_socket_summary_by_instance (
+ EVENT_NAME varchar(128) NOT NULL,
+ OBJECT_INSTANCE_BEGIN bigint(20) unsigned NOT NULL,
+ COUNT_STAR DECIMAL(60,0) NOT NULL,
+ SUM_TIMER_WAIT DECIMAL(60,0) NOT NULL,
+ MIN_TIMER_WAIT DECIMAL(60,0) NOT NULL,
+ AVG_TIMER_WAIT DECIMAL(60,0) NOT NULL,
+ MAX_TIMER_WAIT DECIMAL(60,0) NOT NULL,
+ COUNT_READ DECIMAL(60,0) NOT NULL,
+ SUM_TIMER_READ DECIMAL(60,0) NOT NULL,
+ MIN_TIMER_READ DECIMAL(60,0) NOT NULL,
+ AVG_TIMER_READ DECIMAL(60,0) NOT NULL,
+ MAX_TIMER_READ DECIMAL(60,0) NOT NULL,
+ SUM_NUMBER_OF_BYTES_READ DECIMAL(60,0) NOT NULL,
+ COUNT_WRITE DECIMAL(60,0) NOT NULL,
+ SUM_TIMER_WRITE DECIMAL(60,0) NOT NULL,
+ MIN_TIMER_WRITE DECIMAL(60,0) NOT NULL,
+ AVG_TIMER_WRITE DECIMAL(60,0) NOT NULL,
+ MAX_TIMER_WRITE DECIMAL(60,0) NOT NULL,
+ SUM_NUMBER_OF_BYTES_WRITE DECIMAL(60,0) NOT NULL,
+ COUNT_MISC DECIMAL(60,0) NOT NULL,
+ SUM_TIMER_MISC DECIMAL(60,0) NOT NULL,
+ MIN_TIMER_MISC DECIMAL(60,0) NOT NULL,
+ AVG_TIMER_MISC DECIMAL(60,0) NOT NULL,
+ MAX_TIMER_MISC DECIMAL(60,0) NOT NULL,
+ pk VARCHAR(20),
+ PRIMARY KEY(pk, EVENT_NAME, OBJECT_INSTANCE_BEGIN)
+) DEFAULT CHARSET=utf8;
+
+
+# The CAST(... AS DECIMAL(60,0)) prevents errors which might show up in case
+# we run with the original data type UNSIGNED BIGINT.
+CREATE TABLE mysqltest.socket_summary_by_instance_detail (
+ EVENT_NAME varchar(128) NOT NULL,
+ OBJECT_INSTANCE_BEGIN bigint(20) unsigned NOT NULL,
+ COUNT_READ DECIMAL(60,0) NOT NULL,
+ SUM_TIMER_READ DECIMAL(60,0) NOT NULL,
+ SUM_NUMBER_OF_BYTES_READ DECIMAL(60,0) NOT NULL,
+ COUNT_WRITE DECIMAL(60,0) NOT NULL,
+ SUM_TIMER_WRITE DECIMAL(60,0) NOT NULL,
+ SUM_NUMBER_OF_BYTES_WRITE DECIMAL(60,0) NOT NULL,
+ COUNT_MISC DECIMAL(60,0) NOT NULL,
+ SUM_TIMER_MISC DECIMAL(60,0) NOT NULL,
+ statement VARCHAR(500),
+ run INTEGER
+) DEFAULT CHARSET=utf8;
+
+#
+# Auxiliary SQL functions used to shorten some commands.
+#
+CREATE FUNCTION mysqltest.min_of_triple
+ (f1 DECIMAL(60,0), f2 DECIMAL(60,0), f3 DECIMAL(60,0))
+ RETURNS DECIMAL(60,0)
+ RETURN IF(IF(f1 < f2,f1,f2) < f3,IF(f1 < f2,f1,f2), f3);
+CREATE FUNCTION mysqltest.max_of_triple
+ (f1 DECIMAL(60,0), f2 DECIMAL(60,0), f3 DECIMAL(60,0))
+ RETURNS DECIMAL(60,0)
+ RETURN IF(IF(f1 > f2,f1,f2) > f3,IF(f1 > f2,f1,f2), f3);
+
+#
+# Auxiliary table for experiments with SELECTs earning different result sets.
+#
+CREATE TABLE mysqltest.my_aux (col1 INTEGER, col2 VARCHAR(1024), PRIMARY KEY(col1));
+INSERT INTO mysqltest.my_aux SET col1 = 0, col2 = REPEAT('a',0);
+INSERT INTO mysqltest.my_aux SET col1 = 1, col2 = REPEAT('a',0);
+INSERT INTO mysqltest.my_aux SET col1 = 2, col2 = REPEAT('a',1);
+INSERT INTO mysqltest.my_aux SET col1 = 3, col2 = REPEAT('a',1024);
+
+#
+# Auxiliary mysqltest variables used to shorten commands and to ensure
+# that we run all time the right operation.
+#
+let $truncate=
+TRUNCATE TABLE mysqltest.my_socket_summary_by_instance;
+#
+let $insert_before=
+INSERT INTO mysqltest.my_socket_summary_by_instance
+SELECT *,'Before' FROM performance_schema.socket_summary_by_instance;
+#
+let $insert_after=
+INSERT INTO mysqltest.my_socket_summary_by_instance
+SELECT *,'After' FROM performance_schema.socket_summary_by_instance;
+#
+let $insert_pseudo_before=
+INSERT INTO mysqltest.my_socket_summary_by_instance
+(EVENT_NAME, OBJECT_INSTANCE_BEGIN,
+COUNT_STAR, SUM_TIMER_WAIT, MIN_TIMER_WAIT, AVG_TIMER_WAIT, MAX_TIMER_WAIT,
+COUNT_READ, SUM_TIMER_READ, MIN_TIMER_READ, AVG_TIMER_READ, MAX_TIMER_READ,
+SUM_NUMBER_OF_BYTES_READ,
+COUNT_WRITE, SUM_TIMER_WRITE, MIN_TIMER_WRITE, AVG_TIMER_WRITE, MAX_TIMER_WRITE,
+SUM_NUMBER_OF_BYTES_WRITE,
+COUNT_MISC, SUM_TIMER_MISC, MIN_TIMER_MISC, AVG_TIMER_MISC, MAX_TIMER_MISC,
+pk)
+SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN,
+0, 0, 0, 0, 0,
+0, 0, 0, 0, 0,
+0,
+0, 0, 0, 0, 0,
+0,
+0, 0, 0, 0, 0,
+'Pseudo_Before'
+FROM mysqltest.my_socket_summary_by_instance t1
+WHERE OBJECT_INSTANCE_BEGIN NOT IN
+ (SELECT OBJECT_INSTANCE_BEGIN
+ FROM mysqltest.my_socket_summary_by_instance t2
+ WHERE pk = 'Before');
+#
+let $insert_delta=
+INSERT INTO mysqltest.socket_summary_by_instance_detail
+ (EVENT_NAME,OBJECT_INSTANCE_BEGIN,
+ COUNT_READ, SUM_TIMER_READ, SUM_NUMBER_OF_BYTES_READ,
+ COUNT_WRITE,SUM_TIMER_WRITE,SUM_NUMBER_OF_BYTES_WRITE,
+ COUNT_MISC, SUM_TIMER_MISC, statement,run)
+SELECT EVENT_NAME,OBJECT_INSTANCE_BEGIN,
+ t1.COUNT_READ - t2.COUNT_READ,
+ t1.SUM_TIMER_READ - t2.SUM_TIMER_READ,
+ t1.SUM_NUMBER_OF_BYTES_READ - t2.SUM_NUMBER_OF_BYTES_READ,
+ t1.COUNT_WRITE - t2.COUNT_WRITE,
+ t1.SUM_TIMER_WRITE - t2.SUM_TIMER_WRITE,
+ t1.SUM_NUMBER_OF_BYTES_WRITE - t2.SUM_NUMBER_OF_BYTES_WRITE,
+ t1.COUNT_MISC - t2.COUNT_MISC,
+ t1.SUM_TIMER_MISC - t2.SUM_TIMER_MISC,
+ NULL,NULL
+FROM mysqltest.my_socket_summary_by_instance t1
+JOIN mysqltest.my_socket_summary_by_instance t2
+USING (EVENT_NAME,OBJECT_INSTANCE_BEGIN)
+WHERE t1.pk = 'After' AND t2.pk LIKE '%Before';
+#
+let $get_object_instance_begin=
+SELECT OBJECT_INSTANCE_BEGIN INTO @con1_object_instance_begin
+FROM performance_schema.socket_summary_by_instance AS t1
+WHERE (EVENT_NAME,OBJECT_INSTANCE_BEGIN)
+ NOT IN (SELECT EVENT_NAME,OBJECT_INSTANCE_BEGIN
+ FROM mysqltest.my_socket_summary_by_instance AS t2
+ WHERE pk = 'Before');
+
+# Use this whenever you print data.
+let $column_list=
+RPAD(EVENT_NAME, 38, ' ') AS EVENT_NAME,
+LPAD(OBJECT_INSTANCE_BEGIN, 20, ' ') AS OBJECT_INSTANCE,
+LPAD(COUNT_READ, 7, ' ') AS CREAD,
+LPAD(SUM_TIMER_READ, 12, ' ') AS TREAD,
+LPAD(SUM_NUMBER_OF_BYTES_READ, 7, ' ') AS BREAD,
+LPAD(COUNT_WRITE, 7, ' ') AS CWRITE,
+LPAD(SUM_TIMER_WRITE, 12, ' ') AS TWRITE,
+LPAD(SUM_NUMBER_OF_BYTES_WRITE, 7, ' ') AS BWRITE,
+LPAD(COUNT_MISC, 7, ' ') AS CMISC,
+LPAD(SUM_TIMER_MISC, 13, ' ') AS TMISC,
+RPAD(STATEMENT, 50, ' ') AS STATEMENT,
+LPAD(RUN, 5, ' ') AS RUN;
+
+# Determine OBJECT_INSTANCE_BEGIN of the connection default
+# which acts as the observer
+eval $truncate;
+eval $insert_before;
+--disconnect default
+--connect (default,localhost,root,,,,)
+# --echo ########### Disconnect/Connect
+# --enable_query_log
+eval $insert_after;
+eval $get_object_instance_begin;
+SET @default_object_instance_begin = @con1_object_instance_begin;
+
+# Wait till the old default connection has disappeared
+let $wait_timeout= 5;
+let $wait_condition=
+SELECT COUNT(*) = 1
+FROM performance_schema.threads
+WHERE processlist_user = 'root';
+--source include/wait_condition.inc
+--enable_query_log
+if (!$success)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # Error: The disconnect of the old default connection
+ --echo # (user = 'root') failed. We expect to have only one connection
+ --echo # with user = 'root'. And this is our current connection.
+ SELECT * FROM performance_schema.threads
+ WHERE processlist_user = 'root';
+ --echo # abort
+ die;
+}
+
+# Disable instrumenting of the current default session.
+# Required for check 1.2
+UPDATE performance_schema.threads
+SET INSTRUMENTED='NO' WHERE PROCESSLIST_ID = CONNECTION_ID();
+
+--echo # 1. Basic checks
+--echo # 1.1 Check that the entry of the disconnected old default session really
+--echo # disappeared from performance_schema.socket_summary_by_instance.
+#===============================================================================
+# This failed at some point in history when the instrumenting for the
+# session to be disconnected was disabled.
+if(`SELECT COUNT(*) FROM performance_schema.socket_summary_by_instance
+WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND EVENT_NAME LIKE '%client_connection'`)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # Error: The disconnected old default session did not disappear from
+ --echo # socket_summary_by_instance.
+ SELECT * FROM performance_schema.socket_summary_by_instance
+ WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND EVENT_NAME LIKE '%client_connection';
+}
+
+TRUNCATE TABLE performance_schema.socket_summary_by_instance;
+
+--echo # 1.2 Check the base line
+#===============================
+eval $truncate;
+--source ../include/socket_summary_check.inc
+
+# --disable_query_log
+# --disable_query_log
+
+--echo # 2. Variations on Connect
+let $is_connect= 1;
+--echo # 2.1 Connect fails because the user is unknown
+--echo # length of user name = 4 character
+--echo # length of default db = 9 character
+#========================================================================
+let $connect_host= localhost;
+let $connect_db= mysqltest;
+let $connect_user= boot;
+--source ../include/socket_event.inc
+
+--echo # 2.2 Connect fails because the user is unknown
+--echo # length of user name = 14 character (10 more than in 2.1)
+--echo # length of default db = 9 character
+#========================================================================
+let $connect_host= localhost;
+let $connect_db= mysqltest;
+let $connect_user= boot0123456789;
+--source ../include/socket_event.inc
+
+--echo # 2.3 Connect should pass, host = localhost
+--echo # length of user name = 4 character
+--echo # length of default db = 9 character
+#========================================================================
+let $connect_host= localhost;
+let $connect_db= mysqltest;
+let $connect_user= root;
+--source ../include/socket_event.inc
+
+--echo # 2.4 Connect should pass, host = localhost
+--echo # length of user name = 4 character
+--echo # length of default db = 14 character (5 more than 2.3)
+#========================================================================
+let $connect_host= localhost;
+let $connect_db= mysqlsupertest;
+let $connect_user= root;
+--source ../include/socket_event.inc
+
+--echo # 2.5 Connect should pass, host = localhost
+--echo # length of user name = 10 character
+--echo # length of default db = 9 character
+#========================================================================
+SET @orig_sql_mode= @@sql_mode;
+SET sql_mode= (SELECT replace(@@sql_mode,'NO_AUTO_CREATE_USER',''));
+GRANT ALL PRIVILEGES ON *.* TO 'root012345'@'localhost';
+SET sql_mode= @orig_sql_mode;
+let $connect_host= localhost;
+let $connect_db= mysqltest;
+let $connect_user= root012345;
+--source ../include/socket_event.inc
+DROP USER 'root012345'@'localhost';
+
+--echo # 2.6 Connect should pass, host = localhost
+--echo # length of user name = 14 character
+--echo # length of default db = 9 character
+#========================================================================
+SET @orig_sql_mode= @@sql_mode;
+SET sql_mode= (SELECT replace(@@sql_mode,'NO_AUTO_CREATE_USER',''));
+GRANT ALL PRIVILEGES ON *.* to 'root0123456789'@'localhost';
+SET sql_mode= @orig_sql_mode;
+let $connect_host= localhost;
+let $connect_db= mysqltest;
+let $connect_user= root0123456789;
+--source ../include/socket_event.inc
+DROP USER 'root0123456789'@'localhost';
+
+--echo # 2.7 Connect should pass, host = my_localhost
+--echo # length of user name = 4 character
+--echo # length of default db = 9 character
+--echo # connection runs through server_tcpip_socket !
+#========================================================================
+let $connect_host= $my_localhost;
+let $connect_db= mysqltest;
+let $connect_user= root;
+--source ../include/socket_event.inc
+
+#========================================================================
+--connect (con1,localhost,root,,mysqltest,,)
+# Experiments showed some unexpected result in the counter difference
+# which got con1 for the next statement (see 3.1).
+# The measured diff was too high and was probably caused by some
+# too much delayed counter maintenance for the connect.
+# We run here just some SQL statement because counter maintenance
+# for SQL statements is more fast and reliable than far Connect.
+DO 1;
+--connection default
+--source ../include/wait_till_sleep.inc
+--disable_query_log
+
+--echo # 3 Variations on SELECT
+# Attention: Don't use
+# - any double quotes within the statements because sourced scripts
+# already "decorate" $variables with double quotes
+# - UNION because this leads to result set related byte write
+# counters which cannot good compared to select without union
+let $is_connect= 0;
+eval $get_object_instance_begin;
+--echo # 3.1 Check a SELECT ending with server sending an error message.
+--echo # Error message is short (unknown table).
+#========================================================================
+let $statement= SELECT col2 FROM does_not_exist;
+--source ../include/socket_event.inc
+
+--echo # 3.2 SELECT ending with server sending an error message.
+--echo # Now the statement is a bit longer but the error message
+--echo # length does again not depend on statement.
+#=======================================================================
+let $statement= SELECT col2 FROM does_not_exist WHERE col1 = 0;
+--source ../include/socket_event.inc
+
+--echo # 3.3 SELECT ending with server sending an error message.
+--echo # The statement has the same length like in 3.2 but the error
+--echo # message is now different and much longer.
+#=======================================================================
+let $statement= SELECT col2 FROM does_not_exist WHERE col1 A 0;
+--source ../include/socket_event.inc
+
+--echo # 3.4 SELECT ending with server sending an error message.
+--echo # Statement and error message are a bit longer than in 3.1
+--echo # because the table name is longer.
+#=======================================================================
+let $statement= SELECT col2 FROM does_not_exist0123;
+--source ../include/socket_event.inc
+
+--echo # 3.5 SELECT earning an empty result set.
+#=======================================================
+let $statement= SELECT col2 FROM mysqltest.my_aux WHERE col1 = -1;
+--source ../include/socket_event.inc
+
+--echo # 3.6 SELECT earning an empty result set.
+--echo # Short column name is replaced by longer alias.
+#==========================================================
+let $statement= SELECT col2 AS my_super_col FROM mysqltest.my_aux WHERE col1 = -1;
+--source ../include/socket_event.inc
+
+--echo # 3.7 SELECT earning one row with an empty string.
+#================================================================
+let $statement= SELECT col2 FROM mysqltest.my_aux WHERE col1 = 1;
+--source ../include/socket_event.inc
+
+--echo # 3.8 SELECT earning one row with one string one char long.
+#=========================================================================
+let $statement= SELECT col2 FROM mysqltest.my_aux WHERE col1 = 2;
+--source ../include/socket_event.inc
+
+--echo # 3.9 SELECT earning one row with one string 1024 char long.
+#==========================================================================
+let $statement= SELECT col2 FROM mysqltest.my_aux WHERE col1 = 3;
+--source ../include/socket_event.inc
+
+--echo # 3.10 SELECT earning two rows with an empty string
+#==========================================================================
+let $statement= SELECT col2 FROM mysqltest.my_aux WHERE col1 < 2;
+--source ../include/socket_event.inc
+
+--echo # 3.11 Check that the preceding Connects/SQL command runs have not
+--echo # caused some unexpected state.
+#==========================================================================
+let $my_rules= COUNT(*) = 2;
+let $part=
+FROM performance_schema.threads
+WHERE NAME LIKE '%one_connection';
+if(`SELECT NOT ( $my_rules ) $part `)
+{
+ --echo # ERROR: There must be only two user connections
+ eval
+ SELECT * $part;
+ --echo # abort
+ die;
+}
+let $part=
+FROM performance_schema.socket_summary_by_instance
+WHERE EVENT_NAME LIKE '%client_connection';
+if(`SELECT NOT ( $my_rules ) $part `)
+{
+ --echo # ERROR: There must be only two instances with this EVENT_NAME.
+ eval
+ SELECT * $part;
+ --echo # abort
+ die;
+}
+let $my_rules= COUNT(*) = 1;
+let $part=
+FROM performance_schema.socket_summary_by_instance
+WHERE EVENT_NAME LIKE '%server_unix_socket';
+#DISABLED FOR WINDOWS
+#if(`SELECT NOT ( $my_rules ) $part `)
+if (0)
+{
+ --echo # ERROR: There must be only one instance with this EVENT_NAME.
+ eval
+ SELECT * $part;
+ --echo # abort
+ die;
+}
+let $part=
+FROM performance_schema.socket_summary_by_instance
+WHERE EVENT_NAME LIKE '%server_tcpip_socket';
+if(`SELECT NOT ( $my_rules ) $part `)
+{
+ --echo # ERROR: There must be only one instance with this EVENT_NAME.
+ eval
+ SELECT * $part;
+ --echo # abort
+ die;
+}
+
+--echo # 4. Check delta (value_after_action - value_before_action) details
+# 4.0 . Negative deltas cannot have happened because the counter columns within
+# socket_summary_by_instance_detail are defined as UNSIGNED BIGINT.
+# = The INSERT which computes the diff would have been failed.
+--echo # 4.1 Check that
+--echo # - no change in COUNT_* leads to no change in
+--echo # SUM_TIMER_* and no change in SUM_NUMBER_OF_BYTES_*
+--echo # - increased COUNT_READ leads to increased
+--echo # SUM_NUMBER_OF_BYTES_READ
+--echo # - increased COUNT_WRITE leads to increased
+--echo # SUM_NUMBER_OF_BYTES_WRITE
+--echo # Attention:
+--echo # The time required for some action might be below timer resolution.
+--echo # Therefore some increased COUNT_* does not need to lead to an
+--echo # increased SUM_TIMER_*.
+#==========================================================================
+# Enable the following lines for debugging the check.
+# Attention: socket_summary_by_instance_detail is after that rotten.
+if(0)
+{
+ --enable_info
+ UPDATE mysqltest.socket_summary_by_instance_detail
+ SET SUM_TIMER_MISC = 13, COUNT_MISC = 0
+ WHERE statement LIKE '%WHERE col1 = 3'
+ AND EVENT_NAME LIKE '%client_connection'
+ AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ LIMIT 1;
+ --disable_info
+}
+
+let $my_rules=
+((COUNT_READ = 0 AND SUM_TIMER_READ = 0 AND SUM_NUMBER_OF_BYTES_READ = 0)
+ OR
+ (COUNT_READ > 0 AND SUM_NUMBER_OF_BYTES_READ > 0))
+AND
+((COUNT_WRITE = 0 AND SUM_TIMER_WRITE = 0 AND SUM_NUMBER_OF_BYTES_WRITE = 0)
+ OR
+ (COUNT_WRITE > 0 AND SUM_NUMBER_OF_BYTES_WRITE > 0))
+AND
+((COUNT_MISC = 0 AND SUM_TIMER_MISC = 0)
+ OR
+(COUNT_MISC > 0));
+if(`SELECT COUNT(*) FROM mysqltest.socket_summary_by_instance_detail
+ WHERE NOT ( $my_rules ) `)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo #
+ eval
+ SELECT
+ $column_list
+ FROM mysqltest.socket_summary_by_instance_detail
+ WHERE NOT ( $my_rules )
+ ORDER BY EVENT_NAME, OBJECT_INSTANCE, STATEMENT, RUN;
+ let $print_details= 1;
+}
+
+--echo # 4.2 Results must be stable
+#==========================================================================
+# Enable the following lines for debugging the check.
+# Attention: socket_summary_by_instance_detail is after that rotten.
+if(0)
+{
+ --enable_info
+ UPDATE mysqltest.socket_summary_by_instance_detail
+ SET COUNT_WRITE = 13
+ WHERE statement LIKE '%WHERE col1 = 3'
+ AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND EVENT_NAME LIKE '%client_connection'
+ LIMIT 1;
+ --disable_info
+}
+
+# eval
+# SELECT
+# $column_list
+# FROM mysqltest.socket_summary_by_instance_detail
+# WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+# ORDER BY EVENT_NAME, statement,run;
+
+# In case we are able to wait all time till perfschema has finished the
+# maintenance of counters than the following must be valid.
+let $my_rules=
+COUNT(DISTINCT SUM_NUMBER_OF_BYTES_READ) = 1 AND
+COUNT(DISTINCT COUNT_WRITE) = 1 AND
+COUNT(DISTINCT SUM_NUMBER_OF_BYTES_WRITE) = 1;
+
+# In case we do not get the results somehow deterministic than we
+# we should go with the less strict check based on CV.
+#
+# Compute coefficient of variation (CV) to detect 'notable' variances in the
+# byte count and operation counts. The acceptable range for the CV is purely
+# subjective, however, the CV is a dimensionless quantity therefore valid
+# across platforms.
+# let $my_rules=
+# STD(COUNT_READ)/AVG(COUNT_READ) <= 0.2 AND
+# STD(SUM_NUMBER_OF_BYTES_READ)/AVG(SUM_NUMBER_OF_BYTES_READ) <= 0.2 AND
+# STD(COUNT_WRITE)/AVG(COUNT_WRITE) <= 0.2 AND
+# STD(SUM_NUMBER_OF_BYTES_WRITE)/AVG(SUM_NUMBER_OF_BYTES_WRITE) <= 0.2 AND
+# STD(COUNT_MISC)/AVG(COUNT_MISC) <= 0.4;
+
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail
+WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+GROUP BY EVENT_NAME, statement
+HAVING NOT ($my_rules) ;
+if(`SELECT COUNT(statement) $part`)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo # for GROUP BY EVENT_NAME, statement
+ eval
+ SELECT $column_list
+ FROM mysqltest.socket_summary_by_instance_detail
+ WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND (EVENT_NAME, statement)
+ IN (SELECT EVENT_NAME, statement
+ $part)
+ ORDER BY EVENT_NAME, statement, run, OBJECT_INSTANCE_BEGIN;
+ let $print_details= 1;
+}
+
+--echo # 4.3 Counters must be 0 in client_connection for the default session
+--echo # Instrumenting is disabled since a long time and the counter were
+--echo # reset via TRUNCATE just after the disabling.
+#==========================================================================
+let $my_rules=
+COUNT_STAR = 0 AND SUM_TIMER_WAIT = 0
+AND
+COUNT_READ = 0 AND SUM_TIMER_READ = 0 AND SUM_NUMBER_OF_BYTES_READ = 0
+AND
+COUNT_WRITE = 0 AND SUM_TIMER_WRITE = 0 AND SUM_NUMBER_OF_BYTES_WRITE = 0
+AND
+COUNT_MISC = 0 AND SUM_TIMER_MISC = 0;
+if(`SELECT COUNT(*) FROM performance_schema.socket_summary_by_instance
+ WHERE NOT ( $my_rules )
+ AND OBJECT_INSTANCE_BEGIN = @default_object_instance_begin`)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo #
+ # Attention: We use here performance_schema.socket_summary_by_instance
+ # and not mysqltest.socket_summary_by_instance_detail.
+ # Therefore the convenient $column_list cannot be used.
+ eval
+ SELECT
+ COUNT_STAR, SUM_TIMER_WAIT,
+ COUNT_READ,SUM_TIMER_READ,SUM_NUMBER_OF_BYTES_READ,
+ COUNT_WRITE,SUM_TIMER_WRITE,SUM_NUMBER_OF_BYTES_WRITE,
+ COUNT_MISC,SUM_TIMER_MISC
+ FROM performance_schema.socket_summary_by_instance
+ WHERE OBJECT_INSTANCE_BEGIN = @default_object_instance_begin;
+ let $print_details= 1;
+}
+
+#---------------------------------------------------------------------------
+
+--echo # 4.4 Check the differences caused by SQL statements
+--echo # 4.4.1 There must be no changes in counters of instances
+--echo # NOT LIKE '%client_connection' because everything gets charged
+--echo # into client_connection of the acting connection.
+#===========================================================================
+# Enable the following lines for debugging the check.
+# Attention: socket_summary_by_instance_detail is after that rotten.
+if(0)
+{
+ --enable_info
+ UPDATE mysqltest.socket_summary_by_instance_detail
+ SET COUNT_WRITE = 13
+ WHERE statement LIKE '%WHERE col1 = 3'
+ AND EVENT_NAME NOT LIKE '%client_connection'
+ LIMIT 1;
+ --disable_info
+}
+
+let $my_rules=
+COUNT_READ = 0 AND SUM_TIMER_READ = 0 AND SUM_NUMBER_OF_BYTES_READ = 0
+AND
+COUNT_WRITE = 0 AND SUM_TIMER_WRITE = 0 AND SUM_NUMBER_OF_BYTES_WRITE = 0
+AND
+COUNT_MISC = 0 AND SUM_TIMER_MISC = 0;
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail
+ WHERE NOT ( $my_rules )
+ AND EVENT_NAME NOT LIKE '%client_connection'
+ AND statement NOT LIKE 'Connect%';
+if(`SELECT COUNT(*) $part`)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo #
+ eval
+ SELECT
+ $column_list
+ $part
+ ORDER BY EVENT_NAME, OBJECT_INSTANCE_BEGIN, statement, run;
+ let $print_details= 1;
+}
+
+--echo # 4.4.2 In case of SELECT and our scenarios even COUNT_READ and COUNT_MISC
+--echo # are stable.
+#===========================================================================
+# Enable the following lines for debugging the check.
+# Attention: socket_summary_by_instance_detail is after that rotten.
+if(0)
+{
+ --enable_info
+ UPDATE mysqltest.socket_summary_by_instance_detail
+ SET COUNT_READ = 13
+ WHERE statement LIKE '%WHERE col1 = 3'
+ LIMIT 1;
+ --disable_info
+}
+
+let $my_rules=
+COUNT(DISTINCT COUNT_READ) = 1 AND
+COUNT(DISTINCT COUNT_MISC) = 1;
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail
+WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND statement NOT LIKE '%Connect%'
+GROUP BY EVENT_NAME, statement
+HAVING NOT ($my_rules) ;
+if(`SELECT COUNT(statement) $part`)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo # for GROUP BY EVENT_NAME, statement
+ eval
+ SELECT $column_list
+ FROM mysqltest.socket_summary_by_instance_detail
+ WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND (EVENT_NAME, statement)
+ IN (SELECT EVENT_NAME, statement
+ $part)
+ ORDER BY EVENT_NAME, statement, run, OBJECT_INSTANCE_BEGIN;
+ let $print_details= 1;
+}
+
+--echo # 4.4.3 In our testing scenarios we get for the client_connection entry
+--echo # of the acting connection
+--echo # -> OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+--echo # COUNT_MISC = 0 AND SUM_TIMER_MISC = 0
+--echo # SKIPPED FOR WINDOWS
+#===========================================================================
+# Enable the following lines for debugging the check.
+# Attention: socket_summary_by_instance_detail is after that rotten.
+if(0)
+{
+ --enable_info
+ UPDATE mysqltest.socket_summary_by_instance_detail
+ SET COUNT_MISC = 13
+ WHERE statement LIKE '%WHERE col1 = 3'
+ AND EVENT_NAME LIKE '%client_connection'
+ AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ LIMIT 1;
+ --disable_info
+}
+
+let $my_rules=
+COUNT_MISC = 0 AND SUM_TIMER_MISC = 0;
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail
+WHERE NOT ( $my_rules )
+ AND EVENT_NAME LIKE '%client_connection'
+ AND statement NOT LIKE 'Connect%'
+ AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin;
+#if(`SELECT COUNT(*) $part`)
+if (0)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo #
+ eval
+ SELECT
+ $column_list
+ $part
+ ORDER BY EVENT_NAME, OBJECT_INSTANCE_BEGIN, statement, run;
+ let $print_details= 1;
+}
+
+# Initialize variables
+let $my_rules= my_rules_not_set;
+let $stmt1= stmt1_not_set;
+let $stmt2= stmt2_not_set;
+# $title_prefix is used for the generation of titles
+let $title_prefix= 4.4;
+# $check_num is used for the generation of titles and gets incremented after
+# every call of the current script.
+let $check_num= 4;
+# $column_list is used for the generation of error information and valid for
+# every sub test.
+let $diff_column_list=
+t2.COUNT_READ - t1.COUNT_READ AS D_COUNT_READ,
+t2.COUNT_READ AS S2_COUNT_READ,
+t1.COUNT_READ AS S1_COUNT_READ,
+t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ AS D_SUM_NUMBER_OF_BYTES_READ,
+t2.SUM_NUMBER_OF_BYTES_READ AS S2_SUM_NUMBER_OF_BYTES_READ,
+t1.SUM_NUMBER_OF_BYTES_READ AS S1_SUM_NUMBER_OF_BYTES_READ,
+t2.COUNT_WRITE - t1.COUNT_WRITE AS D_COUNT_WRITE,
+t2.COUNT_WRITE AS S2_COUNT_WRITE,
+t1.COUNT_WRITE AS S1_COUNT_WRITE,
+t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE AS D_SUM_NUMBER_OF_BYTES_WRITE,
+t2.SUM_NUMBER_OF_BYTES_WRITE AS S2_SUM_NUMBER_OF_BYTES_WRITE,
+t1.SUM_NUMBER_OF_BYTES_WRITE AS S1_SUM_NUMBER_OF_BYTES_WRITE,
+t2.COUNT_MISC - t1.COUNT_MISC AS D_COUNT_MISC,
+t2.COUNT_MISC AS S2_COUNT_MISC,
+t1.COUNT_MISC AS S1_COUNT_MISC;
+# $part is used for the generation of "check" statements + error information
+# and valid for every sub test.
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail t1
+JOIN mysqltest.socket_summary_by_instance_detail t2
+USING (EVENT_NAME, OBJECT_INSTANCE_BEGIN, run)
+WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND EVENT_NAME LIKE ('%client_connection')
+ AND run = 1;
+
+--echo # Check the differences between changes caused by SQL statements
+--echo # These differences must correspond to parameters like
+--echo # - statement, table name or column name length
+--echo # - number of rows in result set, size of rows in result set etc.
+# --> Statement NOT LIKE '%Connect%'
+
+let stmt1= SELECT col2 FROM does_not_exist;
+let stmt2= SELECT col2 FROM does_not_exist WHERE col1 = 0;
+#
+# CNT_READ BYTES_READ CNT_WRITE BYTES_WRITE CNT_MISC statement
+# 3 36 1 59 1 SELECT col2 FROM does_not_exist
+# 3 51 1 59 1 SELECT col2 FROM does_not_exist WHERE col1 = 0
+# The string of the statement gets charged into SUM_NUMBER_OF_BYTES_READ.
+# The server error message gets charged into SUM_NUMBER_OF_BYTES_WRITE.
+let $msg=
+# One statement is longer than the other.
+# Both statements fail with the same error message (table does not exist);
+#
+let $my_rules=
+t2.COUNT_READ - t1.COUNT_READ = 0 AND
+t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt2') - LENGTH('$stmt1') AND
+t2.COUNT_WRITE - t1.COUNT_WRITE = 0 AND
+t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE = 0 AND
+t2.COUNT_MISC - t1.COUNT_MISC = 0;
+--source ../include/socket_check1.inc
+
+let $stmt1= SELECT col2 FROM does_not_exist WHERE col1 = 0;
+let $stmt2= SELECT col2 FROM does_not_exist WHERE col1 A 0;
+#
+# CNT_READ BYTES_READ CNT_WRITE BYTES_WRITE CNT_MISC statement
+# 3 51 1 59 1 SELECT col2 FROM does_not_exist WHERE col1 = 0
+# 3 51 1 162 1 SELECT col2 FROM does_not_exist WHERE col1 A 0
+let $msg=
+# Both statements have the same length and fail.
+# The length of the error messages differs.;
+let $my_rules=
+t2.COUNT_READ - t1.COUNT_READ = 0 AND
+t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt2') - LENGTH('$stmt1') AND
+t2.COUNT_WRITE - t1.COUNT_WRITE = 0 AND
+t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE > 0 AND
+t2.COUNT_MISC - t1.COUNT_MISC = 0;
+--source ../include/socket_check1.inc
+
+let $stmt1= SELECT col2 FROM does_not_exist;
+let $stmt2= SELECT col2 FROM does_not_exist0123;
+# CNT_READ BYTES_READ CNT_WRITE BYTES_WRITE CNT_MISC statement
+# 3 36 1 59 1 SELECT col2 FROM does_not_exist
+# 3 40 1 63 1 SELECT col2 FROM does_not_exist0123
+let $msg=
+# Both statements fail (table does not exist).
+# The length of the statement and the length of the error messages differs.
+# Reason for both differences is the length of the table name.;
+let $my_rules=
+t2.COUNT_READ - t1.COUNT_READ = 0 AND
+t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt2') - LENGTH('$stmt1') AND
+t2.COUNT_WRITE - t1.COUNT_WRITE = 0 AND
+t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE = LENGTH('$stmt2') - LENGTH('$stmt1') AND
+t2.COUNT_MISC - t1.COUNT_MISC = 0;
+--source ../include/socket_check1.inc
+
+# Assuming that some new check should be added.
+# How to enforce that a lot info is printed so that it becomes easy to derive
+# the right value for $my_rules?
+#----------------------------------------------------------------------------
+# let $my_rules= 0;
+# This will cause that suite/perfschema/include/socket_check1.inc concludes that
+# the check via $my_rules failed and it will print debug information.
+# let $stmt1= SELECT col2 FROM does_not_exist WHERE col1 = 0;
+# let $stmt2= SELECT col2 FROM does_not_exist WHERE col1 A 0;
+# let $my_rules= 0;
+# --source ../include/socket_check1.inc
+
+let $stmt2= SELECT col2 AS my_super_col FROM mysqltest.my_aux WHERE col1 = -1;
+let $stmt1= SELECT col2 FROM mysqltest.my_aux WHERE col1 = -1;
+#
+# CNT_READ BYTES_READ CNT_WRITE BYTES_WRITE CNT_MISC statement
+# 3 54 1 78 1 SELECT col2 FROM mysqltest.my_aux WHERE col1 = -1
+# 3 70 1 86 1 SELECT col2 AS my_super_col FROM mysqltest.my_aux WHERE col1 = -1
+let $msg=
+# Both statements get an empty result set.
+# The length of the statements and the length of the result sets differs.
+# Reason for both differences is the length of the some column name.;
+let $my_rules=
+t2.COUNT_READ - t1.COUNT_READ = 0 AND
+t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt2') - LENGTH('$stmt1') AND
+t2.COUNT_WRITE - t1.COUNT_WRITE = 0 AND
+t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE = LENGTH('my_super_col') - LENGTH('col2') AND
+t2.COUNT_MISC - t1.COUNT_MISC = 0;
+--source ../include/socket_check1.inc
+
+let $stmt2= SELECT col2 FROM mysqltest.my_aux WHERE col1 = 1;
+let $stmt1= SELECT col2 FROM mysqltest.my_aux WHERE col1 = -1;
+#
+# CNT_READ BYTES_READ CNT_WRITE BYTES_WRITE CNT_MISC statement
+# t1 3 54 1 78 1 SELECT col2 FROM mysqltest.my_aux WHERE col1 = -1
+# t2 3 53 1 83 1 SELECT col2 FROM mysqltest.my_aux WHERE col1 = 1
+let $msg=
+# Both statements differ in the statement length.
+# One statement earns an empty result set.
+# The other statement earns one row containing an empty string.;
+let $my_rules=
+t2.COUNT_READ - t1.COUNT_READ = 0 AND
+t1.SUM_NUMBER_OF_BYTES_READ - t2.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt1') - LENGTH('$stmt2') AND
+t2.COUNT_WRITE - t1.COUNT_WRITE = 0 AND
+t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE > 0 AND
+t2.COUNT_MISC - t1.COUNT_MISC = 0;
+--source ../include/socket_check1.inc
+
+let $stmt2= SELECT col2 FROM mysqltest.my_aux WHERE col1 = 2;
+let $stmt1= SELECT col2 FROM mysqltest.my_aux WHERE col1 = 1;
+#
+# CNT_READ BYTES_READ CNT_WRITE BYTES_WRITE CNT_MISC statement
+# 3 53 1 83 1 SELECT col2 FROM mysqltest.my_aux WHERE col1 = 1
+# 3 53 1 84 1 SELECT col2 FROM mysqltest.my_aux WHERE col1 = 2
+let $msg=
+# Both statements have the same length.
+# One statement earns an one row containing an empty string.
+# The other statement earns one row containing a string 1 byte long.;
+let $my_rules=
+t2.COUNT_READ - t1.COUNT_READ = 0 AND
+t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt2') - LENGTH('$stmt1') AND
+t2.COUNT_WRITE - t1.COUNT_WRITE = 0 AND
+t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE = 1 AND
+t2.COUNT_MISC - t1.COUNT_MISC = 0;
+--source ../include/socket_check1.inc
+
+let $stmt2= SELECT col2 FROM mysqltest.my_aux WHERE col1 = 3;
+let $stmt1= SELECT col2 FROM mysqltest.my_aux WHERE col1 = 1;
+#
+# CNT_READ BYTES_READ CNT_WRITE BYTES_WRITE CNT_MISC statement
+# 3 53 1 83 1 SELECT col2 FROM mysqltest.my_aux WHERE col1 = 1
+# 3 53 1 1109 1 SELECT col2 FROM mysqltest.my_aux WHERE col1 = 3
+let $msg=
+# Both statements have the same length.
+# One statement earns an one row containing an empty string.
+# The other statement earns one row containing a string 1024 byte long.;
+let $my_rules=
+t2.COUNT_READ - t1.COUNT_READ = 0 AND
+t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt2') - LENGTH('$stmt1') AND
+t2.COUNT_WRITE - t1.COUNT_WRITE = 0 AND
+t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE >= 1024 AND
+t2.COUNT_MISC - t1.COUNT_MISC = 0;
+--source ../include/socket_check1.inc
+
+let $stmt2= SELECT col2 FROM mysqltest.my_aux WHERE col1 < 2;
+let $stmt1= SELECT col2 FROM mysqltest.my_aux WHERE col1 = 1;
+#
+# CNT_READ BYTES_READ CNT_WRITE BYTES_WRITE CNT_MISC statement
+# t1 3 53 1 83 1 SELECT col2 FROM mysqltest.my_aux WHERE col1 = 1
+# t2 3 53 1 88 1 SELECT col2 FROM mysqltest.my_aux WHERE col1 < 2
+let $msg=
+# Both statements have the same length.
+# One statement earns an one row containing an empty string.
+# The other statement earns two rows containing an empty string.;
+let $my_rules=
+t2.COUNT_READ - t1.COUNT_READ = 0 AND
+t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt2') - LENGTH('$stmt1') AND
+t2.COUNT_WRITE - t1.COUNT_WRITE = 0 AND
+t2.SUM_NUMBER_OF_BYTES_WRITE - t1.SUM_NUMBER_OF_BYTES_WRITE > 0 AND
+t2.COUNT_MISC - t1.COUNT_MISC = 0;
+--source ../include/socket_check1.inc
+
+--echo # 4.5 Check the differences caused by Connects
+--echo # Attention: Succesful Connects run an additional "DO 1".
+--echo # 4.5.1 Connects do not charge anything into READ or WRITE counters
+--echo # of the instance with EVENT_NAME NOT LIKE ('%client_connection%').
+--echo # This mean all these counters must be 0.
+let $my_rules=
+COUNT_READ = 0 AND SUM_TIMER_READ = 0 AND SUM_NUMBER_OF_BYTES_READ = 0 AND
+COUNT_WRITE = 0 AND SUM_TIMER_WRITE = 0 AND SUM_NUMBER_OF_BYTES_WRITE = 0;
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail
+WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND statement LIKE ('%Connect%')
+ AND EVENT_NAME NOT LIKE ('%client_connection%')
+ AND NOT ( $my_rules );
+if(`SELECT COUNT(*) $part `)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo #
+ eval
+ SELECT
+ $column_list
+ $part;
+ let $print_details= 1;
+}
+
+--echo # 4.5.2 Connects using for host the value 'localhost'
+--echo # 4.5.2.1 For the instance with EVENT_NAME LIKE '%server_tcpip_socket'
+--echo # COUNT_MISC = 0 AND SUM_TIMER_MISC = 0 must be valid
+--echo # because we run through server_unix_socket.
+#===========================================================================
+# Enable the following lines for debugging the check.
+# Attention: socket_summary_by_instance_detail is after that rotten.
+if(0)
+{
+ --enable_info
+ UPDATE mysqltest.socket_summary_by_instance_detail
+ SET COUNT_MISC = 13
+ WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND statement LIKE ('%Connect%localhost%')
+ AND EVENT_NAME LIKE ('%server_tcpip_socket%')
+ LIMIT 1;
+ --disable_info
+}
+
+let $my_rules=
+COUNT_MISC = 0 AND SUM_TIMER_MISC = 0;
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail
+WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND statement LIKE ('%Connect%localhost%')
+ AND EVENT_NAME LIKE ('%server_tcpip_socket%')
+ AND NOT ( $my_rules );
+#if(`SELECT COUNT(*) $part `)
+# DISABLED FOR WINDOWS
+if (0)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo #
+ eval
+ SELECT
+ $column_list
+ $part;
+ let $print_details= 1;
+}
+
+--echo # 4.5.2.2 For the instance with EVENT_NAME LIKE '%server_unix_socket'
+--echo # COUNT_MISC > 0 must be valid.
+--echo # SKIPPED FOR WINDOWS
+#===========================================================================
+# Enable the following lines for debugging the check.
+# Attention: socket_summary_by_instance_detail is after that rotten.
+if(0)
+{
+ --enable_info
+ UPDATE mysqltest.socket_summary_by_instance_detail
+ SET COUNT_MISC = 0
+ WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND statement LIKE ('%Connect%localhost%')
+ AND EVENT_NAME LIKE ('%server_unix_socket%')
+ LIMIT 1;
+ --disable_info
+}
+
+let $my_rules=
+COUNT_MISC > 0;
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail
+WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND statement LIKE ('%Connect%localhost%')
+ AND EVENT_NAME LIKE ('%server_unix_socket%')
+ AND NOT ( $my_rules );
+#if(`SELECT COUNT(*) $part `)
+if (0)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo #
+ eval
+ SELECT
+ $column_list
+ $part;
+ let $print_details= 1;
+}
+
+--echo # 4.5.3 Connects using for host a value <> 'localhost'
+--echo # 4.5.3.1 For the instance with EVENT_NAME LIKE '%server_unix_socket'
+--echo # COUNT_MISC = 0 AND SUM_TIMER_MISC = 0 must be valid
+--echo # because we run through server_tcpip_socket.
+--echo # SKIPPED FOR WINDOWS
+#===========================================================================
+# Enable the following lines for debugging the check.
+# Attention: socket_summary_by_instance_detail is after that rotten.
+if(0)
+{
+ --enable_info
+ eval
+ UPDATE mysqltest.socket_summary_by_instance_detail
+ SET COUNT_MISC = 13
+ WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND EVENT_NAME LIKE ('%server_unix_socket%')
+ AND statement LIKE ('%Connect%$my_localhost%')
+ LIMIT 1;
+ --disable_info
+}
+
+let $my_rules=
+COUNT_MISC = 0 AND SUM_TIMER_MISC = 0;
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail
+WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND statement LIKE ('%Connect%$my_localhost%')
+ AND EVENT_NAME LIKE ('%server_unix_socket%')
+ AND NOT ( $my_rules );
+#if(`SELECT COUNT(*) $part `)
+if (0)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo #
+ eval
+ SELECT
+ $column_list
+ $part;
+ let $print_details= 1;
+}
+
+--echo # 4.5.3.2 For the instance with EVENT_NAME LIKE '%server_tcpip_socket'
+--echo # COUNT_MISC > 0 must be valid.
+#===========================================================================
+# Enable the following lines for debugging the check.
+# Attention: socket_summary_by_instance_detail is after that rotten.
+if(0)
+{
+ --enable_info
+ eval
+ UPDATE mysqltest.socket_summary_by_instance_detail
+ SET COUNT_MISC = 0
+ WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND statement LIKE ('%Connect%$my_localhost%')
+ AND EVENT_NAME LIKE ('%server_tcpip_socket%')
+ LIMIT 1;
+ --disable_info
+}
+
+let $my_rules=
+COUNT_MISC > 0;
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail
+WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND statement LIKE ('%Connect%$my_localhost%')
+ AND EVENT_NAME LIKE ('%server_tcpip_socket%')
+ AND NOT ( $my_rules );
+if(`SELECT COUNT(*) $part `)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo #
+ eval
+ SELECT
+ $column_list
+ $part;
+ let $print_details= 1;
+}
+
+--echo # 4.5.4 Failing Connects do not cause any row with EVENT_NAME
+--echo # LIKE '%client_connection'
+#===========================================================================
+# Enable the following lines for debugging the check.
+# Attention: socket_summary_by_instance_detail is after that rotten.
+if(0)
+{
+ --enable_info
+ eval
+ UPDATE mysqltest.socket_summary_by_instance_detail
+ SET statement = 'Connect boot '
+ WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND statement LIKE ('Connect%root%')
+ AND EVENT_NAME LIKE ('%client_connection')
+ LIMIT 1;
+ --disable_info
+}
+
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail
+WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND statement LIKE ('Connect%boot%')
+ AND EVENT_NAME LIKE ('%client_connection');
+if(`SELECT COUNT(*) $part`)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect that there are no rows because
+ --echo # - failing connects do not cause a row with "client_connection"
+ --echo # - all failing connects contain a user name LIKE '%boot%'
+ eval
+ SELECT
+ $column_list
+ $part;
+ let $print_details= 1;
+}
+
+--echo # 4.5.5 Successful Connects cause a new instance with EVENT_NAME
+--echo # LIKE '%client_connection'
+#===========================================================================
+# Enable the following lines for debugging the check.
+# Attention: socket_summary_by_instance_detail is after that rotten.
+if(0)
+{
+ --enable_info
+ DELETE
+ FROM mysqltest.socket_summary_by_instance_detail
+ WHERE EVENT_NAME LIKE ('%client_connection')
+ AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND statement LIKE ('Connect%root%')
+ LIMIT 1;
+ --disable_info
+}
+
+# - connects which should be successful have statement LIKE ('Connect%root%').
+# - We try every type of Connect $loop_rounds times.
+# Therefore we should find $loop_rounds rows with
+# - EVENT_NAME LIKE ('%client_connection')
+# AND
+# - OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+# We do not want to count the entry of belonging to the default connection.
+# AND
+# - statement LIKE ('Connect%root%')
+# The connects which should be successful.
+#
+let $my_rules=
+COUNT(*) = $loop_rounds;
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail
+WHERE EVENT_NAME LIKE ('%client_connection')
+ AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND statement LIKE ('Connect%root%')
+GROUP BY statement
+HAVING NOT ( $my_rules );
+
+if(`SELECT COUNT(*) $part`)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo # for GROUP BY statement
+ --echo #
+ eval
+ SELECT
+ $column_list
+ FROM mysqltest.socket_summary_by_instance_detail
+ WHERE EVENT_NAME LIKE ('%client_connection')
+ AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND statement IN
+ (SELECT statement
+ $part);
+ let $print_details= 1;
+}
+
+--echo # 4.6 Check the differences caused by Connects
+--echo # - INSTANCES with an EVENT_NAME like server_tcpip_socket or
+--echo # server_unix_socket are already checked
+--echo # - the stability of results is already checked
+--echo # So we con go with the results of the first run.
+
+# Typical content of mysqltest.socket_summary_by_instance_detail
+#
+# eval
+# SELECT $column_list
+# FROM mysqltest.socket_summary_by_instance_detail
+# WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+# AND EVENT_NAME LIKE ('%client_connection')
+# AND statement LIKE ('Connect%')
+# AND run = 1
+# ORDER BY event_name,statement, run;
+# CREAD TREAD BREAD CWRITE TWRITE BWRITE CMISC TMISC STATEMENT
+# 4 6149616 79 3 34008480 117 3 38914128 Connect (con*,::ffff:127.0.0.1,root,,mysqltest,,)
+# 4 7012368 84 3 10112256 117 2 43067376 Connect (con*,localhost,root,,mysqlsupertest,,)
+# 4 7172880 79 3 10247688 117 2 40128000 Connect (con*,localhost,root,,mysqltest,,)
+# 4 6706392 85 3 15509472 117 2 34851168 Connect (con*,localhost,root012345,,mysqltest,,)
+# 4 10543632 89 3 10578744 117 2 39460872 Connect (con*,localhost,root0123456789,,mysqltest,,)
+
+--echo # 4.6.1 The SUM_OF_BYTES_WRITE value depends on length of database
+--echo # since the database name is written in OK packet.
+--echo # Hence the value 2.
+#========================================================================
+let $my_rules= COUNT(DISTINCT SUM_NUMBER_OF_BYTES_WRITE) = 2;
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail
+WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND EVENT_NAME LIKE ('%client_connection')
+ AND statement LIKE ('Connect%')
+ AND run = 1;
+if(`SELECT NOT ( $my_rules) $part`)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo # for all Connects
+ --echo #
+ eval
+ SELECT
+ statement, SUM_NUMBER_OF_BYTES_WRITE
+ $part;
+ let $print_details= 1;
+}
+
+--echo # 4.6.2 The SUM_OF_BYTES_WRITE value hast to be > 100.
+#============================================================
+let $my_rules= SUM_NUMBER_OF_BYTES_WRITE > 100;
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail
+WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND EVENT_NAME LIKE ('%client_connection')
+ AND statement LIKE ('Connect%')
+ AND NOT ( $my_rules )
+ AND run = 1;
+if(`SELECT COUNT(*) $part`)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo # for all Connects
+ --echo #
+ eval
+ SELECT
+ statement, SUM_NUMBER_OF_BYTES_WRITE
+ $part;
+ let $print_details= 1;
+}
+
+--echo # 4.6.3 COUNT_READ, COUNT_WRITE and COUNT_MISC have to be to be > 0
+#=========================================================================
+let $my_rules=
+COUNT_READ > 0 AND COUNT_WRITE > 0 AND COUNT_MISC > 0;
+let $part=
+FROM mysqltest.socket_summary_by_instance_detail
+WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND EVENT_NAME LIKE ('%client_connection')
+ AND statement LIKE ('Connect%')
+ AND NOT ( $my_rules )
+ AND run = 1;
+if(`SELECT COUNT(*) $part`)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo # for all Connects
+ --echo #
+ eval
+ SELECT
+ statement, COUNT_READ, COUNT_WRITE, COUNT_MISC
+ $part;
+ let $print_details= 1;
+}
+
+--echo # 4.6.4 Checks based on comparison of results for connects
+let $part0=
+FROM mysqltest.socket_summary_by_instance_detail t1
+JOIN mysqltest.socket_summary_by_instance_detail t2
+USING (EVENT_NAME, run)
+WHERE EVENT_NAME LIKE ('%client_connection')
+ AND run = 1
+ AND t2.OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND t1.OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin;
+let $part1=
+SELECT RPAD(statement,55,' ') AS STATEMENT,
+ LENGTH(statement), SUM_NUMBER_OF_BYTES_READ
+FROM mysqltest.socket_summary_by_instance_detail
+WHERE OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ AND EVENT_NAME LIKE ('%client_connection')
+ AND run = 1;
+
+
+--echo # 4.6.4 The user name length affects the SUM_OF_BYTES_READ value
+#======================================================================
+# CREAD TREAD BREAD CWRITE TWRITE BWRITE CMISC TMISC STATEMENT
+# 4 6706392 85 3 15509472 117 2 34851168 Connect (con*,localhost,root012345,,mysqltest,,)
+# 4 10543632 89 3 10578744 117 2 39460872 Connect (con*,localhost,root0123456789,,mysqltest,,)
+let $stmt2= Connect (con*,localhost,root0123456789,,mysqltest,,);
+let $stmt1= Connect (con*,localhost,root012345,,mysqltest,,);
+let $my_rules=
+t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt2') - LENGTH('$stmt1');
+if(`SELECT NOT ($my_rules)
+ $part0
+ AND t2.statement = '$stmt2'
+ AND t1.statement = '$stmt1'`)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo #
+ eval
+ $part1
+ AND statement IN('$stmt2','$stmt1');
+ let $print_details= 1;
+}
+
+--echo # 4.6.5 The database name length affects the SUM_OF_BYTES_READ value
+#==========================================================================
+# CREAD TREAD BREAD CWRITE TWRITE BWRITE CMISC TMISC STATEMENT
+# 4 7012368 84 3 10112256 117 2 43067376 Connect (con*,localhost,root,,mysqlsupertest,,)
+# 4 7172880 79 3 10247688 117 2 40128000 Connect (con*,localhost,root,,mysqltest,,)
+let $stmt2= Connect (con*,localhost,root,,mysqlsupertest,,);
+let $stmt1= Connect (con*,localhost,root,,mysqltest,,);
+let $my_rules=
+t2.SUM_NUMBER_OF_BYTES_READ - t1.SUM_NUMBER_OF_BYTES_READ = LENGTH('$stmt2') - LENGTH('$stmt1');
+if(`SELECT NOT ($my_rules)
+ $part0
+ AND t2.statement = '$stmt2'
+ AND t1.statement = '$stmt1'`)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo #
+ eval
+ $part1
+ AND statement IN('$stmt2','$stmt1');
+ let $print_details= 1;
+}
+
+--echo # 5. Check the impact of TRUNCATE on socket_summary_by_instance.
+--echo # It must reset all counters.
+#=======================================================================
+# We do not need to check if the majority of counters is <> 0 because if
+# we ever hit such a bad state than a lot of the preceding checks would
+# have already failed and reported this.
+TRUNCATE TABLE performance_schema.socket_summary_by_instance;
+let $my_rules=
+COUNT_STAR = 0 AND SUM_TIMER_WAIT = 0
+AND
+COUNT_READ = 0 AND SUM_TIMER_READ = 0 AND SUM_NUMBER_OF_BYTES_READ = 0
+AND
+COUNT_WRITE = 0 AND SUM_TIMER_WRITE = 0 AND SUM_NUMBER_OF_BYTES_WRITE = 0
+AND
+COUNT_MISC = 0 AND SUM_TIMER_MISC = 0;
+if(`SELECT COUNT(*) FROM performance_schema.socket_summary_by_instance
+ WHERE NOT ( $my_rules )
+ AND OBJECT_INSTANCE_BEGIN = @default_object_instance_begin`)
+{
+ --enable_query_log
+ --enable_result_log
+ --echo # The statistics looks suspicious.
+ --echo # We expect
+ --echo # $my_rules
+ --echo #
+ eval
+ SELECT
+ COUNT_STAR, SUM_TIMER_WAIT,
+ COUNT_READ,SUM_TIMER_READ,SUM_NUMBER_OF_BYTES_READ,
+ COUNT_WRITE,SUM_TIMER_WRITE,SUM_NUMBER_OF_BYTES_WRITE,
+ COUNT_MISC,SUM_TIMER_MISC
+ FROM performance_schema.socket_summary_by_instance
+ WHERE OBJECT_INSTANCE_BEGIN = @default_object_instance_begin;
+}
+
+
+if($print_details)
+{
+ --enable_query_log
+ --enable_result_log
+ --horizontal_results
+ --echo # Dump detailed differences after - before statement execution
+ --echo # 1. The statement executing connection and hopefully no one else
+ SELECT @default_object_instance_begin;
+ SELECT EVENT_NAME, OBJECT_INSTANCE_BEGIN,
+ COUNT_READ, SUM_NUMBER_OF_BYTES_READ,
+ COUNT_WRITE, SUM_NUMBER_OF_BYTES_WRITE,
+ COUNT_MISC, statement
+ FROM mysqltest.socket_summary_by_instance_detail
+ WHERE EVENT_NAME LIKE '%client_connection%'
+ AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
+ ORDER BY statement, run;
+ --echo # 2. The connection default
+ SELECT EVENT_NAME,
+ COUNT_READ, SUM_NUMBER_OF_BYTES_READ,
+ COUNT_WRITE, SUM_NUMBER_OF_BYTES_WRITE,
+ COUNT_MISC, statement
+ FROM mysqltest.socket_summary_by_instance_detail
+ WHERE OBJECT_INSTANCE_BEGIN = @default_object_instance_begin
+ ORDER BY statement,run;
+ --echo # 3. The "server_unix_socket"
+ # WHERE OBJECT_INSTANCE_BEGIN = @default_object_instance_begin
+ SELECT EVENT_NAME,
+ COUNT_READ, SUM_NUMBER_OF_BYTES_READ,
+ COUNT_WRITE, SUM_NUMBER_OF_BYTES_WRITE,
+ COUNT_MISC, statement
+ FROM mysqltest.socket_summary_by_instance_detail
+ WHERE EVENT_NAME LIKE '%server_unix_socket%'
+ ORDER BY statement,run;
+ --echo # 4. The "server_tcpip_socket"
+ SELECT EVENT_NAME,
+ COUNT_READ, SUM_NUMBER_OF_BYTES_READ,
+ COUNT_WRITE, SUM_NUMBER_OF_BYTES_WRITE,
+ COUNT_MISC, statement
+ FROM mysqltest.socket_summary_by_instance_detail
+ WHERE EVENT_NAME LIKE '%server_tcpip_socket%'
+ ORDER BY statement,run;
+ --echo # 5. mysqltest.my_socket_summary_by_instance
+ --vertical_results
+ SELECT * FROM mysqltest.my_socket_summary_by_instance;
+ --horizontal_results
+}
+
+--echo # 6. Cleanup
+#==================
+# Cleanup
+--disable_query_log
+eval
+UPDATE performance_schema.setup_timers
+SET TIMER_NAME = '$wait_timer'
+WHERE NAME = 'wait';
+DROP SCHEMA mysqltest;
+DROP SCHEMA mysqlsupertest;
+--connection con1
+--disconnect con1
+--source include/wait_until_disconnected.inc
+--connection default
+--enable_query_log
+
diff --git a/mysql-test/suite/perfschema/t/stage_mdl_function.test b/mysql-test/suite/perfschema/t/stage_mdl_function.test
new file mode 100644
index 00000000..3cd0c62f
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/stage_mdl_function.test
@@ -0,0 +1,63 @@
+# Tests for the performance schema
+#
+
+--source ../include/stage_setup.inc
+
+connect (con1, localhost, user1, , );
+
+--disable_warnings
+drop function if exists test.f1;
+--enable_warnings
+
+create function test.f1() returns int
+ return 1;
+
+begin;
+select test.f1();
+
+connect (con2, localhost, user2, , );
+
+# Will wait on con1, "Waiting for stored function metadata lock"
+--send
+drop function test.f1;
+
+--connection default
+
+# user1: Wait for the statement to complete
+let $wait_condition=
+ select count(*) = 1 from performance_schema.threads
+ where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user1'
+ and PROCESSLIST_COMMAND = 'Sleep';
+--source include/wait_condition.inc
+
+# user2: Wait for the drop function to block
+let $wait_condition=
+ select count(*) = 1 from performance_schema.threads
+ where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user2'
+ and PROCESSLIST_STATE = 'Waiting for stored function metadata lock';
+--source include/wait_condition.inc
+
+call dump_one_thread('user1');
+call dump_one_thread('user2');
+
+--connection con1
+select f1();
+commit;
+
+--disconnect con1
+
+--connection con2
+--reap
+
+--disconnect con2
+
+--connection default
+
+# Wait for the disconnect to complete
+let $wait_condition=
+ select count(*) = 0 from performance_schema.threads
+ where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user%';
+--source include/wait_condition.inc
+
+--source ../include/stage_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/stage_mdl_global.opt b/mysql-test/suite/perfschema/t/stage_mdl_global.opt
new file mode 100644
index 00000000..ca3d8a72
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/stage_mdl_global.opt
@@ -0,0 +1,2 @@
+--query-cache-size=1048576
+--query-cache-type=OFF
diff --git a/mysql-test/suite/perfschema/t/stage_mdl_global.test b/mysql-test/suite/perfschema/t/stage_mdl_global.test
new file mode 100644
index 00000000..03c3d315
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/stage_mdl_global.test
@@ -0,0 +1,54 @@
+# Tests for the performance schema
+#
+
+--source ../include/stage_setup.inc
+
+connect (con1, localhost, user1, , );
+
+flush tables with read lock;
+
+connect (con2, localhost, user2, , );
+
+# Will wait on con1, "Waiting for backup lock"
+--send
+insert into test.t1 values (1), (2), (3);
+
+--connection default
+
+# user1: Wait for the statement to complete
+let $wait_condition=
+ select count(*) = 1 from performance_schema.threads
+ where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user1'
+ and PROCESSLIST_COMMAND = 'Sleep';
+--source include/wait_condition.inc
+
+# user2: Wait for the insert to block
+let $wait_condition=
+ select count(*) = 1 from performance_schema.threads
+ where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user2'
+ and PROCESSLIST_STATE = 'Waiting for backup lock';
+--source include/wait_condition.inc
+
+call dump_one_thread('user1');
+call dump_one_thread('user2');
+
+--connection con1
+unlock tables;
+
+--disconnect con1
+
+--connection con2
+--reap
+
+--disconnect con2
+
+--connection default
+
+# Wait for the disconnects to complete
+let $wait_condition=
+ select count(*) = 0 from performance_schema.threads
+ where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user%';
+--source include/wait_condition.inc
+
+--source ../include/stage_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/stage_mdl_procedure.test b/mysql-test/suite/perfschema/t/stage_mdl_procedure.test
new file mode 100644
index 00000000..7d9dc6d8
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/stage_mdl_procedure.test
@@ -0,0 +1,79 @@
+# Tests for the performance schema
+#
+
+--source ../include/stage_setup.inc
+
+connect (con1, localhost, user1, , );
+
+--disable_warnings
+drop function if exists test.f1;
+drop procedure if exists test.p1;
+--enable_warnings
+
+delimiter $$;
+
+create function test.f1() returns int
+begin
+ call test.p1();
+ return 1;
+end
+$$
+
+delimiter ;$$
+
+create procedure test.p1()
+begin end;
+
+begin;
+# The procedure is in a sub statement,
+# so that the current transaction keeps a reference to it.
+select test.f1();
+
+connect (con2, localhost, user2, , );
+
+# Will wait on con1, "Waiting for stored procedure metadata lock"
+--send
+drop procedure test.p1;
+
+--connection default
+
+# user1: Wait for the statement to complete
+let $wait_condition=
+ select count(*) = 1 from performance_schema.threads
+ where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user1'
+ and PROCESSLIST_COMMAND = 'Sleep';
+--source include/wait_condition.inc
+
+# user2: Wait for the drop procedure to block
+let $wait_condition=
+ select count(*) = 1 from performance_schema.threads
+ where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user2'
+ and PROCESSLIST_STATE = 'Waiting for stored procedure metadata lock';
+--source include/wait_condition.inc
+
+call dump_one_thread('user1');
+call dump_one_thread('user2');
+
+--connection con1
+select test.f1();
+commit;
+
+--disconnect con1
+
+--connection con2
+--reap
+
+--disconnect con2
+
+--connection default
+
+# Wait for the disconnect to complete
+let $wait_condition=
+ select count(*) = 0 from performance_schema.threads
+ where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user%';
+--source include/wait_condition.inc
+
+drop function test.f1;
+
+--source ../include/stage_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/stage_mdl_table.test b/mysql-test/suite/perfschema/t/stage_mdl_table.test
new file mode 100644
index 00000000..b522f51a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/stage_mdl_table.test
@@ -0,0 +1,59 @@
+# Tests for the performance schema
+#
+
+--source ../include/stage_setup.inc
+
+connect (con1, localhost, user1, , );
+
+begin;
+insert into test.t1 values (1), (2), (3);
+commit;
+
+begin;
+select * from test.t1 for update;
+
+connect (con2, localhost, user2, , );
+
+# Will wait on con1, "Waiting for table metadata lock"
+--send
+alter table test.t1 add column (b int);
+
+--connection default
+
+# user1: Wait for the statement to complete
+let $wait_condition=
+ select count(*) = 1 from performance_schema.threads
+ where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user1'
+ and PROCESSLIST_COMMAND = 'Sleep';
+--source include/wait_condition.inc
+
+# user2: Wait for the alter to block
+let $wait_condition=
+ select count(*) = 1 from performance_schema.threads
+ where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user2'
+ and PROCESSLIST_STATE = 'Waiting for table metadata lock';
+--source include/wait_condition.inc
+
+call dump_one_thread('user1');
+call dump_one_thread('user2');
+
+--connection con1
+commit;
+
+--disconnect con1
+
+--connection con2
+--reap
+
+--disconnect con2
+
+--connection default
+
+# Wait for the disconnects to complete
+let $wait_condition=
+ select count(*) = 0 from performance_schema.threads
+ where `TYPE`='FOREGROUND' and PROCESSLIST_USER like 'user%';
+--source include/wait_condition.inc
+
+--source ../include/stage_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/start_server_1_digest-master.opt b/mysql-test/suite/perfschema/t/start_server_1_digest-master.opt
new file mode 100644
index 00000000..c3a6012f
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_1_digest-master.opt
@@ -0,0 +1 @@
+--loose-performance-schema-digests-size=1
diff --git a/mysql-test/suite/perfschema/t/start_server_1_digest.test b/mysql-test/suite/perfschema/t/start_server_1_digest.test
new file mode 100644
index 00000000..998d9a5e
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_1_digest.test
@@ -0,0 +1,15 @@
+# -----------------------------------------------------------------------
+# Tests for the performance schema statement Digests.
+# -----------------------------------------------------------------------
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/no_protocol.inc
+
+SELECT "Digest table has a size 1 and is full already." as use_case;
+
+select SCHEMA_NAME, DIGEST, DIGEST_TEXT
+ from performance_schema.events_statements_summary_by_digest;
+
+
+
diff --git a/mysql-test/suite/perfschema/t/start_server_disable_idle-master.opt b/mysql-test/suite/perfschema/t/start_server_disable_idle-master.opt
new file mode 100644
index 00000000..3f1ee203
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_disable_idle-master.opt
@@ -0,0 +1 @@
+--loose-performance-schema-instrument='idle=OFF'
diff --git a/mysql-test/suite/perfschema/t/start_server_disable_idle.test b/mysql-test/suite/perfschema/t/start_server_disable_idle.test
new file mode 100644
index 00000000..6cf8d4a5
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_disable_idle.test
@@ -0,0 +1,28 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no enabled idle instruments
+select * from performance_schema.setup_instruments
+ where name like "idle" and enabled='YES';
+
+# Expect no idle statistics collected
+
+select * from performance_schema.events_waits_summary_global_by_event_name
+ where event_name like "idle" and count_star > 0;
+
+select * from performance_schema.events_waits_summary_by_thread_by_event_name
+ where event_name like "idle" and count_star > 0;
+
+select * from performance_schema.events_waits_summary_by_user_by_event_name
+ where event_name like "idle" and count_star > 0;
+
+select * from performance_schema.events_waits_summary_by_host_by_event_name
+ where event_name like "idle" and count_star > 0;
+
+select * from performance_schema.events_waits_summary_by_account_by_event_name
+ where event_name like "idle" and count_star > 0;
+
diff --git a/mysql-test/suite/perfschema/t/start_server_disable_stages-master.opt b/mysql-test/suite/perfschema/t/start_server_disable_stages-master.opt
new file mode 100644
index 00000000..fb8292c1
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_disable_stages-master.opt
@@ -0,0 +1 @@
+--loose-performance-schema-instrument='stage/%=OFF'
diff --git a/mysql-test/suite/perfschema/t/start_server_disable_stages.test b/mysql-test/suite/perfschema/t/start_server_disable_stages.test
new file mode 100644
index 00000000..83ee6838
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_disable_stages.test
@@ -0,0 +1,28 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no enabled stages instruments
+select * from performance_schema.setup_instruments
+ where name like "stage/%" and enabled='YES';
+
+# Expect no stage statistics collected
+
+select * from performance_schema.events_stages_summary_global_by_event_name
+ where count_star > 0;
+
+select * from performance_schema.events_stages_summary_by_thread_by_event_name
+ where count_star > 0;
+
+select * from performance_schema.events_stages_summary_by_user_by_event_name
+ where count_star > 0;
+
+select * from performance_schema.events_stages_summary_by_host_by_event_name
+ where count_star > 0;
+
+select * from performance_schema.events_stages_summary_by_account_by_event_name
+ where count_star > 0;
+
diff --git a/mysql-test/suite/perfschema/t/start_server_disable_statements-master.opt b/mysql-test/suite/perfschema/t/start_server_disable_statements-master.opt
new file mode 100644
index 00000000..51d222d1
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_disable_statements-master.opt
@@ -0,0 +1 @@
+--loose-performance-schema-instrument='statement/%=OFF'
diff --git a/mysql-test/suite/perfschema/t/start_server_disable_statements.test b/mysql-test/suite/perfschema/t/start_server_disable_statements.test
new file mode 100644
index 00000000..a337fb2a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_disable_statements.test
@@ -0,0 +1,28 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no enabled statements instruments
+select * from performance_schema.setup_instruments
+ where name like "statement/%" and enabled='YES';
+
+# Expect no statement statistics collected
+
+select * from performance_schema.events_statements_summary_global_by_event_name
+ where count_star > 0;
+
+select * from performance_schema.events_statements_summary_by_thread_by_event_name
+ where count_star > 0;
+
+select * from performance_schema.events_statements_summary_by_user_by_event_name
+ where count_star > 0;
+
+select * from performance_schema.events_statements_summary_by_host_by_event_name
+ where count_star > 0;
+
+select * from performance_schema.events_statements_summary_by_account_by_event_name
+ where count_star > 0;
+
diff --git a/mysql-test/suite/perfschema/t/start_server_disable_transactions-master.opt b/mysql-test/suite/perfschema/t/start_server_disable_transactions-master.opt
new file mode 100644
index 00000000..20f93f92
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_disable_transactions-master.opt
@@ -0,0 +1 @@
+--loose-performance-schema-instrument='transaction=OFF'
diff --git a/mysql-test/suite/perfschema/t/start_server_disable_transactions.test b/mysql-test/suite/perfschema/t/start_server_disable_transactions.test
new file mode 100644
index 00000000..723dd102
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_disable_transactions.test
@@ -0,0 +1,28 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no enabled statements instruments
+select * from performance_schema.setup_instruments
+ where name in ('transaction') and enabled='YES';
+
+# Expect no statement statistics collected
+
+select * from performance_schema.events_transactions_summary_global_by_event_name
+ where count_star > 0;
+
+select * from performance_schema.events_transactions_summary_by_thread_by_event_name
+ where count_star > 0;
+
+select * from performance_schema.events_transactions_summary_by_user_by_event_name
+ where count_star > 0;
+
+select * from performance_schema.events_transactions_summary_by_host_by_event_name
+ where count_star > 0;
+
+select * from performance_schema.events_transactions_summary_by_account_by_event_name
+ where count_star > 0;
+
diff --git a/mysql-test/suite/perfschema/t/start_server_disable_waits-master.opt b/mysql-test/suite/perfschema/t/start_server_disable_waits-master.opt
new file mode 100644
index 00000000..c3a8876c
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_disable_waits-master.opt
@@ -0,0 +1 @@
+--loose-performance-schema-instrument='wait/%=OFF'
diff --git a/mysql-test/suite/perfschema/t/start_server_disable_waits.test b/mysql-test/suite/perfschema/t/start_server_disable_waits.test
new file mode 100644
index 00000000..5da7f533
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_disable_waits.test
@@ -0,0 +1,28 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no enabled waits instruments
+select * from performance_schema.setup_instruments
+ where name like "wait/%" and enabled='YES';
+
+# Expect no wait statistics collected
+
+select * from performance_schema.events_waits_summary_global_by_event_name
+ where event_name like "wait/%" and count_star > 0;
+
+select * from performance_schema.events_waits_summary_by_thread_by_event_name
+ where event_name like "wait/%" and count_star > 0;
+
+select * from performance_schema.events_waits_summary_by_user_by_event_name
+ where event_name like "wait/%" and count_star > 0;
+
+select * from performance_schema.events_waits_summary_by_host_by_event_name
+ where event_name like "wait/%" and count_star > 0;
+
+select * from performance_schema.events_waits_summary_by_account_by_event_name
+ where event_name like "wait/%" and count_star > 0;
+
diff --git a/mysql-test/suite/perfschema/t/start_server_innodb-master.opt b/mysql-test/suite/perfschema/t/start_server_innodb-master.opt
new file mode 100644
index 00000000..542720c4
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_innodb-master.opt
@@ -0,0 +1 @@
+--loose-enable-performance-schema
diff --git a/mysql-test/suite/perfschema/t/start_server_innodb.test b/mysql-test/suite/perfschema/t/start_server_innodb.test
new file mode 100644
index 00000000..f190482b
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_innodb.test
@@ -0,0 +1,11 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/have_innodb.inc
+
+--source ../include/start_server_common.inc
+
+# Expecting nothing lost with default parameters
+
+show global status like "performance_schema%";
diff --git a/mysql-test/suite/perfschema/t/start_server_low_digest-master.opt b/mysql-test/suite/perfschema/t/start_server_low_digest-master.opt
new file mode 100644
index 00000000..fc5065f9
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_low_digest-master.opt
@@ -0,0 +1 @@
+--max_digest_length=10
diff --git a/mysql-test/suite/perfschema/t/start_server_low_digest.test b/mysql-test/suite/perfschema/t/start_server_low_digest.test
new file mode 100644
index 00000000..f1ff90d2
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_low_digest.test
@@ -0,0 +1,21 @@
+# -----------------------------------------------------------------------
+# Tests for the performance schema statement Digests.
+# -----------------------------------------------------------------------
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/no_protocol.inc
+
+USE performance_schema;
+truncate table events_statements_history_long;
+
+# -----------------------------------------------------------------------
+# Test to show how the digest behaves with low value of
+# - performance_schema_max_digest_length
+# -----------------------------------------------------------------------
+SELECT 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1;
+
+--echo ####################################
+--echo # QUERYING PS STATEMENT DIGEST
+--echo ####################################
+SELECT event_name, digest_text, sql_text FROM events_statements_history_long;
diff --git a/mysql-test/suite/perfschema/t/start_server_low_digest_sql_length-master.opt b/mysql-test/suite/perfschema/t/start_server_low_digest_sql_length-master.opt
new file mode 100644
index 00000000..e6483c36
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_low_digest_sql_length-master.opt
@@ -0,0 +1,3 @@
+--thread_stack=655360
+--max_digest_length=10
+--loose-performance_schema_max_sql_text_length=10
diff --git a/mysql-test/suite/perfschema/t/start_server_low_digest_sql_length.test b/mysql-test/suite/perfschema/t/start_server_low_digest_sql_length.test
new file mode 100644
index 00000000..ce8233a9
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_low_digest_sql_length.test
@@ -0,0 +1,23 @@
+# -----------------------------------------------------------------------
+# Tests for the performance schema statement Digests.
+# -----------------------------------------------------------------------
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/no_protocol.inc
+
+USE performance_schema;
+truncate table events_statements_history_long;
+
+# -----------------------------------------------------------------------
+# Test to show how the digest behaves with low value of
+# - performance_schema_max_digest_length
+# - performance_schema_max_sql_text_length
+# -----------------------------------------------------------------------
+SELECT 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1;
+
+--echo ####################################
+--echo # QUERYING PS STATEMENT DIGEST
+--echo ####################################
+--sorted_result
+SELECT event_name, digest, digest_text, sql_text FROM events_statements_history_long;
diff --git a/mysql-test/suite/perfschema/t/start_server_low_index-master.opt b/mysql-test/suite/perfschema/t/start_server_low_index-master.opt
new file mode 100644
index 00000000..29cbfa63
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_low_index-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_max_index_stat=34
diff --git a/mysql-test/suite/perfschema/t/start_server_low_index.test b/mysql-test/suite/perfschema/t/start_server_low_index.test
new file mode 100644
index 00000000..eea01091
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_low_index.test
@@ -0,0 +1,187 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_valgrind.inc
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+
+# NOTE : Index stats are manifested during table creation. To force a low index
+# condition, performance_schema_max_index_stat must be set to the number of
+# all system table indexes, plus 1.
+
+#############################
+# Setup database and tables.
+#############################
+--disable_warnings
+drop table if exists db1.t1;
+drop database if exists db1;
+--enable_warnings
+create database db1;
+create table db1.t1 (a int, b char(10) default 'default',
+ unique key uidx(a));
+
+#######################
+# Execute few queries.
+#######################
+insert into db1.t1 values('1', 'abc');
+insert into db1.t1 values('2', 'abc');
+--disable_ps2_protocol
+select * from db1.t1 where a='1';
+--enable_ps2_protocol
+
+#####################################################
+# Run few queries on Performance Schema stats tables.
+#####################################################
+# There should be 3 entries in following table. 2 for insert and 1 for select.
+select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME
+ from performance_schema.table_io_waits_summary_by_table
+ where OBJECT_SCHEMA='db1'
+ order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME;
+
+# Stats for 2 indexes (full scan, uidx)
+select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME
+ from performance_schema.table_io_waits_summary_by_index_usage
+ where OBJECT_SCHEMA='db1'
+ order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME;
+
+flush tables;
+
+# Stats for full scan lost
+select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME
+ from performance_schema.table_io_waits_summary_by_table
+ where OBJECT_SCHEMA='db1'
+ order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME;
+
+# Stats for only 1 index, uidx
+# Stats for full scan lost
+select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME
+ from performance_schema.table_io_waits_summary_by_index_usage
+ where OBJECT_SCHEMA='db1'
+ order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME;
+
+# Expect INDEX_STAT lost, we have room for 1 out of 2
+--disable_warnings
+select variable_value > 0 from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_INDEX_STAT_LOST';
+
+# While at it, check that FLUSH STATUS Resets the lost counter
+FLUSH STATUS;
+
+select variable_value from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_INDEX_STAT_LOST';
+--enable_warnings
+
+
+create table db1.t2 (a int, b char(10) default 'default',
+ unique key uidx(a));
+
+#######################
+# Execute few queries.
+#######################
+insert into db1.t1 values('3', 'abc');
+insert into db1.t1 values('4', 'abc');
+--disable_ps2_protocol
+select * from db1.t1 where a='1';
+--enable_ps2_protocol
+
+insert into db1.t2 values('1', 'abc');
+insert into db1.t2 values('2', 'abc');
+--disable_ps2_protocol
+select * from db1.t2 where a='1';
+--enable_ps2_protocol
+
+#####################################################
+# Run few queries on Performance Schema stats tables.
+#####################################################
+
+select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME
+ from performance_schema.table_io_waits_summary_by_table
+ where OBJECT_SCHEMA='db1'
+ order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME;
+
+select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME
+ from performance_schema.table_io_waits_summary_by_index_usage
+ where OBJECT_SCHEMA='db1'
+ order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME;
+
+flush tables;
+
+select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME
+ from performance_schema.table_io_waits_summary_by_table
+ where OBJECT_SCHEMA='db1'
+ order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME;
+
+select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME
+ from performance_schema.table_io_waits_summary_by_index_usage
+ where OBJECT_SCHEMA='db1'
+ order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME;
+
+# Expect INDEX_STAT lost
+--disable_warnings
+select variable_value > 0 from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_INDEX_STAT_LOST';
+--enable_warnings
+
+FLUSH STATUS;
+
+
+#####################################################################################
+# Update setup_objects to DISABLE TABLE and check index lost stats after flush tables
+#####################################################################################
+
+update performance_schema.setup_objects set ENABLED='NO' where OBJECT_TYPE='TABLE';
+
+
+
+#######################
+# Execute few queries.
+#######################
+insert into db1.t1 values('5', 'abc');
+insert into db1.t1 values('6', 'abc');
+select * from db1.t1 where a='1';
+
+insert into db1.t2 values('3', 'abc');
+insert into db1.t2 values('4', 'abc');
+select * from db1.t2 where a='1';
+
+# Empty, objects are disabled
+select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME
+ from performance_schema.table_io_waits_summary_by_table
+ where OBJECT_SCHEMA='db1'
+ order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME;
+
+# Empty, objects are disabled
+select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME
+ from performance_schema.table_io_waits_summary_by_index_usage
+ where OBJECT_SCHEMA='db1'
+ order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME;
+
+flush tables;
+
+# Empty, objects are disabled
+select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME
+ from performance_schema.table_io_waits_summary_by_table
+ where OBJECT_SCHEMA='db1'
+ order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME;
+
+# Empty, objects are disabled
+select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME
+ from performance_schema.table_io_waits_summary_by_index_usage
+ where OBJECT_SCHEMA='db1'
+ order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME;
+
+# Do not expect lost counter in INDEX_STAT
+--disable_warnings
+select variable_value from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_INDEX_STAT_LOST';
+--enable_warnings
+
+###########
+# Cleanup.
+###########
+drop database db1;
+
+update performance_schema.setup_objects set ENABLED='YES'
+ where OBJECT_TYPE='TABLE' and OBJECT_SCHEMA="%";
diff --git a/mysql-test/suite/perfschema/t/start_server_low_table_lock-master.opt b/mysql-test/suite/perfschema/t/start_server_low_table_lock-master.opt
new file mode 100644
index 00000000..d687f8d0
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_low_table_lock-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_max_table_lock_stat=1
diff --git a/mysql-test/suite/perfschema/t/start_server_low_table_lock.test b/mysql-test/suite/perfschema/t/start_server_low_table_lock.test
new file mode 100644
index 00000000..d397b16e
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_low_table_lock.test
@@ -0,0 +1,136 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+#############################
+# Setup database and tables.
+#############################
+--disable_warnings
+drop table if exists db1.t1;
+drop database if exists db1;
+--enable_warnings
+create database db1;
+create table db1.t1 (a int, b char(10) default 'default');
+
+#######################
+# Execute few queries.
+#######################
+insert into db1.t1 values('1', 'abc');
+insert into db1.t1 values('2', 'abc');
+--disable_ps2_protocol
+select * from db1.t1 where a='1';
+--enable_ps2_protocol
+
+#####################################################
+# Run few queries on Performance Schema stats tables.
+#####################################################
+# There should be 3 entries in following table. 2 for insert and 1 for select.
+select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME
+ from performance_schema.table_lock_waits_summary_by_table
+ where OBJECT_SCHEMA='db1'
+ order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME;
+
+flush tables;
+
+select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME
+ from performance_schema.table_lock_waits_summary_by_table
+ where OBJECT_SCHEMA='db1'
+ order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME;
+
+# Expect no TABLE_LOCK_STAT lost, we have room for 1 table lock for db1.t1
+--disable_warnings
+select variable_value from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_TABLE_LOCK_STAT_LOST';
+--enable_warnings
+
+create table db1.t2 (a int, b char(10) default 'default',
+ unique key uidx(a));
+
+#######################
+# Execute few queries.
+#######################
+insert into db1.t1 values('3', 'abc');
+insert into db1.t1 values('4', 'abc');
+--disable_ps2_protocol
+select * from db1.t1 where a='1';
+--enable_ps2_protocol
+
+insert into db1.t2 values('1', 'abc');
+insert into db1.t2 values('2', 'abc');
+--disable_ps2_protocol
+select * from db1.t2 where a='1';
+--enable_ps2_protocol
+
+#####################################################
+# Run few queries on Performance Schema stats tables.
+#####################################################
+
+select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME
+ from performance_schema.table_lock_waits_summary_by_table
+ where OBJECT_SCHEMA='db1'
+ order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME;
+
+flush tables;
+
+select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME
+ from performance_schema.table_lock_waits_summary_by_table
+ where OBJECT_SCHEMA='db1'
+ order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME;
+
+# Expect TABLE_LOCK_STAT lost, we can not keep stats for db1.t2
+--disable_warnings
+select variable_value > 0 from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_TABLE_LOCK_STAT_LOST';
+--enable_warnings
+
+flush status;
+
+
+#######################################
+# Update setup_objects to DISABLE TABLE
+#######################################
+
+update performance_schema.setup_objects set ENABLED='NO'
+ where OBJECT_TYPE='TABLE' and OBJECT_SCHEMA="%";
+
+#######################
+# Execute few queries.
+#######################
+insert into db1.t1 values('5', 'abc');
+insert into db1.t1 values('6', 'abc');
+select * from db1.t1 where a='1';
+
+insert into db1.t2 values('3', 'abc');
+insert into db1.t2 values('4', 'abc');
+select * from db1.t2 where a='1';
+
+# Empty, objects are disabled
+select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME
+ from performance_schema.table_lock_waits_summary_by_table
+ where OBJECT_SCHEMA='db1'
+ order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME;
+
+flush tables;
+
+# Empty, objects are disabled
+select COUNT_STAR, OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME
+ from performance_schema.table_lock_waits_summary_by_table
+ where OBJECT_SCHEMA='db1'
+ order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME;
+
+# Do not expect lost counter in TABLE_LOCK_STAT
+--disable_warnings
+select variable_value from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_TABLE_LOCK_STAT_LOST';
+--enable_warnings
+
+###########
+# Cleanup.
+###########
+drop database db1;
+
+update performance_schema.setup_objects set ENABLED='YES'
+ where OBJECT_TYPE='TABLE' and OBJECT_SCHEMA="%";
diff --git a/mysql-test/suite/perfschema/t/start_server_no_account-master.opt b/mysql-test/suite/perfschema/t/start_server_no_account-master.opt
new file mode 100644
index 00000000..cfe98cec
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_account-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_accounts_size=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_account.test b/mysql-test/suite/perfschema/t/start_server_no_account.test
new file mode 100644
index 00000000..563fdbaa
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_account.test
@@ -0,0 +1,18 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no records
+show global variables like "performance_schema_accounts_size";
+
+select count(*) from performance_schema.accounts;
+
+# We lost all the data
+--disable_warnings
+select variable_value > 0 from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_ACCOUNTS_LOST';
+--enable_warnings
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_cond_class-master.opt b/mysql-test/suite/perfschema/t/start_server_no_cond_class-master.opt
new file mode 100644
index 00000000..6b15f14c
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_cond_class-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_max_cond_classes=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_cond_class.test b/mysql-test/suite/perfschema/t/start_server_no_cond_class.test
new file mode 100644
index 00000000..8a5cf0f5
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_cond_class.test
@@ -0,0 +1,25 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no classes
+show global variables like "performance_schema_max_cond_classes";
+
+select count(*) from performance_schema.setup_instruments
+ where name like "wait/synch/cond/%";
+
+# We lost all the classes
+--disable_warnings
+select variable_value > 0 from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_COND_CLASSES_LOST';
+--enable_warnings
+
+# Expect no instances
+select count(*) from performance_schema.cond_instances;
+
+# Expect no instances lost
+show global status like "performance_schema_cond_instances_lost";
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_cond_inst-master.opt b/mysql-test/suite/perfschema/t/start_server_no_cond_inst-master.opt
new file mode 100644
index 00000000..12a79eb0
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_cond_inst-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_max_cond_instances=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_cond_inst.test b/mysql-test/suite/perfschema/t/start_server_no_cond_inst.test
new file mode 100644
index 00000000..8168ef10
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_cond_inst.test
@@ -0,0 +1,28 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect classes
+show global variables like "performance_schema_max_cond_classes";
+
+select count(*) > 0 from performance_schema.setup_instruments
+ where name like "wait/synch/cond/%";
+
+# Expect no class lost
+show global status like "performance_schema_cond_classes_lost";
+
+# Expect no instances
+show global variables like "performance_schema_max_cond_instances";
+
+select count(*) from performance_schema.cond_instances;
+
+# Expect instances lost
+--disable_warnings
+select variable_value > 0 from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_COND_INSTANCES_LOST';
+--enable_warnings
+
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_digests-master.opt b/mysql-test/suite/perfschema/t/start_server_no_digests-master.opt
new file mode 100644
index 00000000..397fdefc
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_digests-master.opt
@@ -0,0 +1 @@
+--loose-performance-schema-digests-size=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_digests.test b/mysql-test/suite/perfschema/t/start_server_no_digests.test
new file mode 100644
index 00000000..605ea1f3
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_digests.test
@@ -0,0 +1,32 @@
+# ----------------------------------------------------
+# Tests for the performance schema statement Digests.
+# ----------------------------------------------------
+
+# Test case to show behavior of statements digest when
+# statement-digest-size is 0
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+# Initial Setup for Digest
+--source ../include/digest_setup.inc
+
+TRUNCATE TABLE performance_schema.events_statements_summary_by_digest;
+
+# Executing queries
+--source ../include/digest_execution.inc
+
+--echo ####################################
+--echo # QUERYING PS STATEMENT DIGEST
+--echo ####################################
+SELECT SCHEMA_NAME, DIGEST_TEXT, COUNT_STAR, SUM_ROWS_AFFECTED, SUM_WARNINGS,
+ SUM_ERRORS FROM performance_schema.events_statements_summary_by_digest;
+
+
+# Expect no digest
+SHOW GLOBAL VARIABLES LIKE "performance_schema_digests_size";
+SELECT COUNT(*) FROM performance_schema.events_statements_summary_by_digest;
+
+# Cleanup for Digest
+--source ../include/digest_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_file_class-master.opt b/mysql-test/suite/perfschema/t/start_server_no_file_class-master.opt
new file mode 100644
index 00000000..657de947
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_file_class-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_max_file_classes=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_file_class.test b/mysql-test/suite/perfschema/t/start_server_no_file_class.test
new file mode 100644
index 00000000..74ed465a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_file_class.test
@@ -0,0 +1,25 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no classes
+show global variables like "performance_schema_max_file_classes";
+
+select count(*) from performance_schema.setup_instruments
+ where name like "wait/io/file/%";
+
+# We lost all the classes
+--disable_warnings
+select variable_value > 0 from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_FILE_CLASSES_LOST';
+--enable_warnings
+
+# Expect no instances
+select count(*) from performance_schema.file_instances;
+
+# Expect no instances lost
+show global status like "performance_schema_file_instances_lost";
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_file_inst-master.opt b/mysql-test/suite/perfschema/t/start_server_no_file_inst-master.opt
new file mode 100644
index 00000000..e0a0c6a0
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_file_inst-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_max_file_instances=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_file_inst.test b/mysql-test/suite/perfschema/t/start_server_no_file_inst.test
new file mode 100644
index 00000000..715fe656
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_file_inst.test
@@ -0,0 +1,28 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect classes
+show global variables like "performance_schema_max_file_classes";
+
+select count(*) > 0 from performance_schema.setup_instruments
+ where name like "wait/io/file/%";
+
+# Expect no class lost
+show global status like "performance_schema_file_classes_lost";
+
+# Expect no instances
+show global variables like "performance_schema_max_file_instances";
+
+select count(*) from performance_schema.file_instances;
+
+# Expect instances lost
+--disable_warnings
+select variable_value > 0 from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_FILE_INSTANCES_LOST';
+--enable_warnings
+
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_host-master.opt b/mysql-test/suite/perfschema/t/start_server_no_host-master.opt
new file mode 100644
index 00000000..1cf7956d
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_host-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_hosts_size=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_host.test b/mysql-test/suite/perfschema/t/start_server_no_host.test
new file mode 100644
index 00000000..5f9dd706
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_host.test
@@ -0,0 +1,18 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no records
+show global variables like "performance_schema_hosts_size";
+
+select count(*) from performance_schema.hosts;
+
+# We lost all the data
+--disable_warnings
+select variable_value > 0 from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_HOSTS_LOST';
+--enable_warnings
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_index-master.opt b/mysql-test/suite/perfschema/t/start_server_no_index-master.opt
new file mode 100644
index 00000000..38bbb9ef
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_index-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_max_index_stat=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_index.test b/mysql-test/suite/perfschema/t/start_server_no_index.test
new file mode 100644
index 00000000..6f8f27b2
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_index.test
@@ -0,0 +1,66 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+#############################
+# Setup database and tables.
+#############################
+--disable_warnings
+drop table if exists db1.t1;
+drop database if exists db1;
+--enable_warnings
+create database db1;
+create table db1.t1 (a int, b char(10) default 'default',
+ unique key uidx(a));
+
+#######################
+# Execute few queries.
+#######################
+insert into db1.t1 values('1', 'abc');
+insert into db1.t1 values('2', 'abc');
+--disable_ps2_protocol
+select * from db1.t1 where a='1';
+--enable_ps2_protocol
+
+#####################################################
+# Run few queries on Performance Schema stats tables.
+#####################################################
+# There should be 3 entries in following table. 2 for insert and 1 for select.
+# This is because lock stats are still in the table handles
+select COUNT_STAR from performance_schema.table_io_waits_summary_by_table
+ where OBJECT_SCHEMA='db1' and OBJECT_NAME='t1';
+# There should be 1 entry in following table. Thats is for select.
+# This is because lock stats are still in the table handles
+select COUNT_STAR from performance_schema.table_io_waits_summary_by_index_usage
+ where INDEX_NAME!='NULL';
+
+# Now force aggregation by closing table handles
+FLUSH TABLES;
+
+# Stats are now missing
+select COUNT_STAR from performance_schema.table_io_waits_summary_by_table
+ where OBJECT_SCHEMA='db1' and OBJECT_NAME='t1';
+
+# Stats are now missing
+select COUNT_STAR from performance_schema.table_io_waits_summary_by_index_usage
+ where INDEX_NAME!='NULL';
+
+# Expect INDEX_STAT lost
+--disable_warnings
+select variable_value > 0 from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_INDEX_STAT_LOST';
+
+# While at it, check that FLUSH STATUS Resets the lost counter
+FLUSH STATUS;
+
+select variable_value from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_INDEX_STAT_LOST';
+--enable_warnings
+
+###########
+# Cleanup.
+###########
+drop database db1;
diff --git a/mysql-test/suite/perfschema/t/start_server_no_mdl-master.opt b/mysql-test/suite/perfschema/t/start_server_no_mdl-master.opt
new file mode 100644
index 00000000..93a55af2
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_mdl-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_max_metadata_locks=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_mdl.test b/mysql-test/suite/perfschema/t/start_server_no_mdl.test
new file mode 100644
index 00000000..c3d1ca7d
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_mdl.test
@@ -0,0 +1,23 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+select count(*) from performance_schema.metadata_locks;
+
+# Expect metadata locks lost
+--disable_warnings
+select variable_value > 0 from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_METADATA_LOCK_LOST';
+--enable_warnings
+
+# While at it, check that flush status resets the lost counter
+FLUSH STATUS;
+
+--disable_warnings
+select variable_value from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_METADATA_LOCK_LOST';
+--enable_warnings
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_memory_class-master.opt b/mysql-test/suite/perfschema/t/start_server_no_memory_class-master.opt
new file mode 100644
index 00000000..9ff2f77a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_memory_class-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_max_memory_classes=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_memory_class.test b/mysql-test/suite/perfschema/t/start_server_no_memory_class.test
new file mode 100644
index 00000000..e14e5f39
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_memory_class.test
@@ -0,0 +1,26 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no classes
+show global variables like "performance_schema_max_memory_classes";
+
+# Expect builtin memory classes
+select name from performance_schema.setup_instruments
+ where name like "memory/performance_schema/%"
+ order by name;
+
+# Expect no memory classes
+select count(*) from performance_schema.setup_instruments
+ where name like "memory/%"
+ and name not like "memory/performance_schema/%";
+
+# We lost all the classes
+--disable_warnings
+select variable_value > 0 from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_MEMORY_CLASSES_LOST';
+--enable_warnings
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_mutex_class-master.opt b/mysql-test/suite/perfschema/t/start_server_no_mutex_class-master.opt
new file mode 100644
index 00000000..27d055d3
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_mutex_class-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_max_mutex_classes=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_mutex_class.test b/mysql-test/suite/perfschema/t/start_server_no_mutex_class.test
new file mode 100644
index 00000000..918d79e9
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_mutex_class.test
@@ -0,0 +1,25 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no classes
+show global variables like "performance_schema_max_mutex_classes";
+
+select count(*) from performance_schema.setup_instruments
+ where name like "wait/synch/mutex/%";
+
+# We lost all the classes
+--disable_warnings
+select variable_value > 0 from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_MUTEX_CLASSES_LOST';
+--enable_warnings
+
+# Expect no instances
+select count(*) from performance_schema.mutex_instances;
+
+# Expect no instances lost
+show global status like "performance_schema_mutex_instances_lost";
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_mutex_inst-master.opt b/mysql-test/suite/perfschema/t/start_server_no_mutex_inst-master.opt
new file mode 100644
index 00000000..b8ed7ea7
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_mutex_inst-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_max_mutex_instances=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_mutex_inst.test b/mysql-test/suite/perfschema/t/start_server_no_mutex_inst.test
new file mode 100644
index 00000000..106d5df0
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_mutex_inst.test
@@ -0,0 +1,28 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect classes
+show global variables like "performance_schema_max_mutex_classes";
+
+select count(*) > 0 from performance_schema.setup_instruments
+ where name like "wait/synch/mutex/%";
+
+# Expect no class lost
+show global status like "performance_schema_mutex_classes_lost";
+
+# Expect no instances
+show global variables like "performance_schema_max_mutex_instances";
+
+select count(*) from performance_schema.mutex_instances;
+
+# Expect instances lost
+--disable_warnings
+select variable_value > 0 from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_MUTEX_INSTANCES_LOST';
+--enable_warnings
+
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_prepared_stmts_instances-master.opt b/mysql-test/suite/perfschema/t/start_server_no_prepared_stmts_instances-master.opt
new file mode 100644
index 00000000..5a9501cb
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_prepared_stmts_instances-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_max_prepared_statements_instances=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_prepared_stmts_instances.test b/mysql-test/suite/perfschema/t/start_server_no_prepared_stmts_instances.test
new file mode 100644
index 00000000..840b3afd
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_prepared_stmts_instances.test
@@ -0,0 +1,43 @@
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/no_protocol.inc
+
+--source ../include/start_server_common.inc
+
+CREATE DATABASE db;
+USE db;
+
+# Expect no history
+
+show global variables like "performance_schema_max_prepared_statements_instances";
+select count(*) from performance_schema.prepared_statements_instances;
+
+# Valid operation, edge case
+
+truncate table performance_schema.prepared_statements_instances;
+
+# Prepare statements
+--source suite/perfschema/include/prepared_stmts_setup.inc
+
+# check the lost status
+show global status like "%performance_schema_prepared_statements_lost%";
+
+# Execute statements
+--source suite/perfschema/include/prepared_stmts_execution.inc
+
+# check the lost status
+show global status like "%performance_schema_prepared_statements_lost%";
+
+# deallocate prepared statements
+--source suite/perfschema/include/prepared_stmts_deallocation.inc
+
+# check the lost status
+show global status like "%performance_schema_prepared_statements_lost%";
+
+# Flush status now
+flush status;
+
+# status after flush. expect 0.
+show global status like "%performance_schema_prepared_statements_lost%";
+
+DROP DATABASE db;
diff --git a/mysql-test/suite/perfschema/t/start_server_no_rwlock_class-master.opt b/mysql-test/suite/perfschema/t/start_server_no_rwlock_class-master.opt
new file mode 100644
index 00000000..1c136591
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_rwlock_class-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_max_rwlock_classes=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_rwlock_class.test b/mysql-test/suite/perfschema/t/start_server_no_rwlock_class.test
new file mode 100644
index 00000000..e876faab
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_rwlock_class.test
@@ -0,0 +1,25 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no classes
+show global variables like "performance_schema_max_rwlock_classes";
+
+select count(*) from performance_schema.setup_instruments
+ where name like "wait/synch/rwlock/%";
+
+# We lost all the classes
+--disable_warnings
+select variable_value > 0 from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_RWLOCK_CLASSES_LOST';
+--enable_warnings
+
+# Expect no instances
+select count(*) from performance_schema.rwlock_instances;
+
+# Expect no instances lost
+show global status like "performance_schema_rwlock_instances_lost";
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_rwlock_inst-master.opt b/mysql-test/suite/perfschema/t/start_server_no_rwlock_inst-master.opt
new file mode 100644
index 00000000..e9495b03
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_rwlock_inst-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_max_rwlock_instances=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_rwlock_inst.test b/mysql-test/suite/perfschema/t/start_server_no_rwlock_inst.test
new file mode 100644
index 00000000..ace773a6
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_rwlock_inst.test
@@ -0,0 +1,28 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect classes
+show global variables like "performance_schema_max_rwlock_classes";
+
+select count(*) > 0 from performance_schema.setup_instruments
+ where name like "wait/synch/rwlock/%";
+
+# Expect no class lost
+show global status like "performance_schema_rwlock_classes_lost";
+
+# Expect no instances
+show global variables like "performance_schema_max_rwlock_instances";
+
+select count(*) from performance_schema.rwlock_instances;
+
+# Expect instances lost
+--disable_warnings
+select variable_value > 0 from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_RWLOCK_INSTANCES_LOST';
+--enable_warnings
+
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_setup_actors-master.opt b/mysql-test/suite/perfschema/t/start_server_no_setup_actors-master.opt
new file mode 100644
index 00000000..624ef23b
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_setup_actors-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_setup_actors_size=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_setup_actors.test b/mysql-test/suite/perfschema/t/start_server_no_setup_actors.test
new file mode 100644
index 00000000..970f5008
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_setup_actors.test
@@ -0,0 +1,13 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no setup_actors
+show global variables like "performance_schema_setup_actors_size";
+
+# Expect no setup_actors
+select count(*) from performance_schema.setup_actors;
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_setup_objects-master.opt b/mysql-test/suite/perfschema/t/start_server_no_setup_objects-master.opt
new file mode 100644
index 00000000..76f06066
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_setup_objects-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_setup_objects_size=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_setup_objects.test b/mysql-test/suite/perfschema/t/start_server_no_setup_objects.test
new file mode 100644
index 00000000..039e963e
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_setup_objects.test
@@ -0,0 +1,13 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no setup_objects
+show global variables like "performance_schema_setup_objects_size";
+
+# Expect no setup_objects
+select count(*) from performance_schema.setup_objects;
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_socket_class-master.opt b/mysql-test/suite/perfschema/t/start_server_no_socket_class-master.opt
new file mode 100644
index 00000000..372cfe82
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_socket_class-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_max_socket_classes=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_socket_class.test b/mysql-test/suite/perfschema/t/start_server_no_socket_class.test
new file mode 100644
index 00000000..a956a63e
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_socket_class.test
@@ -0,0 +1,25 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no classes
+show global variables like "performance_schema_max_socket_classes";
+
+select count(*) from performance_schema.setup_instruments
+ where name like "wait/io/socket/%";
+
+# We lost all the classes
+--disable_warnings
+select variable_value > 0 from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_SOCKET_CLASSES_LOST';
+--enable_warnings
+
+# Expect no instances
+select count(*) from performance_schema.socket_instances;
+
+# Expect no instances lost
+show global status like "performance_schema_socket_instances_lost";
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_socket_inst-master.opt b/mysql-test/suite/perfschema/t/start_server_no_socket_inst-master.opt
new file mode 100644
index 00000000..f269db53
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_socket_inst-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_max_socket_instances=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_socket_inst.test b/mysql-test/suite/perfschema/t/start_server_no_socket_inst.test
new file mode 100644
index 00000000..0202869d
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_socket_inst.test
@@ -0,0 +1,28 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect classes
+show global variables like "performance_schema_max_socket_classes";
+
+select count(*) > 0 from performance_schema.setup_instruments
+ where name like "wait/io/socket/%";
+
+# Expect no class lost
+show global status like "performance_schema_socket_classes_lost";
+
+# Expect no instances
+show global variables like "performance_schema_max_socket_instances";
+
+select count(*) from performance_schema.socket_instances;
+
+# Expect instances lost
+--disable_warnings
+select variable_value > 0 from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_SOCKET_INSTANCES_LOST';
+--enable_warnings
+
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_stage_class-master.opt b/mysql-test/suite/perfschema/t/start_server_no_stage_class-master.opt
new file mode 100644
index 00000000..31cf7bdf
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_stage_class-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_max_stage_classes=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_stage_class.test b/mysql-test/suite/perfschema/t/start_server_no_stage_class.test
new file mode 100644
index 00000000..d0a9d8ac
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_stage_class.test
@@ -0,0 +1,28 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no classes
+show global variables like "performance_schema_max_stage_classes";
+
+select count(*) from performance_schema.setup_instruments
+ where name like "stage/%";
+
+# We lost all the classes
+--disable_warnings
+select variable_value > 0 from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_STAGE_CLASSES_LOST';
+--enable_warnings
+
+# Expect no stages
+select count(*) from performance_schema.events_stages_current;
+select count(*) from performance_schema.events_stages_history;
+select count(*) from performance_schema.events_stages_history_long;
+
+# Expect no stages classes
+select count(*) from performance_schema.events_stages_summary_by_thread_by_event_name;
+select count(*) from performance_schema.events_stages_summary_global_by_event_name;
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_stages_history-master.opt b/mysql-test/suite/perfschema/t/start_server_no_stages_history-master.opt
new file mode 100644
index 00000000..c3b7cfd6
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_stages_history-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_events_stages_history_size=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_stages_history.test b/mysql-test/suite/perfschema/t/start_server_no_stages_history.test
new file mode 100644
index 00000000..fca9b5f6
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_stages_history.test
@@ -0,0 +1,14 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no history
+show global variables like "performance_schema_events_stages_history_size";
+select count(*) from performance_schema.events_stages_history;
+
+# Valid operation, edge case
+truncate table performance_schema.events_stages_history;
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_stages_history_long-master.opt b/mysql-test/suite/perfschema/t/start_server_no_stages_history_long-master.opt
new file mode 100644
index 00000000..731c1469
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_stages_history_long-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_events_stages_history_long_size=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_stages_history_long.test b/mysql-test/suite/perfschema/t/start_server_no_stages_history_long.test
new file mode 100644
index 00000000..282e396a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_stages_history_long.test
@@ -0,0 +1,14 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no history long
+show global variables like "performance_schema_events_stages_history_long_size";
+select count(*) from performance_schema.events_stages_history_long;
+
+# Valid operation, edge case
+truncate table performance_schema.events_stages_history_long;
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_statement_class-master.opt b/mysql-test/suite/perfschema/t/start_server_no_statement_class-master.opt
new file mode 100644
index 00000000..6cf6fbdc
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_statement_class-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_max_statement_classes=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_statement_class.test b/mysql-test/suite/perfschema/t/start_server_no_statement_class.test
new file mode 100644
index 00000000..fa80d328
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_statement_class.test
@@ -0,0 +1,28 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no classes
+show global variables like "performance_schema_max_statement_classes";
+
+select count(*) from performance_schema.setup_instruments
+ where name like "statement/%";
+
+# We lost all the classes
+--disable_warnings
+select variable_value > 0 from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_STATEMENT_CLASSES_LOST';
+--enable_warnings
+
+# Expect no statements
+select count(*) from performance_schema.events_statements_current;
+select count(*) from performance_schema.events_statements_history;
+select count(*) from performance_schema.events_statements_history_long;
+
+# Expect no statements classes
+select count(*) from performance_schema.events_statements_summary_by_thread_by_event_name;
+select count(*) from performance_schema.events_statements_summary_global_by_event_name;
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_statements_history-master.opt b/mysql-test/suite/perfschema/t/start_server_no_statements_history-master.opt
new file mode 100644
index 00000000..3389a3c4
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_statements_history-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_events_statements_history_size=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_statements_history.test b/mysql-test/suite/perfschema/t/start_server_no_statements_history.test
new file mode 100644
index 00000000..e87a59dd
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_statements_history.test
@@ -0,0 +1,14 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no history
+show global variables like "performance_schema_events_statements_history_size";
+select count(*) from performance_schema.events_statements_history;
+
+# Valid operation, edge case
+truncate table performance_schema.events_statements_history;
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_statements_history_long-master.opt b/mysql-test/suite/perfschema/t/start_server_no_statements_history_long-master.opt
new file mode 100644
index 00000000..b7728d6e
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_statements_history_long-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_events_statements_history_long_size=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_statements_history_long.test b/mysql-test/suite/perfschema/t/start_server_no_statements_history_long.test
new file mode 100644
index 00000000..c14df52a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_statements_history_long.test
@@ -0,0 +1,14 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no history long
+show global variables like "performance_schema_events_statements_history_long_size";
+select count(*) from performance_schema.events_statements_history_long;
+
+# Valid operation, edge case
+truncate table performance_schema.events_statements_history_long;
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_table_hdl-master.opt b/mysql-test/suite/perfschema/t/start_server_no_table_hdl-master.opt
new file mode 100644
index 00000000..c6b6db94
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_table_hdl-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_max_table_handles=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_table_hdl.test b/mysql-test/suite/perfschema/t/start_server_no_table_hdl.test
new file mode 100644
index 00000000..87c4173c
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_table_hdl.test
@@ -0,0 +1,32 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect instances
+show global variables like "performance_schema_max_table_instances";
+
+# Expect no handles
+show global variables like "performance_schema_max_table_handles";
+
+# Create an instrumented table
+--disable_warnings
+drop table if exists test.instrument_me;
+--enable_warnings
+
+create table test.instrument_me(a int);
+insert into test.instrument_me values (1), (2), (3);
+select * from test.instrument_me;
+drop table test.instrument_me;
+
+# Expect no instances lost
+show global variables like "performance_schema_max_table_instances";
+
+# We lost all the handles
+--disable_warnings
+select variable_value > 0 from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_TABLE_HANDLES_LOST';
+--enable_warnings
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_table_inst-master.opt b/mysql-test/suite/perfschema/t/start_server_no_table_inst-master.opt
new file mode 100644
index 00000000..57145166
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_table_inst-master.opt
@@ -0,0 +1,4 @@
+--loose-enable-performance-schema
+--loose-performance_schema_max_table_instances=0
+--loose-performance_schema_max_index_stat=0
+--loose-performance_schema_max_table_lock_stat=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_table_inst.test b/mysql-test/suite/perfschema/t/start_server_no_table_inst.test
new file mode 100644
index 00000000..ec6674ef
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_table_inst.test
@@ -0,0 +1,32 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no instances
+show global variables like "performance_schema_max_table_instances";
+
+# Expect handles
+show global variables like "performance_schema_max_table_handles";
+
+# Create an instrumented table
+--disable_warnings
+drop table if exists test.instrument_me;
+--enable_warnings
+
+create table test.instrument_me(a int);
+insert into test.instrument_me values (1), (2), (3);
+select * from test.instrument_me;
+drop table test.instrument_me;
+
+# We lost all the instances
+--disable_warnings
+select variable_value > 0 from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_TABLE_INSTANCES_LOST';
+--enable_warnings
+
+# Expect no handle lost
+show global status like "performance_schema_table_handles_lost";
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_table_lock-master.opt b/mysql-test/suite/perfschema/t/start_server_no_table_lock-master.opt
new file mode 100644
index 00000000..2fe2a524
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_table_lock-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_max_table_lock_stat=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_table_lock.test b/mysql-test/suite/perfschema/t/start_server_no_table_lock.test
new file mode 100644
index 00000000..111130b7
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_table_lock.test
@@ -0,0 +1,56 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+#############################
+# Setup database and tables.
+#############################
+--disable_warnings
+drop table if exists db1.t1;
+drop database if exists db1;
+--enable_warnings
+create database db1;
+create table db1.t1 (a int, b char(10) default 'default');
+
+#######################
+# Execute few queries.
+#######################
+insert into db1.t1 values('1', 'abc');
+insert into db1.t1 values('2', 'abc');
+--disable_ps2_protocol
+select * from db1.t1 where a='1';
+--enable_ps2_protocol
+
+#####################################################
+# Run few queries on Performance Schema stats tables.
+#####################################################
+# There should be 3 entries in following table. 2 for insert and 1 for select.
+# This is because lock stats are still in the table handles
+select COUNT_STAR from performance_schema.table_lock_waits_summary_by_table
+ where OBJECT_SCHEMA='db1' and OBJECT_NAME='t1';
+
+# Now force aggregation by closing table handles
+FLUSH TABLES;
+
+select COUNT_STAR from performance_schema.table_lock_waits_summary_by_table
+ where OBJECT_SCHEMA='db1' and OBJECT_NAME='t1';
+
+# Expect TABLE_LOCK_STAT lost
+--disable_warnings
+select variable_value > 0 from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_TABLE_LOCK_STAT_LOST';
+
+# While at it, check that FLUSH STATUS Resets the lost counter
+FLUSH STATUS;
+
+select variable_value from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_TABLE_LOCK_STAT_LOST';
+--enable_warnings
+
+###########
+# Cleanup.
+###########
+drop database db1;
diff --git a/mysql-test/suite/perfschema/t/start_server_no_thread_class-master.opt b/mysql-test/suite/perfschema/t/start_server_no_thread_class-master.opt
new file mode 100644
index 00000000..f3facc95
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_thread_class-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_max_thread_classes=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_thread_class.test b/mysql-test/suite/perfschema/t/start_server_no_thread_class.test
new file mode 100644
index 00000000..7909eb11
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_thread_class.test
@@ -0,0 +1,25 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no classes
+show global variables like "performance_schema_max_thread_classes";
+
+select count(*) from performance_schema.setup_instruments
+ where name like "thread/%";
+
+# We lost all the classes
+--disable_warnings
+select variable_value > 0 from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_THREAD_CLASSES_LOST';
+--enable_warnings
+
+# Expect no instances
+select count(*) from performance_schema.threads;
+
+# Expect no instances lost
+show global status like "performance_schema_thread_instances_lost";
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_thread_inst-master.opt b/mysql-test/suite/perfschema/t/start_server_no_thread_inst-master.opt
new file mode 100644
index 00000000..ba1e4750
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_thread_inst-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_max_thread_instances=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_thread_inst.test b/mysql-test/suite/perfschema/t/start_server_no_thread_inst.test
new file mode 100644
index 00000000..f1e221cc
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_thread_inst.test
@@ -0,0 +1,29 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect classes
+show global variables like "performance_schema_max_thread_classes";
+
+# Not observable yet
+# select count(*) > 0 from performance_schema.setup_instruments
+# where name like "thread/%";
+
+# Expect no class lost
+show global status like "performance_schema_thread_classes_lost";
+
+# Expect no instances
+show global variables like "performance_schema_max_thread_instances";
+
+select count(*) from performance_schema.threads;
+
+# Expect instances lost
+--disable_warnings
+select variable_value > 0 from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_THREAD_INSTANCES_LOST';
+--enable_warnings
+
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_transactions_history-master.opt b/mysql-test/suite/perfschema/t/start_server_no_transactions_history-master.opt
new file mode 100644
index 00000000..76ffd378
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_transactions_history-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_events_transactions_history_size=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_transactions_history.test b/mysql-test/suite/perfschema/t/start_server_no_transactions_history.test
new file mode 100644
index 00000000..266af484
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_transactions_history.test
@@ -0,0 +1,14 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no history
+show global variables like "performance_schema_events_transactions_history_size";
+select count(*) from performance_schema.events_transactions_history;
+
+# Valid operation, edge case
+truncate table performance_schema.events_transactions_history;
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_transactions_history_long-master.opt b/mysql-test/suite/perfschema/t/start_server_no_transactions_history_long-master.opt
new file mode 100644
index 00000000..60d148e8
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_transactions_history_long-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_events_transactions_history_long_size=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_transactions_history_long.test b/mysql-test/suite/perfschema/t/start_server_no_transactions_history_long.test
new file mode 100644
index 00000000..83f80b52
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_transactions_history_long.test
@@ -0,0 +1,14 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no history long
+show global variables like "performance_schema_events_transactions_history_long_size";
+select count(*) from performance_schema.events_transactions_history_long;
+
+# Valid operation, edge case
+truncate table performance_schema.events_transactions_history_long;
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_user-master.opt b/mysql-test/suite/perfschema/t/start_server_no_user-master.opt
new file mode 100644
index 00000000..50571a72
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_user-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_users_size=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_user.test b/mysql-test/suite/perfschema/t/start_server_no_user.test
new file mode 100644
index 00000000..2b1b9fed
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_user.test
@@ -0,0 +1,18 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no records
+show global variables like "performance_schema_users_size";
+
+select count(*) from performance_schema.users;
+
+# We lost all the data
+--disable_warnings
+select variable_value > 0 from information_schema.global_status
+ where variable_name like 'PERFORMANCE_SCHEMA_USERS_LOST';
+--enable_warnings
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_waits_history-master.opt b/mysql-test/suite/perfschema/t/start_server_no_waits_history-master.opt
new file mode 100644
index 00000000..334f805e
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_waits_history-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_events_waits_history_size=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_waits_history.test b/mysql-test/suite/perfschema/t/start_server_no_waits_history.test
new file mode 100644
index 00000000..3eb56177
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_waits_history.test
@@ -0,0 +1,14 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no history
+show global variables like "performance_schema_events_waits_history_size";
+select count(*) from performance_schema.events_waits_history;
+
+# Valid operation, edge case
+truncate table performance_schema.events_waits_history;
+
diff --git a/mysql-test/suite/perfschema/t/start_server_no_waits_history_long-master.opt b/mysql-test/suite/perfschema/t/start_server_no_waits_history_long-master.opt
new file mode 100644
index 00000000..ca6699f8
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_waits_history_long-master.opt
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_events_waits_history_long_size=0
diff --git a/mysql-test/suite/perfschema/t/start_server_no_waits_history_long.test b/mysql-test/suite/perfschema/t/start_server_no_waits_history_long.test
new file mode 100644
index 00000000..b22b1e7e
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_no_waits_history_long.test
@@ -0,0 +1,14 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no history long
+show global variables like "performance_schema_events_waits_history_long_size";
+select count(*) from performance_schema.events_waits_history_long;
+
+# Valid operation, edge case
+truncate table performance_schema.events_waits_history_long;
+
diff --git a/mysql-test/suite/perfschema/t/start_server_nothing-master.opt b/mysql-test/suite/perfschema/t/start_server_nothing-master.opt
new file mode 100644
index 00000000..aa7d019a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_nothing-master.opt
@@ -0,0 +1,47 @@
+--loose-enable-performance-schema
+
+--loose-performance_schema_events_waits_history_long_size=0
+--loose-performance_schema_events_waits_history_size=0
+
+--loose-performance_schema_max_mutex_classes=0
+--loose-performance_schema_max_rwlock_classes=0
+--loose-performance_schema_max_cond_classes=0
+--loose-performance_schema_max_file_classes=0
+--loose-performance_schema_max_thread_classes=0
+--loose-performance_schema_max_socket_classes=0
+--loose-performance_schema_max_memory_classes=0
+
+--loose-performance_schema_max_mutex_instances=0
+--loose-performance_schema_max_rwlock_instances=0
+--loose-performance_schema_max_cond_instances=0
+--loose-performance_schema_max_file_instances=0
+--loose-performance_schema_max_thread_instances=0
+--loose-performance_schema_max_socket_instances=0
+
+--loose-performance_schema_max_table_instances=0
+--loose-performance_schema_max_file_handles=0
+--loose-performance_schema_max_table_handles=0
+--loose-performance_schema_max_index_stat=0
+--loose-performance_schema_max_table_lock_stat=0
+
+--loose-performance_schema_setup_actors_size=0
+--loose-performance_schema_setup_objects_size=0
+--loose-performance_schema_accounts_size=0
+--loose-performance_schema_hosts_size=0
+--loose-performance_schema_users_size=0
+
+--loose-performance_schema_max_stage_classes=0
+--loose-performance_schema_events_stages_history_long_size=0
+--loose-performance_schema_events_stages_history_size=0
+
+--loose-performance_schema_max_statement_classes=0
+--loose-performance_schema_events_statements_history_long_size=0
+--loose-performance_schema_events_statements_history_size=0
+
+--loose-performance_schema_session_connect_attrs_size=0
+
+--loose-performance_schema_digests_size=0
+--loose-performance_schema_max_metadata_locks=0
+
+--loose-performance_schema_max_program_instances=0
+--loose-performance_schema_max_statement_stack=1
diff --git a/mysql-test/suite/perfschema/t/start_server_nothing.test b/mysql-test/suite/perfschema/t/start_server_nothing.test
new file mode 100644
index 00000000..957a2894
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_nothing.test
@@ -0,0 +1,62 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+show global variables like "performance_schema%";
+
+# Not empty
+select * from performance_schema.setup_instruments
+ order by name;
+select TIMER_NAME from performance_schema.performance_timers;
+select * from performance_schema.setup_consumers;
+select NAME from performance_schema.setup_timers;
+
+# All empty
+select * from performance_schema.accounts;
+select * from performance_schema.cond_instances;
+select * from performance_schema.events_stages_current;
+select * from performance_schema.events_stages_history;
+select * from performance_schema.events_stages_history_long;
+select * from performance_schema.events_stages_summary_by_account_by_event_name;
+select * from performance_schema.events_stages_summary_by_host_by_event_name;
+select * from performance_schema.events_stages_summary_by_thread_by_event_name;
+select * from performance_schema.events_stages_summary_by_user_by_event_name;
+select * from performance_schema.events_stages_summary_global_by_event_name;
+select * from performance_schema.events_statements_current;
+select * from performance_schema.events_statements_history;
+select * from performance_schema.events_statements_history_long;
+select * from performance_schema.events_statements_summary_by_account_by_event_name;
+select * from performance_schema.events_statements_summary_by_host_by_event_name;
+select * from performance_schema.events_statements_summary_by_thread_by_event_name;
+select * from performance_schema.events_statements_summary_by_user_by_event_name;
+select * from performance_schema.events_statements_summary_global_by_event_name;
+select * from performance_schema.events_waits_current;
+select * from performance_schema.events_waits_history;
+select * from performance_schema.events_waits_history_long;
+select * from performance_schema.events_waits_summary_by_account_by_event_name;
+select * from performance_schema.events_waits_summary_by_host_by_event_name;
+select * from performance_schema.events_waits_summary_by_instance;
+select * from performance_schema.events_waits_summary_by_thread_by_event_name;
+select * from performance_schema.events_waits_summary_by_user_by_event_name;
+select * from performance_schema.events_waits_summary_global_by_event_name;
+select * from performance_schema.file_instances;
+select * from performance_schema.file_summary_by_event_name;
+select * from performance_schema.file_summary_by_instance;
+select * from performance_schema.hosts;
+select * from performance_schema.metadata_locks;
+select * from performance_schema.mutex_instances;
+select * from performance_schema.objects_summary_global_by_type;
+select * from performance_schema.rwlock_instances;
+select * from performance_schema.session_account_connect_attrs;
+select * from performance_schema.session_connect_attrs;
+select * from performance_schema.setup_actors;
+select * from performance_schema.setup_objects;
+select * from performance_schema.socket_instances;
+select * from performance_schema.socket_summary_by_event_name;
+select * from performance_schema.socket_summary_by_instance;
+select * from performance_schema.table_handles;
+select * from performance_schema.threads;
+select * from performance_schema.users;
diff --git a/mysql-test/suite/perfschema/t/start_server_off-master.opt b/mysql-test/suite/perfschema/t/start_server_off-master.opt
new file mode 100644
index 00000000..600566e8
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_off-master.opt
@@ -0,0 +1 @@
+--loose-disable-performance-schema
diff --git a/mysql-test/suite/perfschema/t/start_server_off.test b/mysql-test/suite/perfschema/t/start_server_off.test
new file mode 100644
index 00000000..6fdc02ac
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_off.test
@@ -0,0 +1,56 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+select * from information_schema.engines
+ where engine = "PERFORMANCE_SCHEMA";
+
+# Expecting all off / zero
+show status like "performance_schema%";
+show variables like "performance_schema";
+
+# Expect all consumers disabled
+
+select * from performance_schema.setup_consumers;
+
+# Expect no instruments
+
+select * from performance_schema.setup_instruments;
+
+select * from performance_schema.setup_actors;
+select * from performance_schema.setup_objects;
+select * from performance_schema.setup_timers;
+
+# Expect INSERT to fail with an error
+
+--error ER_WRONG_PERFSCHEMA_USAGE
+insert into performance_schema.setup_objects values ('TABLE', 'myschema', 'myobject', 'YES', 'YES');
+
+--error ER_WRONG_PERFSCHEMA_USAGE
+insert into performance_schema.setup_actors values ('myhost', 'mysuser', 'myrole', 'YES', 'YES');
+
+# Expect SELECT, UPDATE, DELETE and TRUNCATE to affect 0 rows, but with
+# no error because the target row(s) will not be found
+
+select * from performance_schema.setup_objects;
+update performance_schema.setup_objects set OBJECT_NAME = 'myobject';
+delete from performance_schema.setup_objects;
+
+select * from performance_schema.setup_actors;
+update performance_schema.setup_actors set HOST = 'myhost';
+delete from performance_schema.setup_actors;
+
+truncate performance_schema.events_stages_history_long;
+truncate performance_schema.events_statements_history_long;
+truncate performance_schema.events_waits_history_long;
+truncate performance_schema.setup_objects;
+truncate performance_schema.setup_actors;
+
+--disable_warnings
+# Expect that status variables are still accessible
+show global status like "performance_schema%";
+show session status like "performance_schema%";
+--enable_warnings
diff --git a/mysql-test/suite/perfschema/t/start_server_on-master.opt b/mysql-test/suite/perfschema/t/start_server_on-master.opt
new file mode 100644
index 00000000..542720c4
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_on-master.opt
@@ -0,0 +1 @@
+--loose-enable-performance-schema
diff --git a/mysql-test/suite/perfschema/t/start_server_on.test b/mysql-test/suite/perfschema/t/start_server_on.test
new file mode 100644
index 00000000..dabef20e
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_on.test
@@ -0,0 +1,10 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expecting nothing lost with default parameters
+
+show global status like "performance_schema%";
diff --git a/mysql-test/suite/perfschema/t/start_server_variables.test b/mysql-test/suite/perfschema/t/start_server_variables.test
new file mode 100644
index 00000000..57656f9e
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_variables.test
@@ -0,0 +1,11 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# This has a stable output, printing the result:
+show variables where
+ `Variable_name` != "performance_schema_max_statement_classes" and
+ `Variable_name` like "performance_schema%";
diff --git a/mysql-test/suite/perfschema/t/start_server_zero_digest_sql_length-master.opt b/mysql-test/suite/perfschema/t/start_server_zero_digest_sql_length-master.opt
new file mode 100644
index 00000000..5ee2230e
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_zero_digest_sql_length-master.opt
@@ -0,0 +1,3 @@
+--thread_stack=655360
+--max_digest_length=0
+--loose-performance_schema_max_sql_text_length=0
diff --git a/mysql-test/suite/perfschema/t/start_server_zero_digest_sql_length.test b/mysql-test/suite/perfschema/t/start_server_zero_digest_sql_length.test
new file mode 100644
index 00000000..4d5d5ce7
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/start_server_zero_digest_sql_length.test
@@ -0,0 +1,20 @@
+# -----------------------------------------------------------------------
+# Tests for the performance schema statement Digests.
+# -----------------------------------------------------------------------
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/no_protocol.inc
+
+USE performance_schema;
+truncate table events_statements_history_long;
+
+# -----------------------------------------------------------------------
+# Test to show how the digest behaves with low value of max_digest_length
+# -----------------------------------------------------------------------
+SELECT 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1;
+
+--echo ####################################
+--echo # QUERYING PS STATEMENT DIGEST
+--echo ####################################
+SELECT event_name, digest, digest_text, sql_text FROM events_statements_history_long;
diff --git a/mysql-test/suite/perfschema/t/statement_digest.test b/mysql-test/suite/perfschema/t/statement_digest.test
new file mode 100644
index 00000000..724f9192
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/statement_digest.test
@@ -0,0 +1,25 @@
+# -----------------------------------------------------------------------
+# Tests for the performance schema statement Digests.
+# -----------------------------------------------------------------------
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+SET sql_mode='NO_ENGINE_SUBSTITUTION';
+# Initial Setup for Digest
+--source ../include/digest_setup.inc
+
+TRUNCATE TABLE performance_schema.events_statements_summary_by_digest;
+
+# Executing queries
+--source ../include/digest_execution.inc
+
+--echo ####################################
+--echo # QUERYING PS STATEMENT DIGEST
+--echo ####################################
+SELECT SCHEMA_NAME, DIGEST_TEXT, COUNT_STAR, SUM_ROWS_AFFECTED, SUM_WARNINGS,
+ SUM_ERRORS FROM performance_schema.events_statements_summary_by_digest;
+
+# Cleanup for Digest
+--source ../include/digest_cleanup.inc
+SET sql_mode=default;
diff --git a/mysql-test/suite/perfschema/t/statement_digest_charset.test b/mysql-test/suite/perfschema/t/statement_digest_charset.test
new file mode 100644
index 00000000..2ac9797e
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/statement_digest_charset.test
@@ -0,0 +1,36 @@
+# Test for PERFORMANCE_SCHEMA statement digests
+#
+# Test statements using different character sets.
+# See Bug#13809293 - PERFSCHEMA.DML_ESMS_BY_DIGEST FAILS ON DAILY-TRUNK SPORADICALLY
+#
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_warnings
+DROP DATABASE IF EXISTS pfs_charset_test;
+--enable_warnings
+CREATE DATABASE pfs_charset_test;
+USE pfs_charset_test;
+
+#
+# CP1251 - 8 bits, max multibyte length = 1
+#
+SET NAMES cp1251;
+TRUNCATE TABLE performance_schema.events_statements_summary_by_digest;
+CREATE TABLE äîëåí_ðåãèñòúð_1251a (s1 INT);
+CREATE TABLE ÄîËåÍ_ðåãèñòúð_1251b (s1 INT, s2 INT);
+
+#
+# UTF8 - 8 bits, max multibyte length = 4
+#
+SET NAMES utf8;
+CREATE TABLE ДОЛЕÐ_региÑÑ‚ÑŠÑ€_утф8 (s1 INT);
+
+#
+# Incorrectly converted statement identifiers will result in a warning.
+#
+SET NAMES latin1;
+SELECT * FROM performance_schema.events_statements_summary_by_digest
+ WHERE digest_text LIKE 'XXXYYY%' LIMIT 1;
+
+DROP DATABASE pfs_charset_test;
diff --git a/mysql-test/suite/perfschema/t/statement_digest_consumers-master.opt b/mysql-test/suite/perfschema/t/statement_digest_consumers-master.opt
new file mode 100644
index 00000000..a13a5a2c
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/statement_digest_consumers-master.opt
@@ -0,0 +1,2 @@
+--loose-performance_schema_consumer_statements_digest=1
+--loose-performance_schema_consumer_events_statements_current=0
diff --git a/mysql-test/suite/perfschema/t/statement_digest_consumers.test b/mysql-test/suite/perfschema/t/statement_digest_consumers.test
new file mode 100644
index 00000000..16fa300b
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/statement_digest_consumers.test
@@ -0,0 +1,35 @@
+# ----------------------------------------------------
+# Tests for the performance schema statement Digests.
+# ----------------------------------------------------
+
+# Test case to show behavior of statements digest in combination of different
+# consumers enabled/disabled
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+# Initial Setup for Digest
+--source ../include/digest_setup.inc
+
+# -----------------------------------------
+# Consumer State |
+# -----------------------------------------
+# statements_digest Disabled |
+# events_statement_current Enabled |
+# -----------------------------------------
+
+SELECT * FROM performance_schema.setup_consumers;
+
+TRUNCATE TABLE performance_schema.events_statements_summary_by_digest;
+
+# Executing queries
+--source ../include/digest_execution.inc
+
+--echo ####################################
+--echo # QUERYING PS STATEMENT DIGEST
+--echo ####################################
+SELECT schema_name,digest_text, count_star FROM performance_schema.events_statements_summary_by_digest;
+SELECT digest_text FROM performance_schema.events_statements_current;
+
+# Cleanup for Digest
+--source ../include/digest_cleanup.inc
diff --git a/mysql-test/suite/perfschema/t/statement_digest_consumers2-master.opt b/mysql-test/suite/perfschema/t/statement_digest_consumers2-master.opt
new file mode 100644
index 00000000..60ce703c
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/statement_digest_consumers2-master.opt
@@ -0,0 +1,2 @@
+--loose-performance_schema_consumer_statements_digest=0
+--loose-performance_schema_consumer_events_statements_current=1
diff --git a/mysql-test/suite/perfschema/t/statement_digest_consumers2.test b/mysql-test/suite/perfschema/t/statement_digest_consumers2.test
new file mode 100644
index 00000000..98442349
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/statement_digest_consumers2.test
@@ -0,0 +1,37 @@
+# ----------------------------------------------------
+# Tests for the performance schema statement Digests.
+# ----------------------------------------------------
+
+# Test case to show behavior of statements digest in combination of different
+# consumers enabled/disabled
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+# Initial Setup for Digest
+--source ../include/digest_setup.inc
+
+# -----------------------------------------
+# Consumer State |
+# -----------------------------------------
+# statements_digest Enabled |
+# events_statement_current Disabled |
+# global_implementation Disabled ? |
+# thread_implementation Disabled ? |
+# -----------------------------------------
+
+SELECT * FROM performance_schema.setup_consumers;
+
+TRUNCATE TABLE performance_schema.events_statements_summary_by_digest;
+
+# Executing queries
+--source ../include/digest_execution.inc
+
+--echo ####################################
+--echo # QUERYING PS STATEMENT DIGEST
+--echo ####################################
+SELECT schema_name, digest, digest_text, count_star FROM performance_schema.events_statements_summary_by_digest;
+SELECT digest, digest_text FROM performance_schema.events_statements_current;
+
+# Cleanup for Digest
+--source ../include/digest_cleanup.inc
diff --git a/mysql-test/suite/perfschema/t/statement_digest_long_query-master.opt b/mysql-test/suite/perfschema/t/statement_digest_long_query-master.opt
new file mode 100644
index 00000000..3f9d7900
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/statement_digest_long_query-master.opt
@@ -0,0 +1 @@
+--thread_stack=655360
diff --git a/mysql-test/suite/perfschema/t/statement_digest_long_query.test b/mysql-test/suite/perfschema/t/statement_digest_long_query.test
new file mode 100644
index 00000000..efa33800
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/statement_digest_long_query.test
@@ -0,0 +1,31 @@
+# -----------------------------------------------------------------------
+# Tests for the performance schema statement Digests.
+# -----------------------------------------------------------------------
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+# Test requires: sp-protocol/ps-protocol/view-protocol/cursor-protocol disabled
+--source include/no_protocol.inc
+# Thread stack overrun on solaris
+let $have_solaris = `select convert(@@version_compile_os using latin1) LIKE ("solaris%")`;
+if ($have_solaris)
+{
+ skip Test requires: 'not_solaris';
+}
+
+USE performance_schema;
+truncate table events_statements_summary_by_digest;
+
+# -----------------------------------------------------------------------
+# Test to show how the digest behaves with long queries, when the token
+# stream is truncated. digest text is calculated based on value of
+# performance_schema_max_digest_length.
+# NOTE: For this test case to run, we need to start mysql server
+# with bigger stack using "--thread_stack=#" option.
+# -----------------------------------------------------------------------
+SELECT 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1;
+
+--echo ####################################
+--echo # QUERYING PS STATEMENT DIGEST
+--echo ####################################
+SELECT schema_name, digest_text, count_star FROM events_statements_summary_by_digest;
diff --git a/mysql-test/suite/perfschema/t/statement_program_concurrency-master.opt b/mysql-test/suite/perfschema/t/statement_program_concurrency-master.opt
new file mode 100644
index 00000000..8c0dedee
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/statement_program_concurrency-master.opt
@@ -0,0 +1 @@
+--innodb_lock_wait_timeout=1 --thread_stack=655360
diff --git a/mysql-test/suite/perfschema/t/statement_program_concurrency.test b/mysql-test/suite/perfschema/t/statement_program_concurrency.test
new file mode 100644
index 00000000..8229223c
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/statement_program_concurrency.test
@@ -0,0 +1,132 @@
+#----------------------------------------------------------
+# Concurrency check for instrumentation of stored programs
+#----------------------------------------------------------
+
+
+--source include/big_test.inc
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/no_protocol.inc
+
+TRUNCATE TABLE performance_schema.events_statements_summary_by_program;
+TRUNCATE TABLE performance_schema.events_statements_history;
+
+--echo # concurrency check through multi connections
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+CREATE DATABASE db1;
+CREATE DATABASE db2;
+CREATE DATABASE db3;
+
+# connection 1
+connect (con1,localhost,root,,db1);
+
+USE db1;
+
+CREATE TABLE t1(
+ i INT NOT NULL
+);
+
+LOAD DATA INFILE '../../std_data/wl5766_data.txt' INTO TABLE t1;
+
+DELIMITER |;
+CREATE PROCEDURE proc()
+BEGIN
+ INSERT INTO t1 SELECT * FROM t1;
+END|
+DELIMITER ;|
+
+--send CALL proc();
+
+# connection 2
+connect (con2,localhost,root,,db2);
+
+USE db2;
+
+CREATE TABLE t2(
+ i INT NOT NULL
+);
+
+LOAD DATA INFILE '../../std_data/wl5766_data.txt' INTO TABLE t2;
+DELIMITER |;
+CREATE FUNCTION addition(x INT, y INT) RETURNS INT
+BEGIN
+ INSERT INTO t2 SELECT * FROM t2;
+ RETURN x+y;
+END|
+DELIMITER ;|
+
+--send SELECT addition(1234,9876);
+
+# connection 3
+connect (con3,localhost,root,,db3);
+
+USE db3;
+
+CREATE TABLE t(
+ i INT NOT NULL,
+ j INT
+);
+
+CREATE TABLE t3(
+ i INT NOT NULL
+);
+
+LOAD DATA INFILE '../../std_data/wl5766_data.txt' INTO TABLE t3;
+INSERT INTO t VALUES ( 10,1000 );
+CREATE TRIGGER trg AFTER INSERT ON t FOR EACH ROW
+ INSERT INTO t3 SELECT * FROM t3;
+
+--send INSERT INTO t VALUES ( 20,2000);
+
+connection con1;
+--reap;
+
+connection con2;
+--reap;
+
+connection con3;
+--reap;
+
+connection default;
+
+--let $wait_condition=select count(*)=3 from information_schema.processlist where command='sleep';
+--source include/wait_condition.inc
+
+SELECT OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, COUNT_STAR, COUNT_STATEMENTS
+ FROM performance_schema.events_statements_summary_by_program
+ WHERE OBJECT_SCHEMA='db1' OR OBJECT_SCHEMA='db2' OR OBJECT_SCHEMA='db3'
+ ORDER BY OBJECT_SCHEMA, OBJECT_NAME;
+
+SELECT EVENT_NAME, SQL_TEXT, CURRENT_SCHEMA, OBJECT_TYPE, OBJECT_SCHEMA,
+ OBJECT_NAME, NESTING_EVENT_TYPE, NESTING_EVENT_LEVEL FROM
+ performance_schema.events_statements_history WHERE CURRENT_SCHEMA='db1'
+ OR CURRENT_SCHEMA='db2' OR CURRENT_SCHEMA='db3'
+ ORDER BY CURRENT_SCHEMA, OBJECT_NAME;
+
+TRUNCATE TABLE performance_schema.events_statements_summary_by_program;
+TRUNCATE TABLE performance_schema.events_statements_history;
+
+--echo # Clean-up
+
+DROP PROCEDURE db1.proc;
+DROP FUNCTION db2.addition;
+DROP TRIGGER db3.trg;
+
+DROP TABLE db1.t1;
+DROP TABLE db2.t2;
+DROP TABLE db3.t3;
+DROP TABLE db3.t;
+
+DROP DATABASE db1;
+DROP DATABASE db2;
+DROP DATABASE db3;
+
+disconnect con1;
+disconnect con2;
+disconnect con3;
+
+# Wait till all disconnects are completed
+--source include/wait_until_count_sessions.inc
diff --git a/mysql-test/suite/perfschema/t/statement_program_lost_inst-master.opt b/mysql-test/suite/perfschema/t/statement_program_lost_inst-master.opt
new file mode 100644
index 00000000..699c9193
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/statement_program_lost_inst-master.opt
@@ -0,0 +1,3 @@
+--loose-performance_schema_max_program_instances=7
+--loose-performance_schema_max_statement_stack=2
+--thread_stack=655360
diff --git a/mysql-test/suite/perfschema/t/statement_program_lost_inst.test b/mysql-test/suite/perfschema/t/statement_program_lost_inst.test
new file mode 100644
index 00000000..023180b9
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/statement_program_lost_inst.test
@@ -0,0 +1,72 @@
+#-------------------------------------------------------------
+# Tests for PERFORMANCE_SCHEMA stored programs instrumentation
+#-------------------------------------------------------------
+
+#
+# Test case to show the behaviour of stored program instrumentation
+# when values of the system variables performance_schema_max_program_instances &
+# performance_schema_max_statement_stack are less than the statistics collected.
+# The status of the lost instrumentation is shown through the status variables
+# performance_schema_program_lost & performance_schema_nested_statement_lost
+#
+
+# Restarting the server at the begining of the test.
+# This is to avoid the instrumentation of extra SPs called by MTR
+# These additional stored programs which will be added might cause
+# result content mismatch failure.
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
+--exec echo "wait" > $restart_file
+--shutdown_server
+--source include/wait_until_disconnected.inc
+--exec echo "restart:--performance_schema_max_program_instances=7 --performance_schema_max_statement_stack=2 --thread_stack=655360">$restart_file
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+
+--source ../include/start_server_common.inc
+
+# Values of variables server variables
+show global variables like "performance_schema_max_program_instances";
+show global variables like "performance_schema_max_statement_stack";
+
+--echo #####################
+--echo # Setup
+--echo #####################
+--source suite/perfschema/include/program_nested_setup.inc
+
+# Truncate summary table
+TRUNCATE performance_schema.events_statements_summary_by_program;
+SELECT OBJECT_TYPE, OBJECT_NAME, OBJECT_SCHEMA FROM
+performance_schema.events_statements_summary_by_program
+WHERE OBJECT_SCHEMA='nested_sp' ORDER BY OBJECT_NAME;
+# Flush status now
+Flush status;
+show global status like "%performance_schema_program_lost%";
+show global status like "%performance_schema_nested_statement_lost%";
+
+--echo #####################
+--echo # Executing Queries
+--echo #####################
+--source suite/perfschema/include/program_nested_execution.inc
+
+--echo ###########################################
+--echo # Quering PS statement summary table #
+--echo ###########################################
+
+SELECT OBJECT_TYPE, OBJECT_NAME, OBJECT_SCHEMA
+ FROM performance_schema.events_statements_summary_by_program
+ WHERE OBJECT_SCHEMA='nested_sp' ORDER BY OBJECT_NAME;
+
+# Now check the lost status
+show global status like "%performance_schema_program_lost%";
+show global status like "%performance_schema_nested_statement_lost%";
+
+--echo #####################
+--echo # Cleanup
+--echo #####################
+--source suite/perfschema/include/program_nested_cleanup.inc
+
+
diff --git a/mysql-test/suite/perfschema/t/statement_program_nested-master.opt b/mysql-test/suite/perfschema/t/statement_program_nested-master.opt
new file mode 100644
index 00000000..3f9d7900
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/statement_program_nested-master.opt
@@ -0,0 +1 @@
+--thread_stack=655360
diff --git a/mysql-test/suite/perfschema/t/statement_program_nested.test b/mysql-test/suite/perfschema/t/statement_program_nested.test
new file mode 100644
index 00000000..183e9858
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/statement_program_nested.test
@@ -0,0 +1,75 @@
+# -----------------------------------------------------------------------
+# Tests for the performance schema nested stored program instrumentation.
+# -----------------------------------------------------------------------
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/have_innodb.inc
+
+TRUNCATE TABLE performance_schema.events_statements_summary_by_program;
+TRUNCATE TABLE performance_schema.events_statements_history_long;
+
+--echo #################################################
+--echo # Quering PS statement summary and history_long #
+--echo #################################################
+
+--source suite/perfschema/include/program_nested_setup.inc
+ALTER TABLE t2 ENGINE=InnoDB;
+--source suite/perfschema/include/program_nested_execution.inc
+
+SELECT EVENT_NAME, SQL_TEXT, CURRENT_SCHEMA, OBJECT_TYPE, OBJECT_SCHEMA,
+ OBJECT_NAME, NESTING_EVENT_TYPE, NESTING_EVENT_LEVEL
+ FROM performance_schema.events_statements_history_long WHERE
+ CURRENT_SCHEMA='nested_sp' ORDER BY
+ OBJECT_NAME,NESTING_EVENT_LEVEL,SQL_TEXT,EVENT_NAME;
+
+SELECT OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, COUNT_STAR, COUNT_STATEMENTS
+ FROM performance_schema.events_statements_summary_by_program
+ WHERE OBJECT_SCHEMA='nested_sp' ORDER BY OBJECT_NAME;
+
+--echo # clean-up
+TRUNCATE TABLE performance_schema.events_statements_summary_by_program;
+TRUNCATE TABLE performance_schema.events_statements_history_long;
+
+# After truncate the statictics collected will are reset
+SELECT OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, COUNT_STAR, COUNT_STATEMENTS
+ FROM performance_schema.events_statements_summary_by_program
+ WHERE OBJECT_SCHEMA='nested_sp' ORDER BY OBJECT_NAME;
+
+--source suite/perfschema/include/program_nested_cleanup.inc
+
+# After clean-up the stored programs are removed from PS tables
+SELECT OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, COUNT_STAR, COUNT_STATEMENTS
+ FROM performance_schema.events_statements_summary_by_program
+ WHERE OBJECT_SCHEMA='nested_sp' ORDER BY OBJECT_NAME;
+
+
+# Check the intrumentation of stored programs
+# when statement/sp/% instruments not timed
+
+--source suite/perfschema/include/program_nested_setup.inc
+
+update performance_schema.setup_instruments set enabled='YES', timed='NO'
+ where name like "statement/sp/%" order by name;
+
+TRUNCATE TABLE performance_schema.events_statements_summary_by_program;
+TRUNCATE TABLE performance_schema.events_statements_history_long;
+
+--source suite/perfschema/include/program_nested_execution.inc
+
+# check instrumentation
+
+SELECT EVENT_NAME, TIMER_START, TIMER_END, TIMER_WAIT FROM
+ performance_schema.events_statements_history_long WHERE
+ CURRENT_SCHEMA='nested_sp' AND EVENT_NAME like "statement/sp/%";
+
+# clean-up
+
+# Restore the setup
+update performance_schema.setup_instruments set enabled='YES', timed='YES'
+ where name like "statement/sp/%" order by name;
+
+TRUNCATE TABLE performance_schema.events_statements_summary_by_program;
+TRUNCATE TABLE performance_schema.events_statements_history_long;
+
+--source suite/perfschema/include/program_nested_cleanup.inc
diff --git a/mysql-test/suite/perfschema/t/statement_program_nesting_event_check-master.opt b/mysql-test/suite/perfschema/t/statement_program_nesting_event_check-master.opt
new file mode 100644
index 00000000..3f9d7900
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/statement_program_nesting_event_check-master.opt
@@ -0,0 +1 @@
+--thread_stack=655360
diff --git a/mysql-test/suite/perfschema/t/statement_program_nesting_event_check.test b/mysql-test/suite/perfschema/t/statement_program_nesting_event_check.test
new file mode 100644
index 00000000..73829be8
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/statement_program_nesting_event_check.test
@@ -0,0 +1,47 @@
+#-------------------------------------------------------------
+# Tests for PERFORMANCE_SCHEMA stored programs instrumentation
+#-------------------------------------------------------------
+
+# Test to check the values populated in NESTING_EVENT_TYPE
+# columns of events_statements_current/history/history_long PS tables.
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/have_innodb.inc
+
+TRUNCATE TABLE performance_schema.events_statements_history_long;
+
+--echo #----------------------------
+--echo # Non-nested Stored programs.
+--echo #----------------------------
+--source suite/perfschema/include/program_setup.inc
+ALTER TABLE t2 ENGINE=InnoDB;
+--source suite/perfschema/include/program_execution.inc
+
+SELECT EVENT_NAME, SQL_TEXT, OBJECT_NAME, NESTING_EVENT_TYPE, NESTING_EVENT_LEVEL
+ FROM performance_schema.events_statements_history_long
+ WHERE CURRENT_SCHEMA='stored_programs' AND
+ (SQL_TEXT not like '%count(*) = %' OR SQL_TEXT IS NULL)
+ ORDER BY OBJECT_NAME,NESTING_EVENT_LEVEL,SQL_TEXT;
+
+TRUNCATE TABLE performance_schema.events_statements_history_long;
+
+# Clean-up
+--source suite/perfschema/include/program_cleanup.inc
+
+--echo #------------------------
+--echo # Nested stored programs.
+--echo #------------------------
+--source suite/perfschema/include/program_nested_setup.inc
+ALTER TABLE t2 ENGINE=InnoDB;
+--source suite/perfschema/include/program_nested_execution.inc
+
+SELECT EVENT_NAME, SQL_TEXT, OBJECT_NAME, NESTING_EVENT_TYPE, NESTING_EVENT_LEVEL
+ FROM performance_schema.events_statements_history_long
+ WHERE CURRENT_SCHEMA='nested_sp'
+ ORDER BY OBJECT_NAME, NESTING_EVENT_LEVEL, SQL_TEXT, EVENT_NAME;
+
+TRUNCATE TABLE performance_schema.events_statements_history_long;
+
+# Clean-up
+--source suite/perfschema/include/program_nested_cleanup.inc
diff --git a/mysql-test/suite/perfschema/t/statement_program_non_nested-master.opt b/mysql-test/suite/perfschema/t/statement_program_non_nested-master.opt
new file mode 100644
index 00000000..3f9d7900
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/statement_program_non_nested-master.opt
@@ -0,0 +1 @@
+--thread_stack=655360
diff --git a/mysql-test/suite/perfschema/t/statement_program_non_nested.test b/mysql-test/suite/perfschema/t/statement_program_non_nested.test
new file mode 100644
index 00000000..559bd039
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/statement_program_non_nested.test
@@ -0,0 +1,144 @@
+# -----------------------------------------------------------------------
+# Tests for the performance schema stored program instrumentation.
+# -----------------------------------------------------------------------
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+TRUNCATE TABLE performance_schema.events_statements_summary_by_program;
+TRUNCATE TABLE performance_schema.events_statements_history_long;
+
+--echo ################################################
+--echo # Quering PS statement summary and history_long#
+--echo ################################################
+
+--source suite/perfschema/include/program_setup.inc
+--source suite/perfschema/include/program_execution.inc
+
+SELECT OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, COUNT_STAR, COUNT_STATEMENTS
+ FROM performance_schema.events_statements_summary_by_program
+ WHERE OBJECT_SCHEMA='stored_programs' ORDER BY OBJECT_NAME;
+
+SELECT EVENT_NAME, SQL_TEXT, CURRENT_SCHEMA, OBJECT_TYPE, OBJECT_SCHEMA,
+ OBJECT_NAME, NESTING_EVENT_TYPE, NESTING_EVENT_LEVEL FROM
+ performance_schema.events_statements_history_long WHERE
+ CURRENT_SCHEMA='stored_programs' AND
+ (SQL_TEXT not like '%count(*) = %' OR SQL_TEXT IS NULL)
+ ORDER BY OBJECT_NAME, NESTING_EVENT_LEVEL, SQL_TEXT;
+
+
+--echo # clean -up
+
+TRUNCATE TABLE performance_schema.events_statements_summary_by_program;
+TRUNCATE TABLE performance_schema.events_statements_history_long;
+
+# After truncate the statictics collected will are reset
+SELECT OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, COUNT_STAR, COUNT_STATEMENTS
+ FROM performance_schema.events_statements_summary_by_program
+ WHERE OBJECT_SCHEMA='stored_programs' ORDER BY OBJECT_NAME;
+
+--source suite/perfschema/include/program_cleanup.inc
+
+# After clean-up the stored programs are removed from PS tables
+
+SELECT OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, COUNT_STAR, COUNT_STATEMENTS
+ FROM performance_schema.events_statements_summary_by_program
+ WHERE OBJECT_SCHEMA='stored_programs' ORDER BY OBJECT_NAME;
+
+# Check the intrumentation of stored programs
+# when statement/sp/% instruments not timed
+
+--source suite/perfschema/include/program_setup.inc
+
+update performance_schema.setup_instruments set enabled='YES', timed='NO'
+ where name like "statement/sp/%" order by name;
+
+TRUNCATE TABLE performance_schema.events_statements_summary_by_program;
+TRUNCATE TABLE performance_schema.events_statements_history_long;
+
+--source suite/perfschema/include/program_execution.inc
+
+# check instrumentation
+
+SELECT EVENT_NAME, TIMER_START, TIMER_END, TIMER_WAIT FROM
+ performance_schema.events_statements_history_long WHERE
+ CURRENT_SCHEMA='stored_programs' AND EVENT_NAME like "statement/sp/%";
+
+# clean-up
+
+# Restore the setup
+update performance_schema.setup_instruments set enabled='YES', timed='YES'
+ where name like "statement/sp/%" order by name;
+
+TRUNCATE TABLE performance_schema.events_statements_summary_by_program;
+TRUNCATE TABLE performance_schema.events_statements_history_long;
+
+--source suite/perfschema/include/program_cleanup.inc
+
+#----------------------------------------------------------------
+# The statistics of a stored program are not collected
+# if its execution fails
+#----------------------------------------------------------------
+
+--echo # set-up
+CREATE DATABASE sp;
+USE sp;
+
+CREATE TABLE t1(
+ a INT,
+ b INT
+);
+
+--echo # let the creation of the following stored programs fail
+--error 1064
+CREATE PROCEDURE fail1(IN a INT OUT x CHAR(16))
+ SET a=1;
+
+--error 1064
+CREATE FUNCTION fail2(a INT , b INT) RETURNS INT
+ x=SELECT COUNT(*) FROM t;
+
+--error 1064
+CREATE EVENT fail3 SCHEDULE EVERY MICROSECOND DO
+ DROP TABLE t;
+
+--echo # the below query on PS table doesn't show any rows
+--echo # as the creation of stored programs failed
+SELECT OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, COUNT_STAR, COUNT_STATEMENTS
+ FROM performance_schema.events_statements_summary_by_program
+ WHERE OBJECT_SCHEMA='sp';
+
+--echo # create few stored programs
+DELIMITER |;
+CREATE PROCEDURE p(x1 INT, x2 INT)
+BEGIN
+ INSERT INTO t1 VALUES (x1, x2);
+END|
+DELIMITER ;|
+
+CREATE FUNCTION f(y1 INT, y2 INT) RETURNS INT
+ RETURN y1+y2;
+
+CREATE TRIGGER trg AFTER INSERT ON t1 FOR EACH ROW
+ SET @neg=-1;
+
+--echo # execute the created stored programs such that they fail.
+--error 1318
+CALL p(7);
+--error 1318
+SELECT f("add",1,3);
+--error 1064
+INSERT INTO t1;
+
+--echo # the below query on PS table doesn't expose any statistics as
+--echo # execution of the created stored porgrams failed.
+SELECT OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, COUNT_STAR, COUNT_STATEMENTS
+ FROM performance_schema.events_statements_summary_by_program
+ WHERE OBJECT_SCHEMA='sp';
+
+--echo #clean-up
+DROP PROCEDURE p;
+DROP FUNCTION f;
+DROP TRIGGER trg;
+DROP TABLE t1;
+DROP DATABASE sp;
diff --git a/mysql-test/suite/perfschema/t/status_reprepare.test b/mysql-test/suite/perfschema/t/status_reprepare.test
new file mode 100644
index 00000000..6393655b
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/status_reprepare.test
@@ -0,0 +1,61 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/no_protocol.inc
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--echo #
+--echo # ================================================================================
+--echo # SETUP
+--echo # ================================================================================
+
+# Create a new connection, to get clean statistics
+connect(con1, localhost, root,,);
+
+# Create a table
+CREATE TABLE test.t1 (c1 INT);
+
+#prepare a statement
+PREPARE stmt1 FROM "SELECT c1 FROM test.t1";
+
+#execute prepared statement;
+EXECUTE stmt1;
+
+# Check status from SHOW STATUS
+SHOW SESSION STATUS LIKE "%com_stmt_%prepare%";
+
+#check the statistics
+SELECT * FROM performance_schema.session_status WHERE VARIABLE_NAME LIKE "%com_stmt%";
+
+SELECT VARIABLE_VALUE INTO @count_global_reprepare_before
+ FROM performance_schema.global_status
+ WHERE VARIABLE_NAME LIKE "Com_stmt_reprepare";
+
+# Alter table to make server reprepare the statement
+ALTER TABLE test.t1 ADD COLUMN c2 INTEGER;
+
+#execute prepared statement;
+EXECUTE stmt1;
+
+# Check status from SHOW STATUS
+SHOW SESSION STATUS LIKE "%com_stmt_%prepare%";
+
+#check the statistics
+SELECT * FROM performance_schema.session_status WHERE VARIABLE_NAME LIKE "%com_stmt%";
+
+SELECT VARIABLE_VALUE INTO @count_global_reprepare_after
+ FROM performance_schema.global_status
+ WHERE VARIABLE_NAME LIKE "Com_stmt_reprepare";
+
+# Should increment by 1
+SELECT @count_global_reprepare_after - @count_global_reprepare_before;
+
+--echo #
+--echo # ================================================================================
+--echo # CLEANUP
+--echo # ================================================================================
+
+DROP TABLE test.t1;
+
+--disconnect con1
+--connection default
diff --git a/mysql-test/suite/perfschema/t/sxlock_func.test b/mysql-test/suite/perfschema/t/sxlock_func.test
new file mode 100644
index 00000000..c43adc84
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/sxlock_func.test
@@ -0,0 +1,70 @@
+# Performance schema tests, for SX-lock
+# Note that only Innodb provides instrumented SX-locks,
+# so this test depends largely on the innodb instrumentation.
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/have_innodb.inc
+
+UPDATE performance_schema.setup_instruments SET enabled = 'NO', timed = 'YES';
+
+UPDATE performance_schema.setup_instruments SET enabled = 'YES'
+WHERE name like 'wait/synch/sxlock/%';
+
+UPDATE performance_schema.setup_instruments SET enabled = 'YES'
+WHERE name like 'wait/synch/rwlock/innodb/%';
+
+SELECT DISTINCT name FROM performance_schema.setup_instruments
+WHERE name LIKE 'wait/synch/rwlock/innodb/%'
+AND name!='wait/synch/rwlock/innodb/btr_search_latch' ORDER BY name;
+
+TRUNCATE TABLE performance_schema.events_waits_history_long;
+TRUNCATE TABLE performance_schema.events_waits_history;
+TRUNCATE TABLE performance_schema.events_waits_current;
+
+# Check some SX-locks classes are instrumented
+select name from performance_schema.setup_instruments
+where name like "wait/synch/sxlock/%" order by name;
+
+# Check some SX-locks instances are instrumented
+SELECT DISTINCT name FROM performance_schema.rwlock_instances
+WHERE name LIKE 'wait/synch/sxlock/innodb/%'
+ORDER BY name;
+
+# Some Innodb payload, to produce data
+
+create table t1(a int) engine=innodb;
+begin;
+insert into t1 values (1), (2), (3);
+insert into t1 values (1), (2), (3);
+insert into t1 values (1), (2), (3);
+commit;
+drop table t1;
+
+# Make sure some rw-lock operations have been executed
+# (there will only occasionally be waits on some rw-locks)
+
+SELECT DISTINCT event_name FROM performance_schema.events_waits_history_long
+WHERE event_name LIKE 'wait/synch/rwlock/innodb/%'
+AND event_name NOT IN
+('wait/synch/rwlock/innodb/btr_search_latch',
+ 'wait/synch/rwlock/innodb/dict_operation_lock',
+ 'wait/synch/rwlock/innodb/trx_rseg_latch',
+ 'wait/synch/rwlock/innodb/trx_purge_latch')
+ORDER BY event_name;
+
+# Make sure some shared_lock operations have been executed
+
+SELECT event_name FROM performance_schema.events_waits_history_long
+WHERE event_name = 'wait/synch/sxlock/innodb/index_tree_rw_lock'
+AND operation IN ('try_shared_lock','shared_lock') LIMIT 1;
+
+# Make sure some exclusive_lock operations have been executed
+
+SELECT event_name from performance_schema.events_waits_history_long
+WHERE event_name = 'wait/synch/sxlock/innodb/index_tree_rw_lock'
+AND operation IN ('try_exclusive_lock','exclusive_lock') LIMIT 1;
+
+# Cleanup
+
+UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES';
diff --git a/mysql-test/suite/perfschema/t/table_aggregate_global_2u_2t.test b/mysql-test/suite/perfschema/t/table_aggregate_global_2u_2t.test
new file mode 100644
index 00000000..240be494
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_aggregate_global_2u_2t.test
@@ -0,0 +1,21 @@
+# Tests for the performance schema
+
+--source ../include/table_aggregate_setup.inc
+
+# table io and table lock by default
+
+# global
+update performance_schema.setup_consumers
+ set enabled='NO' where name='thread_instrumentation';
+
+# 2users
+delete from performance_schema.setup_actors
+ where user in ('user2', 'user4');
+
+# 2tables
+delete from performance_schema.setup_objects
+ where object_name='t2';
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_aggregate_global_2u_3t.test b/mysql-test/suite/perfschema/t/table_aggregate_global_2u_3t.test
new file mode 100644
index 00000000..cfee4505
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_aggregate_global_2u_3t.test
@@ -0,0 +1,19 @@
+# Tests for the performance schema
+
+--source ../include/table_aggregate_setup.inc
+
+# table io and table lock by default
+
+# global
+update performance_schema.setup_consumers
+ set enabled='NO' where name='thread_instrumentation';
+
+# 2users
+delete from performance_schema.setup_actors
+ where user in ('user2', 'user4');
+
+# 3tables by default
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_aggregate_global_4u_2t.test b/mysql-test/suite/perfschema/t/table_aggregate_global_4u_2t.test
new file mode 100644
index 00000000..a523ee6c
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_aggregate_global_4u_2t.test
@@ -0,0 +1,19 @@
+# Tests for the performance schema
+
+--source ../include/table_aggregate_setup.inc
+
+# table io and table lock by default
+
+# global
+update performance_schema.setup_consumers
+ set enabled='NO' where name='thread_instrumentation';
+
+# 4users by default
+
+# 2tables
+delete from performance_schema.setup_objects
+ where object_name='t2';
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_aggregate_global_4u_3t.test b/mysql-test/suite/perfschema/t/table_aggregate_global_4u_3t.test
new file mode 100644
index 00000000..01cae774
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_aggregate_global_4u_3t.test
@@ -0,0 +1,17 @@
+# Tests for the performance schema
+
+--source ../include/table_aggregate_setup.inc
+
+# table io and table lock by default
+
+# global
+update performance_schema.setup_consumers
+ set enabled='NO' where name='thread_instrumentation';
+
+# 4users by default
+
+# 3tables by default
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_aggregate_hist_2u_2t.test b/mysql-test/suite/perfschema/t/table_aggregate_hist_2u_2t.test
new file mode 100644
index 00000000..518ca74f
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_aggregate_hist_2u_2t.test
@@ -0,0 +1,19 @@
+# Tests for the performance schema
+
+--source ../include/table_aggregate_setup.inc
+
+# table io and table lock by default
+
+# hist by default
+
+# 2users
+delete from performance_schema.setup_actors
+ where user in ('user2', 'user4');
+
+# 2tables
+delete from performance_schema.setup_objects
+ where object_name='t2';
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_aggregate_hist_2u_3t.test b/mysql-test/suite/perfschema/t/table_aggregate_hist_2u_3t.test
new file mode 100644
index 00000000..6ebaf2f4
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_aggregate_hist_2u_3t.test
@@ -0,0 +1,17 @@
+# Tests for the performance schema
+
+--source ../include/table_aggregate_setup.inc
+
+# table io and table lock by default
+
+# hist by default
+
+# 2users
+delete from performance_schema.setup_actors
+ where user in ('user2', 'user4');
+
+# 3tables by default
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_aggregate_hist_4u_2t.test b/mysql-test/suite/perfschema/t/table_aggregate_hist_4u_2t.test
new file mode 100644
index 00000000..ac8f6f83
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_aggregate_hist_4u_2t.test
@@ -0,0 +1,17 @@
+# Tests for the performance schema
+
+--source ../include/table_aggregate_setup.inc
+
+# table io and table lock by default
+
+# hist by default
+
+# 4users by default
+
+# 2tables
+delete from performance_schema.setup_objects
+ where object_name='t2';
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_aggregate_hist_4u_3t.test b/mysql-test/suite/perfschema/t/table_aggregate_hist_4u_3t.test
new file mode 100644
index 00000000..4201db1a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_aggregate_hist_4u_3t.test
@@ -0,0 +1,15 @@
+# Tests for the performance schema
+
+--source ../include/table_aggregate_setup.inc
+
+# table io and table lock by default
+
+# hist by default
+
+# 4users by default
+
+# 3tables by default
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_aggregate_off.test b/mysql-test/suite/perfschema/t/table_aggregate_off.test
new file mode 100644
index 00000000..a56d6a9b
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_aggregate_off.test
@@ -0,0 +1,13 @@
+# Tests for the performance schema
+
+--source ../include/table_aggregate_setup.inc
+
+# table io and table lock by default
+
+# off
+update performance_schema.setup_consumers
+ set enabled='NO' where name='global_instrumentation';
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_aggregate_thread_2u_2t.test b/mysql-test/suite/perfschema/t/table_aggregate_thread_2u_2t.test
new file mode 100644
index 00000000..ff1bd616
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_aggregate_thread_2u_2t.test
@@ -0,0 +1,21 @@
+# Tests for the performance schema
+
+--source ../include/table_aggregate_setup.inc
+
+# table io and table lock by default
+
+# thread
+update performance_schema.setup_consumers
+ set enabled='NO' where name like 'event%';
+
+# 2users
+delete from performance_schema.setup_actors
+ where user in ('user2', 'user4');
+
+# 2tables
+delete from performance_schema.setup_objects
+ where object_name='t2';
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_aggregate_thread_2u_3t.test b/mysql-test/suite/perfschema/t/table_aggregate_thread_2u_3t.test
new file mode 100644
index 00000000..6f33fd63
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_aggregate_thread_2u_3t.test
@@ -0,0 +1,19 @@
+# Tests for the performance schema
+
+--source ../include/table_aggregate_setup.inc
+
+# table io and table lock by default
+
+# thread
+update performance_schema.setup_consumers
+ set enabled='NO' where name like 'event%';
+
+# 2users
+delete from performance_schema.setup_actors
+ where user in ('user2', 'user4');
+
+# 3tables by default
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_aggregate_thread_4u_2t.test b/mysql-test/suite/perfschema/t/table_aggregate_thread_4u_2t.test
new file mode 100644
index 00000000..e01edbc6
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_aggregate_thread_4u_2t.test
@@ -0,0 +1,19 @@
+# Tests for the performance schema
+
+--source ../include/table_aggregate_setup.inc
+
+# table io and table lock by default
+
+# thread
+update performance_schema.setup_consumers
+ set enabled='NO' where name like 'event%';
+
+# 4users by default
+
+# 2tables
+delete from performance_schema.setup_objects
+ where object_name='t2';
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_aggregate_thread_4u_3t.test b/mysql-test/suite/perfschema/t/table_aggregate_thread_4u_3t.test
new file mode 100644
index 00000000..1e67fbdd
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_aggregate_thread_4u_3t.test
@@ -0,0 +1,17 @@
+# Tests for the performance schema
+
+--source ../include/table_aggregate_setup.inc
+
+# table io and table lock by default
+
+# thread
+update performance_schema.setup_consumers
+ set enabled='NO' where name like 'event%';
+
+# 4users by default
+
+# 3tables by default
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_io_aggregate_global_2u_2t.test b/mysql-test/suite/perfschema/t/table_io_aggregate_global_2u_2t.test
new file mode 100644
index 00000000..025bb8af
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_io_aggregate_global_2u_2t.test
@@ -0,0 +1,23 @@
+# Tests for the performance schema
+
+--source ../include/table_aggregate_setup.inc
+
+# table io
+update performance_schema.setup_instruments
+ set enabled='NO' where name='wait/lock/table/sql/handler';
+
+# global
+update performance_schema.setup_consumers
+ set enabled='NO' where name='thread_instrumentation';
+
+# 2users
+delete from performance_schema.setup_actors
+ where user in ('user2', 'user4');
+
+# 2tables
+delete from performance_schema.setup_objects
+ where object_name='t2';
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_io_aggregate_global_2u_3t.test b/mysql-test/suite/perfschema/t/table_io_aggregate_global_2u_3t.test
new file mode 100644
index 00000000..da566c99
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_io_aggregate_global_2u_3t.test
@@ -0,0 +1,21 @@
+# Tests for the performance schema
+
+--source ../include/table_aggregate_setup.inc
+
+# table io
+update performance_schema.setup_instruments
+ set enabled='NO' where name='wait/lock/table/sql/handler';
+
+# global
+update performance_schema.setup_consumers
+ set enabled='NO' where name='thread_instrumentation';
+
+# 2users
+delete from performance_schema.setup_actors
+ where user in ('user2', 'user4');
+
+# 3tables by default
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_io_aggregate_global_4u_2t.test b/mysql-test/suite/perfschema/t/table_io_aggregate_global_4u_2t.test
new file mode 100644
index 00000000..9d03b1b1
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_io_aggregate_global_4u_2t.test
@@ -0,0 +1,21 @@
+# Tests for the performance schema
+
+--source ../include/table_aggregate_setup.inc
+
+# table io
+update performance_schema.setup_instruments
+ set enabled='NO' where name='wait/lock/table/sql/handler';
+
+# global
+update performance_schema.setup_consumers
+ set enabled='NO' where name='thread_instrumentation';
+
+# 4users by default
+
+# 2tables
+delete from performance_schema.setup_objects
+ where object_name='t2';
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_io_aggregate_global_4u_3t.test b/mysql-test/suite/perfschema/t/table_io_aggregate_global_4u_3t.test
new file mode 100644
index 00000000..90a59940
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_io_aggregate_global_4u_3t.test
@@ -0,0 +1,19 @@
+# Tests for the performance schema
+
+--source ../include/table_aggregate_setup.inc
+
+# table io
+update performance_schema.setup_instruments
+ set enabled='NO' where name='wait/lock/table/sql/handler';
+
+# global
+update performance_schema.setup_consumers
+ set enabled='NO' where name='thread_instrumentation';
+
+# 4users by default
+
+# 3tables by default
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_io_aggregate_hist_2u_2t.test b/mysql-test/suite/perfschema/t/table_io_aggregate_hist_2u_2t.test
new file mode 100644
index 00000000..7c01bd01
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_io_aggregate_hist_2u_2t.test
@@ -0,0 +1,21 @@
+# Tests for the performance schema
+
+--source ../include/table_aggregate_setup.inc
+
+# table io
+update performance_schema.setup_instruments
+ set enabled='NO' where name='wait/lock/table/sql/handler';
+
+# hist by default
+
+# 2users
+delete from performance_schema.setup_actors
+ where user in ('user2', 'user4');
+
+# 2tables
+delete from performance_schema.setup_objects
+ where object_name='t2';
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_io_aggregate_hist_2u_3t.test b/mysql-test/suite/perfschema/t/table_io_aggregate_hist_2u_3t.test
new file mode 100644
index 00000000..b817059c
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_io_aggregate_hist_2u_3t.test
@@ -0,0 +1,19 @@
+# Tests for the performance schema
+
+--source ../include/table_aggregate_setup.inc
+
+# hist by default
+
+# table io
+update performance_schema.setup_instruments
+ set enabled='NO' where name='wait/lock/table/sql/handler';
+
+# 2users
+delete from performance_schema.setup_actors
+ where user in ('user2', 'user4');
+
+# 3tables by default
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_io_aggregate_hist_4u_2t.test b/mysql-test/suite/perfschema/t/table_io_aggregate_hist_4u_2t.test
new file mode 100644
index 00000000..6b6c3906
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_io_aggregate_hist_4u_2t.test
@@ -0,0 +1,19 @@
+# Tests for the performance schema
+
+--source ../include/table_aggregate_setup.inc
+
+# table io
+update performance_schema.setup_instruments
+ set enabled='NO' where name='wait/lock/table/sql/handler';
+
+# hist by default
+
+# 4users by default
+
+# 2tables
+delete from performance_schema.setup_objects
+ where object_name='t2';
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_io_aggregate_hist_4u_3t.test b/mysql-test/suite/perfschema/t/table_io_aggregate_hist_4u_3t.test
new file mode 100644
index 00000000..ff4c74f8
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_io_aggregate_hist_4u_3t.test
@@ -0,0 +1,17 @@
+# Tests for the performance schema
+
+--source ../include/table_aggregate_setup.inc
+
+# table io
+update performance_schema.setup_instruments
+ set enabled='NO' where name='wait/lock/table/sql/handler';
+
+# hist by default
+
+# 4users by default
+
+# 3tables by default
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_io_aggregate_thread_2u_2t.test b/mysql-test/suite/perfschema/t/table_io_aggregate_thread_2u_2t.test
new file mode 100644
index 00000000..6e70be45
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_io_aggregate_thread_2u_2t.test
@@ -0,0 +1,23 @@
+# Tests for the performance schema
+
+--source ../include/table_aggregate_setup.inc
+
+# table io
+update performance_schema.setup_instruments
+ set enabled='NO' where name='wait/lock/table/sql/handler';
+
+# thread
+update performance_schema.setup_consumers
+ set enabled='NO' where name like 'event%';
+
+# 2users
+delete from performance_schema.setup_actors
+ where user in ('user2', 'user4');
+
+# 2tables
+delete from performance_schema.setup_objects
+ where object_name='t2';
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_io_aggregate_thread_2u_3t.test b/mysql-test/suite/perfschema/t/table_io_aggregate_thread_2u_3t.test
new file mode 100644
index 00000000..3dca2916
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_io_aggregate_thread_2u_3t.test
@@ -0,0 +1,21 @@
+# Tests for the performance schema
+
+--source ../include/table_aggregate_setup.inc
+
+# table io
+update performance_schema.setup_instruments
+ set enabled='NO' where name='wait/lock/table/sql/handler';
+
+# thread
+update performance_schema.setup_consumers
+ set enabled='NO' where name like 'event%';
+
+# 2users
+delete from performance_schema.setup_actors
+ where user in ('user2', 'user4');
+
+# 3tables by default
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_io_aggregate_thread_4u_2t.test b/mysql-test/suite/perfschema/t/table_io_aggregate_thread_4u_2t.test
new file mode 100644
index 00000000..e14ccf38
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_io_aggregate_thread_4u_2t.test
@@ -0,0 +1,21 @@
+# Tests for the performance schema
+
+--source ../include/table_aggregate_setup.inc
+
+# table io
+update performance_schema.setup_instruments
+ set enabled='NO' where name='wait/lock/table/sql/handler';
+
+# thread
+update performance_schema.setup_consumers
+ set enabled='NO' where name like 'event%';
+
+# 4users by default
+
+# 2tables
+delete from performance_schema.setup_objects
+ where object_name='t2';
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_io_aggregate_thread_4u_3t.test b/mysql-test/suite/perfschema/t/table_io_aggregate_thread_4u_3t.test
new file mode 100644
index 00000000..eaf55d6a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_io_aggregate_thread_4u_3t.test
@@ -0,0 +1,19 @@
+# Tests for the performance schema
+
+--source ../include/table_aggregate_setup.inc
+
+# table io
+update performance_schema.setup_instruments
+ set enabled='NO' where name='wait/lock/table/sql/handler';
+
+# thread
+update performance_schema.setup_consumers
+ set enabled='NO' where name like 'event%';
+
+# 4users by default
+
+# 3tables by default
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_lock_aggregate_global_2u_2t.test b/mysql-test/suite/perfschema/t/table_lock_aggregate_global_2u_2t.test
new file mode 100644
index 00000000..9205e2b9
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_lock_aggregate_global_2u_2t.test
@@ -0,0 +1,26 @@
+# Tests for the performance schema
+
+# Use MyISAM as InnoDB SE no longer uses THR_LOCK locks.
+#--source include/force_myisam_default.inc
+
+--source ../include/table_aggregate_setup.inc
+
+# table lock
+update performance_schema.setup_instruments
+ set enabled='NO' where name='wait/io/table/sql/handler';
+
+# global
+update performance_schema.setup_consumers
+ set enabled='NO' where name='thread_instrumentation';
+
+# 2users
+delete from performance_schema.setup_actors
+ where user in ('user2', 'user4');
+
+# 2tables
+delete from performance_schema.setup_objects
+ where object_name='t2';
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_lock_aggregate_global_2u_3t.test b/mysql-test/suite/perfschema/t/table_lock_aggregate_global_2u_3t.test
new file mode 100644
index 00000000..60db987b
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_lock_aggregate_global_2u_3t.test
@@ -0,0 +1,24 @@
+# Tests for the performance schema
+
+# Use MyISAM as InnoDB SE no longer uses THR_LOCK locks.
+#--source include/force_myisam_default.inc
+
+--source ../include/table_aggregate_setup.inc
+
+# table lock
+update performance_schema.setup_instruments
+ set enabled='NO' where name='wait/io/table/sql/handler';
+
+# global
+update performance_schema.setup_consumers
+ set enabled='NO' where name='thread_instrumentation';
+
+# 2users
+delete from performance_schema.setup_actors
+ where user in ('user2', 'user4');
+
+# 3tables by default
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_lock_aggregate_global_4u_2t.test b/mysql-test/suite/perfschema/t/table_lock_aggregate_global_4u_2t.test
new file mode 100644
index 00000000..1bac2d52
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_lock_aggregate_global_4u_2t.test
@@ -0,0 +1,24 @@
+# Tests for the performance schema
+
+# Use MyISAM as InnoDB SE no longer uses THR_LOCK locks.
+#--source include/force_myisam_default.inc
+
+--source ../include/table_aggregate_setup.inc
+
+# table lock
+update performance_schema.setup_instruments
+ set enabled='NO' where name='wait/io/table/sql/handler';
+
+# global
+update performance_schema.setup_consumers
+ set enabled='NO' where name='thread_instrumentation';
+
+# 4users by default
+
+# 2tables
+delete from performance_schema.setup_objects
+ where object_name='t2';
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_lock_aggregate_global_4u_3t.test b/mysql-test/suite/perfschema/t/table_lock_aggregate_global_4u_3t.test
new file mode 100644
index 00000000..4909defe
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_lock_aggregate_global_4u_3t.test
@@ -0,0 +1,22 @@
+# Tests for the performance schema
+
+# Use MyISAM as InnoDB SE no longer uses THR_LOCK locks.
+#--source include/force_myisam_default.inc
+
+--source ../include/table_aggregate_setup.inc
+
+# table lock
+update performance_schema.setup_instruments
+ set enabled='NO' where name='wait/io/table/sql/handler';
+
+# global
+update performance_schema.setup_consumers
+ set enabled='NO' where name='thread_instrumentation';
+
+# 4users by default
+
+# 3tables by default
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_lock_aggregate_hist_2u_2t.test b/mysql-test/suite/perfschema/t/table_lock_aggregate_hist_2u_2t.test
new file mode 100644
index 00000000..7721599b
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_lock_aggregate_hist_2u_2t.test
@@ -0,0 +1,24 @@
+# Tests for the performance schema
+
+# Use MyISAM as InnoDB SE no longer uses THR_LOCK locks.
+#--source include/force_myisam_default.inc
+
+--source ../include/table_aggregate_setup.inc
+
+# table lock
+update performance_schema.setup_instruments
+ set enabled='NO' where name='wait/io/table/sql/handler';
+
+# hist by default
+
+# 2users
+delete from performance_schema.setup_actors
+ where user in ('user2', 'user4');
+
+# 2tables
+delete from performance_schema.setup_objects
+ where object_name='t2';
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_lock_aggregate_hist_2u_3t.test b/mysql-test/suite/perfschema/t/table_lock_aggregate_hist_2u_3t.test
new file mode 100644
index 00000000..ef1e196a
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_lock_aggregate_hist_2u_3t.test
@@ -0,0 +1,22 @@
+# Tests for the performance schema
+
+# Use MyISAM as InnoDB SE no longer uses THR_LOCK locks.
+#--source include/force_myisam_default.inc
+
+--source ../include/table_aggregate_setup.inc
+
+# hist by default
+
+# table lock
+update performance_schema.setup_instruments
+ set enabled='NO' where name='wait/io/table/sql/handler';
+
+# 2users
+delete from performance_schema.setup_actors
+ where user in ('user2', 'user4');
+
+# 3tables by default
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_lock_aggregate_hist_4u_2t.test b/mysql-test/suite/perfschema/t/table_lock_aggregate_hist_4u_2t.test
new file mode 100644
index 00000000..ad34cd9f
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_lock_aggregate_hist_4u_2t.test
@@ -0,0 +1,22 @@
+# Tests for the performance schema
+
+# Use MyISAM as InnoDB SE no longer uses THR_LOCK locks.
+#--source include/force_myisam_default.inc
+
+--source ../include/table_aggregate_setup.inc
+
+# table lock
+update performance_schema.setup_instruments
+ set enabled='NO' where name='wait/io/table/sql/handler';
+
+# hist by default
+
+# 4users by default
+
+# 2tables
+delete from performance_schema.setup_objects
+ where object_name='t2';
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_lock_aggregate_hist_4u_3t.test b/mysql-test/suite/perfschema/t/table_lock_aggregate_hist_4u_3t.test
new file mode 100644
index 00000000..078a6d9e
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_lock_aggregate_hist_4u_3t.test
@@ -0,0 +1,20 @@
+# Tests for the performance schema
+
+# Use MyISAM as InnoDB SE no longer uses THR_LOCK locks.
+#--source include/force_myisam_default.inc
+
+--source ../include/table_aggregate_setup.inc
+
+# table lock
+update performance_schema.setup_instruments
+ set enabled='NO' where name='wait/io/table/sql/handler';
+
+# hist by default
+
+# 4users by default
+
+# 3tables by default
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_lock_aggregate_thread_2u_2t.test b/mysql-test/suite/perfschema/t/table_lock_aggregate_thread_2u_2t.test
new file mode 100644
index 00000000..a155619e
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_lock_aggregate_thread_2u_2t.test
@@ -0,0 +1,26 @@
+# Tests for the performance schema
+
+# Use MyISAM as InnoDB SE no longer uses THR_LOCK locks.
+#--source include/force_myisam_default.inc
+
+--source ../include/table_aggregate_setup.inc
+
+# table lock
+update performance_schema.setup_instruments
+ set enabled='NO' where name='wait/io/table/sql/handler';
+
+# thread
+update performance_schema.setup_consumers
+ set enabled='NO' where name like 'event%';
+
+# 2users
+delete from performance_schema.setup_actors
+ where user in ('user2', 'user4');
+
+# 2tables
+delete from performance_schema.setup_objects
+ where object_name='t2';
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_lock_aggregate_thread_2u_3t.test b/mysql-test/suite/perfschema/t/table_lock_aggregate_thread_2u_3t.test
new file mode 100644
index 00000000..c48d39f5
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_lock_aggregate_thread_2u_3t.test
@@ -0,0 +1,24 @@
+# Tests for the performance schema
+
+# Use MyISAM as InnoDB SE no longer uses THR_LOCK locks.
+#--source include/force_myisam_default.inc
+
+--source ../include/table_aggregate_setup.inc
+
+# table lock
+update performance_schema.setup_instruments
+ set enabled='NO' where name='wait/io/table/sql/handler';
+
+# thread
+update performance_schema.setup_consumers
+ set enabled='NO' where name like 'event%';
+
+# 2users
+delete from performance_schema.setup_actors
+ where user in ('user2', 'user4');
+
+# 3tables by default
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_lock_aggregate_thread_4u_2t.test b/mysql-test/suite/perfschema/t/table_lock_aggregate_thread_4u_2t.test
new file mode 100644
index 00000000..ff69d164
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_lock_aggregate_thread_4u_2t.test
@@ -0,0 +1,24 @@
+# Tests for the performance schema
+
+# Use MyISAM as InnoDB SE no longer uses THR_LOCK locks.
+#--source include/force_myisam_default.inc
+
+--source ../include/table_aggregate_setup.inc
+
+# table lock
+update performance_schema.setup_instruments
+ set enabled='NO' where name='wait/io/table/sql/handler';
+
+# thread
+update performance_schema.setup_consumers
+ set enabled='NO' where name like 'event%';
+
+# 4users by default
+
+# 2tables
+delete from performance_schema.setup_objects
+ where object_name='t2';
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_lock_aggregate_thread_4u_3t.test b/mysql-test/suite/perfschema/t/table_lock_aggregate_thread_4u_3t.test
new file mode 100644
index 00000000..3ee77d05
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_lock_aggregate_thread_4u_3t.test
@@ -0,0 +1,22 @@
+# Tests for the performance schema
+
+# Use MyISAM as InnoDB SE no longer uses THR_LOCK locks.
+#--source include/force_myisam_default.inc
+
+--source ../include/table_aggregate_setup.inc
+
+# table lock
+update performance_schema.setup_instruments
+ set enabled='NO' where name='wait/io/table/sql/handler';
+
+# thread
+update performance_schema.setup_consumers
+ set enabled='NO' where name like 'event%';
+
+# 4users by default
+
+# 3tables by default
+
+--source ../include/table_aggregate_load.inc
+--source ../include/table_aggregate_cleanup.inc
+
diff --git a/mysql-test/suite/perfschema/t/table_name.test b/mysql-test/suite/perfschema/t/table_name.test
new file mode 100644
index 00000000..aca713c3
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_name.test
@@ -0,0 +1,177 @@
+#
+# Performance Schema
+#
+# Verify that the Performance Schema correctly identifies normal and temporary
+# tables with non-standard names.
+
+# The server uses the table name prefix "#sql" for temporary and intermediate
+# tables, however user-defined tables having the "#sql" prefix are also permitted.
+# Independent of the table name, temporary or intermediate tables always have the
+# "#sql" prefix in the filename. (For non-temporary tables starting with "#",
+# the "#" is encoded to @0023 in the filename.)
+#
+# Given the ambiguity with temporary table names, the Performance Schema identifies
+# temporary tables tables either by the table category or by the filename.
+#
+--source include/have_perfschema.inc
+--source include/have_innodb.inc
+--source include/not_embedded.inc
+
+--echo #
+--echo #
+--echo # TEST 1: Normal tables prefixed with "#sql" and "sql".
+--echo #
+USE test;
+CREATE TABLE `#sql_1` (a int, b text);
+# INSERT forces path through get_table_share()
+INSERT INTO `#sql_1` VALUES(1,'one');
+--echo #
+CREATE TABLE `sql_1` (a int, b text);
+INSERT INTO `sql_1` VALUES(1,'one');
+--echo #
+--echo # Verify that the tables are treated as normal tables .
+--echo #
+--sorted_result
+SELECT object_type, object_schema, object_name
+FROM performance_schema.objects_summary_global_by_type
+WHERE object_schema="test"
+ORDER BY object_name;
+--echo #
+--echo # Drop the tables, verify that the table objects are removed.
+--echo #
+DROP TABLE `#sql_1`;
+DROP TABLE `sql_1`;
+--echo #
+SELECT object_type, object_schema, object_name
+FROM performance_schema.objects_summary_global_by_type
+WHERE object_schema="test"
+ORDER BY object_name;
+
+--echo #
+--echo #
+--echo # TEST 2: Temporary tables, no special prefix.
+--echo #
+CREATE TEMPORARY TABLE sql_temp2_myisam (a int, b text) ENGINE=MYISAM;
+INSERT INTO sql_temp2_myisam VALUES(1,'one');
+--echo #
+CREATE TEMPORARY TABLE sql_temp2_innodb (a int, b text) ENGINE=INNODB;
+INSERT INTO sql_temp2_innodb VALUES(1,'one');
+--echo #
+--echo # Confirm that the temporary tables are ignored.
+--echo #
+SELECT object_type, object_schema, object_name
+FROM performance_schema.objects_summary_global_by_type
+WHERE object_schema="test"
+ORDER BY object_name;
+--echo #
+--echo # Drop the tables, verify that the table objects are not created.
+--echo #
+DROP TABLE sql_temp2_myisam;
+DROP TABLE sql_temp2_innodb;
+--echo #
+SELECT object_type, object_schema, object_name
+FROM performance_schema.objects_summary_global_by_type
+WHERE object_schema="test"
+ORDER BY object_name;
+
+--echo #
+--echo #
+--echo # TEST 3: Temporary tables with the "#sql" prefix.
+--echo #
+CREATE TEMPORARY TABLE `#sql_temp3_myisam` (a int, b text) ENGINE=MYISAM;
+CHECK TABLE `#sql_temp3_myisam`;
+INSERT INTO `#sql_temp3_myisam` VALUES(1,'one');
+--echo #
+CREATE TEMPORARY TABLE `#sql_temp3_innodb` (a int, b text) ENGINE=INNODB;
+CHECK TABLE `#sql_temp3_innodb`;
+INSERT INTO `#sql_temp3_innodb` VALUES(1,'one');
+--echo #
+--echo # Confirm that the temporary tables are ignored.
+--echo #
+SELECT object_type, object_schema, object_name
+FROM performance_schema.objects_summary_global_by_type
+WHERE object_schema="test"
+ORDER BY object_name;
+--echo #
+--echo # Drop the temporary tables.
+--echo #
+DROP TABLE `#sql_temp3_myisam`;
+DROP TABLE `#sql_temp3_innodb`;
+--echo #
+--echo # Confirm that the temporary tables are still ignored.
+--echo #
+SELECT object_type, object_schema, object_name
+FROM performance_schema.objects_summary_global_by_type
+WHERE object_schema="test"
+ORDER BY object_name;
+
+--echo #
+--echo #
+--echo # TEST 4: Special case: MyISAM temporary tables are recreated as non-temporary
+--echo # when they are truncated.
+--echo #
+CREATE TEMPORARY TABLE `sql_temp4_myisam` (a int, b text) ENGINE=MYISAM;
+INSERT INTO `sql_temp4_myisam` VALUES(1,'one');
+--echo #
+CREATE TEMPORARY TABLE `#sql_temp4_myisam` (a int, b text) ENGINE=MYISAM;
+INSERT INTO `#sql_temp4_myisam` VALUES(1,'one');
+--echo #
+--echo # Confirm that the MyISAM temporary tables are ignored.
+--echo #
+SELECT object_type, object_schema, object_name
+FROM performance_schema.objects_summary_global_by_type
+WHERE object_schema="test"
+ORDER BY object_name;
+--echo #
+--echo # Truncate the MyISAM temporary tables, forcing them to be recreated as non-temporary.
+--echo #
+TRUNCATE TABLE `sql_temp4_myisam`;
+TRUNCATE TABLE `#sql_temp4_myisam`;
+--echo #
+--echo # Confirm that the recreated MyISAM tables are still regarded as temporary and ignored.
+--echo #
+SELECT object_type, object_schema, object_name
+FROM performance_schema.objects_summary_global_by_type
+WHERE object_schema="test"
+ORDER BY object_name;
+--echo #
+--echo # Drop the recreated MyISAM tables;
+--echo #
+DROP TABLE `sql_temp4_myisam`;
+DROP TABLE `#sql_temp4_myisam`;
+--echo #
+--echo # Confirm that the recreated temporary tables are still ignored.
+--echo #
+SELECT object_type, object_schema, object_name
+FROM performance_schema.objects_summary_global_by_type
+WHERE object_schema="test"
+ORDER BY object_name;
+
+--echo #
+--echo #
+--echo # TEST 5: Generate temporary tables with ALTER MyISAM table.
+--echo #
+USE test;
+CREATE TABLE t1 (a int) ENGINE=MYISAM;
+INSERT INTO t1 VALUES (1), (2), (3);
+# Force a path throug mysql_alter_table() and ha_create_table().
+ALTER TABLE t1 ADD COLUMN (b int);
+--echo #
+--echo # Confirm that the recreated temporary tables are still ignored.
+--echo #
+SELECT object_type, object_schema, object_name
+FROM performance_schema.objects_summary_global_by_type
+WHERE object_schema="test"
+ORDER BY object_name;
+--echo #
+--echo # Drop the MyISAM table
+--echo #
+DROP TABLE t1;
+
+--echo #
+--echo # Confirm that no tables remain;
+--echo #
+SELECT object_type, object_schema, object_name
+FROM performance_schema.objects_summary_global_by_type
+WHERE object_schema="test"
+ORDER BY object_name;
diff --git a/mysql-test/suite/perfschema/t/table_schema.test b/mysql-test/suite/perfschema/t/table_schema.test
new file mode 100644
index 00000000..935bd667
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/table_schema.test
@@ -0,0 +1,62 @@
+# Test to detect changest to the PERFORMANCE_SCHEMA table schemas
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+# Use the INFORMATION_SCHEMA to examine the tables in the PERFORMANCE_SCHEMA
+# and detect any tables that have changed.
+
+select * from information_schema.columns where table_schema="performance_schema"
+ order by table_name, ordinal_position;
+
+# Bug#11766504 "59631: BIGINT UNSIGNED BYTE RELATED COLUMNS IN PERFORMANCE_SCHEMA"
+
+# Goal: Confirm that all byte related columns are BIGINT signed. This test will
+# not have to be changed to accommodate new or deleted columns.
+
+# Count the number of NUMBER_OF_BYTES columns.
+
+select count(*) into @count_byte_columns from information_schema.columns
+ where table_schema="performance_schema" and data_type = "bigint"
+ and column_name like "%number_of_bytes";
+
+# Confirm that at least one column was found.
+
+select @count_byte_columns > 0;
+
+# Confirm that all NUMBER_OF_BYTES columns are BIGINT signed.
+
+select count(*) into @count_byte_signed from information_schema.columns
+ where table_schema="performance_schema" and data_type="bigint"
+ and column_name like "%number_of_bytes"
+ and column_type not like "%unsigned";
+
+select (@count_byte_columns - @count_byte_signed) = 0;
+
+# Similar test for OBJECT_INSTANCE_BEGIN values, which are typically derived
+# from a memory address and must therefore be unsigned.
+#
+# Count the number of OBJECT_INSTANCE_BEGIN columns.
+
+select count(*) into @count_object_columns from information_schema.columns
+ where table_schema="performance_schema" and data_type = "bigint"
+ and column_name like "%object_instance_begin";
+
+# Confirm that at least one column was found.
+
+select @count_object_columns > 0;
+
+# Confirm that all OBJECT_INSTANCE_BEGIN columns are BIGINT unsigned.
+
+select count(*) into @count_object_unsigned from information_schema.columns
+ where table_schema="performance_schema" and data_type="bigint"
+ and column_name like "%object_instance_begin"
+ and column_type like "%unsigned";
+
+select (@count_object_columns - @count_object_unsigned) = 0;
+
+# Confirm that all columns have comments
+#
+select count(*) from information_schema.columns
+ where table_schema="performance_schema"
+ and (column_comment is null or column_comment = '');
diff --git a/mysql-test/suite/perfschema/t/temp_table_io.test b/mysql-test/suite/perfschema/t/temp_table_io.test
new file mode 100644
index 00000000..7a4d6999
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/temp_table_io.test
@@ -0,0 +1,28 @@
+# Tests for PERFORMANCE_SCHEMA table io
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source ../include/table_io_setup_helper.inc
+
+let $engine_type= MyISAM;
+let $table_item= test.no_index_tab;
+--disable_warnings
+eval drop temporary table if exists $table_item;
+--enable_warnings
+
+# Start recording events
+update performance_schema.setup_consumers set enabled = 'YES';
+insert into marker set a = 1;
+eval create temporary table $table_item
+( a varchar(255) not null, b int not null) engine = $engine_type;
+insert into marker set a = 1;
+eval show create table $table_item;
+--source ../include/table_io_basic_dml.inc
+eval drop temporary table $table_item;
+
+# Stop recording events + pull result
+--source ../include/table_io_result_helper.inc
+
+# Cleanup
+--source ../include/table_io_cleanup_helper.inc
+
diff --git a/mysql-test/suite/perfschema/t/thread_cache-master.opt b/mysql-test/suite/perfschema/t/thread_cache-master.opt
new file mode 100644
index 00000000..52d8d233
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/thread_cache-master.opt
@@ -0,0 +1 @@
+--loose-performance_schema_max_thread_class=200
diff --git a/mysql-test/suite/perfschema/t/thread_cache.test b/mysql-test/suite/perfschema/t/thread_cache.test
new file mode 100644
index 00000000..92309bb9
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/thread_cache.test
@@ -0,0 +1,173 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+#
+# Important note:
+# this test is extremely sensitive to how threads are running inside the server,
+# so it has it's own -master.opt file, to enforce it runs alone in mysqld
+#
+
+# Setup
+
+flush status;
+
+SET @saved_thread_cache_size = @@global.thread_cache_size;
+
+set global thread_cache_size = 0;
+
+show global variables like "thread_cache_size";
+
+connect (con1, localhost, root, , );
+
+let $con1_ID=`select connection_id()`;
+
+let $con1_THREAD_ID=`select thread_id from performance_schema.threads
+ where PROCESSLIST_ID = connection_id()`;
+
+connect (con2, localhost, root, , );
+
+let $con2_ID=`select connection_id()`;
+
+let $con2_THREAD_ID=`select thread_id from performance_schema.threads
+ where PROCESSLIST_ID = connection_id()`;
+
+--connection default
+
+--disable_query_log
+eval select ($con2_ID - $con1_ID) into @id_increment;
+eval select ($con2_THREAD_ID - $con1_THREAD_ID) into @thread_id_increment;
+--enable_query_log
+
+# Expect 1, connection_id() is incremented for each new connection
+select @id_increment;
+# Expect 1, THREAD_ID is incremented for each new connection
+select @thread_id_increment;
+
+--disconnect con2
+
+--connection default
+
+# Debug
+# select * from performance_schema.threads
+# where name like "thread/sql/one_connection";
+
+# Wait for the disconnect con2 to complete
+let $wait_condition=
+ select count(*) = 2 from performance_schema.threads
+ where name like "thread/sql/one_connection";
+--source include/wait_condition.inc
+
+connect (con3, localhost, root, , );
+
+let $con3_ID=`select connection_id()`;
+
+let $con3_THREAD_ID=`select thread_id from performance_schema.threads
+ where PROCESSLIST_ID = connection_id()`;
+
+--disconnect con3
+--disconnect con1
+
+--connection default
+
+# Debug
+# select * from performance_schema.threads
+# where name like "thread/sql/one_connection";
+
+# Wait for the disconnect con1 and con3 to complete
+let $wait_condition=
+ select count(*) = 1 from performance_schema.threads
+ where name like "thread/sql/one_connection";
+--source include/wait_condition.inc
+
+--disable_query_log
+eval select ($con3_ID - $con2_ID) into @id_increment;
+eval select ($con3_THREAD_ID - $con2_THREAD_ID) into @thread_id_increment;
+--enable_query_log
+
+select @id_increment;
+select @thread_id_increment;
+
+set global thread_cache_size = 100;
+
+show global variables like "thread_cache_size";
+
+connect (con1, localhost, root, , );
+
+let $con1_ID=`select connection_id()`;
+
+let $con1_THREAD_ID=`select thread_id from performance_schema.threads
+ where PROCESSLIST_ID = connection_id()`;
+
+connect (con2, localhost, root, , );
+
+let $con2_ID=`select connection_id()`;
+
+let $con2_THREAD_ID=`select thread_id from performance_schema.threads
+ where PROCESSLIST_ID = connection_id()`;
+
+--connection default
+
+--disable_query_log
+eval select ($con2_ID - $con1_ID) into @id_increment;
+eval select ($con2_THREAD_ID - $con1_THREAD_ID) into @thread_id_increment;
+--enable_query_log
+
+select @id_increment;
+select @thread_id_increment;
+
+--disconnect con2
+
+--connection default
+
+# Debug
+# select * from performance_schema.threads
+# where name like "thread/sql/one_connection";
+
+# Wait for the disconnect con2 to complete
+let $wait_condition=
+ select count(*) = 2 from performance_schema.threads
+ where name like "thread/sql/one_connection";
+--source include/wait_condition.inc
+
+connect (con3, localhost, root, , );
+
+let $con3_ID=`select connection_id()`;
+
+let $con3_THREAD_ID=`select thread_id from performance_schema.threads
+ where PROCESSLIST_ID = connection_id()`;
+
+--disconnect con3
+--disconnect con1
+
+--connection default
+
+# Debug
+# select * from performance_schema.threads
+# where name like "thread/sql/one_connection";
+
+# Wait for the disconnect con1 and con3 to complete
+let $wait_condition=
+ select count(*) = 1 from performance_schema.threads
+ where name like "thread/sql/one_connection";
+--source include/wait_condition.inc
+
+--disable_query_log
+eval select ($con3_ID - $con2_ID) into @id_increment;
+eval select ($con3_THREAD_ID - $con2_THREAD_ID) into @thread_id_increment;
+--enable_query_log
+
+# When caching threads, the pthread that executed con2 was parked in the
+# cache on disconnect, and then picked up con3.
+
+# Still expect a new connection_id()
+select @id_increment;
+
+# And expect a new instrumentation: the THREAD_ID of old connections should not be reused.
+select @thread_id_increment;
+
+set global thread_cache_size = @saved_thread_cache_size;
+
+show global status like "performance_schema_thread%";
+
diff --git a/mysql-test/suite/perfschema/t/thread_misc-master.opt b/mysql-test/suite/perfschema/t/thread_misc-master.opt
new file mode 100644
index 00000000..34586f1f
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/thread_misc-master.opt
@@ -0,0 +1 @@
+--loose-performance-schema-consumer-thread-instrumentation=0
diff --git a/mysql-test/suite/perfschema/t/thread_misc.test b/mysql-test/suite/perfschema/t/thread_misc.test
new file mode 100644
index 00000000..4f5fa4f0
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/thread_misc.test
@@ -0,0 +1,11 @@
+
+# Bug#22118669 - ASSERTION `PFS_FILE != __NULL' FAILED
+
+# Cause a temporary file to be instrumented,
+# while there are no per thread statistics collected.
+
+--disable_result_log
+select * from information_schema.columns ORDER BY table_name;
+--enable_result_log
+
+
diff --git a/mysql-test/suite/perfschema/t/threads_history.test b/mysql-test/suite/perfschema/t/threads_history.test
new file mode 100644
index 00000000..f42dd6d0
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/threads_history.test
@@ -0,0 +1,727 @@
+# Check the impact of changes done in HISTORY column in
+# performance_schema.setup_actors.
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/no_protocol.inc
+
+# Presence of the query cache changes query stages,
+# causing noise in the test output
+#--source include/have_query_cache_disabled.inc
+
+create user user1@localhost;
+create user user2@localhost;
+create user user3@localhost;
+create user user4@localhost;
+
+grant ALL on *.* to user1@localhost;
+grant ALL on *.* to user2@localhost;
+grant ALL on *.* to user3@localhost;
+grant ALL on *.* to user4@localhost;
+
+flush privileges;
+
+select * from performance_schema.setup_consumers;
+
+--echo # Switch to (con1, localhost, user1, , )
+connect (con1, localhost, user1, , );
+
+update performance_schema.threads
+ set INSTRUMENTED='YES', HISTORY='YES'
+ where PROCESSLIST_ID = connection_id();
+
+let $con1_thread_id= `select THREAD_ID from performance_schema.threads
+ where PROCESSLIST_ID = connection_id()`;
+
+--echo # Switch to (con2, localhost, user2, , )
+connect (con2, localhost, user2, , );
+
+update performance_schema.threads
+ set INSTRUMENTED='YES', HISTORY='NO'
+ where PROCESSLIST_ID = connection_id();
+
+let $con2_thread_id= `select THREAD_ID from performance_schema.threads
+ where PROCESSLIST_ID = connection_id()`;
+
+--echo # Switch to (con3, localhost, user3, , )
+connect (con3, localhost, user3, , );
+
+update performance_schema.threads
+ set INSTRUMENTED='NO', HISTORY='YES'
+ where PROCESSLIST_ID = connection_id();
+
+let $con3_thread_id= `select THREAD_ID from performance_schema.threads
+ where PROCESSLIST_ID = connection_id()`;
+
+--echo # Switch to (con4, localhost, user4, , )
+connect (con4, localhost, user4, , );
+
+update performance_schema.threads
+ set INSTRUMENTED='NO', HISTORY='NO'
+ where PROCESSLIST_ID = connection_id();
+
+let $con4_thread_id= `select THREAD_ID from performance_schema.threads
+ where PROCESSLIST_ID = connection_id()`;
+
+--echo # Switch to connection default
+--connection default
+
+truncate table performance_schema.events_transactions_current;
+truncate table performance_schema.events_transactions_history;
+truncate table performance_schema.events_transactions_history_long;
+truncate table performance_schema.events_statements_current;
+truncate table performance_schema.events_statements_history;
+truncate table performance_schema.events_statements_history_long;
+truncate table performance_schema.events_stages_current;
+truncate table performance_schema.events_stages_history;
+truncate table performance_schema.events_stages_history_long;
+truncate table performance_schema.events_waits_current;
+truncate table performance_schema.events_waits_history;
+truncate table performance_schema.events_waits_history_long;
+
+--echo # Switch to connection con1
+--connection con1
+
+XA START 'XA_CON1', 'XA_BQUAL', 12;
+select "Hi from con1";
+XA END 'XA_CON1', 'XA_BQUAL', 12;
+XA PREPARE 'XA_CON1', 'XA_BQUAL', 12;
+XA COMMIT 'XA_CON1', 'XA_BQUAL', 12;
+
+--echo # Switch to connection con2
+--connection con2
+
+XA START 'XA_CON2', 'XA_BQUAL', 12;
+select "Hi from con2";
+XA END 'XA_CON2', 'XA_BQUAL', 12;
+XA PREPARE 'XA_CON2', 'XA_BQUAL', 12;
+XA COMMIT 'XA_CON2', 'XA_BQUAL', 12;
+
+--echo # Switch to connection con3
+--connection con3
+
+XA START 'XA_CON3', 'XA_BQUAL', 12;
+select "Hi from con3";
+XA END 'XA_CON3', 'XA_BQUAL', 12;
+XA PREPARE 'XA_CON3', 'XA_BQUAL', 12;
+XA COMMIT 'XA_CON3', 'XA_BQUAL', 12;
+
+--echo # Switch to connection con4
+--connection con4
+
+XA START 'XA_CON4', 'XA_BQUAL', 12;
+select "Hi from con4";
+XA END 'XA_CON4', 'XA_BQUAL', 12;
+XA PREPARE 'XA_CON4', 'XA_BQUAL', 12;
+XA COMMIT 'XA_CON4', 'XA_BQUAL', 12;
+
+--connection default
+
+--disable_query_log
+
+echo "=========================== Transactions user 1";
+
+eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current
+ where THREAD_ID = $con1_thread_id;
+eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_history
+ where THREAD_ID = $con1_thread_id;
+eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_history_long
+ where THREAD_ID = $con1_thread_id;
+
+echo "=========================== Transactions user 2";
+
+eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current
+ where THREAD_ID = $con2_thread_id;
+eval select count(*) from performance_schema.events_transactions_history
+ where THREAD_ID = $con2_thread_id;
+eval select count(*) from performance_schema.events_transactions_history_long
+ where THREAD_ID = $con2_thread_id;
+
+echo "=========================== Transactions user 3";
+
+eval select count(*) from performance_schema.events_transactions_current
+ where THREAD_ID = $con3_thread_id;
+eval select count(*) from performance_schema.events_transactions_history
+ where THREAD_ID = $con3_thread_id;
+eval select count(*) from performance_schema.events_transactions_history_long
+ where THREAD_ID = $con3_thread_id;
+
+echo "=========================== Transactions user 4";
+
+eval select count(*) from performance_schema.events_transactions_current
+ where THREAD_ID = $con4_thread_id;
+eval select count(*) from performance_schema.events_transactions_history
+ where THREAD_ID = $con4_thread_id;
+eval select count(*) from performance_schema.events_transactions_history_long
+ where THREAD_ID = $con4_thread_id;
+
+echo "=========================== Statements user 1";
+
+eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current
+ where THREAD_ID = $con1_thread_id
+ order by THREAD_ID, EVENT_ID;
+eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_history
+ where THREAD_ID = $con1_thread_id
+ order by THREAD_ID, EVENT_ID;
+eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_history_long
+ where THREAD_ID = $con1_thread_id
+ order by THREAD_ID, EVENT_ID;
+
+echo "=========================== Statements user 2";
+
+eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current
+ where THREAD_ID = $con2_thread_id
+ order by THREAD_ID, EVENT_ID;
+eval select count(*) from performance_schema.events_statements_history
+ where THREAD_ID = $con2_thread_id;
+eval select count(*) from performance_schema.events_statements_history_long
+ where THREAD_ID = $con2_thread_id;
+
+echo "=========================== Statements user 3";
+
+eval select count(*) from performance_schema.events_statements_current
+ where THREAD_ID = $con3_thread_id;
+eval select count(*) from performance_schema.events_statements_history
+ where THREAD_ID = $con3_thread_id;
+eval select count(*) from performance_schema.events_statements_history_long
+ where THREAD_ID = $con3_thread_id;
+
+echo "=========================== Statements user 4";
+
+eval select count(*) from performance_schema.events_statements_current
+ where THREAD_ID = $con4_thread_id;
+eval select count(*) from performance_schema.events_statements_history
+ where THREAD_ID = $con4_thread_id;
+eval select count(*) from performance_schema.events_statements_history_long
+ where THREAD_ID = $con4_thread_id;
+
+echo "=========================== Stages user 1";
+
+eval select EVENT_NAME from performance_schema.events_stages_current
+ where THREAD_ID = $con1_thread_id
+ order by THREAD_ID, EVENT_ID;
+eval select EVENT_NAME from performance_schema.events_stages_history
+ where THREAD_ID = $con1_thread_id
+ order by THREAD_ID, EVENT_ID;
+eval select EVENT_NAME from performance_schema.events_stages_history_long
+ where THREAD_ID = $con1_thread_id
+ order by THREAD_ID, EVENT_ID;
+
+echo "=========================== Stages user 2";
+
+eval select EVENT_NAME from performance_schema.events_stages_current
+ where THREAD_ID = $con2_thread_id
+ order by THREAD_ID, EVENT_ID;
+eval select count(*) from performance_schema.events_stages_history
+ where THREAD_ID = $con2_thread_id;
+eval select count(*) from performance_schema.events_stages_history_long
+ where THREAD_ID = $con2_thread_id;
+
+echo "=========================== Stages user 3";
+
+eval select count(*) from performance_schema.events_stages_current
+ where THREAD_ID = $con3_thread_id;
+eval select count(*) from performance_schema.events_stages_history
+ where THREAD_ID = $con3_thread_id;
+eval select count(*) from performance_schema.events_stages_history_long
+ where THREAD_ID = $con3_thread_id;
+
+echo "=========================== Stages user 4";
+
+eval select count(*) from performance_schema.events_stages_current
+ where THREAD_ID = $con4_thread_id;
+eval select count(*) from performance_schema.events_stages_history
+ where THREAD_ID = $con4_thread_id;
+eval select count(*) from performance_schema.events_stages_history_long
+ where THREAD_ID = $con4_thread_id;
+
+echo "=========================== Waits user 1";
+
+eval select EVENT_NAME from performance_schema.events_waits_current
+ where THREAD_ID = $con1_thread_id
+ order by THREAD_ID, EVENT_ID;
+eval select (count(*) > 5) as has_waits from performance_schema.events_waits_history
+ where THREAD_ID = $con1_thread_id;
+eval select (count(*) > 15) as has_waits from performance_schema.events_waits_history_long
+ where THREAD_ID = $con1_thread_id;
+
+echo "=========================== Waits user 2";
+
+eval select EVENT_NAME from performance_schema.events_waits_current
+ where THREAD_ID = $con2_thread_id
+ order by THREAD_ID, EVENT_ID;
+eval select count(*) from performance_schema.events_waits_history
+ where THREAD_ID = $con2_thread_id;
+eval select count(*) from performance_schema.events_waits_history_long
+ where THREAD_ID = $con2_thread_id;
+
+echo "=========================== Waits user 3";
+
+eval select count(*) from performance_schema.events_waits_current
+ where THREAD_ID = $con3_thread_id;
+eval select count(*) from performance_schema.events_waits_history
+ where THREAD_ID = $con3_thread_id;
+eval select count(*) from performance_schema.events_waits_history_long
+ where THREAD_ID = $con3_thread_id;
+
+echo "=========================== Waits user 4";
+
+eval select count(*) from performance_schema.events_waits_current
+ where THREAD_ID = $con4_thread_id;
+eval select count(*) from performance_schema.events_waits_history
+ where THREAD_ID = $con4_thread_id;
+eval select count(*) from performance_schema.events_waits_history_long
+ where THREAD_ID = $con4_thread_id;
+
+--enable_query_log
+
+--echo # Switch to connection default, disable consumers
+--connection default
+
+update performance_schema.setup_consumers
+ set enabled='NO' where name like "%history%";
+
+select * from performance_schema.setup_consumers;
+
+truncate table performance_schema.events_transactions_current;
+truncate table performance_schema.events_transactions_history;
+truncate table performance_schema.events_transactions_history_long;
+truncate table performance_schema.events_statements_current;
+truncate table performance_schema.events_statements_history;
+truncate table performance_schema.events_statements_history_long;
+truncate table performance_schema.events_stages_current;
+truncate table performance_schema.events_stages_history;
+truncate table performance_schema.events_stages_history_long;
+truncate table performance_schema.events_waits_current;
+truncate table performance_schema.events_waits_history;
+truncate table performance_schema.events_waits_history_long;
+
+--echo # Switch to connection con1
+--connection con1
+
+XA START 'XA_CON1', 'XA_BQUAL', 12;
+select "Hi from con1";
+XA END 'XA_CON1', 'XA_BQUAL', 12;
+XA PREPARE 'XA_CON1', 'XA_BQUAL', 12;
+XA COMMIT 'XA_CON1', 'XA_BQUAL', 12;
+
+--echo # Switch to connection con2
+--connection con2
+
+XA START 'XA_CON2', 'XA_BQUAL', 12;
+select "Hi from con2";
+XA END 'XA_CON2', 'XA_BQUAL', 12;
+XA PREPARE 'XA_CON2', 'XA_BQUAL', 12;
+XA COMMIT 'XA_CON2', 'XA_BQUAL', 12;
+
+--echo # Switch to connection con3
+--connection con3
+
+XA START 'XA_CON3', 'XA_BQUAL', 12;
+select "Hi from con3";
+XA END 'XA_CON3', 'XA_BQUAL', 12;
+XA PREPARE 'XA_CON3', 'XA_BQUAL', 12;
+XA COMMIT 'XA_CON3', 'XA_BQUAL', 12;
+
+--echo # Switch to connection con4
+--connection con4
+
+XA START 'XA_CON4', 'XA_BQUAL', 12;
+select "Hi from con4";
+XA END 'XA_CON4', 'XA_BQUAL', 12;
+XA PREPARE 'XA_CON4', 'XA_BQUAL', 12;
+XA COMMIT 'XA_CON4', 'XA_BQUAL', 12;
+
+--connection default
+
+--disable_query_log
+
+echo "=========================== Transactions user 1";
+
+eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current
+ where THREAD_ID = $con1_thread_id;
+eval select count(*) from performance_schema.events_transactions_history
+ where THREAD_ID = $con1_thread_id;
+eval select count(*) from performance_schema.events_transactions_history_long
+ where THREAD_ID = $con1_thread_id;
+
+echo "=========================== Transactions user 2";
+
+eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current
+ where THREAD_ID = $con2_thread_id;
+eval select count(*) from performance_schema.events_transactions_history
+ where THREAD_ID = $con2_thread_id;
+eval select count(*) from performance_schema.events_transactions_history_long
+ where THREAD_ID = $con2_thread_id;
+
+echo "=========================== Transactions user 3";
+
+eval select count(*) from performance_schema.events_transactions_current
+ where THREAD_ID = $con3_thread_id;
+eval select count(*) from performance_schema.events_transactions_history
+ where THREAD_ID = $con3_thread_id;
+eval select count(*) from performance_schema.events_transactions_history_long
+ where THREAD_ID = $con3_thread_id;
+
+echo "=========================== Transactions user 4";
+
+eval select count(*) from performance_schema.events_transactions_current
+ where THREAD_ID = $con4_thread_id;
+eval select count(*) from performance_schema.events_transactions_history
+ where THREAD_ID = $con4_thread_id;
+eval select count(*) from performance_schema.events_transactions_history_long
+ where THREAD_ID = $con4_thread_id;
+
+echo "=========================== Statements user 1";
+
+eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current
+ where THREAD_ID = $con1_thread_id
+ order by THREAD_ID, EVENT_ID;
+eval select count(*) from performance_schema.events_statements_history
+ where THREAD_ID = $con1_thread_id;
+eval select count(*) from performance_schema.events_statements_history_long
+ where THREAD_ID = $con1_thread_id;
+
+echo "=========================== Statements user 2";
+
+eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current
+ where THREAD_ID = $con2_thread_id
+ order by THREAD_ID, EVENT_ID;
+eval select count(*) from performance_schema.events_statements_history
+ where THREAD_ID = $con2_thread_id;
+eval select count(*) from performance_schema.events_statements_history_long
+ where THREAD_ID = $con2_thread_id;
+
+echo "=========================== Statements user 3";
+
+eval select count(*) from performance_schema.events_statements_current
+ where THREAD_ID = $con3_thread_id;
+eval select count(*) from performance_schema.events_statements_history
+ where THREAD_ID = $con3_thread_id;
+eval select count(*) from performance_schema.events_statements_history_long
+ where THREAD_ID = $con3_thread_id;
+
+echo "=========================== Statements user 4";
+
+eval select count(*) from performance_schema.events_statements_current
+ where THREAD_ID = $con4_thread_id;
+eval select count(*) from performance_schema.events_statements_history
+ where THREAD_ID = $con4_thread_id;
+eval select count(*) from performance_schema.events_statements_history_long
+ where THREAD_ID = $con4_thread_id;
+
+echo "=========================== Stages user 1";
+
+eval select EVENT_NAME from performance_schema.events_stages_current
+ where THREAD_ID = $con1_thread_id
+ order by THREAD_ID, EVENT_ID;
+eval select count(*) from performance_schema.events_stages_history
+ where THREAD_ID = $con1_thread_id;
+eval select count(*) from performance_schema.events_stages_history_long
+ where THREAD_ID = $con1_thread_id;
+
+echo "=========================== Stages user 2";
+
+eval select EVENT_NAME from performance_schema.events_stages_current
+ where THREAD_ID = $con2_thread_id
+ order by THREAD_ID, EVENT_ID;
+eval select count(*) from performance_schema.events_stages_history
+ where THREAD_ID = $con2_thread_id;
+eval select count(*) from performance_schema.events_stages_history_long
+ where THREAD_ID = $con2_thread_id;
+
+echo "=========================== Stages user 3";
+
+eval select count(*) from performance_schema.events_stages_current
+ where THREAD_ID = $con3_thread_id;
+eval select count(*) from performance_schema.events_stages_history
+ where THREAD_ID = $con3_thread_id;
+eval select count(*) from performance_schema.events_stages_history_long
+ where THREAD_ID = $con3_thread_id;
+
+echo "=========================== Stages user 4";
+
+eval select count(*) from performance_schema.events_stages_current
+ where THREAD_ID = $con4_thread_id;
+eval select count(*) from performance_schema.events_stages_history
+ where THREAD_ID = $con4_thread_id;
+eval select count(*) from performance_schema.events_stages_history_long
+ where THREAD_ID = $con4_thread_id;
+
+echo "=========================== Waits user 1";
+
+eval select EVENT_NAME from performance_schema.events_waits_current
+ where THREAD_ID = $con1_thread_id
+ order by THREAD_ID, EVENT_ID;
+eval select count(*) as has_waits from performance_schema.events_waits_history
+ where THREAD_ID = $con1_thread_id;
+eval select count(*) as has_waits from performance_schema.events_waits_history_long
+ where THREAD_ID = $con1_thread_id;
+
+echo "=========================== Waits user 2";
+
+eval select EVENT_NAME from performance_schema.events_waits_current
+ where THREAD_ID = $con2_thread_id
+ order by THREAD_ID, EVENT_ID;
+eval select count(*) from performance_schema.events_waits_history
+ where THREAD_ID = $con2_thread_id;
+eval select count(*) from performance_schema.events_waits_history_long
+ where THREAD_ID = $con2_thread_id;
+
+echo "=========================== Waits user 3";
+
+eval select count(*) from performance_schema.events_waits_current
+ where THREAD_ID = $con3_thread_id;
+eval select count(*) from performance_schema.events_waits_history
+ where THREAD_ID = $con3_thread_id;
+eval select count(*) from performance_schema.events_waits_history_long
+ where THREAD_ID = $con3_thread_id;
+
+echo "=========================== Waits user 4";
+
+eval select count(*) from performance_schema.events_waits_current
+ where THREAD_ID = $con4_thread_id;
+eval select count(*) from performance_schema.events_waits_history
+ where THREAD_ID = $con4_thread_id;
+eval select count(*) from performance_schema.events_waits_history_long
+ where THREAD_ID = $con4_thread_id;
+
+--enable_query_log
+
+--echo # Switch to connection default, enable consumers
+--connection default
+
+update performance_schema.setup_consumers
+ set enabled='YES' where name like "%history%";
+
+select * from performance_schema.setup_consumers;
+
+truncate table performance_schema.events_transactions_current;
+truncate table performance_schema.events_transactions_history;
+truncate table performance_schema.events_transactions_history_long;
+truncate table performance_schema.events_statements_current;
+truncate table performance_schema.events_statements_history;
+truncate table performance_schema.events_statements_history_long;
+truncate table performance_schema.events_stages_current;
+truncate table performance_schema.events_stages_history;
+truncate table performance_schema.events_stages_history_long;
+truncate table performance_schema.events_waits_current;
+truncate table performance_schema.events_waits_history;
+truncate table performance_schema.events_waits_history_long;
+
+--echo # Switch to connection con1
+--connection con1
+
+XA START 'XA_CON1', 'XA_BQUAL', 12;
+select "Hi from con1";
+XA END 'XA_CON1', 'XA_BQUAL', 12;
+XA PREPARE 'XA_CON1', 'XA_BQUAL', 12;
+XA COMMIT 'XA_CON1', 'XA_BQUAL', 12;
+
+--echo # Switch to connection con2
+--connection con2
+
+XA START 'XA_CON2', 'XA_BQUAL', 12;
+select "Hi from con2";
+XA END 'XA_CON2', 'XA_BQUAL', 12;
+XA PREPARE 'XA_CON2', 'XA_BQUAL', 12;
+XA COMMIT 'XA_CON2', 'XA_BQUAL', 12;
+
+--echo # Switch to connection con3
+--connection con3
+
+XA START 'XA_CON3', 'XA_BQUAL', 12;
+select "Hi from con3";
+XA END 'XA_CON3', 'XA_BQUAL', 12;
+XA PREPARE 'XA_CON3', 'XA_BQUAL', 12;
+XA COMMIT 'XA_CON3', 'XA_BQUAL', 12;
+
+--echo # Switch to connection con4
+--connection con4
+
+XA START 'XA_CON4', 'XA_BQUAL', 12;
+select "Hi from con4";
+XA END 'XA_CON4', 'XA_BQUAL', 12;
+XA PREPARE 'XA_CON4', 'XA_BQUAL', 12;
+XA COMMIT 'XA_CON4', 'XA_BQUAL', 12;
+
+--connection default
+
+--disable_query_log
+
+echo "=========================== Transactions user 1";
+
+eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current
+ where THREAD_ID = $con1_thread_id;
+eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_history
+ where THREAD_ID = $con1_thread_id;
+eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_history_long
+ where THREAD_ID = $con1_thread_id;
+
+echo "=========================== Transactions user 2";
+
+eval select XID_FORMAT_ID, XID_GTRID, XID_BQUAL from performance_schema.events_transactions_current
+ where THREAD_ID = $con2_thread_id;
+eval select count(*) from performance_schema.events_transactions_history
+ where THREAD_ID = $con2_thread_id;
+eval select count(*) from performance_schema.events_transactions_history_long
+ where THREAD_ID = $con2_thread_id;
+
+echo "=========================== Transactions user 3";
+
+eval select count(*) from performance_schema.events_transactions_current
+ where THREAD_ID = $con3_thread_id;
+eval select count(*) from performance_schema.events_transactions_history
+ where THREAD_ID = $con3_thread_id;
+eval select count(*) from performance_schema.events_transactions_history_long
+ where THREAD_ID = $con3_thread_id;
+
+echo "=========================== Transactions user 4";
+
+eval select count(*) from performance_schema.events_transactions_current
+ where THREAD_ID = $con4_thread_id;
+eval select count(*) from performance_schema.events_transactions_history
+ where THREAD_ID = $con4_thread_id;
+eval select count(*) from performance_schema.events_transactions_history_long
+ where THREAD_ID = $con4_thread_id;
+
+echo "=========================== Statements user 1";
+
+eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current
+ where THREAD_ID = $con1_thread_id
+ order by THREAD_ID, EVENT_ID;
+eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_history
+ where THREAD_ID = $con1_thread_id
+ order by THREAD_ID, EVENT_ID;
+eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_history_long
+ where THREAD_ID = $con1_thread_id
+ order by THREAD_ID, EVENT_ID;
+
+echo "=========================== Statements user 2";
+
+eval select EVENT_NAME, SQL_TEXT from performance_schema.events_statements_current
+ where THREAD_ID = $con2_thread_id
+ order by THREAD_ID, EVENT_ID;
+eval select count(*) from performance_schema.events_statements_history
+ where THREAD_ID = $con2_thread_id;
+eval select count(*) from performance_schema.events_statements_history_long
+ where THREAD_ID = $con2_thread_id;
+
+echo "=========================== Statements user 3";
+
+eval select count(*) from performance_schema.events_statements_current
+ where THREAD_ID = $con3_thread_id;
+eval select count(*) from performance_schema.events_statements_history
+ where THREAD_ID = $con3_thread_id;
+eval select count(*) from performance_schema.events_statements_history_long
+ where THREAD_ID = $con3_thread_id;
+
+echo "=========================== Statements user 4";
+
+eval select count(*) from performance_schema.events_statements_current
+ where THREAD_ID = $con4_thread_id;
+eval select count(*) from performance_schema.events_statements_history
+ where THREAD_ID = $con4_thread_id;
+eval select count(*) from performance_schema.events_statements_history_long
+ where THREAD_ID = $con4_thread_id;
+
+echo "=========================== Stages user 1";
+
+eval select EVENT_NAME from performance_schema.events_stages_current
+ where THREAD_ID = $con1_thread_id
+ order by THREAD_ID, EVENT_ID;
+eval select EVENT_NAME from performance_schema.events_stages_history
+ where THREAD_ID = $con1_thread_id
+ order by THREAD_ID, EVENT_ID;
+eval select EVENT_NAME from performance_schema.events_stages_history_long
+ where THREAD_ID = $con1_thread_id
+ order by THREAD_ID, EVENT_ID;
+
+echo "=========================== Stages user 2";
+
+eval select EVENT_NAME from performance_schema.events_stages_current
+ where THREAD_ID = $con2_thread_id
+ order by THREAD_ID, EVENT_ID;
+eval select count(*) from performance_schema.events_stages_history
+ where THREAD_ID = $con2_thread_id;
+eval select count(*) from performance_schema.events_stages_history_long
+ where THREAD_ID = $con2_thread_id;
+
+echo "=========================== Stages user 3";
+
+eval select count(*) from performance_schema.events_stages_current
+ where THREAD_ID = $con3_thread_id;
+eval select count(*) from performance_schema.events_stages_history
+ where THREAD_ID = $con3_thread_id;
+eval select count(*) from performance_schema.events_stages_history_long
+ where THREAD_ID = $con3_thread_id;
+
+echo "=========================== Stages user 4";
+
+eval select count(*) from performance_schema.events_stages_current
+ where THREAD_ID = $con4_thread_id;
+eval select count(*) from performance_schema.events_stages_history
+ where THREAD_ID = $con4_thread_id;
+eval select count(*) from performance_schema.events_stages_history_long
+ where THREAD_ID = $con4_thread_id;
+
+echo "=========================== Waits user 1";
+
+eval select EVENT_NAME from performance_schema.events_waits_current
+ where THREAD_ID = $con1_thread_id
+ order by THREAD_ID, EVENT_ID;
+eval select (count(*) > 5) as has_waits from performance_schema.events_waits_history
+ where THREAD_ID = $con1_thread_id;
+eval select (count(*) > 15) as has_waits from performance_schema.events_waits_history_long
+ where THREAD_ID = $con1_thread_id;
+
+echo "=========================== Waits user 2";
+
+eval select EVENT_NAME from performance_schema.events_waits_current
+ where THREAD_ID = $con2_thread_id
+ order by THREAD_ID, EVENT_ID;
+eval select count(*) from performance_schema.events_waits_history
+ where THREAD_ID = $con2_thread_id;
+eval select count(*) from performance_schema.events_waits_history_long
+ where THREAD_ID = $con2_thread_id;
+
+echo "=========================== Waits user 3";
+
+eval select count(*) from performance_schema.events_waits_current
+ where THREAD_ID = $con3_thread_id;
+eval select count(*) from performance_schema.events_waits_history
+ where THREAD_ID = $con3_thread_id;
+eval select count(*) from performance_schema.events_waits_history_long
+ where THREAD_ID = $con3_thread_id;
+
+echo "=========================== Waits user 4";
+
+eval select count(*) from performance_schema.events_waits_current
+ where THREAD_ID = $con4_thread_id;
+eval select count(*) from performance_schema.events_waits_history
+ where THREAD_ID = $con4_thread_id;
+eval select count(*) from performance_schema.events_waits_history_long
+ where THREAD_ID = $con4_thread_id;
+
+--enable_query_log
+
+--echo # Switch to connection default
+--connection default
+
+revoke all privileges, grant option from user1@localhost;
+revoke all privileges, grant option from user2@localhost;
+revoke all privileges, grant option from user3@localhost;
+revoke all privileges, grant option from user4@localhost;
+drop user user1@localhost;
+drop user user2@localhost;
+drop user user3@localhost;
+drop user user4@localhost;
+flush privileges;
+
+truncate table performance_schema.setup_actors;
+
+insert into performance_schema.setup_actors
+values ('%', '%', '%', 'YES', 'YES');
+
+select * from performance_schema.setup_actors;
+
diff --git a/mysql-test/suite/perfschema/t/threads_innodb.test b/mysql-test/suite/perfschema/t/threads_innodb.test
new file mode 100644
index 00000000..366c3b82
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/threads_innodb.test
@@ -0,0 +1,23 @@
+
+# Tests for special content of performance_schema.threads
+#
+# Show InnoDB related content in performance_schema.threads
+
+--source include/not_embedded.inc
+--source include/have_innodb.inc
+--source include/have_perfschema.inc
+
+#--source include/turn_off_only_full_group_by.inc
+
+# There are several InnoDB io_handler_threads servicing for read IO, write IO etc.
+# The number of these threads is at least for some types configurable.
+# We suppress here duplicates rows with the goal to avoid that the test fails
+# in case some defaults are changed.
+SELECT name, type, processlist_user, processlist_host, processlist_db,
+ processlist_command, processlist_time, processlist_state, processlist_info,
+ parent_thread_id, role, instrumented
+FROM performance_schema.threads
+WHERE name LIKE 'thread/innodb/%'
+GROUP BY name;
+
+#--source include/restore_sql_mode_after_turn_off_only_full_group_by.inc
diff --git a/mysql-test/suite/perfschema/t/threads_mysql-master.opt b/mysql-test/suite/perfschema/t/threads_mysql-master.opt
new file mode 100644
index 00000000..00efa80d
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/threads_mysql-master.opt
@@ -0,0 +1 @@
+--event-scheduler --thread-cache-size=0
diff --git a/mysql-test/suite/perfschema/t/threads_mysql.test b/mysql-test/suite/perfschema/t/threads_mysql.test
new file mode 100644
index 00000000..e19b3664
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/threads_mysql.test
@@ -0,0 +1,116 @@
+
+# Tests for special content of performance_schema.threads
+#
+# Show MySQL server related content in performance_schema.threads
+
+--source include/not_windows.inc
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+# Ensure that the event scheduler (started via threads_mysql-master.opt)
+# is really running.
+--source include/pfs_running_event_scheduler.inc
+
+SET GLOBAL event_scheduler = OFF;
+--source include/pfs_no_running_event_scheduler.inc
+
+--vertical_results
+
+# Show all "system" threads except the event scheduler
+# ---------------------------------------------------
+# 0. The values within the columns "thread_id" and "processlist_id" depend
+# on server history. Therefore they are unstable and need to be omitted.
+# 1. The columns "time" and "state" are omitted because it is thinkable that
+# they contain slightly unstable though correct values.
+# 2. The unification of the column "parent_thread_id" is in the moment most
+# probably not required because I observed all time that the parent is
+# "thread/sql/main" with the thread_id = 1.
+# But there might be more kinds of parents with most probably unstable
+# "thread_id" values in future.
+# 3. In case the test is started with the option "--ps-protocol" we will
+# find a correcet row for our current thread but the content will differ.
+# Therefore we have to disable this protocol for the next statement.
+--disable_ps_protocol
+SELECT name, type, processlist_user, processlist_host, processlist_db,
+ processlist_command, processlist_info, connection_type,
+ IF(parent_thread_id IS NULL, parent_thread_id, 'unified parent_thread_id')
+ AS unified_parent_thread_id,
+ `role`, instrumented
+FROM performance_schema.threads
+WHERE name LIKE 'thread/sql%'
+ORDER BY name;
+--enable_ps_protocol
+
+CREATE TEMPORARY TABLE t1 AS
+SELECT thread_id FROM performance_schema.threads
+WHERE name LIKE 'thread/sql%';
+
+
+SET GLOBAL event_scheduler = ON;
+--source include/pfs_running_event_scheduler.inc
+
+# Show entries belonging to the just started event scheduler
+SELECT name, type, processlist_user, processlist_host, processlist_db,
+ processlist_command, processlist_info,
+ IF(parent_thread_id IS NULL, parent_thread_id, 'unified parent_thread_id')
+ AS unified_parent_thread_id,
+ `role`, instrumented
+FROM performance_schema.threads
+WHERE name LIKE 'thread/sql%'
+ AND thread_id NOT IN (SELECT thread_id FROM t1)
+ORDER BY name;
+
+TRUNCATE t1;
+INSERT INTO t1
+SELECT thread_id FROM performance_schema.threads
+WHERE name LIKE 'thread/sql%';
+SELECT COUNT(*) INTO @aux FROM t1;
+
+# Attention:
+# Just waiting for some new thread showing up is not sufficient because
+# because the successing SELECT showing the thread might catch this thread
+# in a very early and short phase.
+# process_info si quite often
+# CREATE PROCEDURE `t_ps_event`() SQL SECURITY INVOKER SELECT SLEEP(3)
+#
+let $wait_condition=
+SELECT COUNT(*) = 1 FROM information_schema.processlist
+WHERE info = 'SELECT SLEEP(3)';
+
+--disable_warnings
+DROP EVENT IF EXISTS t_ps_event;
+--enable_warnings
+CREATE EVENT t_ps_event
+ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND
+DO SELECT SLEEP(3);
+
+# Wait till one more thread comes up.
+# This must be the event worker thread.
+let $wait_timeout= 20;
+--source include/wait_condition.inc
+
+# Show entries belonging to the just started event worker
+SELECT name, type, processlist_user, processlist_host, processlist_db,
+ processlist_command, processlist_info,
+ IF(parent_thread_id IS NULL, parent_thread_id, 'unified parent_thread_id')
+ AS unified_parent_thread_id,
+ `role`, instrumented
+FROM performance_schema.threads
+WHERE name LIKE 'thread/sql%'
+ AND thread_id NOT IN (SELECT thread_id FROM t1)
+ORDER BY name;
+
+# Show parent - child relations between "system" threads
+# ------------------------------------------------------
+--horizontal_results
+SELECT t2.name AS parent_thread_name, t1.name AS child_thread_name
+FROM performance_schema.threads t1 INNER JOIN performance_schema.threads t2
+ON t1.parent_thread_id = t2.thread_id
+WHERE t1.name LIKE 'thread/sql%'
+ AND t1.parent_thread_id IS NOT NULL
+ORDER BY parent_thread_name, child_thread_name;
+
+# Cleanup
+# Wait till the event worker disappeared
+--source include/no_running_events.inc
+
diff --git a/mysql-test/suite/perfschema/t/threads_mysql_freebsd.test b/mysql-test/suite/perfschema/t/threads_mysql_freebsd.test
new file mode 100644
index 00000000..a0752636
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/threads_mysql_freebsd.test
@@ -0,0 +1,22 @@
+
+# Tests for special content of performance_schema.threads
+#
+# Show MySQL server related content in performance_schema.threads
+
+--source include/freebsd.inc
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+# Every thread should be bound to an operating system thread
+# (this test is not using the thread_pool)
+
+# Note that this test will fail:
+# - on platforms where my_thread_os_id() is not supported,
+# which is not the case on FreeBSD
+# - if some code in the server does not assign a THREAD_OS_ID
+# to an instrumented thread, in which case this is a bug
+# in the component instrumentation.
+
+SELECT THREAD_ID, NAME, THREAD_OS_ID from performance_schema.threads
+ WHERE THREAD_OS_ID is NULL;
+
diff --git a/mysql-test/suite/perfschema/t/threads_mysql_linux.test b/mysql-test/suite/perfschema/t/threads_mysql_linux.test
new file mode 100644
index 00000000..d56fe73d
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/threads_mysql_linux.test
@@ -0,0 +1,22 @@
+
+# Tests for special content of performance_schema.threads
+#
+# Show MySQL server related content in performance_schema.threads
+
+--source include/linux.inc
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+# Every thread should be bound to an operating system thread
+# (this test is not using the thread_pool)
+
+# Note that this test will fail:
+# - on platforms where my_thread_os_id() is not supported,
+# which is not the case on linux
+# - if some code in the server does not assign a THREAD_OS_ID
+# to an instrumented thread, in which case this is a bug
+# in the component instrumentation.
+
+SELECT THREAD_ID, NAME, THREAD_OS_ID from performance_schema.threads
+ WHERE THREAD_OS_ID is NULL;
+
diff --git a/mysql-test/suite/perfschema/t/threads_mysql_windows.test b/mysql-test/suite/perfschema/t/threads_mysql_windows.test
new file mode 100644
index 00000000..f7c1145f
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/threads_mysql_windows.test
@@ -0,0 +1,22 @@
+
+# Tests for special content of performance_schema.threads
+#
+# Show MySQL server related content in performance_schema.threads
+
+--source include/windows.inc
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+# Every thread should be bound to an operating system thread
+# (this test is not using the thread_pool)
+
+# Note that this test will fail:
+# - on platforms where my_thread_os_id() is not supported,
+# which is not the case on windows
+# - if some code in the server does not assign a THREAD_OS_ID
+# to an instrumented thread, in which case this is a bug
+# in the component instrumentation.
+
+SELECT THREAD_ID, NAME, THREAD_OS_ID from performance_schema.threads
+ WHERE THREAD_OS_ID is NULL;
+
diff --git a/mysql-test/suite/perfschema/t/transaction-master.opt b/mysql-test/suite/perfschema/t/transaction-master.opt
new file mode 100644
index 00000000..c720b9a1
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/transaction-master.opt
@@ -0,0 +1,4 @@
+--loose-gtid-mode=on
+--loose-enforce-gtid-consistency
+--log-bin
+--log-slave-updates
diff --git a/mysql-test/suite/perfschema/t/transaction.test b/mysql-test/suite/perfschema/t/transaction.test
new file mode 100644
index 00000000..b6164603
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/transaction.test
@@ -0,0 +1,734 @@
+############# suite/perfschema/t/transaction.test ####################
+# #
+# Test processing of transaction events by the Performance Schema, #
+# including explicit/implicit transactions, access modes, isolation #
+# levels, statement counts and state transitions. #
+# #
+# #
+######################################################################
+
+--source include/have_perfschema.inc
+--source include/not_embedded.inc
+--source include/have_innodb.inc
+--source include/no_protocol.inc
+--disable_query_log
+--source ../include/transaction_setup.inc
+--enable_query_log
+set global binlog_format=ROW;
+
+--echo #
+--echo # ========================================================================
+--echo # STEP 1 - SETUP
+--echo # ========================================================================
+
+--echo #
+--echo # Control thread
+--echo #
+--connection default
+SET SESSION AUTOCOMMIT= 1;
+eval $get_thread_id;
+let $default_thread_id= `SELECT @my_thread_id`;
+
+--echo #
+--echo # Connection 1
+--echo #
+connect(con1, localhost, root,,);
+--disable_query_log
+eval $get_thread_id;
+let $con1_thread_id= `SELECT @my_thread_id`;
+--enable_query_log
+SET SESSION AUTOCOMMIT= 0;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ WRITE;
+
+--disable_parsing
+--echo #
+--echo # Connection 2
+--echo #
+connect(con2, localhost, root,,);
+--disable_query_log
+eval $get_thread_id;
+let $con2_thread_id= `SELECT @my_thread_id`;
+--enable_query_log
+SET SESSION AUTOCOMMIT= 0;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ WRITE;
+--enable_parsing
+
+--connection default
+--disable_query_log
+eval SET @con1_thread_id= $con1_thread_id;
+#eval SET @con2_thread_id= $con2_thread_id;
+--enable_query_log
+
+--echo #
+--echo # Create test tables, one transactional and one non-transactional
+--echo #
+--connection default
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS nt1;
+--enable_warnings
+CREATE TABLE t1 (s1 int, s2 varchar(64)) ENGINE=INNODB;
+CREATE TABLE nt1 (s1 int, s2 varchar(64)) ENGINE=MYISAM;
+
+--echo #
+--echo # Disable all events from the control thread
+--echo #
+--disable_query_log
+UPDATE performance_schema.threads
+ SET instrumented='NO' WHERE processlist_id = CONNECTION_ID();
+--enable_query_log
+
+--echo #
+--echo # Clear transaction tables
+--echo #
+CALL clear_transaction_tables();
+
+--echo #
+--echo # ========================================================================
+--echo # STEP 2 - BASIC TRANSACTION
+--echo # ========================================================================
+--echo #
+--connection con1
+SELECT @@global.tx_isolation;
+SELECT @@global.autocommit;
+SELECT @@global.binlog_format;
+SELECT @@tx_isolation;
+SELECT @@autocommit;
+SELECT @@binlog_format;
+
+--echo #
+--echo # STEP 2.1 - START/COMMIT
+--echo #
+START TRANSACTION;
+INSERT INTO t1 VALUES (101, 'COMMITTED');
+COMMIT;
+
+--echo #
+--echo # STEP 2.2 - ROLLBACK
+--echo #
+START TRANSACTION;
+INSERT INTO t1 VALUES (102, 'ROLLED BACK');
+ROLLBACK;
+
+--echo #
+--echo ## Expect 1 committed and 1 rolled back transaction
+--connection default
+CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', 'REPEATABLE READ', 'NO', 0, 0, 0, 1);
+CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'ROLLED BACK', 0, '', '', '', '', 'READ WRITE', 'REPEATABLE READ', 'NO', 0, 0, 0, 1);
+CALL clear_transaction_tables();
+
+--echo #
+--echo # STEP 2.3 - COMMIT AND CHAIN
+--echo #
+--connection con1
+START TRANSACTION;
+INSERT INTO t1 VALUES (103, 'COMMIT AND CHAIN');
+COMMIT AND CHAIN;
+INSERT INTO t1 VALUES (104, 'COMMIT AND CHAIN');
+COMMIT;
+
+--echo #
+--echo ## Expect 2 committed transactions
+--connection default
+CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', 'REPEATABLE READ', 'NO', 0, 0, 0, 2);
+CALL clear_transaction_tables();
+
+--echo #
+--echo # ========================================================================
+--echo # STEP 3 - ISOLATION LEVEL
+--echo # ========================================================================
+--echo #
+--echo # connection con1
+--connection con1
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+START TRANSACTION;
+INSERT INTO t1 VALUES (301, 'SERIALIZABLE');
+COMMIT;
+
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+START TRANSACTION;
+INSERT INTO t1 VALUES (302, 'REPEATABLE READ');
+COMMIT;
+
+## NOTE - InnoDB requires binlog_format = ROW for READ COMMITTED/UNCOMMITTED
+SELECT @@binlog_format INTO @binlog_save;
+SET SESSION BINLOG_FORMAT=ROW;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+START TRANSACTION;
+INSERT INTO t1 VALUES (303, 'READ COMMITTED');
+COMMIT;
+
+SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+START TRANSACTION;
+INSERT INTO t1 VALUES (304, 'READ UNCOMMITTED');
+COMMIT;
+
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+SET binlog_format= @binlog_save;
+
+--echo #
+--connection default
+CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', 'SERIALIZABLE', 'NO', 0, 0, 0, 1);
+CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', 'REPEATABLE READ', 'NO', 0, 0, 0, 1);
+CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', 'READ COMMITTED', 'NO', 0, 0, 0, 1);
+CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', 'READ UNCOMMITTED', 'NO', 0, 0, 0, 1);
+CALL clear_transaction_tables();
+
+--echo #
+--echo # ========================================================================
+--echo # STEP 4 - ACCESS MODE
+--echo # ========================================================================
+--echo #
+--echo # STEP 4.1 - READ ONLY, TIMING ENABLED
+--echo #
+--echo #
+--echo # connection con1
+--connection con1
+SET SESSION TRANSACTION READ WRITE;
+START TRANSACTION;
+INSERT INTO t1 VALUES (410, 'READ ONLY');
+INSERT INTO t1 VALUES (411, 'READ ONLY');
+INSERT INTO t1 VALUES (412, 'READ ONLY');
+INSERT INTO t1 VALUES (413, 'READ ONLY');
+COMMIT;
+
+SET SESSION TRANSACTION READ ONLY;
+START TRANSACTION;
+SELECT * FROM t1 ORDER BY s1;
+COMMIT;
+
+--echo #
+--echo ## Expect 1 read only, committed transaction in events_transactions_history
+--connection default
+CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ ONLY', 'REPEATABLE READ', 'NO', 0, 0, 0, 1);
+CALL clear_transaction_tables();
+
+--echo #
+--echo #
+--echo # STEP 4.2 - READ ONLY, TIMING DISABLED
+--echo #
+--echo #
+--echo ## Disable timing stats for 'transaction'
+UPDATE performance_schema.setup_instruments SET timed = 'NO' WHERE name = 'transaction';
+--echo #
+TRUNCATE performance_schema.events_transactions_summary_global_by_event_name;
+
+--echo # connection con1
+--connection con1
+START TRANSACTION;
+SELECT * FROM t1 ORDER BY s1;
+COMMIT;
+--echo #
+SET SESSION TRANSACTION READ WRITE;
+
+--connection default
+--echo #
+--echo ## Expect 1 event, 0 stats
+SELECT * FROM performance_schema.events_transactions_summary_global_by_event_name;
+--echo #
+--echo ## Restore setup_instruments
+UPDATE performance_schema.setup_instruments SET enabled = 'YES' WHERE name = 'transaction';
+
+--echo #
+--echo # ========================================================================
+--echo # STEP 5 - IMPLICIT START
+--echo # ========================================================================
+--echo # When AUTOCOMMIT is disabled, the first statement following a committed
+--echo # transaction marks the start of a new transaction. Subsequent statements will
+--echo # be part of the transaction until it is committed.
+--echo #
+--connection con1
+SET SESSION AUTOCOMMIT = 0;
+INSERT INTO t1 VALUES (501, 'IMPLICIT START');
+
+--echo #
+--echo ## Expect 1 active transaction in events_transactions_current
+--connection default
+CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ACTIVE', 0, '', '', '', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1);
+
+--connection con1
+INSERT INTO t1 VALUES (502, 'IMPLICIT START');
+COMMIT;
+
+--echo #
+--echo ## Expect one committed transaction in events_transactions_current and history
+--connection default
+CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1);
+CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1);
+CALL clear_transaction_tables();
+
+--echo #
+--echo # ========================================================================
+--echo # STEP 6 - IMPLICIT COMMIT (DDL, ETC)
+--echo # ========================================================================
+--echo # Transactions are implicitly ended by DDL statements, locking statements
+--echo # and server administration commands.
+--echo #
+--connection con1
+SET SESSION AUTOCOMMIT = 0;
+INSERT INTO t1 VALUES (601, 'IMPLICIT COMMIT');
+
+--echo #
+--echo ## Expect one active transaction in events_transactions_current, zero events in history
+--connection default
+CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ACTIVE', 0, '', '', '', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1);
+CALL transaction_verifier(1, @con1_thread_id, 'transaction', '', 0, '', '', '', '', '', '', 'NO', 0, 0, 0, 0);
+
+--connection con1
+INSERT INTO t1 VALUES (602, 'IMPLICIT COMMIT');
+
+--echo ## Issue a DDL statement to force a commmit
+CREATE TABLE t2 (s1 INT, s2 VARCHAR(64)) ENGINE=INNODB;
+
+--echo #
+--echo ## Expect 0 active transactions, 1 committed transaction
+--connection default
+CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ACTIVE', 0, '', '', '', '', 'READ WRITE', '', 'NO', 0, 0, 0, 0);
+CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1);
+CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1);
+CALL clear_transaction_tables();
+DROP TABLE test.t2;
+
+--echo #
+--echo # ========================================================================
+--echo # STEP 7 - XA TRANSACTIONS
+--echo # ========================================================================
+--echo #
+--echo # STEP 7.1 - XA START
+--echo #
+--connection con1
+XA START 'XA_CON1_GTRID_001', 'XA_CON1_BQUAL_001', 1234567890;
+
+--echo #
+--echo ## Expect 1 active XA transaction, state ACTIVE
+--connection default
+
+CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ACTIVE', 1234567890, 'XA_CON1_GTRID_001', 'XA_CON1_BQUAL_001', 'ACTIVE', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1);
+
+--echo #
+--echo # STEP 7.2 - XA END
+--echo #
+--connection con1
+INSERT INTO t1 VALUES (701, 'XA');
+XA END 'XA_CON1_GTRID_001', 'XA_CON1_BQUAL_001', 1234567890;
+
+--echo #
+--echo ## Expect 1 active XA transaction, state IDLE
+--connection default
+CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ACTIVE', 1234567890, 'XA_CON1_GTRID_001', 'XA_CON1_BQUAL_001', 'IDLE', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1);
+
+--echo #
+--echo #
+--echo # STEP 7.3 - XA PREPARE
+--echo #
+--connection con1
+XA PREPARE 'XA_CON1_GTRID_001', 'XA_CON1_BQUAL_001', 1234567890;
+
+--echo #
+--echo ## Expect 1 active XA transaction, state PREPARED
+--connection default
+CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ACTIVE', 1234567890, 'XA_CON1_GTRID_001', 'XA_CON1_BQUAL_001', 'PREPARED', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1);
+
+--echo #
+--echo #
+--echo # STEP 7.4 - XA COMMIT
+--echo #
+--connection con1
+XA COMMIT 'XA_CON1_GTRID_001', 'XA_CON1_BQUAL_001', 1234567890;
+
+--echo #
+--echo ## Expect 1 committed XA transaction, state COMMITTED in current and history
+--connection default
+CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'COMMITTED', 1234567890, 'XA_CON1_GTRID_001', 'XA_CON1_BQUAL_001', 'COMMITTED', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1);
+CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 1234567890, 'XA_CON1_GTRID_001', 'XA_CON1_BQUAL_001', 'COMMITTED', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1);
+
+CALL clear_transaction_tables();
+
+--echo #
+--echo #
+--echo # STEP 7.5 - XA ROLLBACK
+--echo #
+--connection con1
+XA START 'XA_CON1_002';
+INSERT INTO t1 VALUES (702, 'XA');
+XA END 'XA_CON1_002';
+XA PREPARE 'XA_CON1_002';
+
+--echo #
+--echo ## Expect 1 active XA transaction, state PREPARED
+--connection default
+CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ACTIVE', 0, 'XA_CON1_002', '', 'PREPARED', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1);
+
+--connection con1
+XA ROLLBACK 'XA_CON1_002';
+
+--echo #
+--echo ## Expect 1 XA transaction, state ROLLBACK ONLY in current and history
+--connection default
+CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ROLLED BACK', 0, 'XA_CON1_002', '', 'ROLLBACK ONLY', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1);
+CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'ROLLED BACK', 0, 'XA_CON1_002', '', 'ROLLBACK ONLY', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1);
+CALL clear_transaction_tables();
+SELECT * FROM performance_schema.events_transactions_current ORDER BY event_id;
+
+--echo #
+--echo # STEP 7.6 - XA TRANSACTION - LONG GTRID AND BQUAL
+--echo #
+--connection con1
+XA START 'GTRID_6789012345678901234567890123456789012345678901234567890123','BQUAL_6789012345678901234567890123456789012345678901234567890123',1234567890;
+INSERT INTO t1 VALUES (703, 'XA LONG');
+XA END 'GTRID_6789012345678901234567890123456789012345678901234567890123','BQUAL_6789012345678901234567890123456789012345678901234567890123',1234567890;
+XA PREPARE 'GTRID_6789012345678901234567890123456789012345678901234567890123','BQUAL_6789012345678901234567890123456789012345678901234567890123',1234567890;
+XA COMMIT 'GTRID_6789012345678901234567890123456789012345678901234567890123','BQUAL_6789012345678901234567890123456789012345678901234567890123',1234567890;
+
+--echo #
+--echo ## Expect 1 committed XA transaction, state COMMITTED in current and history
+--connection default
+CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'COMMITTED', 1234567890, 'GTRID_6789012345678901234567890123456789012345678901234567890123', 'BQUAL_6789012345678901234567890123456789012345678901234567890123', 'COMMITTED', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1);
+CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 1234567890, 'GTRID_6789012345678901234567890123456789012345678901234567890123', 'BQUAL_6789012345678901234567890123456789012345678901234567890123', 'COMMITTED', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1);
+CALL clear_transaction_tables();
+
+--echo #
+--echo # STEP 7.7 - XA TRANSACTION - LONG GTRID AND BINARY BQUAL
+--echo #
+--connection con1
+XA START 'GTRID_6789012345678901234567890123456789012345678901234567890123',0x425155414C5FA5A53839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233,1234567890;
+INSERT INTO t1 VALUES (704, 'XA LONG/BINARY');
+XA END 'GTRID_6789012345678901234567890123456789012345678901234567890123',0x425155414C5FA5A53839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233,1234567890;
+XA PREPARE 'GTRID_6789012345678901234567890123456789012345678901234567890123',0x425155414C5FA5A53839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233,1234567890;
+XA COMMIT 'GTRID_6789012345678901234567890123456789012345678901234567890123',0x425155414C5FA5A53839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233,1234567890;
+--echo #
+--echo ## Expect 1 committed XA transaction, state COMMITTED in current and history
+--connection default
+CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'COMMITTED', 1234567890, 'GTRID_6789012345678901234567890123456789012345678901234567890123', '0x425155414C5FA5A53839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233', 'COMMITTED', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1);
+CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 1234567890, 'GTRID_6789012345678901234567890123456789012345678901234567890123', '0x425155414C5FA5A53839303132333435363738393031323334353637383930313233343536373839303132333435363738393031323334353637383930313233', 'COMMITTED', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1);
+CALL clear_transaction_tables();
+
+--echo #
+--echo # ========================================================================
+--echo # STEP 8 - TRANSACTIONAL AND NON-TRANSACTIONAL TABLES
+--echo # ========================================================================
+--echo #
+--echo ## MariaDB bug: MDEV-6012? MDEV-14436?
+set @mariadb_bug=1;
+
+## Statements that work with non-transactional engines have no effect on the
+## transaction state of the connection. For implicit transactions,
+## the transaction event begins with the first statement that uses a
+## transactional engine. This means that statements operating exclusively on
+## non-transactional tables will be ignored, even following START TRANSACTION.
+
+--connection con1
+SET SESSION AUTOCOMMIT = 0;
+SELECT * FROM performance_schema.events_transactions_current ORDER BY event_id;
+
+--echo #
+--echo #
+--echo # STEP 8.1 - UPDATE NON-TRANSACTIONAL TABLE
+--echo #
+INSERT INTO nt1 VALUES (801, 'NON-TRANSACTIONAL');
+
+--echo #
+--echo ## Expect 0 transactions in events_transactions_current
+--connection default
+CALL transaction_verifier(0, @con1_thread_id, 'transaction', '', 0, '', '', '', '', '', '', '', 0, 0, 0, @mariadb_bug);
+
+--connection con1
+COMMIT;
+
+--echo #
+--echo ## Expect 0 transactions in events_transactions_history
+--connection default
+CALL transaction_verifier(1, @con1_thread_id, 'transaction', '', 0, '', '', '', '', '', '', '', 0, 0, 0, @mariadb_bug);
+
+--echo #
+--echo #
+--echo # STEP 8.2 - UPDATE TRANSACTIONAL AND NON-TRANSACTIONAL TABLES
+--echo #
+--echo #
+--echo ## First non-transactional...
+--echo #
+--connection con1
+INSERT INTO nt1 VALUES (802, 'NON-TRANSACTIONAL');
+
+--echo #
+--echo ## Expect 0 transactions in events_transactions_current
+--connection default
+CALL transaction_verifier(0, @con1_thread_id, 'transaction', '', 0, '', '', '', '', '', '', '', 0, 0, 0, @mariadb_bug);
+
+--echo #
+--echo ## Now transactional. Transaction should be started.
+--connection con1
+INSERT INTO t1 VALUES (802, 'TRANSACTIONAL');
+
+--echo #
+--echo ## Expect 1 transaction in events_transactions_current
+--connection default
+CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ACTIVE', 0, '', '', '', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1);
+
+## Commit
+--echo #
+--connection con1
+COMMIT;
+
+--echo #
+--echo ## Expect 1 committed transaction in events_transactions_current and history
+--connection default
+CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1);
+CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1+@mariadb_bug);
+CALL clear_transaction_tables();
+
+--echo #
+--echo # ========================================================================
+--echo # STEP 9 - SAVEPOINTS
+--echo # ========================================================================
+--echo #
+--echo # STEP 9.1 - SAVEPOINT 1
+--echo #
+--connection con1
+START TRANSACTION;
+INSERT INTO t1 VALUES (901, 'SAVEPOINT');
+SAVEPOINT SVP001;
+
+--echo #
+--echo ## Expect 1 active transaction with 1 savepoint
+--connection default
+CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ACTIVE', 0, '', '', '', '', 'READ WRITE', '', 'NO', 1, 0, 0, 1);
+
+--echo #
+--echo #
+--echo # STEP 9.2 - SAVEPOINTS 2 and 3
+--echo #
+--connection con1
+INSERT INTO t1 VALUES (902, 'SAVEPOINT');
+SAVEPOINT SVP002;
+INSERT INTO t1 VALUES (903, 'SAVEPOINT');
+SAVEPOINT SVP003;
+INSERT INTO t1 VALUES (904, 'SAVEPOINT');
+SELECT COUNT(*) FROM t1 WHERE s1 > 900;
+
+--echo #
+--echo #
+--echo # STEP 9.3 - ROLLBACK TO SAVEPOINT 2
+--echo #
+--connection con1
+ROLLBACK TO SVP002;
+
+--echo #
+--echo ## Expect 1 active transaction with 3 savepoints, 1 rollback to savepoint
+--connection default
+CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ACTIVE', 0, '', '', '', '', 'READ WRITE', '', 'NO', 3, 1, 0, 1);
+
+--echo #
+--echo #
+--echo # STEP 9.4 - RELEASE SAVEPOINT 1
+--echo #
+--connection con1
+RELEASE SAVEPOINT SVP001;
+
+--echo #
+--echo ## Expect 1 active transaction with 3 savepoints, 1 rollback to savepoint, 1 release savepoint
+--connection default
+CALL transaction_verifier(0, @con1_thread_id, 'transaction', 'ACTIVE', 0, '', '', '', '', 'READ WRITE', '', 'NO', 3, 1, 1, 1);
+
+--echo #
+--echo # STEP 9.5 - COMMIT
+--echo #
+--connection con1
+COMMIT;
+
+--echo #
+--echo ## Expect 1 committed transaction with 3 savepoints, 1 rollback to savepoint, 1 release savepoint
+--connection default
+CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', 'READ WRITE', '', 'NO', 3, 1, 1, 1);
+CALL clear_transaction_tables();
+
+--echo #
+--echo # ========================================================================
+--echo # STEP 10 - GTIDs
+--echo # ========================================================================
+--echo # GTIDs are tested in transaction_gtid.test.
+
+--echo #
+--echo # ========================================================================
+--echo # STEP 11 - MISCELLANY
+--echo # ========================================================================
+--echo #
+--echo # STEP 11.1 - TRUNCATE DURING ACTIVE TRANSACTION
+--echo #
+--echo #
+--echo # Verify that truncating events_transactions_current during an active transaction
+--echo # does not leave an orphaned transaction event, and that the row index to
+--echo # events_transactions_history is reset to 0.
+--echo #
+--connection con1
+START TRANSACTION;
+INSERT INTO t1 VALUES (1110, 'INSERT 1110');
+--connection default
+TRUNCATE performance_schema.events_transactions_current;
+--connection con1
+--echo #
+COMMIT;
+--echo #
+START TRANSACTION;
+INSERT INTO t1 VALUES (1111, 'INSERT 1111');
+COMMIT;
+
+--echo #
+--echo ## Expect 1 transaction for connection 1
+--connection default
+CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', '', '', '', 0, 0, 0, 1);
+CALL clear_transaction_tables();
+
+--echo #
+--echo #
+--echo # STEP 11.2 - DISABLE THREAD INSTRUMENTATION
+--echo #
+--connection default
+UPDATE performance_schema.setup_consumers
+ SET enabled = 'NO'
+ WHERE name = 'thread_instrumentation';
+--echo #
+TRUNCATE performance_schema.events_transactions_summary_global_by_event_name;
+
+--connection con1
+--echo #
+START TRANSACTION;
+INSERT INTO t1 VALUES (1120, 'INSERT 1120');
+COMMIT;
+
+--connection default
+--echo #
+--echo ## Expect 1 event with non-zero summary stats
+--replace_column 3 sum_timer_wait 4 min_timer_wait 5 avg_timer_wait
+SELECT EVENT_NAME, COUNT_STAR, SUM_TIMER_WAIT, MIN_TIMER_WAIT, AVG_TIMER_WAIT, COUNT_READ_WRITE
+ FROM performance_schema.events_transactions_summary_global_by_event_name
+ WHERE count_star = 1 and sum_timer_wait != 0;
+
+--echo #
+--echo ## Disable timing stats for 'transaction'
+UPDATE performance_schema.setup_instruments SET timed = 'NO' WHERE name = 'transaction';
+--echo #
+TRUNCATE performance_schema.events_transactions_summary_global_by_event_name;
+
+--connection default
+--echo #
+START TRANSACTION;
+INSERT INTO t1 VALUES (1121, 'INSERT 1121');
+COMMIT;
+
+--connection default
+--echo #
+--echo ## Expect 1 event, 0 stats
+SELECT * FROM performance_schema.events_transactions_summary_global_by_event_name;
+
+--echo #
+--echo ## Restore setup_consumers and setup_instruments
+UPDATE performance_schema.setup_consumers SET enabled = 'YES' WHERE name = 'thread_instrumentation';
+UPDATE performance_schema.setup_instruments SET enabled = 'YES' WHERE name = 'transaction';
+--echo #
+DELETE FROM t1;
+CALL clear_history();
+
+--echo #
+--echo #
+--echo # STEP 11.3 - STATEMENT ROLLBACK - AUTOCOMMIT OFF - BINLOG FORMAT 'STATEMENT'
+--echo #
+--connection con1
+SET SESSION binlog_format = STATEMENT;
+SET SESSION AUTOCOMMIT = 0;
+
+# A transaction with a rolled back statement should not show as rolled back.
+#
+# Force a statement rollback by attempting to update a transactional table
+# and a non-replicatable table with binlog_format = STATEMENT.
+
+--echo #
+START TRANSACTION;
+INSERT INTO t1 VALUES (1130, 'INSERT 1130');
+--echo #
+--echo ## Expect binlog statement mode error
+--error 0, ER_BINLOG_STMT_MODE_AND_NO_REPL_TABLES
+UPDATE t1, performance_schema.setup_instruments pfs
+ SET t1.s1 = 1, pfs.timed = 'NO';
+--echo #
+COMMIT;
+--echo #
+SET SESSION AUTOCOMMIT = 1;
+
+--echo #
+--echo ## Expect 1 committed transaction
+--connection default
+CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'COMMITTED', 0, '', '', '', '', '', '', 'NO', 0, 0, 0, 1);
+--echo #
+DELETE FROM t1;
+CALL clear_history();
+
+--echo #
+--echo #
+--echo # STEP 11.4 - STATEMENT ROLLBACK - AUTOCOMMIT ON - BINLOG FORMAT 'STATEMENT'
+--echo #
+--connection con1
+SET SESSION binlog_format = STATEMENT;
+SET SESSION AUTOCOMMIT = 1;
+
+# A rolled back autocommit statement should be recorded as a rolled back transaction
+#
+# Force a statement rollback by attempting to update a transactional table
+# and a non-replicatable table with binlog_format = STATEMENT.
+--echo #
+--echo ## Expect binlog statement mode error
+--error 0, ER_BINLOG_STMT_MODE_AND_NO_REPL_TABLES
+UPDATE t1, performance_schema.setup_instruments pfs
+ SET t1.s1 = 1, pfs.timed = 'NO';
+
+--echo #
+--echo ## Expect 1 rolled back transaction
+--connection default
+CALL transaction_verifier(1, @con1_thread_id, 'transaction', 'ROLLED BACK', 0, '', '', '', '', '', '', 'YES', 0, 0, 0, 1);
+CALL clear_history();
+
+--disable_parsing
+# TODO: Add wait timer
+--echo #
+--echo #
+--echo # STEP 11.5 - DROPPED CONNECTION DURING TRANSACTION
+--echo #
+--connection con2
+START TRANSACTION;
+INSERT INTO t1 VALUES (1150, 'DROP CONNECTION');
+--echo #
+--echo ## Expect 1 active transaction for connection 2
+--connection default
+CALL transaction_verifier(0, @con2_thread_id, 'transaction', 'ACTIVE', 0, '', '', '', '', 'READ WRITE', '', 'NO', 0, 0, 0, 1);
+
+--echo #
+--echo ## Drop connection
+--connection con2
+--disconnect con2
+--source include/wait_until_disconnected.inc
+--connection default
+
+--echo #
+--echo ## Expect 0 transactions for connection 2
+CALL transaction_verifier(0, @con2_thread_id, '', '', 0, '', '', '', '', '', '', '', 0, 0, 0, 0);
+CALL transaction_verifier(1, @con2_thread_id, '', '', 0, '', '', '', '', '', '', '', 0, 0, 0, 0);
+CALL clear_transaction_tables();
+
+--enable_parsing
+
+--echo #
+--echo # ========================================================================
+--echo # CLEAN UP
+--echo # ========================================================================
+--echo #
+
+--disconnect con1
+##--disconnect con2
+
+--connection default
+DROP TABLE t1;
+DROP TABLE nt1;
+
+--source ../include/transaction_cleanup.inc
+set global binlog_format=default;
diff --git a/mysql-test/suite/perfschema/t/transaction_gtid.test b/mysql-test/suite/perfschema/t/transaction_gtid.test
new file mode 100644
index 00000000..c97c042b
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/transaction_gtid.test
@@ -0,0 +1,194 @@
+# ==== Purpose ====
+#
+# Verify that the GTID column of
+# performance_schema.events_transactions_current and
+# performance_schema.events_transactions_history has the correct
+# value, during different parts of the transaction life cycle.
+#
+# There are several cases:
+#
+# - When GTID_MODE=ON, a GTID of the form UUID:NUMBER is generated.
+# When GTID_MODE=OFF, transactions have the special GTID
+# "ANONYMOUS".
+#
+# - On a master, the GTID is generated during the transaction commit;
+# prior to that it is "AUTOMATIC". On a slave, the GTID is specified
+# (using SET GTID_NEXT) prior to executing the transaction.
+#
+# ==== Implementation ====
+#
+# Execute a transaction like:
+# BEGIN;
+# INSERT;
+# COMMIT;
+# On a different connection, check the GTID columns of the tables
+# between each statement.
+#
+# Transactions to be checked are executed on connection
+# 'default'. Auxiliary statements to read or truncate the tables are
+# executed on connection 'server_1'.
+#
+# Also execute a ROLLBACK transaction.
+#
+# Execute the transaction in these two cases:
+# - GTID_MODE=ON,
+# - GTID_MODE=OFF.
+#
+# Execute the transaction in these two cases:
+# - GTID_NEXT='UUID:NUMBER'/'ANONYMOUS' (when GTID_MODE=ON/OFF)
+# - GTID_NEXT='AUTOMATIC'.
+#
+# Due to implementation details, there is a window in time at the
+# beginning of the transaction when the GTID has not been copied from
+# the server to the performance_schema internal structures. During
+# this window, the GTID should be AUTOMATIC even if GTID_NEXT is set
+# to 'UUID:NUMBER' or 'ANONYMOUS'. To verify this, we use a debug
+# sync point during the execution of the BEGIN statement.
+#
+# ==== References ====
+#
+# WL#7592: GTIDS: generate Gtid_log_event and Previous_gtids_log_event always
+# - The current behavior was specified and the test was introduced in
+# this worklog.
+
+--source include/have_debug_sync.inc
+--source include/not_gtid_enabled.inc
+--let $rpl_topology= none
+--let $rpl_server_count= 1
+--source include/rpl_init.inc
+
+--echo # ==== Configure ====
+
+--connection default
+
+SET GLOBAL ENFORCE_GTID_CONSISTENCY = ON;
+
+--let $thread_id= `SELECT THREAD_ID FROM performance_schema.threads WHERE PROCESSLIST_ID = CONNECTION_ID()`
+--let $server_uuid= `SELECT @@GLOBAL.SERVER_UUID`
+
+CREATE TABLE t1 (a INT);
+
+# These are parameters to include/execute_at_sync_point.inc,
+# which will remain the same each time the script is invoked.
+--let $statement_connection= default
+--let $auxiliary_connection= server_1
+--let $auxiliary_file= suite/perfschema/include/show_transaction_gtid.inc
+--let $quiet= 1
+
+--echo # ==== Test ====
+
+--let $n= 1
+while ($n <= 4) {
+ if ($n == 1) {
+ --echo ---- Case 1: Specify ANONYMOUS prior to transaction ----
+ --let $gtid= ANONYMOUS
+ }
+ if ($n == 2) {
+ --echo ---- Case 2: Generate ANONYMOUS at commit ----
+ --let $gtid= AUTOMATIC
+ }
+ if ($n == 3) {
+ --let $rpl_gtid_mode= ON
+ --source include/rpl_set_gtid_mode.inc
+ --echo ---- Case 3: Specify GTID prior to transaction ----
+ --let $gtid= aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1
+ }
+ if ($n == 4) {
+ --echo ---- Case 4: Generate GTID at commit ----
+ --let $gtid= AUTOMATIC
+ }
+
+ # Execute a transaction, show the GTID column of the tables
+ # after ROLLBACK.
+
+ --echo * BEGIN ... ROLLBACK
+ --source ../include/reset_transaction_gtid.inc
+
+ --source ../include/show_transaction_gtid.inc
+ eval SET SESSION GTID_NEXT = '$gtid';
+ BEGIN;
+ eval INSERT INTO t1 VALUES ($n);
+ ROLLBACK;
+ --source ../include/show_transaction_gtid.inc
+
+ # Same transaction as above, but with a commit. Show the GTID column
+ # of the tables between each statement, as well as in the middle of
+ # the BEGIN statement.
+
+ --echo * BEGIN ... COMMIT
+ --source ../include/reset_transaction_gtid.inc
+
+ --source ../include/show_transaction_gtid.inc
+ eval SET SESSION GTID_NEXT = '$gtid';
+ --source ../include/show_transaction_gtid.inc
+ --let $statement= BEGIN
+ --let $sync_point= after_set_transaction_psi_before_set_transaction_gtid
+ --source include/execute_at_sync_point.inc
+ --source ../include/show_transaction_gtid.inc
+ eval INSERT INTO t1 VALUES ($n);
+ --source ../include/show_transaction_gtid.inc
+ COMMIT;
+ --source ../include/show_transaction_gtid.inc
+
+ # A transaction executed with AUTOCOMMIT=OFF and no BEGIN. Show the
+ # GTID column between each statement, as well as in the middle of
+ # the first DML statement.
+
+ --echo * AUTOCOMMIT = OFF
+ SET @@SESSION.AUTOCOMMIT = 0;
+ --source ../include/reset_transaction_gtid.inc
+
+ --source ../include/show_transaction_gtid.inc
+ eval SET SESSION GTID_NEXT = '$gtid';
+ --source ../include/show_transaction_gtid.inc
+ --let $statement= INSERT INTO t1 VALUES ($n)
+ --let $sync_point= begin_decide_logging_format
+ --source include/execute_at_sync_point.inc
+ --source ../include/show_transaction_gtid.inc
+ COMMIT;
+ --source ../include/show_transaction_gtid.inc
+
+ # A single-statement transaction executed with AUTOCOMMIT=ON and no
+ # BEGIN. Show the GTID column before and after, as well as in the
+ # middle of the statement.
+
+ --echo * AUTOCOMMIT = ON
+ SET @@SESSION.AUTOCOMMIT = 1;
+ --source ../include/reset_transaction_gtid.inc
+
+ --source ../include/show_transaction_gtid.inc
+ eval SET SESSION GTID_NEXT = '$gtid';
+ --source ../include/show_transaction_gtid.inc
+ --let $statement= INSERT INTO t1 VALUES ($n)
+ --let $sync_point= begin_decide_logging_format
+ --source include/execute_at_sync_point.inc
+ --source ../include/show_transaction_gtid.inc
+
+ # Disabled because DDL is not inserted into the tables
+ if (0) {
+ # An implicitly committing statement (DDL), no BEGIN.
+ --echo * implicit commit (DDL)
+ --source ../include/reset_transaction_gtid.inc
+
+ --source ../include/show_transaction_gtid.inc
+ eval SET SESSION GTID_NEXT = '$gtid';
+ --source ../include/show_transaction_gtid.inc
+ --let $statement= CREATE TABLE t_$n (a INT)
+ --let $sync_point= begin_decide_logging_format
+ --source include/execute_at_sync_point.inc
+ --source ../include/show_transaction_gtid.inc
+ }
+
+ --inc $n
+}
+
+--echo # ==== Clean up ====
+
+DROP TABLE t1;
+# DROP TABLE t_1, t_2, t_3, t_4;
+
+--let $rpl_gtid_mode= OFF
+--source include/rpl_set_gtid_mode.inc
+SET GLOBAL ENFORCE_GTID_CONSISTENCY = OFF;
+
+--source include/rpl_end.inc
diff --git a/mysql-test/suite/perfschema/t/transaction_nested_events-master.opt b/mysql-test/suite/perfschema/t/transaction_nested_events-master.opt
new file mode 100644
index 00000000..0583801e
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/transaction_nested_events-master.opt
@@ -0,0 +1,19 @@
+--event-scheduler
+--query_cache_size=0
+--loose-performance_schema_events_statements_history_size=20
+--loose-performance_schema_events_statements_history_long_size=50
+--loose-performance_schema_events_transactions_history_long_size=50
+--loose-performance_schema_max_thread_instances=60
+
+--loose-performance-schema-consumer-events-stages-current=OFF
+--loose-performance-schema-consumer-events-stages-history=OFF
+--loose-performance-schema-consumer-events-stages-history-long=OFF
+--loose-performance-schema-consumer-events-statements-current=ON
+--loose-performance-schema-consumer-events-statements-history=ON
+--loose-performance-schema-consumer-events-statements-history-long=ON
+--loose-performance-schema-consumer-events-transactions-current=ON
+--loose-performance-schema-consumer-events-transactions-history=ON
+--loose-performance-schema-consumer-events-transactions-history-long=ON
+--loose-performance-schema-consumer-events-waits-current=OFF
+--loose-performance-schema-consumer-events-waits-history=OFF
+--loose-performance-schema-consumer-events-waits-history-long=OFF
diff --git a/mysql-test/suite/perfschema/t/transaction_nested_events.test b/mysql-test/suite/perfschema/t/transaction_nested_events.test
new file mode 100644
index 00000000..1be7dc0f
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/transaction_nested_events.test
@@ -0,0 +1,387 @@
+########## suite/perfschema/t/transaction_nested_events.test #########
+# #
+# This test checks the following #
+# 1) nested events #
+# 2) various scenarios of stored program & transaction combinations #
+# #
+# #
+######################################################################
+
+--source include/have_perfschema.inc
+--source include/not_embedded.inc
+--source include/have_innodb.inc
+--source include/no_protocol.inc
+--source include/maybe_pool_of_threads.inc
+
+--disable_query_log
+--source ../include/transaction_setup.inc
+--enable_query_log
+
+--echo #
+--echo #========================================================================
+--echo # STEP 1 - SETUP
+--echo #========================================================================
+
+--echo #
+--echo ## Setup control thread
+--echo #
+--connection default
+SET SESSION AUTOCOMMIT= 1;
+--disable_warnings
+USE test;
+DROP DATABASE IF EXISTS db;
+--enable_warnings
+--echo #
+--echo ## Create test database, test tables, one transactional and one non-transactional
+CREATE DATABASE db;
+CREATE TABLE db.t1 (s1 int, s2 varchar(64)) ENGINE=INNODB;
+CREATE TABLE db.nt1 (s1 int, s2 varchar(64)) ENGINE=MYISAM;
+
+--echo #
+--echo ## Setup connection 1
+connect(con1, localhost, root,,);
+USE db;
+SET SESSION AUTOCOMMIT = 1;
+eval $get_thread_id;
+let $con1_thread_id= `SELECT @my_thread_id`;
+
+--connection default
+--disable_query_log
+eval SET @con1_thread_id= $con1_thread_id;
+--enable_query_log
+
+--echo #
+--echo ## Disable events from the control (default) connection
+UPDATE performance_schema.threads SET instrumented = 'NO' WHERE processlist_id = CONNECTION_ID();
+
+# Use this to select events from all threads
+eval SET @all_threads= 0;
+
+--echo #
+--echo ## Enable only transaction and statement instruments
+UPDATE performance_schema.setup_instruments SET enabled='NO', timed='NO';
+UPDATE performance_schema.setup_instruments SET enabled='YES'
+ WHERE name LIKE ('statement/%') OR name = 'transaction';
+
+--echo #
+--echo ## Clear statement and transaction history
+CALL test.clear_history();
+
+--echo #
+--echo #========================================================================
+--echo # STEP 2 - BASIC TRANSACTION
+--echo #========================================================================
+--echo #
+--echo # STEP 2.1 - IMPLICIT
+--echo #
+--connection con1
+INSERT INTO t1 VALUES (210, "INSERT 210");
+INSERT INTO t1 VALUES (211, "INSERT 211");
+INSERT INTO t1 VALUES (212, "INSERT 212");
+UPDATE t1 SET s1 = s1 + 1 WHERE s1 = 212;
+
+## Verify and reset
+--source ../include/transaction_nested_events_verifier.inc
+
+--echo #
+--echo # STEP 2.2 - EXPLICIT
+--echo #
+--connection con1
+START TRANSACTION;
+INSERT INTO t1 VALUES (220, "INSERT 220"), (221, "INSERT 221");
+UPDATE t1 SET s2 = "UPDATE 221" WHERE s1 = 221;
+COMMIT;
+
+## Verify and reset
+--source ../include/transaction_nested_events_verifier.inc
+
+--echo #========================================================================
+--echo # STEP 3 - TRANSACTIONS AND STORED PROCEDURES
+--echo #========================================================================
+--echo #
+--echo # STEP 3.1 - STORED PROCEDURE STARTED WITHIN TRANSACTION
+--echo #
+--connection con1
+CREATE PROCEDURE tp_update() UPDATE t1 SET s1 = s1 + 1;
+--echo #
+START TRANSACTION;
+INSERT INTO t1 VALUES (310, "INSERT 310");
+INSERT INTO t1 VALUES (311, "INSERT 311");
+INSERT INTO t1 VALUES (312, "INSERT 312");
+INSERT INTO t1 VALUES (313, "INSERT 313");
+CALL tp_update();
+COMMIT;
+
+## Verify and reset
+--source ../include/transaction_nested_events_verifier.inc
+
+--echo #
+--echo # STEP 3.2 - TRANSACTION STARTED WITHIN STORED PROCEDURE
+--echo #
+--connection con1
+CREATE PROCEDURE tp_start() START TRANSACTION;
+--echo #
+CALL tp_start();
+INSERT INTO t1 VALUES (320, "INSERT 320"),(321, "INSERT 321");
+INSERT INTO t1 VALUES (322, "INSERT 322"),(323, "INSERT 323");
+UPDATE t1 SET s1 = s1 + 1 WHERE s1 > 320;
+--echo #
+SELECT * FROM t1 ORDER BY s1;
+COMMIT;
+
+## Verify and reset
+--source ../include/transaction_nested_events_verifier.inc
+
+--echo #
+--echo # STEP 3.3 - TRANSACTION ENDED WITHIN STORED PROCEDURE
+--echo #
+--connection con1
+CREATE PROCEDURE tp_rollback() ROLLBACK;
+CREATE PROCEDURE tp_commit() COMMIT;
+
+--echo #
+--echo ## COMMIT within stored procedure
+START TRANSACTION;
+INSERT INTO t1 VALUES (330, "INSERT 330"),(331, "INSERT 331");
+INSERT INTO t1 VALUES (332, "INSERT 332"),(333, "INSERT 333");
+DELETE FROM t1 WHERE s1 > 331;
+CALL tp_commit();
+--echo #
+SELECT * FROM t1 ORDER BY s1;
+
+--echo #
+--echo ## ROLLBACK within stored procedure
+START TRANSACTION;
+UPDATE t1 SET s1 = s1*2 WHERE s1 > 331;
+CALL tp_rollback();
+--echo #
+SELECT * FROM t1 ORDER BY s1;
+
+## Verify and reset
+--source ../include/transaction_nested_events_verifier.inc
+
+--echo #========================================================================
+--echo # STEP 4 - TRANSACTIONS AND STORED FUNCTIONS
+--echo #========================================================================
+--echo #
+--echo #
+--echo # STEP 4.1 - FUNCTION WITHIN A TRANSACTION
+--echo #
+--connection con1
+DELIMITER |;
+CREATE FUNCTION fn_add(x INT, y INT) RETURNS INT
+BEGIN
+ INSERT INTO t1 VALUES (x, "INSERT x"),(y, "INSERT y");
+RETURN x+y;
+END |
+DELIMITER ;|
+
+--echo #
+--echo ## Clear history
+--connection default
+CALL test.clear_history();
+--connection con1
+
+--echo #
+START TRANSACTION;
+INSERT INTO t1 VALUES (410, "INSERT 410");
+INSERT INTO t1 VALUES (411, "INSERT 411");
+INSERT INTO t1 VALUES (412, "INSERT 412");
+DELETE FROM t1 WHERE s1 > 410;
+--echo #
+SELECT * FROM t1 ORDER BY s1;
+--echo #
+SELECT fn_add(413, 414);
+COMMIT;
+--echo #
+SELECT * FROM t1 ORDER BY s1;
+
+## Verify and reset
+--source ../include/transaction_nested_events_verifier.inc
+
+--connection con1
+--echo #
+--echo ## Again, but this time with a rollback
+--echo #
+START TRANSACTION;
+SELECT fn_add(415, 416);
+--echo #
+ROLLBACK;
+--echo #
+SELECT * FROM t1 ORDER BY s1;
+
+## Verify and reset
+--source ../include/transaction_nested_events_verifier.inc
+
+--echo #
+--echo # STEP 4.2 - TRANSACTION CANNOT BE STARTED OR ENDED WITHIN FUNCTION
+--echo #
+--connection con1
+DELIMITER |;
+--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
+CREATE FUNCTION fn_err1() RETURNS VARCHAR(10) BEGIN START TRANSACTION ; RETURN 'invalid' ; END|
+DELIMITER ;|
+
+--echo #
+--echo ## Expect 0 transactions
+--connection default
+SELECT COUNT(*) FROM performance_schema.events_transactions_history;
+--connection con1
+
+--echo #
+--echo ## Expect stored function does not exist
+--echo #
+--error ER_SP_DOES_NOT_EXIST
+SELECT fn_err1();
+
+--echo #
+--echo ## Expect 1 transactions
+--connection default
+SELECT COUNT(*) FROM performance_schema.events_transactions_history;
+--connection con1
+
+--echo #
+DELIMITER |;
+--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
+CREATE FUNCTION fn_err2() RETURNS VARCHAR(10) BEGIN COMMIT; RETURN 'invalid' ; END|
+DELIMITER ;|
+
+--echo #
+--echo ## Expect stored function does not exist
+--echo #
+START TRANSACTION;
+DELETE FROM t1 WHERE s1 > 320;
+--error ER_SP_DOES_NOT_EXIST
+SELECT fn_err2();
+
+--echo #
+--echo ## Expect 2 transactions
+--connection default
+SELECT COUNT(*) FROM performance_schema.events_transactions_history;
+
+--echo #
+--echo ## Clear transaction and statement tables
+CALL test.clear_history();
+
+--echo #========================================================================
+--echo # STEP 5 - TRANSACTIONS AND TRIGGERS
+--echo #========================================================================
+--echo #
+--echo #
+--echo # STEP 5.1 - FORCE STATEMENT ROLLBACK FROM TRIGGER
+--echo #
+--connection con1
+--echo ## Create a trigger to force statement rollback
+--echo #
+DELIMITER |;
+CREATE TRIGGER trigger_before_update BEFORE UPDATE ON t1
+FOR EACH ROW
+BEGIN
+ IF OLD.s1 >= 505 THEN
+ SIGNAL sqlstate '45001' SET message_text = "FORCE ERROR";
+ END IF;
+END;|
+DELIMITER ;|
+
+--echo #
+--echo ## Clear history
+--connection default
+CALL test.clear_history();
+--connection con1
+
+--echo #
+--echo ## Insert multiple rows, then update. Trigger will force rollback the
+--echo ## UPDATE statement, but the transaction should not roll back.
+--echo #
+START TRANSACTION;
+INSERT INTO t1 VALUES (500, "INSERT 500");
+INSERT INTO t1 VALUES (501, "INSERT 501");
+INSERT INTO t1 VALUES (502, "INSERT 502");
+INSERT INTO t1 VALUES (503, "INSERT 503");
+INSERT INTO t1 VALUES (504, "INSERT 504");
+INSERT INTO t1 VALUES (505, "INSERT 505");
+--echo #
+SELECT * FROM t1 ORDER BY s1;
+--echo #
+--echo ## Expect error when UPDATE hits record 505
+--echo #
+--error ER_SIGNAL_EXCEPTION
+UPDATE t1 SET s1 = s1 * 2 WHERE s1 >= 500;
+--echo #
+--echo ## Verify that INSERT succeeded, UPDATE failed and transaction did not rollback
+--echo #
+SELECT * FROM t1 ORDER BY s1;
+COMMIT;
+--echo #
+DROP TRIGGER trigger_before_update;
+
+## Verify and reset
+--source ../include/transaction_nested_events_verifier.inc
+
+--echo # TODO: Detect statement events from scheduled event
+--disable_parsing
+--echo #========================================================================
+--echo # STEP 6 - SCHEDULED EVENTS
+--echo #========================================================================
+--connection con1
+
+# Check that the event_scheduler is really running
+#--source include/running_event_scheduler.inc
+
+--echo #
+--echo ## Create a one-time event that will insert, update, commit and rollback.
+--echo #
+DELIMITER |;
+CREATE EVENT trx_event ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 5 SECOND DO
+BEGIN
+ START TRANSACTION;
+ INSERT INTO t1 VALUES (600, "INSERT 600");
+ INSERT INTO t1 VALUES (601, "INSERT 601");
+ INSERT INTO t1 VALUES (602, "INSERT 602");
+ COMMIT;
+ START TRANSACTION;
+ UPDATE t1 SET s1 = s1 + 1, s2 = 'THIS SHOULD NOT BE HERE';
+ ROLLBACK;
+ START TRANSACTION;
+ INSERT INTO t1 VALUES (699, "INSERT 699");
+ COMMIT;
+END;|
+DELIMITER ;|
+
+--echo #
+--echo ## Clear history
+--connection default
+CALL test.clear_history();
+--connection con1
+--echo #
+--echo ## Wait a few seconds for scheduled event to execute and finish.
+# Check based on the expected content in t1.
+let $wait_condition= SELECT COUNT(*) = 4 FROM t1;
+--source include/wait_condition.inc
+--echo #
+--echo ## Confirm that the scheduled event completed and the content of t1 is right.
+--echo #
+SELECT * FROM t1 ORDER BY s1;
+--echo #
+--echo ## Verify and reset
+--echo #
+eval SET @all_threads= 1;
+--source ../include/transaction_nested_events_verifier.inc
+eval SET @all_threads= 0;
+
+--enable_parsing
+
+--echo #=======================================================================
+--echo # Cleanup
+--echo #=======================================================================
+--connection con1
+--disconnect con1
+--source include/wait_until_disconnected.inc
+--connection default
+DROP DATABASE db;
+UPDATE performance_schema.setup_instruments SET enabled='YES', timed='YES';
+
+--source ../include/transaction_cleanup.inc
+
+
+
diff --git a/mysql-test/suite/perfschema/t/trigger_table_io.test b/mysql-test/suite/perfschema/t/trigger_table_io.test
new file mode 100644
index 00000000..2b374c79
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/trigger_table_io.test
@@ -0,0 +1,76 @@
+# Tests for PERFORMANCE_SCHEMA table io
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source ../include/table_io_setup_helper.inc
+
+let $engine_type= MyISAM;
+
+--disable_warnings
+drop table if exists test.t1;
+drop table if exists test.t2;
+--enable_warnings
+
+eval create table test.t1 (a int, v int) engine = $engine_type;
+eval create table test.t2 (b int, v int) engine = $engine_type;
+
+create trigger t1_bi before insert on t1
+for each row insert into test.t2 set b = new.a, v = 0;
+
+create trigger t1_ai after insert on t1
+for each row update test.t2 set v = 1 where b = new.a;
+
+create trigger t1_bu before update on t1
+for each row update test.t2 set v = 3 where b = old.a;
+
+create trigger t1_au after update on t1
+for each row update test.t2 set v = 4 where b = new.a;
+
+create trigger t1_bd before delete on t1
+for each row delete from test.t2 where b = old.a;
+
+create trigger t1_ad after delete on t1
+for each row insert into test.t2 set b = old.a, v = 99;
+
+# Start recording events
+update performance_schema.setup_consumers set enabled = 'YES';
+
+# Code to test
+
+--disable_ps2_protocol
+insert into marker set a = 1;
+insert into t1 set a = 1, v = 10;
+insert into marker set a = 1;
+insert into t1 set a = 2, v = 20;
+insert into marker set a = 1;
+select * from t1;
+insert into marker set a = 1;
+select * from t2;
+insert into marker set a = 1;
+update t1 set v = v + 100;
+insert into marker set a = 1;
+select * from t1;
+insert into marker set a = 1;
+select * from t2;
+insert into marker set a = 1;
+delete from t1 where a = 1;
+insert into marker set a = 1;
+select * from t1;
+insert into marker set a = 1;
+select * from t2;
+insert into marker set a = 1;
+delete from t1 where a = 2;
+insert into marker set a = 1;
+select * from t1;
+insert into marker set a = 1;
+select * from t2;
+--enable_ps2_protocol
+
+# Stop recording events + pull results
+--source ../include/table_io_result_helper.inc
+
+# Cleanup
+drop table test.t1;
+drop table test.t2;
+--source ../include/table_io_cleanup_helper.inc
+
diff --git a/mysql-test/suite/perfschema/t/unary_digest.test b/mysql-test/suite/perfschema/t/unary_digest.test
new file mode 100644
index 00000000..d8daea70
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/unary_digest.test
@@ -0,0 +1,98 @@
+# ----------------------------------------------------
+# Tests for the performance schema statement Digests.
+# ----------------------------------------------------
+
+# Test case to show behavior of statements digest when
+# statement-digest-size is 0
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/no_protocol.inc
+
+TRUNCATE TABLE performance_schema.events_statements_summary_by_digest;
+
+--disable_query_log
+
+--error ER_NO_SUCH_TABLE
+select 1 from expect_unary;
+--error ER_NO_SUCH_TABLE
+select +1 from expect_unary;
+--error ER_NO_SUCH_TABLE
+select -1 from expect_unary;
+--error ER_NO_SUCH_TABLE
+select ++++++++++++++++++++++++++++++++++++++++++++++++1 from expect_unary;
+--error ER_NO_SUCH_TABLE
+select ------------------------------------------------1 from expect_unary;
+
+--error ER_NO_SUCH_TABLE
+select 0+1 from expect_binary;
+--error ER_NO_SUCH_TABLE
+select 0-1 from expect_binary;
+--error ER_NO_SUCH_TABLE
+select 0 ++++++++++++++++++++++++++++++++++++++++++++++++1 from expect_binary;
+--error ER_NO_SUCH_TABLE
+select 0 ------------------------------------------------1 from expect_binary;
+
+--error ER_NO_SUCH_TABLE
+insert into expect_full_reduce values (0, 0, 0);
+--error ER_NO_SUCH_TABLE
+insert into expect_full_reduce values (0, 0, -1);
+--error ER_NO_SUCH_TABLE
+insert into expect_full_reduce values (0, 0, +1);
+--error ER_NO_SUCH_TABLE
+insert into expect_full_reduce values (0, -1, 0);
+--error ER_NO_SUCH_TABLE
+insert into expect_full_reduce values (0, -1, -1);
+--error ER_NO_SUCH_TABLE
+insert into expect_full_reduce values (0, -1, +1);
+--error ER_NO_SUCH_TABLE
+insert into expect_full_reduce values (0, +1, 0);
+--error ER_NO_SUCH_TABLE
+insert into expect_full_reduce values (0, +1, -1);
+--error ER_NO_SUCH_TABLE
+insert into expect_full_reduce values (0, +1, +1);
+--error ER_NO_SUCH_TABLE
+insert into expect_full_reduce values (-1, 0, 0);
+--error ER_NO_SUCH_TABLE
+insert into expect_full_reduce values (-1, 0, -1);
+--error ER_NO_SUCH_TABLE
+insert into expect_full_reduce values (-1, 0, +1);
+--error ER_NO_SUCH_TABLE
+insert into expect_full_reduce values (-1, -1, 0);
+--error ER_NO_SUCH_TABLE
+insert into expect_full_reduce values (-1, -1, -1);
+--error ER_NO_SUCH_TABLE
+insert into expect_full_reduce values (-1, -1, +1);
+--error ER_NO_SUCH_TABLE
+insert into expect_full_reduce values (-1, +1, 0);
+--error ER_NO_SUCH_TABLE
+insert into expect_full_reduce values (-1, +1, -1);
+--error ER_NO_SUCH_TABLE
+insert into expect_full_reduce values (-1, +1, +1);
+--error ER_NO_SUCH_TABLE
+insert into expect_full_reduce values (+1, 0, 0);
+--error ER_NO_SUCH_TABLE
+insert into expect_full_reduce values (+1, 0, -1);
+--error ER_NO_SUCH_TABLE
+insert into expect_full_reduce values (+1, 0, +1);
+--error ER_NO_SUCH_TABLE
+insert into expect_full_reduce values (+1, -1, 0);
+--error ER_NO_SUCH_TABLE
+insert into expect_full_reduce values (+1, -1, -1);
+--error ER_NO_SUCH_TABLE
+insert into expect_full_reduce values (+1, -1, +1);
+--error ER_NO_SUCH_TABLE
+insert into expect_full_reduce values (+1, +1, 0);
+--error ER_NO_SUCH_TABLE
+insert into expect_full_reduce values (+1, +1, -1);
+--error ER_NO_SUCH_TABLE
+insert into expect_full_reduce values (+1, +1, +1);
+
+--error ER_NO_SUCH_TABLE
+select a-b, a+b, -a, -b, +a, +b from expect_unchanged;
+
+--enable_query_log
+
+SELECT SCHEMA_NAME, DIGEST_TEXT, COUNT_STAR
+ FROM performance_schema.events_statements_summary_by_digest;
+
diff --git a/mysql-test/suite/perfschema/t/update_order-3837.test b/mysql-test/suite/perfschema/t/update_order-3837.test
new file mode 100644
index 00000000..72e3941f
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/update_order-3837.test
@@ -0,0 +1,8 @@
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+#
+# MDEV-3837 Assertion `table->read_set == &table->def_read_set' failed on updating a performance_schema table
+#
+UPDATE performance_schema.setup_instruments SET timed = 'YES' ORDER BY name;
+
diff --git a/mysql-test/suite/perfschema/t/user_var_func.test b/mysql-test/suite/perfschema/t/user_var_func.test
new file mode 100644
index 00000000..3c9ea4f3
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/user_var_func.test
@@ -0,0 +1,101 @@
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+set @v1a="Hello";
+set @v2a="World";
+set @v3a=65;
+set @v4a=NULL;
+
+select @v1a, @v2a, @v3a, @v4a, @v_unknown;
+
+select VARIABLE_NAME, VARIABLE_VALUE
+ from performance_schema.user_variables_by_thread
+ order by VARIABLE_NAME;
+
+connect(con1, localhost, root,,);
+
+set @v1b="Salut";
+set @v2b="La compagnie";
+set @v3b=12;
+set @v4b=NULL;
+
+select @v1b, @v2b, @v3b, @v4b, @v_unknown;
+
+select VARIABLE_NAME, VARIABLE_VALUE
+ from performance_schema.user_variables_by_thread
+ order by VARIABLE_NAME;
+
+--connection default
+--disconnect con1
+
+# Wait till all disconnects are completed
+let $count_sessions= 1;
+--source include/wait_until_count_sessions.inc
+
+select VARIABLE_NAME, VARIABLE_VALUE
+ from performance_schema.user_variables_by_thread
+ order by VARIABLE_NAME;
+
+# Make sure large values are not truncated
+set @blob_under_16_bits=repeat("a", 65000);
+set @blob_under_24_bits=repeat("a", 1000000);
+
+# Not testable because of limitation on max_allowed_packet
+# set @blob_under_32_bits=repeat("a", 20000000);
+
+select length(@blob_under_16_bits);
+select length(@blob_under_24_bits);
+# select length(@blob_under_32_bits);
+
+select variable_name, length(variable_value)
+ from performance_schema.user_variables_by_thread
+ where VARIABLE_NAME like "blob%"
+ order by VARIABLE_NAME;
+
+
+# Check the behaviour with procedures if the values passed inside procedures gets reflected in the table performance_schema.user_variables_by_thread.
+
+set @a=10;
+
+DELIMITER |;
+CREATE procedure test_user_val
+(IN input INT,OUT output INT)
+BEGIN
+ SELECT input + input
+ INTO output;
+END|
+DELIMITER ;|
+
+CALL test_user_val(@a , @total);
+select VARIABLE_NAME,VARIABLE_VALUE from performance_schema.user_variables_by_thread
+where variable_name in ('a','total') order by VARIABLE_NAME;
+
+
+# Checking behaviour around triggers if the values in performance_schema.user_variables_by_thread are updated from within trigger
+
+create table t1 (c1 int);
+
+DELIMITER |;
+CREATE TRIGGER test_uvar_trigger
+ AFTER INSERT ON t1
+ FOR EACH ROW BEGIN
+ set @a=@a+@a;
+END|
+DELIMITER ;|
+
+insert into t1 values(1);
+select VARIABLE_NAME,VARIABLE_VALUE from performance_schema.user_variables_by_thread
+where variable_name ='a' order by VARIABLE_NAME;
+
+insert into t1 values(1);
+select VARIABLE_NAME,VARIABLE_VALUE from performance_schema.user_variables_by_thread
+where variable_name ='a' order by VARIABLE_NAME;
+
+drop table t1;
+drop procedure test_user_val;
+#drop TRIGGER test_uvar_trigger;
+
+
+
+
diff --git a/mysql-test/suite/perfschema/t/view_table_io.test b/mysql-test/suite/perfschema/t/view_table_io.test
new file mode 100644
index 00000000..f5b017dc
--- /dev/null
+++ b/mysql-test/suite/perfschema/t/view_table_io.test
@@ -0,0 +1,42 @@
+# Tests for PERFORMANCE_SCHEMA table io
+# Reveal that in case of DML on an updatable view the
+# base table used within the view shows up whereas
+# the view itself never shows up.
+
+## To skip the test with QC enabled till BUG#14830950 is fixed.
+#-- source include/have_QC_Disabled.inc
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source ../include/table_io_setup_helper.inc
+
+let $engine_type= MyISAM;
+let $table_item= test.v1;
+
+--disable_warnings
+eval drop view if exists $table_item;
+drop table if exists test.no_index_tab;
+--enable_warnings
+
+
+# Start recording events
+update performance_schema.setup_consumers set enabled='YES';
+insert into marker set a = 1;
+eval create table test.no_index_tab
+( a varchar(255) not null, b int not null) engine = $engine_type;
+insert into marker set a = 1;
+# Make sure the proper engine is used
+show create table test.no_index_tab;
+insert into marker set a = 1;
+eval create view $table_item as select * from test.no_index_tab;
+--source ../include/table_io_basic_dml.inc
+eval drop view $table_item;
+insert into marker set a = 1;
+drop table test.no_index_tab;
+
+# Stop recording events + pull result
+--source ../include/table_io_result_helper.inc
+
+# Cleanup
+--source ../include/table_io_cleanup_helper.inc
+