summaryrefslogtreecommitdiff
path: root/mysql-test/suite/perfschema/include/connection_setup.inc
blob: da57b6dd38811993f629341b585277833e868a7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Tests for the performance schema

# =============
# DOCUMENTATION
# =============

# Verify how connections are counted into various tables:
# - accounts
# - users
# - hosts
#
# The tests are written with the following helpers:
# - include/connection_setup.inc
# - include/connection_load.inc
# - include/connection_cleanup.inc
#
# Helpers are intended to be used as follows.
#
# A Typical test t/connection_xxx.test will consist of:
# --source ../include/connection_setup.inc
# --source ../include/connection_load.inc
# --source ../include/connection_cleanup.inc
# and a t/connection_xxx-master.opt file
#
# Naming conventions for t/connection_xxx.test are as follows:
# t/connection_<account><user><host>
#
# <account> corresponds to different sizing settings for 
# the variable performance-schema-accounts-size
# - (blank): accounts-size sufficient to represent all records
# - 3a: accounts-size set to 3
# - no_a: accounts-size set to 0
#
# <user> corresponds to different sizing settings for 
# the variable performance-schema-users-size
# - (blank): users-size sufficient to represent all records
# - 3u: users-size set to 3
# - no_u: users-size set to 0
#
# <host> corresponds to different sizing settings for 
# the variable performance-schema-hosts-size
# - (blank): hosts-size sufficient to represent all records
# - no_h: hosts-size set to 0

# ========================================
# HELPER include/event_aggregate_setup.inc
# ========================================

--source include/not_embedded.inc
--source include/have_perfschema.inc
--source ../include/no_protocol.inc
--source ../include/wait_for_pfs_thread_count.inc

--disable_query_log

grant ALL on *.* to user1@localhost;
grant ALL on *.* to user2@localhost;
grant ALL on *.* to user3@localhost;
grant ALL on *.* to user4@localhost;
grant ALL on *.* to user5@localhost;

flush privileges;

# Purge old users, hosts, user/host from previous tests
truncate table performance_schema.accounts;
truncate table performance_schema.users;
truncate table performance_schema.hosts;

# Save the setup

# Start from a known clean state, to avoid noise from previous tests
flush tables;
flush status;

--disable_warnings
drop procedure if exists dump_all;
--enable_warnings

delimiter $$;

create procedure dump_all()
begin
  select processlist_user, processlist_host
    from performance_schema.threads
    where (processlist_user is not null) and (processlist_host is not null)
    order by processlist_user;

  select * from performance_schema.accounts
    where (user is not null) and (host is not null)
    order by user, host;

  select * from performance_schema.users
    where user is not null
    order by user;

  select * from performance_schema.hosts
    where host is not null
    order by host;

  select variable_name, variable_value from information_schema.global_status
    where variable_name in ('PERFORMANCE_SCHEMA_ACCOUNTS_LOST',
                            'PERFORMANCE_SCHEMA_USERS_LOST',
                            'PERFORMANCE_SCHEMA_HOSTS_LOST');
end
$$

delimiter ;$$

--enable_query_log