aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2005-12-03 23:04:34 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2005-12-03 23:04:34 +0000
commit6c9cfd64ca5e35445e4fdcc822dbdcd5b2339d87 (patch)
treeccfa23a4e2ab506239383ff75d8b98cdf84cbe0a /activerecord
parent4f1e37ccd4cf19f74ce6c4b1fe746c20a548292f (diff)
downloadrails-6c9cfd64ca5e35445e4fdcc822dbdcd5b2339d87.tar.gz
rails-6c9cfd64ca5e35445e4fdcc822dbdcd5b2339d87.tar.bz2
rails-6c9cfd64ca5e35445e4fdcc822dbdcd5b2339d87.zip
MySQL: work around ruby-mysql/mysql-ruby inconsistency with mysql.stat. Eliminate usage of mysql.ping because it doesn't guarantee reconnect. Explicitly close and reopen the connection instead. References #428.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3216 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG2
-rwxr-xr-xactiverecord/lib/active_record/connection_adapters/mysql_adapter.rb16
2 files changed, 11 insertions, 7 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index 44f00e0418..f5c6f84ae8 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* MySQL: work around ruby-mysql/mysql-ruby inconsistency with mysql.stat. Eliminate usage of mysql.ping because it doesn't guarantee reconnect. Explicitly close and reopen the connection instead. [Jeremy Kemper]
+
* Added preliminary support for polymorphic associations [DHH]
* Added preliminary support for join models [DHH]
diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
index c43a84a386..6327840752 100755
--- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -155,18 +155,20 @@ module ActiveRecord
else
@connection.query 'select 1'
end
- true
+
+ # mysql-ruby doesn't raise an exception when stat fails.
+ if @connection.respond_to?(:errno)
+ @connection.errno.zero?
+ else
+ true
+ end
rescue Mysql::Error
false
end
def reconnect!
- if @connection.respond_to?(:ping)
- @connection.ping
- else
- @connection.close rescue nil
- connect
- end
+ @connection.close rescue nil
+ connect
end