Debian Codegraph @

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

raw
1 ########### ../t/crud_myisam_memory.test #########
2 ## #
3 ## This test aims to run crud message on myisam/memory engine. #
4 ## Test runs following message on #
5 ## - create_collection message #
6 ## - Insert message #
7 ## - create_collection_index #
8 ## - update message #
9 ## - delete message #
10 #######################################################################
11
12 --source include/xplugin_preamble.inc
13 --source include/have_myisam.inc
14 --source include/xplugin_create_user.inc
15
16 SET @start_global_value = @@global.default_storage_engine;
17 SELECT @start_global_value;
18 SET @@global.default_storage_engine = myisam;
19
20 ## Test starts here
21 --write_file $MYSQL_TMP_DIR/mysqlx-in.xpl
22 -->sql
23 #-- "Creating database for testcase"
24 DROP DATABASE IF EXISTS xplugintest;
25 CREATE DATABASE xplugintest;
26 USE xplugintest;
27
28 CREATE TABLE `table1` (
29 `doc` VARCHAR(100) DEFAULT NULL,
30 `_id` INT AUTO_INCREMENT PRIMARY KEY
31 ) ENGINE=memory;
32
33 -->endsql
34
35 #-- "Create table table2 in xplugintest "
36 -->stmtadmin create_collection {"schema":"xplugintest","name":"table2"}
37 -->recvresult
38
39 -->echo Insert multiple rows into a Document column : myisam table
40 Mysqlx.Crud.Insert {
41 collection {
42 name: "table2"
43 schema: "xplugintest"
44 }
45 data_model: DOCUMENT
46 row {
47 field {
48 type: LITERAL
49 literal {
50 type: V_STRING
51 v_string {
52 value: "\n{\n \"_id\": \"1\",\n \"name\": \"Omar Bras\", \"id\": \"1\"\n}"
53 }
54 }
55 }}
56 row {
57 field {
58 type: LITERAL
59 literal {
60 type: V_STRING
61 v_string {
62 value: "\n{\n \"_id\": \"2\",\n \"name\": \"Omar Mex\", \"id\": \"2\"\n}"
63 }
64 }}
65 }
66 }
67 -->recvresult
68
69 -->echo Insert into memory table
70 Mysqlx.Crud.Insert {
71 collection {
72 name: "table1"
73 schema: "xplugintest"
74 }
75 data_model: TABLE
76 projection {
77 name: "_id"
78 }
79 projection {
80 name: "doc"
81 }
82
83 row {
84 field {
85 type: LITERAL
86 literal {
87 type: V_SINT
88 v_signed_int: 10
89 }
90 }
91 field {
92 type: LITERAL
93 literal {
94 type: V_STRING
95 v_string {
96 value: "Omar Bras"
97 }
98 }
99 }}
100 row {
101 field {
102 type: LITERAL
103 literal {
104 type: V_SINT
105 v_signed_int: 11
106 }
107 }
108 field {
109 type: LITERAL
110 literal {
111 type: V_STRING
112 v_string {
113 value: "Omar Mex"
114 }
115 }}
116 }
117
118 }
119 -->recvresult
120 -->sql
121 SELECT * FROM xplugintest.table2;
122 SELECT * FROM xplugintest.table1;
123 -->endsql
124
125
126 -->echo "Index with unique(true), index column NOT NULL (true)":myisam table
127 -->stmtadmin create_collection_index {"schema":"xplugintest", "collection":"table2", "name":"name_index", "unique":true, "fields":{"field":"$.name", "type":"TEXT(50)","required":true}}
128 -->recvresult
129 -->sql
130 SHOW CREATE TABLE xplugintest.table2;
131 SHOW CREATE TABLE xplugintest.table1;
132 SELECT * FROM xplugintest.table2;
133 SELECT * FROM xplugintest.table1;
134 -->endsql
135
136 -->echo Update - myisam table
137 Mysqlx.Crud.Update {
138 collection {
139 name: "table2"
140 schema: "xplugintest"
141 }
142 data_model: DOCUMENT
143 criteria {
144 type: OPERATOR
145 operator {
146 name: "=="
147 param {
148 type: IDENT
149 identifier {
150 name: "_id"
151 }
152 }
153 param {
154 type: LITERAL
155 literal {
156 type: V_SINT
157 v_signed_int: 2
158 }
159 }
160 }
161 }
162 operation {
163 source {
164 document_path {
165 type: MEMBER
166 value: "name"
167 }
168 }
169 operation: ITEM_SET
170 value {
171 type: LITERAL
172 literal {
173 type: V_STRING
174 v_string {
175 value: "\"Omar Argentina\""
176 }
177 }
178 }
179 }
180
181
182 }
183 -->recvresult
184 -->echo Update value - memory table
185 Mysqlx.Crud.Update {
186 collection {
187 name: "table1"
188 schema: "xplugintest"
189 }
190 data_model: TABLE
191 criteria {
192 type: OPERATOR
193 operator {
194 name: "=="
195 param {
196 type: IDENT
197 identifier {
198 name: "_id"
199 }
200 }
201 param {
202 type: LITERAL
203 literal {
204 type: V_SINT
205 v_signed_int: 10
206 }
207 }
208 }
209 }
210 operation {
211 source {
212 name: "doc"
213 }
214 operation: SET
215 value {
216 type: LITERAL
217 literal {
218 type: V_STRING
219 v_string {
220 value: "Omar Argentina"
221 }
222 }
223 }
224 }
225
226
227 }
228 -->recvresult
229
230
231 -->sql
232 SHOW CREATE TABLE xplugintest.table2;
233 SHOW CREATE TABLE xplugintest.table1;
234 SELECT JSON_EXTRACT(doc,'$.name') FROM xplugintest.table2;
235 SELECT * FROM xplugintest.table2;
236 SELECT * FROM xplugintest.table1;
237 -->endsql
238
239 -->echo Delete with == operator : myisam table
240 Mysqlx.Crud.Delete {
241 collection {
242 name: "table2"
243 schema: "xplugintest"
244 }
245 data_model: DOCUMENT
246 criteria {
247 type: OPERATOR
248 operator {
249 name: "=="
250 param {
251 type: IDENT identifier { name: "_id" }
252 }
253 param {
254 type: LITERAL
255 literal {
256 type: V_SINT
257 v_signed_int: 2
258 }
259 }
260 }
261 }
262 }
263 #-- Mysqlx.Sql.StmtExecuteOk
264 -->recvresult
265
266 -->echo Delete with == operator : memory table
267 Mysqlx.Crud.Delete {
268 collection {
269 name: "table1"
270 schema: "xplugintest"
271 }
272 data_model: TABLE
273 criteria {
274 type: OPERATOR
275 operator {
276 name: "=="
277 param {
278 type: IDENT
279 identifier {
280 name: "_id"
281 }
282 }
283 param {
284 type: LITERAL
285 literal {
286 type: V_SINT
287 v_signed_int: 11
288 }
289 }
290 }
291 }
292 }
293 #-- Mysqlx.Sql.StmtExecuteOk
294 -->recvresult
295
296 -->sql
297 SELECT JSON_EXTRACT(doc,'$.name') FROM xplugintest.table2;
298 SELECT * FROM xplugintest.table2;
299 SELECT * FROM xplugintest.table1;
300 -->endsql
301
302 -->echo insert : myisam table
303 Mysqlx.Crud.Insert {
304 collection {
305 name: "table2"
306 schema: "xplugintest"
307 }
308 data_model: DOCUMENT
309 row {
310 field {
311 type: LITERAL
312 literal {
313 type: V_STRING
314 v_string {
315 value: "\n{\n \"_id\": \"3\",\n \"name\": \"Omar Peru\", \"id\": \"3\"\n}"
316 }
317 }
318 }}
319 }
320 -->recvresult
321
322
323 -->echo insert : memory table
324 Mysqlx.Crud.Insert {
325 collection {
326 name: "table1"
327 schema: "xplugintest"
328 }
329 projection {
330 name: "_id"
331 }
332 projection {
333 name: "doc"
334 }
335 data_model: TABLE
336 row {
337 field {
338 type: LITERAL
339 literal {
340 type: V_SINT
341 v_signed_int: 12
342 }
343 }
344 field {
345 type: LITERAL
346 literal {
347 type: V_STRING
348 v_string {
349 value: "Omar Peru"
350 }
351 }
352 }
353 }
354 }
355 -->recvresult
356
357 -->echo # Insert fail due to non unique _id doc member: myisam table
358 Mysqlx.Crud.Insert {
359 collection {
360 name: "table2"
361 schema: "xplugintest"
362 }
363 data_model: DOCUMENT
364 row {
365 field {
366 type: LITERAL
367 literal {
368 type: V_STRING
369 v_string {
370 value: "\n{\n \"_id\": \"1\",\n \"name\": \"Omar Colombia\", \"id\": \"3\"\n}"
371 }
372 }
373 }}
374 }
375 -->expecterror 5116
376 -->recvresult
377
378
379
380 -->echo # Insert fail due to non unique _id doc member: memory table
381 Mysqlx.Crud.Insert {
382 collection {
383 name: "table1"
384 schema: "xplugintest"
385 }
386 projection {
387 name: "_id"
388 }
389 projection {
390 name: "doc"
391 }
392 data_model: TABLE
393 row {
394 field {
395 type: LITERAL
396 literal {
397 type: V_SINT
398 v_signed_int: 10
399 }
400 }
401 field {
402 type: LITERAL
403 literal {
404 type: V_STRING
405 v_string {
406 value: "Omar Colombia"
407 }
408 }
409 }}
410 }
411 -->expecterror 1062
412 -->recvresult
413
414 -->sql
415 SELECT * FROM xplugintest.table2;
416 SELECT * FROM xplugintest.table1;
417 -->endsql
418
419 EOF
420
421 --exec $MYSQLXTEST -u x_root --password='' --file=$MYSQL_TMP_DIR/mysqlx-in.xpl 2>&1
422
423 ## Cleanup
424 DROP DATABASE IF EXISTS xplugintest;
425 SET @@global.default_storage_engine = @start_global_value;
426 SELECT @@global.default_storage_engine;
427 --source ../include/xplugin_cleanup.inc