1# Check the impact of changes done in HISTORY column in
2# performance_schema.setup_actors.
3
4# The initial number of rows is 1. The initial row always looks like this:
5# mysql> select * from performance_schema.setup_actors;
6# +------+------+------+---------+---------+
7# | HOST | USER | ROLE | ENABLED | HISTORY |
8# +------+------+------+---------+---------+
9# | %    | %    | %    | YES     | YES     |
10# +------+------+------+---------+---------+
11select * from performance_schema.setup_actors;
12
13truncate table performance_schema.setup_actors;
14
15insert into performance_schema.setup_actors
16values ('localhost', 'user1', '%', 'YES', 'YES');
17
18insert into performance_schema.setup_actors
19values ('localhost', 'user2', '%', 'YES', 'NO');
20
21insert into performance_schema.setup_actors
22values ('localhost', 'user3', '%', 'NO', 'YES');
23
24insert into performance_schema.setup_actors
25values ('localhost', 'user4', '%', 'NO', 'NO');
26
27create user user1@localhost;
28create user user2@localhost;
29create user user3@localhost;
30create user user4@localhost;
31
32grant ALL on *.* to user1@localhost;
33grant ALL on *.* to user2@localhost;
34grant ALL on *.* to user3@localhost;
35grant ALL on *.* to user4@localhost;
36
37flush privileges;
38
39--echo # Switch to (con1, localhost, user1, , )
40connect (con1, localhost, user1, , );
41
42# Expecting INSTRUMENTED=YES, HISTORY=YES
43select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
44from performance_schema.threads
45where PROCESSLIST_ID = connection_id();
46
47--echo # Switch to (con2, localhost, user2, , )
48connect (con2, localhost, user2, , );
49
50# Expecting INSTRUMENTED=YES, HISTORY=NO
51select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
52from performance_schema.threads
53where PROCESSLIST_ID = connection_id();
54
55--echo # Switch to (con3, localhost, user3, , )
56connect (con3, localhost, user3, , );
57
58# Expecting INSTRUMENTED=NO, HISTORY=YES
59select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
60from performance_schema.threads
61where PROCESSLIST_ID = connection_id();
62
63--echo # Switch to (con4, localhost, user4, , )
64connect (con4, localhost, user4, , );
65
66# Expecting INSTRUMENTED=NO, HISTORY=NO
67select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
68from performance_schema.threads
69where PROCESSLIST_ID = connection_id();
70
71--echo # Switch to connection default
72--connection default
73update performance_schema.setup_actors
74  set HISTORY='NO' where USER in ('user1', 'user3');
75update performance_schema.setup_actors
76  set HISTORY='YES' where USER in ('user2', 'user4');
77
78--echo # Switch to connection con1
79--connection con1
80
81# Expecting INSTRUMENTED=YES, HISTORY=YES
82select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
83from performance_schema.threads
84where PROCESSLIST_ID = connection_id();
85
86--echo # Switch to connection con2
87--connection con2
88
89# Expecting INSTRUMENTED=YES, HISTORY=NO
90select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
91from performance_schema.threads
92where PROCESSLIST_ID = connection_id();
93
94--echo # Switch to connection con3
95--connection con3
96
97# Expecting INSTRUMENTED=NO, HISTORY=YES
98select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
99from performance_schema.threads
100where PROCESSLIST_ID = connection_id();
101
102--echo # Switch to connection con4
103--connection con4
104
105# Expecting INSTRUMENTED=NO, HISTORY=NO
106select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
107from performance_schema.threads
108where PROCESSLIST_ID = connection_id();
109
110--echo # Disconnect all con
111--disconnect con1
112--disconnect con2
113--disconnect con3
114--disconnect con4
115
116# Now reconnect
117--echo # Switch to (con1, localhost, user1, , )
118connect (con1, localhost, user1, , );
119
120# Expecting INSTRUMENTED=YES, HISTORY=NO
121select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
122from performance_schema.threads
123where PROCESSLIST_ID = connection_id();
124
125--echo # Switch to (con2 localhost, user2, , )
126connect (con2, localhost, user2, , );
127
128# Expecting INSTRUMENTED=YES, HISTORY=YES
129select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
130from performance_schema.threads
131where PROCESSLIST_ID = connection_id();
132
133--echo # Switch to (con3, localhost, user3, , )
134connect (con3, localhost, user3, , );
135
136# Expecting INSTRUMENTED=NO, HISTORY=NO
137select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
138from performance_schema.threads
139where PROCESSLIST_ID = connection_id();
140
141--echo # Switch to (con4 localhost, user4, , )
142connect (con4, localhost, user4, , );
143
144# Expecting INSTRUMENTED=NO, HISTORY=YES
145select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
146from performance_schema.threads
147where PROCESSLIST_ID = connection_id();
148
149--echo # Disconnect all con
150--disconnect con1
151--disconnect con2
152--disconnect con3
153--disconnect con4
154
155--echo # Switch to connection default
156--connection default
157
158revoke all privileges, grant option from user1@localhost;
159revoke all privileges, grant option from user2@localhost;
160revoke all privileges, grant option from user3@localhost;
161revoke all privileges, grant option from user4@localhost;
162drop user user1@localhost;
163drop user user2@localhost;
164drop user user3@localhost;
165drop user user4@localhost;
166flush privileges;
167
168truncate table performance_schema.setup_actors;
169
170insert into performance_schema.setup_actors
171values ('%', '%', '%', 'YES', 'YES');
172
173select * from performance_schema.setup_actors;
174
175