Debian Codegraph @

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

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