From: Warren Young Date: June 15 2009 4:25pm Subject: Re: Issue with ReconnectOption List-Archive: http://lists.mysql.com/plusplus/8635 Message-Id: <4A367602.6060506@etr-usa.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------000308060100040503070603" --------------000308060100040503070603 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Kevin Regan wrote: > It seems that the dbd->connected() check should only be performed for > versions of MySQL greater than 5.1.6. Isn't that backwards? As I read your reference manual excerpt, after the fix in 5.1.6, you can set this option at any time, and it will be set as expected. It's only with the older versions, where the option handling had the bug, where we should check for a connection before allowing the option to be set. See the attached patch for my take on this. > Was this just an oversight, or > has something changed to make this an issue? As far as I know, this is the first change expressly made with 5.1 in mind. Personally, the newest version I'm using is 5.0. I'm waiting for some of this dust to clear before moving to a newer version. By all means, continue to submit 5.1 related patches, though, if that's where your itch is. --------------000308060100040503070603 Content-Type: text/x-patch; name="reconn-opt.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="reconn-opt.patch" 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 --------------000308060100040503070603--