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 # 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 # +------+------+------+---------+---------+
11 select * from performance_schema.setup_actors;
12
13 truncate table performance_schema.setup_actors;
14
15 insert into performance_schema.setup_actors
16 values ('localhost', 'user1', '%', 'YES', 'YES');
17
18 insert into performance_schema.setup_actors
19 values ('localhost', 'user2', '%', 'YES', 'NO');
20
21 insert into performance_schema.setup_actors
22 values ('localhost', 'user3', '%', 'NO', 'YES');
23
24 insert into performance_schema.setup_actors
25 values ('localhost', 'user4', '%', 'NO', 'NO');
26
27 create user user1@localhost;
28 create user user2@localhost;
29 create user user3@localhost;
30 create user user4@localhost;
31
32 grant ALL on *.* to user1@localhost;
33 grant ALL on *.* to user2@localhost;
34 grant ALL on *.* to user3@localhost;
35 grant ALL on *.* to user4@localhost;
36
37 flush privileges;
38
39 --echo # Switch to (con1, localhost, user1, , )
40 connect (con1, localhost, user1, , );
41
42 # Expecting INSTRUMENTED=YES, HISTORY=YES
43 select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
44 from performance_schema.threads
45 where PROCESSLIST_ID = connection_id();
46
47 --echo # Switch to (con2, localhost, user2, , )
48 connect (con2, localhost, user2, , );
49
50 # Expecting INSTRUMENTED=YES, HISTORY=NO
51 select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
52 from performance_schema.threads
53 where PROCESSLIST_ID = connection_id();
54
55 --echo # Switch to (con3, localhost, user3, , )
56 connect (con3, localhost, user3, , );
57
58 # Expecting INSTRUMENTED=NO, HISTORY=YES
59 select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
60 from performance_schema.threads
61 where PROCESSLIST_ID = connection_id();
62
63 --echo # Switch to (con4, localhost, user4, , )
64 connect (con4, localhost, user4, , );
65
66 # Expecting INSTRUMENTED=NO, HISTORY=NO
67 select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
68 from performance_schema.threads
69 where PROCESSLIST_ID = connection_id();
70
71 --echo # Switch to connection default
72 --connection default
73 update performance_schema.setup_actors
74 set HISTORY='NO' where USER in ('user1', 'user3');
75 update 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
82 select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
83 from performance_schema.threads
84 where PROCESSLIST_ID = connection_id();
85
86 --echo # Switch to connection con2
87 --connection con2
88
89 # Expecting INSTRUMENTED=YES, HISTORY=NO
90 select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
91 from performance_schema.threads
92 where PROCESSLIST_ID = connection_id();
93
94 --echo # Switch to connection con3
95 --connection con3
96
97 # Expecting INSTRUMENTED=NO, HISTORY=YES
98 select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
99 from performance_schema.threads
100 where PROCESSLIST_ID = connection_id();
101
102 --echo # Switch to connection con4
103 --connection con4
104
105 # Expecting INSTRUMENTED=NO, HISTORY=NO
106 select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
107 from performance_schema.threads
108 where 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, , )
118 connect (con1, localhost, user1, , );
119
120 # Expecting INSTRUMENTED=YES, HISTORY=NO
121 select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
122 from performance_schema.threads
123 where PROCESSLIST_ID = connection_id();
124
125 --echo # Switch to (con2 localhost, user2, , )
126 connect (con2, localhost, user2, , );
127
128 # Expecting INSTRUMENTED=YES, HISTORY=YES
129 select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
130 from performance_schema.threads
131 where PROCESSLIST_ID = connection_id();
132
133 --echo # Switch to (con3, localhost, user3, , )
134 connect (con3, localhost, user3, , );
135
136 # Expecting INSTRUMENTED=NO, HISTORY=NO
137 select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
138 from performance_schema.threads
139 where PROCESSLIST_ID = connection_id();
140
141 --echo # Switch to (con4 localhost, user4, , )
142 connect (con4, localhost, user4, , );
143
144 # Expecting INSTRUMENTED=NO, HISTORY=YES
145 select NAME, TYPE, INSTRUMENTED, HISTORY, PROCESSLIST_USER, PROCESSLIST_HOST
146 from performance_schema.threads
147 where 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
158 revoke all privileges, grant option from user1@localhost;
159 revoke all privileges, grant option from user2@localhost;
160 revoke all privileges, grant option from user3@localhost;
161 revoke all privileges, grant option from user4@localhost;
162 drop user user1@localhost;
163 drop user user2@localhost;
164 drop user user3@localhost;
165 drop user user4@localhost;
166 flush privileges;
167
168 truncate table performance_schema.setup_actors;
169
170 insert into performance_schema.setup_actors
171 values ('%', '%', '%', 'YES', 'YES');
172
173 select * from performance_schema.setup_actors;
174