Author: wyoung
Date: Wed Jul 11 22:50:40 2007
New Revision: 1661
URL: http://svn.gna.org/viewcvs/mysqlpp?rev=1661&view=rev
Log:
Fixed a bug in setting the "multi statements" connection option before
the connection is up. The new option handling mistakenly tried to set
this immediately, which doesn't work for this one particular option. We
now store the intent to set this option, and only act on it right before
connection establishment, as the old option handling used to. (Indeed,
this issue was probably why I designed option handling the way I did...)
Modified:
trunk/lib/connection.cpp
Modified: trunk/lib/connection.cpp
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/connection.cpp?rev=1661&r1=1660&r2=1661&view=diff
==============================================================================
--- trunk/lib/connection.cpp (original)
+++ trunk/lib/connection.cpp Wed Jul 11 22:50:40 2007
@@ -181,6 +181,15 @@
set_option_default(opt_compress);
}
+#if MYSQL_VERSION_ID >= 40101
+ // Check to see if user turned on multi-statements before
+ // establishing the connection. This one we handle specially, by
+ // setting a flag during connection establishment.
+ if (option_set(opt_multi_statements)) {
+ client_flag |= CLIENT_MULTI_STATEMENTS;
+ }
+#endif
+
// Establish connection
scoped_var_set<bool> sb(connecting_, true);
if (mysql_real_connect(&mysql_, host, user, passwd, db, port,
@@ -523,9 +532,20 @@
break;
case opt_multi_statements:
- success = set_option_impl(arg ?
- MYSQL_OPTION_MULTI_STATEMENTS_ON :
- MYSQL_OPTION_MULTI_STATEMENTS_OFF);
+ // If connection is up, set the flag immediately. If
not,
+ // and caller wants this turned on, pretend success so
that
+ // we store the info we need to turn this flag on when
+ // bringing the connection up. (If the caller is
turning it
+ // off before conn comes up, we effectively ignore
this,
+ // because that's the default.)
+ if (connected()) {
+ success = set_option_impl(arg ?
+
MYSQL_OPTION_MULTI_STATEMENTS_ON :
+
MYSQL_OPTION_MULTI_STATEMENTS_OFF);
+ }
+ else {
+ success = arg;
+ }
break;
#endif
#if MYSQL_VERSION_ID >= 50003
_______________________________________________
Mysqlpp-commits mailing list
[email protected]
https://mail.gna.org/listinfo/mysqlpp-commits