brianmario/mysql2 — pull request #224 by woahdae (2011-11-10 21:35:38+00:00)
Title: 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

Note that this was discovered while investigating https://github.com/brianmario/mysql2/issues/66

Also, from the bottom of [the mysql_field_count() docs](http://dev.mysql.com/doc/refman/5.0/en/mysql-field-count.html), it notes:

An alternative is to replace the mysql_field_count(&mysql)
call with mysql_errno(&mysql). In this case, you are checking
directly for an error from mysql_store_result() rather than
inferring from the value of mysql_field_count() whether the
statement was a SELECT.

While neither documentation says it explicitly, it seems that mysql_errno() will return errors that the strategy based on mysql_field_count() won't.

It is certainly my experience that there are connection errors happening that only checking mysql_errno() detects (see https://github.com/brianmario/mysql2/issues/66)