Debian Codegraph @

mysql-test/suite/x/t/prep_stmt_sql.test

raw
1 ## Test of general functionality of prepare statement sql message
2
3 ## Preamble
4 --source include/xplugin_preamble.inc
5 --source include/xplugin_create_user.inc
6 ## Test starts here
7
8 --write_file $MYSQL_TMP_DIR/prep_stmt_sql.xpl
9 -->import assert_variable.macro
10 -->quiet
11
12
13 -->title =Stmt 1: Prepare malformed stmt
14
15 Mysqlx.Prepare.Prepare {
16 stmt_id: 1
17 stmt: {
18 type: STMT
19 stmt_execute: {
20 stmt: 'BLA BLA'
21 }
22 }
23 }
24 -->recverror ER_PARSE_ERROR
25
26 -->callmacro Assert_status_variable Mysqlx_prep_prepare 1
27
28 -->title =Stmt 1: Try to execute
29
30 Mysqlx.Prepare.Execute {
31 stmt_id: 1
32 }
33 -->expecterror ER_X_BAD_STATEMENT_ID
34 -->recvresult
35
36 -->callmacro Assert_status_variable Mysqlx_prep_execute 1
37
38 -->title =Stmt 1: Try to deallocate
39
40 Mysqlx.Prepare.Deallocate {
41 stmt_id: 1
42 }
43 -->recverror ER_X_BAD_STATEMENT_ID
44
45 -->callmacro Assert_status_variable Mysqlx_prep_deallocate 1
46
47
48
49 -->title =Stmt 2: Prepare correct stmt (no placeholders)
50
51 Mysqlx.Prepare.Prepare {
52 stmt_id: 2
53 stmt: {
54 type: STMT
55 stmt_execute: {
56 stmt: 'SELECT * FROM xtest.xtable'
57 }
58 }
59 }
60 -->recvok
61
62 -->callmacro Assert_status_variable Mysqlx_prep_prepare 2
63
64
65 -->title =Stmt 2: Execute (no params)
66
67 Mysqlx.Prepare.Execute {
68 stmt_id: 2
69 }
70 -->recvresult
71
72 -->callmacro Assert_status_variable Mysqlx_prep_execute 2
73
74
75 -->title =Stmt 2: Execute (one extra param to ignore)
76
77 Mysqlx.Prepare.Execute {
78 stmt_id: 2
79 args {
80 type: SCALAR scalar {
81 type: V_STRING v_string {
82 value: "Alice%"
83 }
84 }
85 }
86 }
87 -->recvresult
88
89 -->callmacro Assert_status_variable Mysqlx_prep_execute 3
90
91
92 -->title =Stmt 2: Deallocate
93
94 Mysqlx.Prepare.Deallocate {
95 stmt_id: 2
96 }
97 -->recvok
98
99 -->callmacro Assert_status_variable Mysqlx_prep_deallocate 2
100
101
102 -->title =Stmt 3: Prepare correct stmt (one placeholder)
103
104 Mysqlx.Prepare.Prepare {
105 stmt_id: 3
106 stmt: {
107 type: STMT
108 stmt_execute: {
109 stmt: 'SELECT * FROM xtest.xtable WHERE phrase LIKE ?'
110 }
111 }
112 }
113 -->recvok
114
115 -->callmacro Assert_status_variable Mysqlx_prep_prepare 3
116
117
118 -->title =Stmt 3: Try to execute (no params)
119
120 Mysqlx.Prepare.Execute {
121 stmt_id: 3
122 }
123 -->expecterror ER_X_PREPARED_EXECUTE_ARGUMENT_CONSISTENCY
124 -->recvresult
125
126 -->callmacro Assert_status_variable Mysqlx_prep_execute 4
127
128
129 -->title =Stmt 3: Execute with param
130
131 Mysqlx.Prepare.Execute {
132 stmt_id: 3
133 args {
134 type: SCALAR scalar {
135 type: V_STRING v_string {
136 value: "Alice%"
137 }
138 }
139 }
140 }
141 -->recvresult
142
143 -->callmacro Assert_status_variable Mysqlx_prep_execute 5
144
145
146 -->title =Stmt 3: Execute with params (one extra to ignore)
147
148 Mysqlx.Prepare.Execute {
149 stmt_id: 3
150 args {
151 type: SCALAR scalar {
152 type: V_STRING v_string {
153 value: "Bob%"
154 }
155 }
156 }
157 args {
158 type: SCALAR scalar {
159 type: V_STRING v_string {
160 value: "123"
161 }
162 }
163 }
164 }
165 -->recvresult
166
167 -->callmacro Assert_status_variable Mysqlx_prep_execute 6
168
169
170 -->title =Stmt 3: Deallocate
171
172 Mysqlx.Prepare.Deallocate {
173 stmt_id: 3
174 }
175 -->recvok
176
177 -->callmacro Assert_status_variable Mysqlx_prep_deallocate 3
178
179
180
181 -->title =Stmt 4: Prepare correct stmt (insert)
182
183 Mysqlx.Prepare.Prepare {
184 stmt_id: 4
185 stmt: {
186 type: STMT
187 stmt_execute: {
188 stmt: 'INSERT INTO xtest.xtable (phrase) VALUES(?)'
189 }
190 }
191 }
192 -->recvok
193
194 -->callmacro Assert_status_variable Mysqlx_prep_prepare 4
195
196
197 -->title =Stmt 4: Execute (one param)
198
199 Mysqlx.Prepare.Execute {
200 stmt_id: 4
201 args {
202 type: SCALAR scalar {
203 type: V_STRING v_string {
204 value: "Christina has a hamster"
205 }
206 }
207 }
208 }
209 -->recvresult
210
211 -->callmacro Assert_status_variable Mysqlx_prep_execute 7
212
213 -->stmtsql SELECT * FROM xtest.xtable
214 -->recvresult
215
216
217 -->title =Stmt 4: Deallocate
218
219 Mysqlx.Prepare.Deallocate {
220 stmt_id: 4
221 }
222 -->recvok
223
224 -->callmacro Assert_status_variable Mysqlx_prep_deallocate 4
225
226
227
228 -->title =Stmt 5: Prepare correct stmt (update)
229
230 Mysqlx.Prepare.Prepare {
231 stmt_id: 5
232 stmt: {
233 type: STMT
234 stmt_execute: {
235 stmt: 'UPDATE xtest.xtable SET phrase = ? ORDER BY phrase LIMIT 1'
236 }
237 }
238 }
239 -->recvok
240
241 -->callmacro Assert_status_variable Mysqlx_prep_prepare 5
242
243
244 -->title =Stmt 5: Execute (one param)
245
246 Mysqlx.Prepare.Execute {
247 stmt_id: 5
248 args {
249 type: SCALAR scalar {
250 type: V_STRING v_string {
251 value: "David has a parot"
252 }
253 }
254 }
255 }
256 -->recvresult
257
258 -->callmacro Assert_status_variable Mysqlx_prep_execute 8
259
260 -->stmtsql SELECT * FROM xtest.xtable
261 -->recvresult
262
263
264 -->title =Stmt 5: Deallocate
265
266 Mysqlx.Prepare.Deallocate {
267 stmt_id: 5
268 }
269 -->recvok
270
271 -->callmacro Assert_status_variable Mysqlx_prep_deallocate 5
272
273
274
275 #-----------------------------
276
277 -->title =Stmt 6: Prepare correct stmt (delete)
278
279 Mysqlx.Prepare.Prepare {
280 stmt_id: 6
281 stmt: {
282 type: STMT
283 stmt_execute: {
284 stmt: 'DELETE FROM xtest.xtable WHERE phrase LIKE ?'
285 }
286 }
287 }
288 -->recvok
289
290 -->callmacro Assert_status_variable Mysqlx_prep_prepare 6
291
292
293 -->title =Stmt 6: Execute (one param)
294
295 Mysqlx.Prepare.Execute {
296 stmt_id: 6
297 args {
298 type: SCALAR scalar {
299 type: V_STRING v_string {
300 value: "Bob%"
301 }
302 }
303 }
304 }
305 -->recvresult
306
307 -->callmacro Assert_status_variable Mysqlx_prep_execute 9
308
309 -->stmtsql SELECT * FROM xtest.xtable
310 -->recvresult
311
312
313 -->title =Stmt 5: Deallocate
314
315 Mysqlx.Prepare.Deallocate {
316 stmt_id: 6
317 }
318 -->recvok
319
320 -->callmacro Assert_status_variable Mysqlx_prep_deallocate 6
321 EOF
322
323
324 CREATE SCHEMA IF NOT EXISTS xtest;
325 USE xtest;
326 CREATE TABLE xtable (phrase VARCHAR(30));
327 INSERT INTO xtable (phrase) VALUES ('Alice has a cat');
328 INSERT INTO xtable (phrase) VALUES ('Bob has a dog');
329
330 exec $MYSQLXTEST
331 -ux_root --password=''
332 --file=$MYSQL_TMP_DIR/prep_stmt_sql.xpl 2>&1;
333
334
335
336 ## Cleanup
337 --source ../include/xplugin_cleanup.inc