Author: mysqlpp
Date: Mon Dec  3 11:49:57 2007
New Revision: 1960

URL: http://svn.gna.org/viewcvs/mysqlpp?rev=1960&view=rev
Log:
- Removed EndOfResults and EndOfResultSets exceptions.  These are *not*
  exceptional conditions: they're the normal exit state from a use query
  or multiquery.
- Query::store_next() and Result::fetch_row() now return false on
  reaching the end of results/result sets instead of throwing these
  exceptions.
- Removed examples/usequery.cpp: there's no essential difference between
  this and simple3 now.

Removed:
    trunk/examples/usequery.cpp
Modified:
    trunk/README.examples
    trunk/Wishlist
    trunk/bmark.txt
    trunk/doc/userman/userman.dbx
    trunk/dtest
    trunk/examples/multiquery.cpp
    trunk/examples/simple3.cpp
    trunk/lib/exceptions.h
    trunk/lib/query.cpp
    trunk/lib/result.h
    trunk/mysql++.bkl

Modified: trunk/README.examples
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/README.examples?rev=1960&r1=1959&r2=1960&view=diff
==============================================================================
--- trunk/README.examples (original)
+++ trunk/README.examples Mon Dec  3 11:49:57 2007
@@ -76,13 +76,6 @@
 
         custom1-6: Demonstrates the SSQLS features.  These examples
             are explained in the user manual.
-
-        usequery: Demonstrates Query::use().  Unlike simple3, which
-            also showcases this function, this one shows how use
-            queries interact with exception handling: when you walk
-            past the end of a "use" query set with exceptions enabled,
-            MySQL++ throws an exception to indicate end of results,
-            which you must catch.
 
         multiquery: MySQL++ allows you to issue multiple queries at
             once, and get the results as separate sets.  This shows

Modified: trunk/Wishlist
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/Wishlist?rev=1960&r1=1959&r2=1960&view=diff
==============================================================================
--- trunk/Wishlist (original)
+++ trunk/Wishlist Mon Dec  3 11:49:57 2007
@@ -34,6 +34,10 @@
 
        o Add userman chapter on connection options
 
+       o Still mysql_*() stuff in Row at least.  Check result module too.
+
+       o Replace all my_ulonglong with ulonglong.
+
     o Create an SSQLS base class containing all of the common
       boilerplate, which leaf SSQLSes derive from.  This should in turn
       allow template functions like Query::insert<T> to become regular
@@ -55,16 +59,6 @@
     This is stuff that would be nice to have, but it wouldn't be a
     good idea to bet on seeing it in v3.0.  If you really want some
     of this, best to just get coding and provide a patch!
-
-       o Return false from Query::store_next() instead of throwing
-         EndOfResultSets?
-
-    o Query::storein() variants taking SSQLS like store_if()?  If we
-      do this, use it to tighten up the example at the end of userman
-      section 2.3.
-
-    o Make RefCountedPointer::swap() private?  Could be a good reason
-      for it to be public, but no one's given such a reason yet.
 
     o Atomic inc/dec of reference counts in RefCounted*?  To justify
       it, one has to justify using two threads to process data,

Modified: trunk/bmark.txt
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/bmark.txt?rev=1960&r1=1959&r2=1960&view=diff
==============================================================================
--- trunk/bmark.txt (original)
+++ trunk/bmark.txt Mon Dec  3 11:49:57 2007
@@ -170,13 +170,6 @@
 Reinitialized sample database successfully.
 ================ END resetdb OUTPUT ================
 
----------------- BEGIN usequery OUTPUT ----------------
-             Nürnberger Brats        97       1.5      8.79 2005-03-10
-                 Pickle Relish        87       1.5      1.75 1998-09-04
-                   Hot Mustard        73      0.95      0.97 1998-05-25
-                   Hotdog Buns        65       1.1       1.1 1998-04-23
-================ END usequery OUTPUT ================
-
 ---------------- BEGIN custom1 OUTPUT ----------------
 Records found: 4
 

