Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

No longer use native autoreconnection in the mysql adapter

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...
commit edbfbb78018f62a14400f562024ef03c389a2cd4 1 parent 1670de3
@jeremyevans authored
Showing with 3 additions and 2 deletions.
  1. +2 −0  CHANGELOG
  2. +1 −2  lib/sequel/adapters/mysql.rb
View
2  CHANGELOG
@@ -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)
View
3  lib/sequel/adapters/mysql.rb
@@ -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
@@ -124,7 +124,6 @@ class << conn
attr_accessor :prepared_statements
end
conn.prepared_statements = {}
- conn.reconnect = true
conn
end
Please sign in to comment.
Something went wrong with that request. Please try again.