Index: lib/options.h =================================================================== --- lib/options.h (revision 2523) +++ lib/options.h (working copy) @@ -62,7 +62,8 @@ err_NONE, ///< option was set successfully err_api_limit, ///< option not supported by underlying C API err_api_reject, ///< underlying C API returned error when setting option - err_connected ///< can't set the given option while connected + err_connected, ///< can't set the given option while connected + err_disconnected,///< can only set the given option while connected }; virtual ~Option() { } ///< Destroy object Index: lib/options.cpp =================================================================== --- lib/options.cpp (revision 2523) +++ lib/options.cpp (working copy) @@ -223,10 +223,20 @@ Option::Error ReconnectOption::set(DBDriver* dbd) { -#if MYSQL_VERSION_ID >= 50013 - return dbd->connected() ? Option::err_connected : +#if MYSQL_VERSION_ID >= 50106 + // Option fixed in this version to work correctly whether set before + // connection comes up, or after + return dbd->set_option(MYSQL_OPT_RECONNECT, &arg_) ? + Option::err_NONE : Option::err_api_reject; +#elif MYSQL_VERSION_ID >= 50013 + // Between the time the option was created in 5.0.13 and when it was + // fixed in 5.1.6, it only worked correctly if set after initial + // connection. So, don't accept it if disconnected, even though API + // does accept it; option gets reset when the connection comes up. + return dbd->connected() ? dbd->set_option(MYSQL_OPT_RECONNECT, &arg_) ? - Option::err_NONE : Option::err_api_reject; + Option::err_NONE : Option::err_api_reject : + Option::err_disconnected; #else return Option::err_api_limit; #endif