Modified: trunk/doc/userman/userman.dbx
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/doc/userman/userman.dbx?rev=1960&r1=1959&r2=1960&view=diff
==============================================================================
--- trunk/doc/userman/userman.dbx (original)
+++ trunk/doc/userman/userman.dbx Mon Dec  3 11:49:57 2007
@@ -1047,10 +1047,7 @@
 
         <para>This example does the same thing as
         <filename>simple2</filename>, only with a "use" query instead
-        of a "store" query. If your program uses exceptions, you should
-        instead look at <filename>examples/usequery.cpp</filename>,
-        which does the same thing as <filename>simple3</filename>,
-        but with exception-awareness.</para>
+        of a "store" query.</para>
 
         <para>Valuable as <methodname>use()</methodname> queries are,
         they should not be the first resort in solving problems of

Modified: trunk/dtest
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/dtest?rev=1960&r1=1959&r2=1960&view=diff
==============================================================================
--- trunk/dtest (original)
+++ trunk/dtest Mon Dec  3 11:49:57 2007
@@ -35,7 +35,7 @@
 for t in \
        resetdb simple[0-9] store_if for_each multiquery tquery1 \
        resetdb tquery2 dbinfo fieldinf \
-       resetdb usequery custom[0-9]
+       resetdb custom[0-9]
 do
        if [ -x $t ]
        then

Modified: trunk/examples/multiquery.cpp
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/examples/multiquery.cpp?rev=1960&r1=1959&r2=1960&view=diff
==============================================================================
--- trunk/examples/multiquery.cpp (original)
+++ trunk/examples/multiquery.cpp Mon Dec  3 11:49:57 2007
@@ -120,19 +120,12 @@
 static void
 print_multiple_results(Query& query)
 {
-       try {
-               // Execute query and print all result sets
-               Result res = query.store();
-               print_result(res, 0);
-               for (int i = 1; query.more_results(); ++i) {
-                       res = query.store_next();
-                       print_result(res, i);
-               }
-       }
-       catch (Exception& err) {
-               // Something bad happened....
-               cerr << "Multi-query failure: " << err.what() << endl;
-               exit(1);
+       // Execute query and print all result sets
+       Result res = query.store();
+       print_result(res, 0);
+       for (int i = 1; query.more_results(); ++i) {
+               res = query.store_next();
+               print_result(res, i);
        }
 }
 

Modified: trunk/examples/simple3.cpp
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/examples/simple3.cpp?rev=1960&r1=1959&r2=1960&view=diff
==============================================================================
--- trunk/examples/simple3.cpp (original)
+++ trunk/examples/simple3.cpp Mon Dec  3 11:49:57 2007
@@ -71,7 +71,9 @@
                                                endl;
                        }
 
-                       return 0;
+                       // Check for error: can't distinguish error return or 
normal
+                       // "end of results" return from fetch_row() otherwise.
+                       return con.errnum();
                }
                else {
                        cerr << "Failed to get stock item: " << query.error() 
<< endl;

Removed: trunk/examples/usequery.cpp
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/examples/usequery.cpp?rev=1959&view=auto
==============================================================================
--- trunk/examples/usequery.cpp (original)
+++ trunk/examples/usequery.cpp (removed)
@@ -1,82 +1,0 @@
-/***********************************************************************
- usequery.cpp - Same as simple3 example, only with exceptions enabled.
-       The end of the result set is signalled differently in this case.
-
- Copyright (c) 2005-2007 by Educational Technology Resources, Inc.
- Others may also hold copyrights on code in this file.  See the CREDITS
- file in the top directory of the distribution for details.
-
- This file is part of MySQL++.
-
- MySQL++ is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- MySQL++ is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
- License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with MySQL++; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
- USA
-***********************************************************************/
-
-#include "cmdline.h"
-#include "printdata.h"
-
-#include <mysql++.h>
-
-#include <iostream>
-
-int
-main(int argc, char *argv[])
-{
-       // Get database access parameters from command line
-    const char* db = 0, *server = 0, *user = 0, *pass = "";
-       if (!parse_command_line(argc, argv, &db, &server, &user, &pass)) {
-               return 1;
-       }
-
-       try {
-               // Establish the connection to the database server.
-               mysqlpp::Connection con(db, server, user, pass);
-
-               // Build query to retrieve the entire stock table
-               mysqlpp::Query query = con.query("select * from stock");
-
-               // Execute the query, but don't save results in memory
-               mysqlpp::ResUse res = query.use();
-               if (!res) {
-                       std::cerr << "Result set is empty!" << std::endl;
-                       return 1;
-               }
-
-               // Iterate through result set, printing each row.
-               mysqlpp::Row r;
-               while (r = res.fetch_row()) {
-                       print_stock_row(r);
-               }
-       }
-       catch (const mysqlpp::BadQuery& e) {
-               // Something went wrong with the SQL query.
-               std::cerr << "Query failed: " << e.what() << std::endl;
-               return 1;
-       }
-       catch (const mysqlpp::EndOfResults&) {
-               // Last query result received.  Exit normally.
-               return 0;
-       }
-       catch (const mysqlpp::Exception& er) {
-               // Catch-all for any other MySQL++ exceptions
-               std::cerr << "Error: " << er.what() << std::endl;
-               return 1;
-       }
-
-       // Shouldn't happen!  Program should either error out through one of
-       // the "return 1" cases above, or successfully walk off the end of
-       // the result set and go through the EndOfResults path above.
-       return 2;
-}

Modified: trunk/lib/exceptions.h
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/exceptions.h?rev=1960&r1=1959&r2=1960&view=diff
==============================================================================
--- trunk/lib/exceptions.h (original)
+++ trunk/lib/exceptions.h Mon Dec  3 11:49:57 2007
@@ -368,34 +368,6 @@
 };
 
 
