Debian Codegraph @

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

raw
1 ## Inserting values described as a cast expression
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/crud_insert_cast.xpl
9 ## Test data
10 -->sql
11 DROP SCHEMA IF EXISTS xtest;
12 CREATE SCHEMA xtest;
13 CREATE TABLE xtest.my_int (value INTEGER);
14 -->endsql
15
16 Mysqlx.Crud.Insert {
17 collection { name: "my_int" schema: "xtest"}
18 data_model: TABLE
19 projection {name: "value"}
20 row {
21 field {
22 type: OPERATOR operator {
23 name: "cast"
24 param {
25 type : LITERAL
26 literal { type: V_SINT v_signed_int: 11 }
27 }
28 param {
29 type : LITERAL
30 literal { type: V_OCTETS v_octets {value:"UNSIGNED"} }
31 }
32 }
33 }
34 }
35 row {
36 field {
37 type: OPERATOR operator {
38 name: "cast"
39 param {
40 type : LITERAL
41 literal { type: V_SINT v_signed_int: -11 }
42 }
43 param {
44 type : LITERAL
45 literal { type: V_OCTETS v_octets {value:"SIGNED"} }
46 }
47 }
48 }
49 }
50 row {
51 field {
52 type: OPERATOR operator {
53 name: "cast"
54 param {
55 type : LITERAL
56 literal { type: V_SINT v_signed_int: 12 }
57 }
58 param {
59 type : LITERAL
60 literal { type: V_OCTETS v_octets {value:"UNSIGNED INTEGER"} }
61 }
62 }
63 }
64 }
65 row {
66 field {
67 type: OPERATOR operator {
68 name: "cast"
69 param {
70 type : LITERAL
71 literal { type: V_SINT v_signed_int: -12 }
72 }
73 param {
74 type : LITERAL
75 literal { type: V_OCTETS v_octets {value:"SIGNED INTEGER"} }
76 }
77 }
78 }
79 }
80 row {
81 field {
82 type: OPERATOR operator {
83 name: "cast"
84 param {
85 type : LITERAL
86 literal { type: V_OCTETS v_octets {value:"-123"} }
87 }
88 param {
89 type : LITERAL
90 literal { type: V_OCTETS v_octets {value:"SIGNED"} }
91 }
92 }
93 }
94 }
95 row {
96 field {
97 type: OPERATOR operator {
98 name: "cast"
99 param {
100 type : LITERAL
101 literal { type: V_OCTETS v_octets {value:"123"} }
102 }
103 param {
104 type : LITERAL
105 literal { type: V_OCTETS v_octets {value:"UNSIGNED"} }
106 }
107 }
108 }
109 }
110 }
111
112 #-- Mysqlx.Sql.StmtExecuteOk
113 -->recvresult
114
115 -->sql
116 SELECT * FROM xtest.my_int;
117 -->endsql
118
119 Mysqlx.Crud.Insert {
120 collection { name: "my_int" schema: "xtest"}
121 data_model: TABLE
122 projection {name: "value"}
123 row {
124 field {
125 type: OPERATOR operator {
126 name: "cast"
127 param {
128 type : LITERAL
129 literal { type: V_SINT v_signed_int: 13 }
130 }
131 param {
132 type : LITERAL
133 literal { type: V_OCTETS v_octets {value:"undefined"} }
134 }
135 }
136 }
137 }
138 }
139
140 -->expecterror 5154
141 -->recvresult
142
143 -->sql
144 CREATE TABLE xtest.my_datetime (value DATETIME);
145 -->endsql
146
147 Mysqlx.Crud.Insert {
148 collection { name: "my_datetime" schema: "xtest"}
149 data_model: TABLE
150 projection {name: "value"}
151 row {
152 field {
153 type: OPERATOR operator {
154 name: "cast"
155 param {
156 type : LITERAL
157 literal { type: V_OCTETS v_octets {value:"2011.11.11T3:14"} }
158 }
159 param {
160 type : LITERAL
161 literal { type: V_OCTETS v_octets {value:"DATETIME"} }
162 }
163 }
164 }
165 }
166 row {
167 field {
168 type: OPERATOR operator {
169 name: "cast"
170 param {
171 type : LITERAL
172 literal { type: V_OCTETS v_octets {value:"2012.12.12"} }
173 }
174 param {
175 type : LITERAL
176 literal { type: V_OCTETS v_octets {value:"DATE"} }
177 }
178 }
179 }
180 }
181 }
182 -->recvresult
183
184 -->sql
185 SELECT * FROM xtest.my_datetime;
186 CREATE TABLE xtest.my_time (value TIME);
187 -->endsql
188
189 Mysqlx.Crud.Insert {
190 collection { name: "my_time" schema: "xtest"}
191 data_model: TABLE
192 projection {name: "value"}
193 row {
194 field {
195 type: OPERATOR operator {
196 name: "cast"
197 param {
198 type : LITERAL
199 literal { type: V_OCTETS v_octets {value:"1024"} }
200 }
201 param {
202 type : LITERAL
203 literal { type: V_OCTETS v_octets {value:"TIME"} }
204 }
205 }
206 }
207 }
208 row {
209 field {
210 type: OPERATOR operator {
211 name: "cast"
212 param {
213 type : LITERAL
214 literal { type: V_SINT v_signed_int: 314 }
215 }
216 param {
217 type : LITERAL
218 literal { type: V_OCTETS v_octets {value:"TIME"} }
219 }
220 }
221 }
222 }
223 }
224
225 -->recvresult
226
227 -->sql
228 SELECT * FROM xtest.my_time;
229 CREATE TABLE xtest.my_json (value JSON);
230 -->endsql
231
232 Mysqlx.Crud.Insert {
233 collection { name: "my_json" schema: "xtest"}
234 data_model: TABLE
235 projection {name: "value"}
236 row {
237 field {
238 type: OPERATOR operator {
239 name: "cast"
240 param {
241 type : LITERAL
242 literal { type: V_OCTETS v_octets {value:"{\"pi\": 3.14}"} }
243 }
244 param {
245 type : LITERAL
246 literal { type: V_OCTETS v_octets {value:"JSON"} }
247 }
248 }
249 }
250 }
251 }
252
253 -->recvresult
254
255 -->sql
256 SELECT * FROM xtest.my_json;
257 CREATE TABLE xtest.my_float (value FLOAT);
258 -->endsql
259
260 Mysqlx.Crud.Insert {
261 collection { name: "my_float" schema: "xtest"}
262 data_model: TABLE
263 projection {name: "value"}
264 row {
265 field {
266 type: OPERATOR operator {
267 name: "cast"
268 param {
269 type : LITERAL
270 literal { type: V_FLOAT v_float: 3.14159 }
271 }
272 param {
273 type : LITERAL
274 literal { type: V_OCTETS v_octets {value:"DECIMAL"} }
275 }
276 }
277 }
278 }
279 row {
280 field {
281 type: OPERATOR operator {
282 name: "cast"
283 param {
284 type : LITERAL
285 literal { type: V_FLOAT v_float: 3.14159 }
286 }
287 param {
288 type : LITERAL
289 literal { type: V_OCTETS v_octets {value:"DECIMAL(4)"} }
290 }
291 }
292 }
293 }
294 row {
295 field {
296 type: OPERATOR operator {
297 name: "cast"
298 param {
299 type : LITERAL
300 literal { type: V_FLOAT v_float: 3.14159 }
301 }
302 param {
303 type : LITERAL
304 literal { type: V_OCTETS v_octets {value:"DECIMAL(4,2)"} }
305 }
306 }
307 }
308 }
309 row {
310 field {
311 type: OPERATOR operator {
312 name: "cast"
313 param {
314 type : LITERAL
315 literal { type: V_OCTETS v_octets {value:"3.14159"} }
316 }
317 param {
318 type : LITERAL
319 literal { type: V_OCTETS v_octets {value:"DECIMAL(4,2)"} }
320 }
321 }
322 }
323 }
324 }
325
326 -->recvresult
327
328 -->sql
329 SELECT * FROM xtest.my_float;
330 CREATE TABLE xtest.my_char (value VARCHAR(20));
331 -->endsql
332
333 Mysqlx.Crud.Insert {
334 collection { name: "my_char" schema: "xtest"}
335 data_model: TABLE
336 projection {name: "value"}
337 row {
338 field {
339 type: OPERATOR operator {
340 name: "cast"
341 param {
342 type : LITERAL
343 literal { type: V_OCTETS v_octets {value:"one"} }
344 }
345 param {
346 type : LITERAL
347 literal { type: V_OCTETS v_octets {value:"CHAR"} }
348 }
349 }
350 }
351 }
352 row {
353 field {
354 type: OPERATOR operator {
355 name: "cast"
356 param {
357 type : LITERAL
358 literal { type: V_OCTETS v_octets {value:"two"} }
359 }
360 param {
361 type : LITERAL
362 literal { type: V_OCTETS v_octets {value:"CHAR(4)"} }
363 }
364 }
365 }
366 }
367 row {
368 field {
369 type: OPERATOR operator {
370 name: "cast"
371 param {
372 type : LITERAL
373 literal { type: V_OCTETS v_octets {value:"three"} }
374 }
375 param {
376 type : LITERAL
377 literal { type: V_OCTETS v_octets {value:"BINARY"} }
378 }
379 }
380 }
381 }
382 row {
383 field {
384 type: OPERATOR operator {
385 name: "cast"
386 param {
387 type : LITERAL
388 literal { type: V_OCTETS v_octets {value:"four"} }
389 }
390 param {
391 type : LITERAL
392 literal { type: V_OCTETS v_octets {value:"BINARY(4)"} }
393 }
394 }
395 }
396 }
397 row {
398 field {
399 type: OPERATOR operator {
400 name: "cast"
401 param {
402 type : LITERAL
403 literal { type: V_SINT v_signed_int: -20 }
404 }
405 param {
406 type : LITERAL
407 literal { type: V_OCTETS v_octets {value:"CHAR"} }
408 }
409 }
410 }
411 }
412 row {
413 field {
414 type: OPERATOR operator {
415 name: "cast"
416 param {
417 type : LITERAL
418 literal { type: V_SINT v_signed_int: 40 }
419 }
420 param {
421 type : LITERAL
422 literal { type: V_OCTETS v_octets {value:"BINARY"} }
423 }
424 }
425 }
426 }
427 }
428
429 -->recvresult
430
431 -->sql
432 SELECT * FROM xtest.my_char;
433 -->endsql
434
435
436 ## Cleanup
437 -->sql
438 drop schema if exists xtest;
439 -->endsql
440 EOF
441
442 --exec $MYSQLXTEST -ux_root --password='' --file=$MYSQL_TMP_DIR/crud_insert_cast.xpl 2>&1
443
444 ## Cleanup
445 --source ../include/xplugin_cleanup.inc