List:MySQL++« Previous MessageNext Message »
From:Michael Hanselmann Date:March 25 2007 12:31am
Subject:Conceptual issue in mysql++ 2.2.x (use(), store(), execute())
View as plain text  
Hello

Starting with 2.2.x, mysql++ contains more variants of the use(),
store() and execute() functions. One of these takes a single parameter
of "const SQLString&". If there's only one parameter defined it takes
that parameter as a lone parameter for a template query. The same
function is used for the "SQLQueryParams&" variant. This creates a
conflict where a template uses only one parameter. In that case, the
logic doesn't work at all and the generated queries are unusable.

The attached patch fixes this issue by not allowing a single query
parameter to be passed directly to the function. It shouldn't break
binary compatibility. For the next minor or major update, "bool
processing_" can be removed from SQLQueryParms.

Greets,
Michael

-- 
Gentoo Linux developer, http://hansmi.ch/, http://forkbomb.ch/

diff -ru mysql++-2.2.1.orig/lib/query.cpp mysql++-2.2.1/lib/query.cpp
--- mysql++-2.2.1.orig/lib/query.cpp	2007-02-28 15:51:27.000000000 +0100
+++ mysql++-2.2.1/lib/query.cpp	2007-03-25 00:57:42.000000000 +0100
@@ -108,18 +108,7 @@
 ResNSel
 Query::execute(const SQLString& str)
 {
-	if ((def.size() == 1) && !def.processing_) {
-		// Take str to be a lone parameter for a template query.  The
-		// auto-reset flag is required because we'll end up back in this
-		// function once the query string is built, but we need to take
-		// the 'else' path to avoid an infinite loop.
-		AutoFlag<> af(def.processing_);
-		return execute(SQLQueryParms() << str);
-	}
-	else {
-		// Take str to be the entire query string
-		return execute(str.c_str(), str.length());
-	}
+	return execute(str.c_str(), str.length());
 }
 
 
@@ -406,18 +395,7 @@
 Result 
 Query::store(const SQLString& str)
 {
-	if ((def.size() == 1) && !def.processing_) {
-		// Take str to be a lone parameter for a template query.  The
-		// auto-reset flag is required because we'll end up back in this
-		// function once the query string is built, but we need to take
-		// the 'else' path to avoid an infinite loop.
-		AutoFlag<> af(def.processing_);
-		return store(SQLQueryParms() << str);
-	}
-	else {
-		// Take str to be the entire query string
-		return store(str.c_str(), str.length());
-	}
+	return store(str.c_str(), str.length());
 }
 
 
@@ -576,18 +554,7 @@
 ResUse
 Query::use(const SQLString& str)
 {
-	if ((def.size() == 1) && !def.processing_) {
-		// Take str to be a lone parameter for a template query.  The
-		// auto-reset flag is required because we'll end up back in this
-		// function once the query string is built, but we need to take
-		// the 'else' path to avoid an infinite loop.
-		AutoFlag<> af(def.processing_);
-		return use(SQLQueryParms() << str);
-	}
-	else {
-		// Take str to be the entire query string
-		return use(str.c_str(), str.length());
-	}
+	return use(str.c_str(), str.length());
 }
 
 

Attachment: [application/pgp-signature]
Thread
Conceptual issue in mysql++ 2.2.x (use(), store(), execute())Michael Hanselmann25 Mar
  • Re: Conceptual issue in mysql++ 2.2.x (use(), store(), execute())Warren Young26 Mar
    • Re: Conceptual issue in mysql++ 2.2.x (use(), store(), execute())Michael Hanselmann26 Mar
      • Re: Conceptual issue in mysql++ 2.2.x (use(), store(), execute())Warren Young28 Mar
        • Re: Conceptual issue in mysql++ 2.2.x (use(), store(), execute())Warren Young28 Mar
        • Re: Conceptual issue in mysql++ 2.2.x (use(), store(), execute())Michael Hanselmann31 Mar
          • Re: Conceptual issue in mysql++ 2.2.x (use(), store(), execute())Warren Young2 Apr
            • Re: Conceptual issue in mysql++ 2.2.x (use(), store(), execute())Michael Hanselmann2 Apr
              • Re: Conceptual issue in mysql++ 2.2.x (use(), store(), execute())Warren Young3 Apr
                • Re: Conceptual issue in mysql++ 2.2.x (use(), store(), execute())Michael Hanselmann4 Apr
Re: Conceptual issue in mysql++ 2.2.x (use(), store(), execute())Warren Young29 Mar