Author: wyoung
Date: Thu Jun 21 18:56:17 2007
New Revision: 1577
URL: http://svn.gna.org/viewcvs/mysqlpp?rev=1577&view=rev
Log:
Failure to set a pending option during connection establishment while
exceptions are disabled now results in connection failure. This used to
be ignored, which was inconsistent with behavior with exceptions
enabled.
Modified:
trunk/lib/connection.cpp
trunk/lib/connection.h
Modified: trunk/lib/connection.cpp
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/connection.cpp?rev=1577&r1=1576&r2=1577&view=diff
==============================================================================
--- trunk/lib/connection.cpp (original)
+++ trunk/lib/connection.cpp Thu Jun 21 18:56:17 2007
@@ -179,15 +179,10 @@
if (compress) {
set_option(opt_compress);
}
-#if MYSQL_VERSION_ID >= 40101
- if (option_pending(opt_multi_statements, true)) {
- client_flag |= CLIENT_MULTI_STATEMENTS;
- }
-#endif
- apply_pending_options();
// Establish connection
- if (mysql_real_connect(&mysql_, host, user, passwd, db, port,
+ if (apply_pending_options() &&
+ mysql_real_connect(&mysql_, host, user, passwd, db,
port,
socket_name, client_flag)) {
unlock();
success_ = is_connected_ = true;
@@ -534,7 +529,7 @@
}
-void
+bool
Connection::apply_pending_options()
{
bool success = true;
@@ -710,9 +705,9 @@
pending_options_.clear();
- // If option failed, throw an exception to report the problem unless
- // that isn't allowed, in which case the failure will be lost.
if (!success && throw_exceptions()) {
+ // Failed to set one of the queued options, so throw an
exception
+ // to report the problem.
ostringstream os;
os << "Failed to set pending option " << it->option;
if (it->arg_type != opt_type_none) {
@@ -727,24 +722,8 @@
}
throw BadOption(os.str(), it->option);
}
-}
-
-
-bool
-Connection::option_pending(Option option, bool arg) const
-{
- OptionListIt it;
- for (it = pending_options_.begin(); it != pending_options_.end(); ++it)
{
- if (it->option == option) {
- // Found the option, but return true only if the pending
- // option was given a bool argument equal to the value
- // passed to this function.
- return it->arg_type == opt_type_boolean &&
- it->bool_arg == arg;
- }
- }
-
- return false;
+
+ return success;
}
Modified: trunk/lib/connection.h
URL:
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/connection.h?rev=1577&r1=1576&r2=1577&view=diff
==============================================================================
--- trunk/lib/connection.h (original)
+++ trunk/lib/connection.h Thu Jun 21 18:56:17 2007
@@ -472,19 +472,12 @@
/// object should always be connected.
void disconnect();
- /// \brief Returns true if the given option is to be set once
- /// connection comes up.
- ///
- /// \param option option to check for in queue
- /// \param arg argument to match against
- bool option_pending(Option option, bool arg) const;
-
- /// \brief For each option in pending option queue, call
- /// set_option()
- ///
- /// Called within connect() method after connection is established.
- /// Despools options in the order given to set_option().
- void apply_pending_options();
+ /// \brief Set all options that have been queued pending connection
+ /// establishment.
+ ///
+ /// Called within connect() method just before we try opening the
+ /// database server connection.
+ bool apply_pending_options();
/// \brief Generic wrapper for bad_option_*()
bool bad_option(Option option, OptionArgType type);
_______________________________________________
Mysqlpp-commits mailing list
[email protected]
https://mail.gna.org/listinfo/mysqlpp-commits