Debian Codegraph @

mysql-test/suite/x/include/test_flow_resultset_prepexecute_crud_document.inc

raw
1
2 --write_file $MYSQL_TMP_DIR/resultset.xpl
3 -->import assert_messages.macro
4 -->import assert_notices.macro
5 -->import crud_insert.macro
6
7 -->echo
8 -->echo
9 -->echo ## Test setup
10
11 -->macro Insert_doc %COLL% %DOC%
12 callmacro Insert_one
13 DOCUMENT %COLL%
14 type: LITERAL literal{type: V_OCTETS v_octets{value:%DOC% content_type:2}}
15 ER_SUCCESS;
16 -->endmacro
17
18 DROP TABLE IF EXISTS xtest.coll;
19 stmtadmin create_collection {"schema":"xtest","name":"coll"};
20 recvresult;
21 callmacro Insert_doc coll '{"_id": "1", "name":"first", "prio":1}';
22 callmacro Insert_doc coll '{"_id": "2", "name":"second", "prio":2}';
23 callmacro Insert_doc coll '{"_id": "3", "name":"third", "prio":1}';
24 callmacro Insert_doc coll '{"_id": "5", "name":"fifth", "prio":4}';
25
26
27 ##
28 ## Purpose of this test is:
29 #
30 # * validating that resultsets are in align to the UML flow:
31 #
32 # ...
33 # loop has more resultsets or not at end of fetch
34 # group resultset
35 # loop has more columns
36 # server --> client: ColumnMetaData
37 # end
38 # loop has more rows
39 # server --> client: Row
40 # end
41 # end
42 # alt has more resultsets
43 # server --> client: FetchDoneMoreResultsets
44 # end
45 # end
46 # loop has more OUT-paramsets or not at end of fetch
47 # server --> client: FetchDoneMoreOutParams
48 # group resultset
49 # loop has more columns
50 # server --> client: ColumnMetaData
51 # end
52 # loop has more rows
53 # server --> client: Row
54 # end
55 # end
56 # end
57 # alt at end of all resultsets
58 # server --> client: FetchDone
59 # else cursor is opened
60 # server --> client: FetchSuspended
61 # end
62 # ...
63 #
64 # * expecting following notices for CRUD operations on collection:
65 #
66 # |Notice\Stmt |Select |Insert |Update |Delete |
67 # |-----------------------|-------|-------|-------|-------|
68 # |ROWS_AFFECTED |X(0) |X |X |X |
69 # |PRODUCED_MESSAGE | | |X | |
70 # |GENERATED_INSERT_ID | | | | |
71 # |GENERATED_DOCUMENT_IDS | |X | | |
72 #
73 -->echo
74 -->echo
75 -->echo ## I. Validate simple resultsets for CRUD messages
76 -->echo #
77 -->echo # 1. Assert resultset for CRUD-delete message
78 -->echo # 2. Assert resultset for CRUD-update message
79 -->echo # 3. Assert resultset for CRUD-create message (doc with id)
80 -->echo # 4. Assert resultset for CRUD-create message (doc without id)
81 -->echo # 5. Assert resultset for CRUD-read message
82 -->echo
83 -->echo ## II. Validate simple resultset with warnings
84 -->echo #
85 -->echo # 1. Assert one resultsets for select queries
86
87
88 -->echo
89 -->echo #
90 -->echo # I.1
91 Mysqlx.Prepare.Prepare {
92 stmt_id: 1
93 stmt: {
94 type: DELETE
95 delete {
96 collection {
97 name: "coll"
98 }
99 data_model: DOCUMENT
100 criteria {
101 type: OPERATOR
102 operator {
103 name: "=="
104 param {
105 type: IDENT
106 identifier {
107 document_path {
108 type: MEMBER
109 value: "name"
110 }
111 }
112 }
113 param {
114 type: LITERAL
115 literal {
116 type: V_OCTETS
117 v_octets {
118 value: "fifth"
119 }
120 }
121 }
122 }
123 }
124 }
125 }
126 }
127 recvok;
128 Mysqlx.Prepare.Execute {
129 stmt_id: 1
130 }
131 callmacro Assert_notice_session_state ROWS_AFFECTED v_unsigned_int:1;
132 callmacro Assert_message Mysqlx.Sql.StmtExecuteOk;
133
134
135 -->echo
136 -->echo #
137 -->echo # I.2
138 Mysqlx.Prepare.Prepare {
139 stmt_id: 2
140 stmt: {
141 type: UPDATE
142 update {
143 collection {
144 name: "coll"
145 }
146 data_model: DOCUMENT
147 operation {
148 source {
149 document_path {
150 type: MEMBER
151 value: "prio"
152 }
153 }
154 operation: ITEM_SET
155 value {
156 type: OPERATOR
157 operator {
158 name: "-"
159 param {
160 type: IDENT
161 identifier {
162 document_path {
163 type: MEMBER
164 value: "prio"
165 }
166 }
167 }
168 param {
169 type: LITERAL
170 literal {
171 type: V_SINT
172 v_signed_int: 1
173 }
174 }
175 }
176 }
177 }
178 }
179 }
180 }
181 recvok;
182 Mysqlx.Prepare.Execute {
183 stmt_id: 2
184 }
185 callmacro Assert_notice_session_state PRODUCED_MESSAGE type: V_STRING;
186 callmacro Assert_notice_session_state ROWS_AFFECTED v_unsigned_int:3;
187 callmacro Assert_message Mysqlx.Sql.StmtExecuteOk;
188
189
190 -->echo
191 -->echo #
192 -->echo # I.3
193 Mysqlx.Prepare.Prepare {
194 stmt_id: 3
195 stmt: {
196 type: INSERT
197 insert {
198 collection {
199 name: "coll"
200 schema: "xtest"
201 }
202 data_model: DOCUMENT
203 row {
204 field {
205 type: LITERAL
206 literal {
207 type: V_OCTETS
208 v_octets {
209 value: "{\"_id\": \"6\", \"name\":\"sixth\", \"prio\":3}"
210 content_type: 2
211 }
212 }
213 }
214 }
215 upsert: false
216 }
217 }
218 }
219 recvok;
220 Mysqlx.Prepare.Execute {
221 stmt_id: 3
222 }
223 callmacro Assert_notice_session_state ROWS_AFFECTED v_unsigned_int:1;
224 callmacro Assert_message Mysqlx.Sql.StmtExecuteOk;
225
226
227 -->echo
228 -->echo #
229 -->echo # I.4
230 Mysqlx.Prepare.Prepare {
231 stmt_id: 4
232 stmt: {
233 type: INSERT
234 insert {
235 collection {
236 name: "coll"
237 schema: "xtest"
238 }
239 data_model: DOCUMENT
240 row {
241 field {
242 type: LITERAL
243 literal {
244 type: V_OCTETS
245 v_octets {
246 value: "{\"name\":\"sixth\", \"prio\":3}"
247 content_type: 2
248 }
249 }
250 }
251 }
252 upsert: false
253 }
254 }
255 }
256 recvok;
257 Mysqlx.Prepare.Execute {
258 stmt_id: 4
259 }
260 callmacro Assert_notice_session_state ROWS_AFFECTED v_unsigned_int:1;
261 callmacro Assert_notice_session_state GENERATED_DOCUMENT_IDS type: V_OCTETS;
262 callmacro Assert_message Mysqlx.Sql.StmtExecuteOk;
263
264
265 -->echo
266 -->echo #
267 -->echo # I.5
268 Mysqlx.Prepare.Prepare {
269 stmt_id: 5
270 stmt: {
271 type: FIND
272 find {
273 collection {
274 name: "coll"
275 }
276 data_model: DOCUMENT
277 projection {
278 alias:"name"
279 source {
280 type: IDENT
281 identifier {
282 document_path {
283 type: MEMBER
284 value: "name"
285 }
286 }
287 }
288 }
289 }
290 }
291 }
292 recvok;
293 Mysqlx.Prepare.Execute {
294 stmt_id: 5
295 }
296 callmacro Assert_metadata BYTES "doc";
297 callmacro Assert_rows 5;
298 callmacro Assert_message Mysqlx.Resultset.FetchDone;
299 callmacro Assert_message Mysqlx.Sql.StmtExecuteOk;
300
301
302 -->echo
303 -->echo #
304 -->echo # II.1
305 Mysqlx.Prepare.Prepare {
306 stmt_id: 6
307 stmt: {
308 type: FIND
309 find {
310 collection {
311 name: "coll"
312 }
313 data_model: DOCUMENT
314 projection {
315 alias:"name"
316 source {
317 type: OPERATOR
318 operator {
319 name: "/"
320 param {
321 type: LITERAL
322 literal {
323 type: V_SINT
324 v_signed_int: 1
325 }
326 }
327 param {
328 type: IDENT
329 identifier {
330 document_path {
331 type: MEMBER
332 value: "prio"
333 }
334 }
335 }
336 }
337 }
338 }
339 }
340 }
341 }
342 recvok;
343 Mysqlx.Prepare.Execute {
344 stmt_id: 6
345 }
346 callmacro Assert_metadata BYTES "doc";
347 callmacro Assert_rows 5;
348 callmacro Assert_message Mysqlx.Resultset.FetchDone;
349 ## ER_DIVISION_BY_ZERO == 1365
350 callmacro Assert_notice_warning WARNING 1365;
351 callmacro Assert_notice_warning WARNING 1365;
352 callmacro Assert_message Mysqlx.Sql.StmtExecuteOk;
353
354 EOF
355
356
357 CREATE SCHEMA IF NOT EXISTS xtest;
358 USE xtest;