Skip to content

Commit a609ea1

Browse files
committed
Change mysql error detection strategy
Previous to this commit, some mysql connection errors were not detected by the client. This commit changes from implicit error detection via checking mysql_field_count() to explicit detection via mysql_errno(). http://dev.mysql.com/doc/refman/5.0/en/null-mysql-store-result.html
1 parent d449b55 commit a609ea1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ext/mysql2/client.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,10 @@ static VALUE rb_mysql_client_async_result(VALUE self) {
311311
result = (MYSQL_RES *)rb_thread_blocking_region(nogvl_store_result, wrapper, RUBY_UBF_IO, 0);
312312

313313
if (result == NULL) {
314-
if (mysql_field_count(wrapper->client) != 0) {
314+
if (mysql_errno(wrapper->client) != 0) {
315315
rb_raise_mysql2_error(wrapper);
316316
}
317+
// no data and no error, so query was not a SELECT
317318
return Qnil;
318319
}
319320

0 commit comments

Comments
 (0)