Author: wyoung
Date: Fri Jun 26 13:36:06 2009
New Revision: 2543

URL: http://svn.gna.org/viewcvs/mysqlpp?rev=2543&view=rev
Log:
ReconnectOption can now only be set after a connection is up in versions
5.0.13 (where the option was added to the C API) and 5.1.5, as the
option is reset on connection establishment before 5.1.6.

Modified:
    trunk/lib/options.cpp
    trunk/lib/options.h

Modified: trunk/lib/options.cpp
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/options.cpp?rev=2543&r1=2542&r2=2543&view=diff
==============================================================================
--- trunk/lib/options.cpp (original)
+++ trunk/lib/options.cpp Fri Jun 26 13:36:06 2009
@@ -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

Modified: trunk/lib/options.h
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/options.h?rev=2543&r1=2542&r2=2543&view=diff
==============================================================================
--- trunk/lib/options.h (original)
+++ trunk/lib/options.h Fri Jun 26 13:36:06 2009
@@ -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


_______________________________________________
Mysqlpp-commits mailing list
[email protected]
https://mail.gna.org/listinfo/mysqlpp-commits

Reply via email to