-/// \brief Exception thrown when ResUse::fetch_row() walks off the end
-/// of a use-query's result set.
-
-class MYSQLPP_EXPORT EndOfResults : public Exception
-{
-public:
-       /// \brief Create exception object
-       explicit EndOfResults(const char* w = "end of results") :
-       Exception(w)
-       {
-       }
-};
-
-
-/// \brief Exception thrown when Query::store_next() walks off the end
-/// of a use-query's multi result sets.
-
-class MYSQLPP_EXPORT EndOfResultSets : public Exception
-{
-public:
-       /// \brief Create exception object
-       explicit EndOfResultSets(const char* w = "end of result sets") :
-       Exception(w)
-       {
-       }
-};
-
-
 /// \brief Exception thrown when a BeecryptMutex object fails.
 
 class MYSQLPP_EXPORT MutexFailed : public Exception

Modified: trunk/lib/query.cpp
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/query.cpp?rev=1960&r1=1959&r2=1960&view=diff
==============================================================================
--- trunk/lib/query.cpp (original)
+++ trunk/lib/query.cpp Mon Dec  3 11:49:57 2007
@@ -539,9 +539,12 @@
         if (rc == DBDriver::nr_error) {
             throw BadQuery(error(), errnum());
         }
-        else {
-            throw EndOfResultSets();
+               else if (conn_->errnum()) {
+                       throw BadQuery(error(), errnum());
         }
+               else {
+                       return Result();        // normal end-of-result-sets 
case
+               }
     }
     else {
         return Result();

Modified: trunk/lib/result.h
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/result.h?rev=1960&r1=1959&r2=1960&view=diff
==============================================================================
--- trunk/lib/result.h (original)
+++ trunk/lib/result.h Mon Dec  3 11:49:57 2007
@@ -124,12 +124,7 @@
                        return Row(row, this, lengths, throw_exceptions());
                }
                else {
-                       if (throw_exceptions()) {
-                               throw EndOfResults();
-                       }
-                       else {
-                               return Row();
-                       }
+                       return Row();
                }
        }
 

Modified: trunk/mysql++.bkl
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/mysql%2B%2B.bkl?rev=1960&r1=1959&r2=1960&view=diff
==============================================================================
--- trunk/mysql++.bkl (original)
+++ trunk/mysql++.bkl Mon Dec  3 11:49:57 2007
@@ -280,9 +280,6 @@
                <exe id="transaction" template="libexcommon-user,programs">
                        <sources>examples/transaction.cpp</sources>
                </exe>
-               <exe id="usequery" template="libexcommon-user,programs">
-                       <sources>examples/usequery.cpp</sources>
-               </exe>
        </if>   <!-- build examples -->
 
        <if cond="FORMAT=='autoconf'">


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

Reply via email to