Author: wyoung
Date: Mon Jul 16 21:00:12 2007
New Revision: 1703

URL: http://svn.gna.org/viewcvs/mysqlpp?rev=1703&view=rev
Log:
- Fixed single-parameter template query when using SQLQueryParms.
  Just a matter of preventing one unwanted re-entrance.
- Renamed examples/tquery.cpp to tquery1.cpp
- Created examples/tquery2.cpp to demonstrate new code
- Updated dtest to run new example

Added:
    trunk/examples/tquery1.cpp
      - copied, changed from r1696, trunk/examples/tquery.cpp
    trunk/examples/tquery2.cpp
Removed:
    trunk/examples/tquery.cpp
Modified:
    trunk/Wishlist
    trunk/bmark.txt   (contents, props changed)
    trunk/doc/userman/Makefile
    trunk/doc/userman/userman.dbx
    trunk/dtest
    trunk/lib/query.cpp
    trunk/mysql++.bkl

Modified: trunk/Wishlist
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/Wishlist?rev=1703&r1=1702&r2=1703&view=diff
==============================================================================
--- trunk/Wishlist (original)
+++ trunk/Wishlist Mon Jul 16 21:00:12 2007
@@ -12,8 +12,6 @@
     The items in this section are those things we definitely want to
     get done in v3.0.  Most of them break the ABI, so they can't wait
     for a future version, because v4 could be years out.
-
-    o Fix single-parameter template query stuff.
 
     o Add conditional code to the Lockable mechanism to use platform
       mutexes if available, to implement these MySQL C API

Modified: trunk/bmark.txt
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/bmark.txt?rev=1703&r1=1702&r2=1703&view=diff
==============================================================================
Binary files - no diff available.

Propchange: trunk/bmark.txt
------------------------------------------------------------------------------
--- svn:mime-type (original)
+++ svn:mime-type (removed)
@@ -1,1 +1,0 @@
-application/octet-stream

Modified: trunk/doc/userman/Makefile
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/doc/userman/Makefile?rev=1703&r1=1702&r2=1703&view=diff
==============================================================================
--- trunk/doc/userman/Makefile (original)
+++ trunk/doc/userman/Makefile Mon Jul 16 21:00:12 2007
@@ -20,7 +20,7 @@
 EX_TXT=cgi_jpeg.txt custom1.txt custom2.txt custom3.txt custom4.txt \
                custom5.txt custom6.txt fieldinf1.txt for_each.txt 
load_jpeg.txt \
                resetdb.txt simple1.txt simple2.txt simple3.txt stock.txt \
-               store_if.txt tquery.txt xaction.txt
+               store_if.txt tquery1.txt xaction.txt
 
 
 ## ------------------------

Modified: trunk/doc/userman/userman.dbx
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/doc/userman/userman.dbx?rev=1703&r1=1702&r2=1703&view=diff
==============================================================================
--- trunk/doc/userman/userman.dbx (original)
+++ trunk/doc/userman/userman.dbx Mon Jul 16 21:00:12 2007
@@ -1039,9 +1039,9 @@
     those placeholders.</para>
 
     <para>The following program demonstrates how to use this
-    feature. This is <filename>examples/tquery.cpp</filename>:</para>
-
-    <programlisting><xi:include href="tquery.txt" parse="text" 
+    feature. This is <filename>examples/tquery1.cpp</filename>:</para>
+
+    <programlisting><xi:include href="tquery1.txt" parse="text" 
     xmlns:xi="http://www.w3.org/2001/XInclude"/></programlisting>
 
     <para>The line just before the call to

Modified: trunk/dtest
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/dtest?rev=1703&r1=1702&r2=1703&view=diff
==============================================================================
--- trunk/dtest (original)
+++ trunk/dtest Mon Jul 16 21:00:12 2007
@@ -6,8 +6,8 @@
 # after the examples that change the database in a way that will cause
 # subsequent examples to fail because data they need isn't present.
 for t in resetdb simple1 simple2 simple3 store_if for_each \
-       multiquery tquery resetdb usequery custom1 custom2 custom3 custom4 \
-       custom5 custom6
+       multiquery tquery1 resetdb tquery2 resetdb usequery \
+       custom1 custom2 custom3 custom4 custom5 custom6
 do
        if [ -x $t ]
        then

