Debian Codegraph @

mysql-test/suite/perfschema/t/setup_actors_history.test

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