Debian Codegraph @

mysql-test/suite/x/t/macros/test_prep_stmt_crud_limit.macro

raw
1 ## Following macros are defined in this file:
2 #
3 # * Setup_testcase
4 # * Setup_collection_with_data
5 # * Find_execute_and_expect_error
6 # * Update_execute_and_expect_error
7 # * Delete_execute_and_expect_error
8 # * Find_execute_and_expect
9 # * Update_execute_and_expect
10 # * Delete_execute_and_expect
11 #
12
13 -->macro Setup_testcase
14 varlet %PREP_ID% 0;
15 varlet %ANY_START% type:SCALAR scalar {;
16 varlet %ANY_END% };
17 -->endmacro
18
19
20 -->macro Setup_collection_with_data
21 echo;
22 echo [Setup table coll];
23 quiet;
24 noquery_result;
25 DROP TABLE IF EXISTS coll;
26 stmtadmin ensure_collection {"name":"coll"};
27 recvresult be-quiet;
28
29 callmacro Crud_insert Collection1 'coll' Row_octet '{"myid":0, "group3": "test", "group2": 5}';
30 recvresult be-quiet;
31
32 callmacro Crud_insert Collection1 'coll' Row_octet '{"myid":1, "group3": "test", "group2": 5}';
33 recvresult be-quiet;
34
35 callmacro Crud_insert Collection1 'coll' Row_octet '{"myid":2, "group3": "test", "group2": 4}';
36 recvresult be-quiet;
37
38 callmacro Crud_insert Collection1 'coll' Row_octet '{"myid":3, "group3": "dev", "group2": 4}';
39 recvresult be-quiet;
40
41 callmacro Crud_insert Collection1 'coll' Row_octet '{"myid":4, "group3": "dev", "group2": 3}';
42 recvresult be-quiet;
43
44 callmacro Crud_insert Collection1 'coll' Row_octet '{"myid":5, "group3": "dev", "group2": 3}';
45 recvresult be-quiet;
46
47 callmacro Crud_insert Collection1 'coll' Row_octet '{"myid":6, "group3": "prod", "group2": 2}';
48 recvresult be-quiet;
49
50 callmacro Crud_insert Collection1 'coll' Row_octet '{"myid":7, "group3": "prod", "group2": 2}';
51 recvresult be-quiet;
52
53 callmacro Crud_insert Collection1 'coll' Row_octet '{"myid":8, "group3": "prod", "group2": 1}';
54 recvresult be-quiet;
55
56 noquiet;
57 query_result;
58 -->endmacro
59
60
61 -->macro_varg Find_execute_and_expect_error %ERROR% %OPTIONS%
62 echo [Assert Find operation returns an error, executed with %OPTIONS%];
63 quiet;
64 varinc %PREP_ID% 1;
65 Mysqlx.Prepare.Prepare {
66 stmt_id:%PREP_ID%
67 stmt {
68 type: FIND
69 find {
70 collection { name: "coll" }
71 data_model: DOCUMENT
72 %OPTIONS%
73 }
74 }
75 }
76 expecterror %ERROR%;
77 recvresult be-quiet;
78 noquiet;
79 -->endmacro
80
81
82 -->macro_varg Delete_execute_and_expect_error %ERROR% %OPTIONS%
83 echo [Assert Delete operation returns an error, executed with %OPTIONS%];
84 quiet;
85 varinc %PREP_ID% 1;
86 Mysqlx.Prepare.Prepare {
87 stmt_id:%PREP_ID%
88 stmt {
89 type: DELETE
90 delete {
91 collection { name: "coll" }
92 data_model: DOCUMENT
93 %OPTIONS%
94 }
95 }
96 }
97 expecterror %ERROR%;
98 recvresult be-quiet;
99 noquiet;
100 -->endmacro
101
102
103 -->macro_varg Update_execute_and_expect_error %ERROR% %OPTIONS%
104 quiet;
105 echo [Assert Update operation returns an error, executed with %OPTIONS%];
106 varinc %PREP_ID% 1;
107 Mysqlx.Prepare.Prepare {
108 stmt_id:%PREP_ID%
109 stmt {
110 type: UPDATE
111 update {
112 collection { name: "coll" }
113 data_model: DOCUMENT
114 operation {
115 operation: ITEM_SET
116 source{
117 document_path {
118 type: MEMBER
119 value: "group2"
120 }
121 }
122 value {
123 type: OPERATOR
124 operator {
125 name: "sign_minus"
126 param {
127 type: IDENT
128 identifier {
129 document_path{
130 type: MEMBER
131 value: "group2"
132 }
133 }
134 }
135 }
136 }
137 }
138 %OPTIONS%
139 }
140 }
141 }
142 expecterror %ERROR%;
143 recvresult be-quiet;
144 quiet;
145 -->endmacro
146
147
148 -->macro_varg Find_execute_and_expect %EXPECT_ROWS% %OPTIONS%
149 echo [Assert Find operation and expect %EXPECT_ROWS% rows returned, executed with %OPTIONS%];
150 noquery_result;
151 clear_received;
152 quiet;
153 varinc %PREP_ID% 1;
154 Mysqlx.Prepare.Prepare {
155 stmt_id: %PREP_ID%
156 stmt {
157 type: FIND
158 find {
159 collection { name: "coll" }
160 data_model: DOCUMENT
161 %OPTIONS%
162 }
163 }
164 }
165 recvtype Mysqlx.Ok;
166
167 Mysqlx.Prepare.Execute {
168 stmt_id: %PREP_ID%
169 %VAR_ARGS%
170 }
171 recvresult be-quiet;
172 received Mysqlx.Resultset.Row %RESULTSET_ROWS%;
173 assert_eq %EXPECT_ROWS% %RESULTSET_ROWS%;
174 noquiet;
175 query_result;
176 -->endmacro
177
178
179 -->macro_varg Delete_execute_and_expect %EXPECT_ROWS% %OPTIONS%
180 echo [Assert Delete operation and expect deletion of %EXPECT_ROWS% rows, executed with %OPTIONS%];
181 quiet;
182 noquery_result;
183 clear_received;
184 varinc %PREP_ID% 1;
185 Mysqlx.Prepare.Prepare {
186 stmt_id: %PREP_ID%
187 stmt {
188 type: DELETE
189 delete {
190 collection { name: "coll" }
191 data_model: DOCUMENT
192 %OPTIONS%
193 }
194 }
195 }
196 recvtype Mysqlx.Ok;
197
198 Mysqlx.Prepare.Execute {
199 stmt_id: %PREP_ID%
200 %VAR_ARGS%
201 }
202 recvresult be-quiet;
203 assert_eq %EXPECT_ROWS% %RESULT_ROWS_AFFECTED%;
204 noquiet;
205 query_result;
206 -->endmacro
207
208
209 -->macro_varg Update_execute_and_expect %EXPECT_ROWS% %OPTIONS%
210 quiet;
211 noquery_result;
212 echo [Assert Update operation and expect rows modified %EXPECT_ROWS%, executed with %OPTIONS%];
213 clear_received;
214 varinc %PREP_ID% 1;
215 Mysqlx.Prepare.Prepare {
216 stmt_id: %PREP_ID%
217 stmt {
218 type: UPDATE
219 update {
220 collection { name: "coll" }
221 data_model: DOCUMENT
222 operation {
223 operation: ITEM_SET
224 source{
225 document_path {
226 type: MEMBER
227 value: "group2"
228 }
229 }
230 value {
231 type: OPERATOR
232 operator {
233 name: "sign_minus"
234 param {
235 type: IDENT
236 identifier {
237 document_path{
238 type: MEMBER
239 value: "group2"
240 }
241 }
242 }
243 }
244 }
245 }
246 %OPTIONS%
247 }
248 }
249 }
250 recvtype Mysqlx.Ok;
251
252 Mysqlx.Prepare.Execute {
253 stmt_id: %PREP_ID%
254 %VAR_ARGS%
255 }
256 recvresult be-quiet;
257
258 assert_eq %EXPECT_ROWS% %RESULT_ROWS_AFFECTED%;
259 quiet;
260 query_result;
261 -->endmacro
262