Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 3216

Show
Ignore:
Timestamp:
12/03/05 23:04:34 (4 years ago)
Author:
bitsweat
Message:

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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/CHANGELOG

    r3213 r3216  
    11*SVN* 
     2 
     3* 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] 
    24 
    35* Added preliminary support for polymorphic associations [DHH] 
  • trunk/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb

    r3194 r3216  
    156156          @connection.query 'select 1' 
    157157        end 
    158         true 
     158 
     159        # mysql-ruby doesn't raise an exception when stat fails. 
     160        if @connection.respond_to?(:errno) 
     161          @connection.errno.zero? 
     162        else 
     163          true 
     164        end 
    159165      rescue Mysql::Error 
    160166        false 
     
    162168 
    163169      def reconnect! 
    164         if @connection.respond_to?(:ping) 
    165           @connection.ping 
    166         else 
    167           @connection.close rescue nil 
    168           connect 
    169         end 
     170        @connection.close rescue nil 
     171        connect 
    170172      end 
    171173