Removed: trunk/examples/tquery.cpp
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/examples/tquery.cpp?rev=1702&view=auto
==============================================================================
--- trunk/examples/tquery.cpp (original)
+++ trunk/examples/tquery.cpp (removed)
@@ -1,88 +1,0 @@
-/***********************************************************************
- tquery.cpp - Example similar to custom3.cpp, except that it uses
-       template queries instead of SSQLS.
-
- Copyright (c) 1998 by Kevin Atkinson, (c) 1999, 2000 and 2001 by
- MySQL AB, and (c) 2004-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 "util.h"
-
-#include <iostream>
-
-using namespace std;
-
-int
-main(int argc, char *argv[])
-{
-       try {
-               // Establish the connection to the database server.
-               mysqlpp::Connection con(mysqlpp::use_exceptions);
-               if (!connect_to_db(argc, argv, con)) {
-                       return 1;
-               }
-
-               // Build a template query to retrieve a stock item given by
-               // item name.
-               mysqlpp::Query query = con.query();
-               query << "select * from stock where item = %0q";
-               query.parse();
-
-               // Retrieve an item added by resetdb; it won't be there if
-               // tquery or custom3 is run since resetdb.
-               mysqlpp::Result res1 = query.store("Nürnberger Brats");
-               if (res1.empty()) {
-                       throw mysqlpp::BadQuery("UTF-8 bratwurst item not found 
in "
-                                       "table, run resetdb");
-               }
-
-               // Replace the proper German name with a 7-bit ASCII
-               // approximation using a different template query.
-               query.reset();
-               query << "update stock set item = %0q where item = %1q";
-               query.parse();
-               mysqlpp::ResNSel res2 = query.execute("Nuerenberger Bratwurst",
-                               res1[0][0].c_str());
-
-               // Print the new table contents.
-               print_stock_table(query);
-       }
-       catch (const mysqlpp::BadQuery& er) {
-               // Handle any query errors
-               cerr << "Query error: " << er.what() << endl;
-               return -1;
-       }
-       catch (const mysqlpp::BadConversion& er) {
-               // Handle bad conversions
-               cerr << "Conversion error: " << er.what() << endl <<
-                               "\tretrieved data size: " << er.retrieved <<
-                               ", actual size: " << er.actual_size << endl;
-               return -1;
-       }
-       catch (const mysqlpp::Exception& er) {
-               // Catch-all for any other MySQL++ exceptions
-               cerr << "Error: " << er.what() << endl;
-               return -1;
-       }
-
-       return 0;
-}

Copied: trunk/examples/tquery1.cpp (from r1696, trunk/examples/tquery.cpp)
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/examples/tquery1.cpp?p2=trunk/examples/tquery1.cpp&p1=trunk/examples/tquery.cpp&r1=1696&r2=1703&rev=1703&view=diff
==============================================================================
--- trunk/examples/tquery.cpp (original)
+++ trunk/examples/tquery1.cpp Mon Jul 16 21:00:12 2007
@@ -1,5 +1,5 @@
 /***********************************************************************
- tquery.cpp - Example similar to custom3.cpp, except that it uses
+ tquery1.cpp - Example similar to custom3.cpp, except that it uses
        template queries instead of SSQLS.
 
  Copyright (c) 1998 by Kevin Atkinson, (c) 1999, 2000 and 2001 by
@@ -48,7 +48,7 @@
                query.parse();
 
                // Retrieve an item added by resetdb; it won't be there if
-               // tquery or custom3 is run since resetdb.
+               // tquery* or custom3 is run since resetdb.
                mysqlpp::Result res1 = query.store("Nürnberger Brats");
                if (res1.empty()) {
                        throw mysqlpp::BadQuery("UTF-8 bratwurst item not found 
in "

Added: trunk/examples/tquery2.cpp
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/examples/tquery2.cpp?rev=1703&view=auto
==============================================================================
--- trunk/examples/tquery2.cpp (added)
+++ trunk/examples/tquery2.cpp Mon Jul 16 21:00:12 2007
@@ -1,0 +1,94 @@
+/***********************************************************************
+ tquery2.cpp - Same as tquery1.cpp, except that it passes the template
+    query parameters in a SQLQueryParms object, instead of separately.
+       This is useful when the calling code doesn't know in advance how
+       many parameters there will be.  This is most likely because the
+       templates are coming from somewhere else, or being generated.
+
+ Copyright (c) 1998 by Kevin Atkinson, (c) 1999, 2000 and 2001 by
+ MySQL AB, and (c) 2004-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 "util.h"
+
+#include <iostream>
+
+using namespace std;
+
+int
+main(int argc, char *argv[])
+{
+       try {
+               // Establish the connection to the database server.
+               mysqlpp::Connection con(mysqlpp::use_exceptions);
+               if (!connect_to_db(argc, argv, con)) {
+                       return 1;
+               }
+
+               // Build a template query to retrieve a stock item given by
+               // item name.
+               mysqlpp::Query query = con.query();
+               query << "select * from stock where item = %0q";
+               query.parse();
+
+               // Retrieve an item added by resetdb; it won't be there if
+               // tquery* or custom3 is run since resetdb.
+               mysqlpp::SQLQueryParms sqp;
+               sqp << "Nürnberger Brats";
+               mysqlpp::Result res1 = query.store(sqp);
+               if (res1.empty()) {
+                       throw mysqlpp::BadQuery("UTF-8 bratwurst item not found 
in "
+                                       "table, run resetdb");
+               }
+
+               // Replace the proper German name with a 7-bit ASCII
+               // approximation using a different template query.
+               query.reset();
+               query << "update stock set item = %0q where item = %1q";
+               query.parse();
+               sqp.clear();
+               sqp << "Nuerenberger Bratwurst" << res1[0][0].c_str();
+               mysqlpp::ResNSel res2 = query.execute(sqp);
+
+               // Print the new table contents.
+               print_stock_table(query);
+       }
+       catch (const mysqlpp::BadQuery& er) {
+               // Handle any query errors
+               cerr << "Query error: " << er.what() << endl;
+               return -1;
+       }
+       catch (const mysqlpp::BadConversion& er) {
+               // Handle bad conversions
+               cerr << "Conversion error: " << er.what() << endl <<
+                               "\tretrieved data size: " << er.retrieved <<
+                               ", actual size: " << er.actual_size << endl;
+               return -1;
+       }
+       catch (const mysqlpp::Exception& er) {
+               // Catch-all for any other MySQL++ exceptions
+               cerr << "Error: " << er.what() << endl;
+               return -1;
+       }
+
+       return 0;
+}

Modified: trunk/lib/query.cpp
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/lib/query.cpp?rev=1703&r1=1702&r2=1703&view=diff
==============================================================================
--- trunk/lib/query.cpp (original)
+++ trunk/lib/query.cpp Mon Jul 16 21:00:12 2007
@@ -101,6 +101,7 @@
 ResNSel
 Query::execute(SQLQueryParms& p)
 {
+       AutoFlag<> af(template_defaults.processing_);
        return execute(str(p));
 }
 
@@ -389,6 +390,7 @@
 Result
 Query::store(SQLQueryParms& p)
 {
+       AutoFlag<> af(template_defaults.processing_);
        return store(str(p));
 }
 
@@ -530,6 +532,7 @@
 ResUse
 Query::use(SQLQueryParms& p)
 {
+       AutoFlag<> af(template_defaults.processing_);
        return use(str(p));
 }
 

Modified: trunk/mysql++.bkl
URL: 
http://svn.gna.org/viewcvs/mysqlpp/trunk/mysql%2B%2B.bkl?rev=1703&r1=1702&r2=1703&view=diff
==============================================================================
--- trunk/mysql++.bkl (original)
+++ trunk/mysql++.bkl Mon Jul 16 21:00:12 2007
@@ -208,8 +208,11 @@
                <exe id="multiquery" template="libutil-user,examples">
                        <sources>examples/multiquery.cpp</sources>
                </exe>
-               <exe id="tquery" template="libutil-user,examples">
-                       <sources>examples/tquery.cpp</sources>
+               <exe id="tquery1" template="libutil-user,examples">
+                       <sources>examples/tquery1.cpp</sources>
+               </exe>
+               <exe id="tquery2" template="libutil-user,examples">
+                       <sources>examples/tquery2.cpp</sources>
                </exe>
                <exe id="usequery" template="libutil-user,examples">
                        <sources>examples/usequery.cpp</sources>


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

Reply via email to