Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

r3419@asus: jeremy | 2005-12-09 15:36:50 -0800

 Apply [3165] to stable. MySQL, PostgreSQL: reconnect! also reconfigures the connection. Otherwise, the connection 'loses' its settings if it times out and is reconnected. References #2978.


git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/stable@3266 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 36619f2084eee985452b176af53d3e4b7480203b 1 parent d2b0cc7
@jeremy jeremy authored
View
2  activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* MySQL, PostgreSQL: reconnect! also reconfigures the connection. Otherwise, the connection 'loses' its settings if it times out and is reconnected. #2978 [Shugo Maeda]
+
* Oracle: active? performs a select instead of a commit. #3133 [Michael Schoen]
View
19 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -34,17 +34,7 @@ def self.mysql_connection(config) # :nodoc:
mysql = Mysql.init
mysql.ssl_set(config[:sslkey], config[:sslcert], config[:sslca], config[:sslcapath], config[:sslcipher]) if config[:sslkey]
- if config[:encoding]
- begin
- mysql.options(Mysql::SET_CHARSET_NAME, config[:encoding])
- rescue
- raise ActiveRecord::ConnectionFailed, 'The :encoding option is only available for MySQL 4.1 and later with the mysql-ruby driver. Again, this does not work with the ruby-mysql driver or MySQL < 4.1.'
- end
- end
-
- conn = mysql.real_connect(host, username, password, database, port, socket)
- conn.query("SET NAMES '#{config[:encoding]}'") if config[:encoding]
- ConnectionAdapters::MysqlAdapter.new(conn, logger, [host, username, password, database, port, socket], mysql)
+ ConnectionAdapters::MysqlAdapter.new(mysql, logger, [host, username, password, database, port, socket], config)
end
end
@@ -90,11 +80,12 @@ class MysqlAdapter < AbstractAdapter
"MySQL server has gone away"
]
- def initialize(connection, logger, connection_options=nil, mysql=Mysql)
+ def initialize(connection, logger, connection_options=nil, config={})
super(connection, logger)
@connection_options = connection_options
@null_values_in_each_hash = Mysql.const_defined?(:VERSION)
- @mysql = mysql
+ @config = config
+ connect
end
def adapter_name #:nodoc:
@@ -138,7 +129,7 @@ def quote_column_name(name) #:nodoc:
end
def quote_string(string) #:nodoc:
- @mysql.quote(string)
+ @connection.quote(string)
end
def quoted_true
Please sign in to comment.
Something went wrong with that request. Please try again.