Debian Codegraph @

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

raw
1 ## generated
2 ## Doc: Find a document with projection
3
4 --source include/xplugin_preamble.inc
5 --source include/xplugin_create_user.inc
6
7 create schema xtest default charset 'utf8mb4';
8
9 ## Test starts here
10 --write_file $MYSQL_TMP_DIR/find_doc_proj.xpl
11 ## Test data
12
13 -->stmtadmin create_collection {"schema":"xtest","name":"mycoll"}
14 -->recvresult
15 -->stmtadmin create_collection {"schema":"xtest","name":"funkycoll"}
16 -->recvresult
17
18 -->sql
19 use xtest;
20 insert into mycoll (doc) values ('{"_id": "1", "name": "Joe1"}');
21 insert into mycoll (doc) values ('{"_id": "2", "name": "Joe2", "last_name": "Smith"}');
22 insert into mycoll (doc) values ('{"_id": "3", "name": "Joe2", "last_name": "Shmo"}');
23 insert into mycoll (doc) values ('{"_id": "4", "name": "小島", "last_name": "Bla"}');
24
25 insert into funkycoll (doc) values ('{"_id": "1", "I love \\\"\'quotes\'\\\"\\n": "I love \\\"\'quotes\'\\\"\\n"}');
26 insert into funkycoll (doc) values ('{"_id": "2", "I love \\\"\'quotes\'\\\"\\n": "\\\",$.array[2]\\\\\\\""}');
27 insert into funkycoll (doc) values ('{"_id": "3", "\\\",$.array[2]\\\\\\\"": "I love \\\"\'quotes\'\\\"\\n"}');
28 insert into funkycoll (doc) values ('{"_id": "4", "\\\",$.array[2]\\\\\\\"": "\\\",$.array[2]\\\\\\\""}');
29 -->endsql
30
31 Mysqlx.Crud.Find {
32 collection {
33 name: "mycoll"
34 schema: "xtest"
35 }
36 data_model: DOCUMENT
37 projection {
38 source {
39 type: IDENT
40 identifier {
41 document_path {
42 type: MEMBER
43 value: "name"
44 }
45 }
46 }
47 alias: "Name"
48 }
49 }
50
51 ## expect Mysqlx.Resultset.ColumnMetaData
52 -->recv
53 ## expect Mysqlx.Resultset.Row
54 -->recv
55 ## expect Mysqlx.Resultset.Row
56 -->recv
57 ## expect Mysqlx.Resultset.Row
58 -->recv
59 ## expect Mysqlx.Resultset.Row
60 -->recv
61 ## expect Mysqlx.Resultset.FetchDone
62 -->recv
63 ## expect Mysqlx.Sql.StmtExecuteOk
64 -->recv
65
66 ## Bad projection
67 Mysqlx.Crud.Find {
68 collection {
69 name: "funkycoll"
70 schema: "xtest"
71 }
72 data_model: DOCUMENT
73 projection {
74 source {
75 type: IDENT
76 identifier {
77 document_path {
78 type: MEMBER
79 value: "I love \"\'quotes\'\"\n"
80 }
81 }
82 }
83 alias: "key"
84 }
85 projection {
86 source {
87 type: IDENT
88 identifier {
89 document_path {
90 type: MEMBER
91 value: "_id"
92 }
93 }
94 }
95 alias: "\"\'"
96 }
97 }
98
99 ## expect Mysqlx.Resultset.ColumnMetaData
100 -->recv
101 ## expect Mysqlx.Resultset.Row
102 -->recv
103 ## expect Mysqlx.Resultset.Row
104 -->recv
105 ## expect Mysqlx.Resultset.Row
106 -->recv
107 ## expect Mysqlx.Resultset.Row
108 -->recv
109 ## expect Mysqlx.Sql.CursorFetchDone
110 -->recv
111 ## expect Mysqlx.Sql.StmtExecuteOk
112 -->recv
113
114 ## Doc: Find document with projection, attempt to break
115
116 Mysqlx.Crud.Find {
117 collection {
118 name: "funkycoll"
119 schema: "xtest"
120 }
121 data_model: DOCUMENT
122 projection {
123 source {
124 type: IDENT
125 identifier {
126 document_path {
127 type: MEMBER
128 value: "I love \"\'quotes\'\"\n\\/\b\f\r\t"
129 }
130 }
131 }
132 alias: "I love \"\'quotes\'\"\n"
133 }
134 projection {
135 source {
136 type: IDENT
137 identifier {
138 document_path {
139 type: MEMBER
140 value: "_id"
141 }
142 }
143 }
144 alias: "\"\'"
145 }
146 limit {
147 row_count: 1
148 offset: 2
149 }
150 }
151
152 ## expect Mysqlx.Resultset.ColumnMetaData
153 -->recv
154 ## expect Mysqlx.Resultset.Row
155 -->recv
156 ## expect Mysqlx.Sql.CursorFetchDone
157 -->recv
158 ## expect Mysqlx.Sql.StmtExecuteOk
159 -->recv
160
161 ## Doc: Find a document with projection with missing key in some rows
162
163 Mysqlx.Crud.Find {
164 collection {
165 name: "mycoll"
166 schema: "xtest"
167 }
168 data_model: DOCUMENT
169 projection {
170 source {
171 type: IDENT
172 identifier {
173 document_path {
174 type: MEMBER
175 value: "name"
176 }
177 }
178 }
179 alias: "name"
180 }
181 projection {
182 source {
183 type: IDENT
184 identifier {
185 document_path {
186 type: MEMBER
187 value: "last_name"
188 }
189 }
190 }
191 alias: "last_name"
192 }
193 }
194
195 ## expect Mysqlx.Resultset.ColumnMetaData
196 -->recv
197 ## expect Mysqlx.Resultset.Row
198 -->recv
199 ## expect Mysqlx.Resultset.Row
200 -->recv
201 ## expect Mysqlx.Resultset.Row
202 -->recv
203 ## expect Mysqlx.Resultset.Row
204 -->recv
205 ## expect Mysqlx.Resultset.FetchDone
206 -->recv
207 ## expect Mysqlx.Sql.StmtExecuteOk
208 -->recv
209
210 ## ERROR sceanrio
211 ## Doc: Find causing an error
212
213 Mysqlx.Crud.Find {
214 collection {
215 name: "mycoll"
216 schema: "xtest"
217 }
218 data_model: DOCUMENT
219 projection {
220 source {
221 type: OBJECT
222 object {
223 fld {
224 key: "X"
225 value {
226 type: OPERATOR
227 operator {
228 name: "-"
229 param {
230 type: OPERATOR
231 operator {
232 name: "cast"
233 param {
234 type: LITERAL
235 literal {
236 type: V_SINT
237 v_signed_int: 0
238 }
239 }
240 param {
241 type: LITERAL
242 literal {
243 type: V_OCTETS
244 v_octets {value:"UNSIGNED"}
245 }
246 }
247 }
248 }
249 param {
250 type: LITERAL
251 literal {
252 type: V_SINT
253 v_signed_int: 1
254 }
255 }
256 }
257 }
258 }
259 }
260 }
261 }
262 }
263
264 -->expecterror 1690
265 -->recvresult
266 EOF
267
268 --exec $MYSQLXTEST -ux_root --password='' --file=$MYSQL_TMP_DIR/find_doc_proj.xpl 2>&1
269
270 ## Cleanup
271 --source ../include/xplugin_cleanup.inc