222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
|
# File 'ext/mysql2/client.c', line 222
static VALUE rb_mysql_client_async_result(VALUE self) {
MYSQL_RES * result;
GET_CLIENT(self)
REQUIRE_OPEN_DB(client);
if (rb_thread_blocking_region(nogvl_read_query_result, client, RUBY_UBF_IO, 0) == Qfalse) {
// an error occurred, mark this connection inactive
MARK_CONN_INACTIVE(self);
return rb_raise_mysql2_error(client);
}
result = (MYSQL_RES *)rb_thread_blocking_region(nogvl_store_result, client, RUBY_UBF_IO, 0);
// we have our result, mark this connection inactive
MARK_CONN_INACTIVE(self);
if (result == NULL) {
if (mysql_field_count(client) != 0) {
rb_raise_mysql2_error(client);
}
return Qnil;
}
VALUE resultObj = rb_mysql_result_to_obj(result);
// pass-through query options for result construction later
rb_iv_set(resultObj, "@query_options", rb_obj_dup(rb_iv_get(self, "@query_options")));
#ifdef HAVE_RUBY_ENCODING_H
mysql2_result_wrapper * result_wrapper;
GetMysql2Result(resultObj, result_wrapper);
result_wrapper->encoding = wrapper->encoding;
#endif
return resultObj;
}
|