Skip to content

Commit

Permalink
No longer use native autoreconnection in the mysql adapter
Browse files Browse the repository at this point in the history
Native autoreconnection has problems with prepared statements, where
a new native connection is used behind Sequel's back, so Sequel
thinks the prepared statement has already been defined on the
connection, when it fact it hasn't.  Any other changes that affect
the state of the connection will be lost when native autoreconnection
is used as well.

Sequel's connection pool already handles reconnection if it detects a
disconnection.  This commit also adds an additional exception message
to recognize as a disconnect.
  • Loading branch information
jeremyevans committed Nov 21, 2009
1 parent 1670de3 commit edbfbb7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
=== HEAD

* No longer use native autoreconnection in the mysql adapter (jeremyevans)

* Add NULL, NOTNULL, TRUE, SQLTRUE, FALSE, and SQLFALSE constants (jeremyevans)

* Add Dataset #select_map, #select_order_map, and #select_hash (jeremyevans)
Expand Down
3 changes: 1 addition & 2 deletions lib/sequel/adapters/mysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Database < Sequel::Database
include Sequel::MySQL::DatabaseMethods

# Mysql::Error messages that indicate the current connection should be disconnected
MYSQL_DATABASE_DISCONNECT_ERRORS = /\A(Commands out of sync; you can't run this command now\z|Can't connect to local MySQL server through socket)/
MYSQL_DATABASE_DISCONNECT_ERRORS = /\A(Commands out of sync; you can't run this command now|Can't connect to local MySQL server through socket|MySQL server has gone away)/

set_adapter_scheme :mysql

Expand Down Expand Up @@ -124,7 +124,6 @@ class << conn
attr_accessor :prepared_statements
end
conn.prepared_statements = {}
conn.reconnect = true
conn
end

Expand Down

0 comments on commit edbfbb7

Please sign in to comment.