Author: wyoung
Date: Thu Jun 21 16:54:02 2007
New Revision: 1575

URL: http://svn.gna.org/viewcvs/mysqlpp?rev=1575&view=rev
Log:
- Was applying pending options after connection establishment, but that's
  wrong.  MySQL only pays attention if you apply them after mysql_init()
  but before mysql_connect().  Fixed.
- Added a few typedefs to make pending option list handling code a bit
  easier to read.

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=1575&r1=1574&r2=1575&view=diff
==============================================================================
--- trunk/lib/connection.cpp (original)
+++ trunk/lib/connection.cpp Thu Jun 21 16:54:02 2007
@@ -182,13 +182,13 @@
                client_flag |= CLIENT_MULTI_STATEMENTS;
        }
 #endif
+       apply_pending_options();
 
        // Establish connection
        if (mysql_real_connect(&mysql_, host, user, passwd, db, port,
                        socket_name, client_flag)) {
                unlock();
                success_ = is_connected_ = true;
-               apply_pending_options();
 
                if (db && db[0]) {
                        // Also attach to given database
@@ -598,12 +598,8 @@
 void
 Connection::apply_pending_options()
 {
-       if (pending_options_.size() == 0) {
-               return;
-       }
-
-       for (deque<OptionInfo>::const_iterator it(pending_options_.begin());
-                       it != pending_options_.end(); ++it) {
+       OptionListIt it;
+       for (it = pending_options_.begin(); it != pending_options_.end(); ++it) 
{
                // Try to set the option
                bool success;
                switch (it->arg_type) {
@@ -651,8 +647,8 @@
 bool
 Connection::option_pending(Option option, bool arg) const
 {
-       for (deque<OptionInfo>::const_iterator it(pending_options_.begin());
-                       it != pending_options_.end(); ++it) {
+       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

Modified: trunk/lib/connection.h
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/connection.h?rev=1575&r1=1574&r2=1575&view=diff
==============================================================================
--- trunk/lib/connection.h (original)
+++ trunk/lib/connection.h Thu Jun 21 16:54:02 2007
@@ -563,12 +563,14 @@
                {
                }
        };
+       typedef std::deque<OptionInfo> OptionList;
+       typedef OptionList::const_iterator OptionListIt;
 
        MYSQL mysql_;
        bool is_connected_;
        bool connecting_;
        bool success_;
-       std::deque<OptionInfo> pending_options_;
+       OptionList pending_options_;
        static OptionArgType legal_opt_arg_types_[];
 };
 


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

Reply via email to