List:MySQL++« Previous MessageNext Message »
From:Dale Stewart Date:January 28 2009 3:59pm
Subject:RE: Question about BadQuery
View as plain text  
I just realized, that particular implementation is not thread safe, but
if you need that you could, in a protected way, append the query string
to a list or log it.  Also using:

#define Query MyQuery

... would reduce the pain of having it change everywhere.  This could be
part of a debug build definition only, or not depending on your
preferences.

I suppose you could even catch and re-throw BadQuery exceptions in an
override of the store() method, and only log the query strings there, to
eliminate the noise of logging every query.

-----Original Message-----
From: Dale Stewart 
Sent: Wednesday, January 28, 2009 9:46 AM
To: plusplus@stripped
Subject: RE: Question about BadQuery

You could derive a class from Query, i.e. MyQuery, add a static member
such as last_query (and possibly an accessor for it), override the
members you want to record it, and have them save the query and call the
base class.  That would eliminate the need to modify the library.  Don't
know if that reduces the impact significantly enough or not, but thought
I'd mention it.

-----Original Message-----
From: Jim Wallace [mailto:jwallace@stripped] 
Sent: Wednesday, January 28, 2009 7:16 AM
To: plusplus@stripped
Subject: RE: Question about BadQuery

I do that exact same thing elsewhere and was thinking the about doing it
in for the query to avoid getting my MySQL++ code out-of-sync.  However,
it does require the extra str() and quite a bit of code changes to do
that.  I'm going to look at when BadQuery is thrown and if it's easy to
put in the completed query I'll do that.

Thanks.

-----Original Message-----
From: Warren Young [mailto:mysqlpp@stripped] 
Sent: Tuesday, January 27, 2009 11:45 PM
To: Jim Wallace
Subject: Re: Question about BadQuery

Jim Wallace wrote:
> if I have multiple statements in a try/catch I could figure out
> which one caused the exception.

A way you could get by without it:

string last_query;
try {
	Query q("stuff");
	last_query = q.str();
	StoreQueryResult res = q.store();
	// do something with res

	q = "other stuff";
	last_query = q.str();
	res = q.store();
	// do more stuff

	...
}
catch (const BadQuery& e) {
	cerr << "Query failed: \"" << last_query << "\"" << endl;
}


-- 
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe:
http://lists.mysql.com/plusplus?unsub=1
m




-- 
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe:
http://lists.mysql.com/plusplus?unsub=1
m



Thread
RELEASE: v3.0.5Warren Young7 Aug
  • query.str() in template query -- help!Jim Wallace28 Jan
    • RE: query.str() in template query -- <blush>Jim Wallace28 Jan
      • Re: query.str() in template query -- <blush>Warren Young28 Jan
        • storein with parametersJim Wallace28 Jan
          • Re: storein with parametersWarren Young28 Jan
            • RE: storein with parametersJim Wallace28 Jan
              • Re: storein with parametersWarren Young28 Jan
            • Question about BadQueryJim Wallace28 Jan
              • Re: Question about BadQueryWarren Young28 Jan
RE: RELEASE: v3.0.5Bernard8 Aug
  • Re: RELEASE: v3.0.5Warren Young8 Aug
    • Re: RELEASE: v3.0.5Alex9 Aug
RE: Question about BadQueryJim Wallace28 Jan
RE: Question about BadQueryDale Stewart28 Jan
RE: Question about BadQueryDale Stewart28 Jan
  • Re: Question about BadQueryWarren Young28 Jan