Debian Codegraph @

mysql-test/suite/x/include/test_flow_resultset_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
20 stmtadmin create_collection {"schema":"xtest","name":"coll"};
21 recvresult;
22 callmacro Insert_doc coll '{"_id": "1", "name":"first", "prio":1}';
23 callmacro Insert_doc coll '{"_id": "2", "name":"second", "prio":2}';
24 callmacro Insert_doc coll '{"_id": "3", "name":"third", "prio":1}';
25 callmacro Insert_doc coll '{"_id": "5", "name":"fifth", "prio":4}';
26
27
28 ##
29 ## Execution of SQL through X Protocol can generate flow
30 ## described by following 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 ## Following suite is going to ensure that all CRUD
65 ## executions work according to this flow.
66 ##
67
68 ## Test case description:
69 -->echo
70 -->echo
71 -->echo ## I. Validate simple resultsets for CRUD messages
72 -->echo #
73 -->echo # 1. Assert resultset for CRUD-delete message
74 -->echo # 2. Assert resultset for CRUD-update message
75 -->echo # 3. Assert resultset for CRUD-create message (doc with id)
76 -->echo # 4. Assert resultset for CRUD-create message (doc without id)
77 -->echo # 5. Assert resultset for CRUD-read message
78 -->echo
79 -->echo ## II. Validate simple resultset with warnings
80 -->echo #
81 -->echo # 1. Assert one resultsets for select queries
82
83 -->echo
84 -->echo #
85 -->echo # I.1
86 Mysqlx.Crud.Delete {
87 collection {
88 name: "coll"
89 }
90 data_model: DOCUMENT
91 criteria {
92 type: OPERATOR
93 operator {
94 name: "=="
95 param {
96 type: IDENT
97 identifier {
98 document_path {
99 type: MEMBER
100 value: "name"
101 }
102 }
103 }
104 param {
105 type: LITERAL
106 literal {
107 type: V_OCTETS
108 v_octets {
109 value: "fifth"
110 }
111 }
112 }
113 }
114 }
115 }
116 -->callmacro Assert_notice_session_state ROWS_AFFECTED v_unsigned_int:1
117 -->callmacro Assert_message Mysqlx.Sql.StmtExecuteOk
118
119 -->echo
120 -->echo #
121 -->echo # I.2
122 Mysqlx.Crud.Update {
123 collection {
124 name: "coll"
125 }
126 data_model: DOCUMENT
127 operation {
128 source {
129 document_path {
130 type: MEMBER
131 value: "prio"
132 }
133 }
134 operation: ITEM_SET
135 value {
136 type: OPERATOR
137 operator {
138 name: "-"
139 param {
140 type: IDENT
141 identifier {
142 document_path {
143 type: MEMBER
144 value: "prio"
145 }
146 }
147 }
148 param {
149 type: LITERAL
150 literal {
151 type: V_SINT
152 v_signed_int: 1
153 }
154 }
155 }
156 }
157 }
158 }
159 -->callmacro Assert_notice_session_state PRODUCED_MESSAGE type: V_STRING
160 -->callmacro Assert_notice_session_state ROWS_AFFECTED v_unsigned_int:3
161 -->callmacro Assert_message Mysqlx.Sql.StmtExecuteOk
162
163 -->echo
164 -->echo #
165 -->echo # I.3
166 Mysqlx.Crud.Insert {
167 collection {
168 name: "coll"
169 schema: "xtest"
170 }
171 data_model: DOCUMENT
172 row {
173 field {
174 type: LITERAL
175 literal {
176 type: V_OCTETS
177 v_octets {
178 value: "{\"_id\": \"6\", \"name\":\"sixth\", \"prio\":3}"
179 content_type: 2
180 }
181 }
182 }
183 }
184 upsert: false
185 }
186 -->callmacro Assert_notice_session_state ROWS_AFFECTED v_unsigned_int:1
187 -->callmacro Assert_message Mysqlx.Sql.StmtExecuteOk
188
189 -->echo
190 -->echo #
191 -->echo # I.4
192 Mysqlx.Crud.Insert {
193 collection {
194 name: "coll"
195 schema: "xtest"
196 }
197 data_model: DOCUMENT
198 row {
199 field {
200 type: LITERAL
201 literal {
202 type: V_OCTETS
203 v_octets {
204 value: "{\"name\":\"sixth\", \"prio\":3}"
205 content_type: 2
206 }
207 }
208 }
209 }
210 upsert: false
211 }
212 -->callmacro Assert_notice_session_state ROWS_AFFECTED v_unsigned_int:1
213 -->callmacro Assert_notice_session_state GENERATED_DOCUMENT_IDS type: V_OCTETS
214 -->callmacro Assert_message Mysqlx.Sql.StmtExecuteOk
215
216 -->echo
217 -->echo #
218 -->echo # I.5
219 Mysqlx.Crud.Find {
220 collection {
221 name: "coll"
222 }
223 data_model: DOCUMENT
224 projection {
225 alias:"name"
226 source {
227 type: IDENT
228 identifier {
229 document_path {
230 type: MEMBER
231 value: "name"
232 }
233 }
234 }
235 }
236 }
237 -->callmacro Assert_metadata BYTES "doc"
238 -->callmacro Assert_rows 5
239 -->callmacro Assert_message Mysqlx.Resultset.FetchDone
240 -->callmacro Assert_message Mysqlx.Sql.StmtExecuteOk
241
242
243 -->echo
244 -->echo #
245 -->echo # II.1
246 Mysqlx.Crud.Find {
247 collection {
248 name: "coll"
249 }
250 data_model: DOCUMENT
251 projection {
252 alias:"name"
253 source {
254 type: OPERATOR
255 operator {
256 name: "/"
257 param {
258 type: LITERAL
259 literal {
260 type: V_SINT
261 v_signed_int: 1
262 }
263 }
264 param {
265 type: IDENT
266 identifier {
267 document_path {
268 type: MEMBER
269 value: "prio"
270 }
271 }
272 }
273 }
274 }
275 }
276 }
277 -->callmacro Assert_metadata BYTES "doc"
278 -->callmacro Assert_rows 5
279 -->callmacro Assert_message Mysqlx.Resultset.FetchDone
280 ## ER_DIVISION_BY_ZERO == 1365
281 -->callmacro Assert_notice_warning WARNING 1365
282 -->callmacro Assert_notice_warning WARNING 1365
283 -->callmacro Assert_message Mysqlx.Sql.StmtExecuteOk
284
285 EOF
286
287
288 CREATE SCHEMA IF NOT EXISTS xtest;
289 USE xtest;