Debian Codegraph @

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

raw
1
2 # Test requires: sp-protocol/ps-protocol/view-protocol/cursor-protocol disabled
3 --source include/no_protocol.inc
4
5 --echo
6 --echo # Connection 1
7 --echo
8 connect(con1, localhost, root,,);
9 --disable_query_log
10 let $con1_thread_id= `SELECT ps_current_thread_id()`;
11 let $con1_connection_id= `SELECT connection_id()`;
12 --enable_query_log
13
14 --connection default
15 CREATE TABLE test.t1(a int, b varchar(80));
16 INSERT INTO test.t1 VALUES (1, "a"), (2, "b"), (3, "c");
17 SELECT * FROM test.t1;
18
19 BEGIN;
20 SELECT * FROM test.t1 FOR UPDATE;
21
22 --echo
23 --echo # Regular query
24 --echo
25 --connection con1
26 SELECT "This is not secret" as normal_query;
27 --connection default
28
29 # Wait for con1 to complete cleanup after sending the OK packet.
30 let $wait_condition= select count(*) = 1
31 from performance_schema.threads
32 where
33 PROCESSLIST_INFO is NULL
34 AND THREAD_ID=$con1_thread_id;
35 --source include/wait_condition.inc
36
37 --source ../include/rewritten_queries.inc
38
39 --echo
40 --echo # Regular query (in flight)
41 --echo
42 --connection con1
43 --send INSERT INTO test.t1 VALUES (4, "This is not secret");
44 --connection default
45
46 # Wait for con1 to reach the INSERT code
47 let $wait_condition= select count(*) = 1
48 from performance_schema.metadata_locks
49 where
50 OBJECT_TYPE='TABLE' and
51 OBJECT_SCHEMA='test' and
52 OBJECT_NAME="t1" and
53 OWNER_THREAD_ID=$con1_thread_id;
54 --source include/wait_condition.inc
55
56 --source ../include/rewritten_queries.inc
57
58 COMMIT;
59 --connection con1
60 --reap
61 --connection default
62
63 # Wait for con1 to complete cleanup after sending the OK packet.
64 let $wait_condition= select count(*) = 1
65 from performance_schema.threads
66 where
67 PROCESSLIST_INFO is NULL
68 AND THREAD_ID=$con1_thread_id;
69 --source include/wait_condition.inc
70
71 --source ../include/rewritten_queries.inc
72
73 --echo
74 --echo # Sensitive query
75 --echo
76 --connection con1
77 CREATE USER alice IDENTIFIED BY 'thisisapassword';
78 --connection default
79
80 # Wait for con1 to complete cleanup after sending the OK packet.
81 let $wait_condition= select count(*) = 1
82 from performance_schema.threads
83 where
84 PROCESSLIST_INFO is NULL
85 AND THREAD_ID=$con1_thread_id;
86 --source include/wait_condition.inc
87
88 --source ../include/rewritten_queries.inc
89
90 --echo
91 --echo # Regular prepared statement (prepare)
92 --echo
93 --connection con1
94 PREPARE stmt FROM "SELECT 'This is not a secret either' as prepared_query";
95 --connection default
96
97 # Wait for con1 to complete cleanup after sending the OK packet.
98 let $wait_condition= select count(*) = 1
99 from performance_schema.threads
100 where
101 PROCESSLIST_INFO is NULL
102 AND THREAD_ID=$con1_thread_id;
103 --source include/wait_condition.inc
104
105 --source ../include/rewritten_queries.inc
106
107 --echo
108 --echo # Regular prepared statement (execute)
109 --echo
110 --connection con1
111 EXECUTE stmt;
112 --connection default
113
114 # Wait for con1 to complete cleanup after sending the OK packet.
115 let $wait_condition= select count(*) = 1
116 from performance_schema.threads
117 where
118 PROCESSLIST_INFO is NULL
119 AND THREAD_ID=$con1_thread_id;
120 --source include/wait_condition.inc
121
122 --source ../include/rewritten_queries.inc
123
124 --echo
125 --echo # Regular prepared statement (deallocate)
126 --echo
127 --connection con1
128 DEALLOCATE PREPARE stmt;
129 --connection default
130
131 # Wait for con1 to complete cleanup after sending the OK packet.
132 let $wait_condition= select count(*) = 1
133 from performance_schema.threads
134 where
135 PROCESSLIST_INFO is NULL
136 AND THREAD_ID=$con1_thread_id;
137 --source include/wait_condition.inc
138
139 --source ../include/rewritten_queries.inc
140
141 BEGIN;
142 SELECT * FROM test.t1 FOR UPDATE;
143
144 --echo
145 --echo # Regular prepared statement (prepare)
146 --echo
147 --connection con1
148 PREPARE stmt FROM "INSERT INTO test.t1 VALUES (5, 'This is not secret either')";
149 --connection default
150
151 # Wait for con1 to complete cleanup after sending the OK packet.
152 let $wait_condition= select count(*) = 1
153 from performance_schema.threads
154 where
155 PROCESSLIST_INFO is NULL
156 AND THREAD_ID=$con1_thread_id;
157 --source include/wait_condition.inc
158
159 --source ../include/rewritten_queries.inc
160
161 --echo
162 --echo # Regular prepared statement (execute, in flight)
163 --echo
164 --connection con1
165 --send EXECUTE stmt;
166 --connection default
167
168 # Wait for con1 to reach the EXECUTE code
169 let $wait_condition= select count(*) = 1
170 from performance_schema.metadata_locks
171 where
172 OBJECT_TYPE='TABLE' and
173 OBJECT_SCHEMA='test' and
174 OBJECT_NAME="t1" and
175 OWNER_THREAD_ID=$con1_thread_id;
176 --source include/wait_condition.inc
177
178 --source ../include/rewritten_queries.inc
179
180 COMMIT;
181 --connection con1
182 --reap
183 --connection default
184
185 # Wait for con1 to complete cleanup after sending the OK packet.
186 let $wait_condition= select count(*) = 1
187 from performance_schema.threads
188 where
189 PROCESSLIST_INFO is NULL
190 AND THREAD_ID=$con1_thread_id;
191 --source include/wait_condition.inc
192
193 --source ../include/rewritten_queries.inc
194
195 --echo
196 --echo # Regular prepared statement (deallocate)
197 --echo
198 --connection con1
199 DEALLOCATE PREPARE stmt;
200 --connection default
201
202 # Wait for con1 to complete cleanup after sending the OK packet.
203 let $wait_condition= select count(*) = 1
204 from performance_schema.threads
205 where
206 PROCESSLIST_INFO is NULL
207 AND THREAD_ID=$con1_thread_id;
208 --source include/wait_condition.inc
209
210 --source ../include/rewritten_queries.inc
211
212 --echo
213 --echo # Sensitive prepared statement (prepare)
214 --echo
215 --connection con1
216 PREPARE stmt FROM "CREATE USER bob IDENTIFIED BY 'thisisapassword'";
217 --connection default
218
219 # Wait for con1 to complete cleanup after sending the OK packet.
220 let $wait_condition= select count(*) = 1
221 from performance_schema.threads
222 where
223 PROCESSLIST_INFO is NULL
224 AND THREAD_ID=$con1_thread_id;
225 --source include/wait_condition.inc
226
227 --source ../include/rewritten_queries.inc
228
229 --echo
230 --echo # Sensitive prepared statement (execute)
231 --echo
232 --connection con1
233 EXECUTE stmt;
234 --connection default
235
236 # Wait for con1 to complete cleanup after sending the OK packet.
237 let $wait_condition= select count(*) = 1
238 from performance_schema.threads
239 where
240 PROCESSLIST_INFO is NULL
241 AND THREAD_ID=$con1_thread_id;
242 --source include/wait_condition.inc
243
244 --source ../include/rewritten_queries.inc
245
246 --echo
247 --echo # Sensitive prepared statement (deallocate)
248 --echo
249 --connection con1
250 DEALLOCATE PREPARE stmt;
251 --connection default
252
253 # Wait for con1 to complete cleanup after sending the OK packet.
254 let $wait_condition= select count(*) = 1
255 from performance_schema.threads
256 where
257 PROCESSLIST_INFO is NULL
258 AND THREAD_ID=$con1_thread_id;
259 --source include/wait_condition.inc
260
261 --source ../include/rewritten_queries.inc
262
263 --connection default
264 --disconnect con1
265
266 DROP USER alice;
267 DROP USER bob;
268 DROP TABLE test.t1;