@@ -140,3 +140,121 @@ TEST_F(Bugs, bug_26962725_double_bind)
140
140
141
141
EXPECT_EQ (0 , myColl.find ().execute ().count ());
142
142
}
143
+
144
+ TEST_F (Bugs, bug_27727505_multiple_results)
145
+ {
146
+ mysqlx::Session &sess = get_sess ();
147
+ sess.dropSchema (" bug_27727505_multiple_results" );
148
+ sess.createSchema (" bug_27727505_multiple_results" );
149
+
150
+ /* ddl */
151
+ std::string strValue = " " ;
152
+ sess.sql (" use bug_27727505_multiple_results" ).execute ();
153
+ sess.sql (" drop table if exists bug_27727505_multiple_results" ).execute ();
154
+ sess.sql (" create table newtable(f0 int, f1 varchar(1024))" ).execute ();
155
+ for (int i=0 ;i<100 ;i++)
156
+ {
157
+ strValue.resize (1024 , ' a' );
158
+ sess.sql (" insert into newtable values(?,?)" )
159
+ .bind (i)
160
+ .bind (strValue.c_str ())
161
+ .execute ();
162
+ }
163
+ sess.sql (" drop procedure if exists test" ).execute ();
164
+ sess.sql (" CREATE PROCEDURE test() BEGIN select f0, f1 from newtable where"
165
+ " f0 <= 33; select f0, f1 from newtable where f0 <= 10; END" )
166
+ .execute ();
167
+ SqlResult res = sess.sql (" call test" ).execute ();
168
+
169
+ Row row;
170
+ int setNo = 0 ;
171
+ do
172
+ {
173
+ std::vector<Row> rowAll = res.fetchAll ();
174
+ unsigned int j=0 ;
175
+ for (j = 0 ;j < rowAll.size ();j++)
176
+ {
177
+ string data = (string)rowAll[j][1 ];
178
+ int num = rowAll[j][0 ];
179
+ if ((unsigned int )num!=j || strValue.compare (data))
180
+ {
181
+ std::stringstream ss;
182
+ ss << " Fetch fail in set : " <<setNo<<" row : " <<num ;
183
+ throw ss.str ();
184
+ }
185
+ else
186
+ {
187
+ cout << " Fetch pass in set : " <<setNo<<" row : " <<num << endl;
188
+ }
189
+ }
190
+ if ((setNo == 0 && j != 34 ) || (setNo == 1 && j != 11 ))
191
+ {
192
+ throw " Not all results fetched" ;
193
+ }
194
+ std::vector<Type> expcType;
195
+ expcType.push_back (Type::INT);
196
+ expcType.push_back (Type::STRING);
197
+ std::vector<string> expcName;
198
+ expcName.push_back (" f0" );
199
+ expcName.push_back (" f1" );
200
+
201
+ const Columns &cc = res.getColumns ();
202
+ for (unsigned int i=0 ;i < res.getColumnCount ();i++)
203
+ {
204
+ if (expcName[i].compare (cc[i].getColumnName ()))
205
+ {
206
+ throw " Column Name mismatch" ;
207
+ }
208
+ if (expcType[i] != cc[i].getType ())
209
+ {
210
+ throw " Column Type mismatch" ;
211
+ }
212
+ if (0 != cc[i].getFractionalDigits ())
213
+ {
214
+ throw " getFractionalDigits is not zero" ;
215
+ }
216
+ cout << cc[i].getColumnName () << endl;
217
+ cout << cc[i].getType () << endl;
218
+ cout << cc[i].isNumberSigned () << endl;
219
+ cout << cc[i].getFractionalDigits () << endl;
220
+ }
221
+
222
+ setNo++;
223
+ }
224
+ while (res.nextResult ());
225
+ sess.sql (" drop procedure if exists test" ).execute ();
226
+ sess.sql (" CREATE PROCEDURE test() BEGIN select f0, f1 from newtable "
227
+ " where f0 > 1000; select f0, f1 from newtable where f0 <= 10;"
228
+ " END" ).execute ();
229
+ res = sess.sql (" call test" ).execute ();
230
+ setNo = 0 ;
231
+ do
232
+ {
233
+ unsigned int j=0 ;
234
+ std::vector<Row> rowAll = res.fetchAll ();
235
+ for (j = 0 ;j < rowAll.size ();j++)
236
+ {
237
+ string data = (string)rowAll[j][1 ];
238
+ int num = rowAll[j][0 ];
239
+ if ((unsigned int )num!=j || strValue.compare (data))
240
+ {
241
+ std::stringstream ss;
242
+ ss << " Fetch fail in set : " <<setNo<<" row : " <<num ;
243
+ throw ss.str ();
244
+ }
245
+ else
246
+ {
247
+ cout << " Fetch pass in set : " <<setNo<<" row : " <<num << endl;
248
+ }
249
+ }
250
+ if ((setNo == 0 && j != 0 ) || (setNo == 1 && j != 11 ))
251
+ {
252
+ throw " Not all results fetched" ;
253
+ }
254
+
255
+ setNo++;
256
+ }
257
+ while (res.nextResult ());
258
+ }
259
+
260
+
0 commit comments