List:MySQL++« Previous MessageNext Message »
From:Daniel Rivin Date:June 27 2008 5:53pm
Subject:RE: Query::storein does not throw exception correctly
View as plain text  
I've discovered the issue, which came from improperly combining two
examples in my own code.  The first example I ran was the non-SSQLS way
to obtain a query result which began:

mysqlpp::Connection conn(false);
if (! conn.connect(db, server, user, pass)) {
	cerr << "DB connection failed: " << conn.error() << endl;
	return 1;
}
mysqlpp::Query query = conn.query("select * from <table_name>");
mysqlpp::StoreQueryResult res = query.store();
...

I then switched to SSQLSes and modified the last line to
vector<<table_name>> result;
query.storein(result);

At the same time I switched to using exceptions and wrapped the code in
try/catch.

Looking closer at the ssqls1 example, I noticed the connection was
established entirely using the constructor, rather than initting to
false and calling connect.  That "false" passed in is quite important,
it turns out, as it modifies the framework throwing exceptions on/off.
This is a bit unclear when reading through the user manual, as sections
2.1, 2.4, and 3.5 don't mention directly that the connection object's
constructor is responsible for toggling exception throwing.  I looked
through the code a bit and found this out quickly once I realized the
culprit.  

I actually just found the reference to the parameter "te" in the refman,
section 5.10.2.1, so the documentation does exist, but it might help to
also include this in the examples as well.

Thanks again,
Dan

-----Original Message-----
From: Warren Young [mailto:mysqlpp@stripped] 
Sent: Thursday, June 26, 2008 9:06 PM
To: MySQL++ Mailing List
Subject: Re: Query::storein does not throw exception correctly

Daniel Rivin wrote:
> 
> there are any misspellings in the SQL statement (table name, SQL
> keywords, etc.) used for the query, an unhandled exception is thrown
in
> mysql++.  I've traced it to the UseQueryResult::fetch_raw_row()
function
> in result.cpp, where driver_ looks to be NULL.  I'm using source
version
> 3.0.3.

I think you've misdiagnosed the problem.

If driver_ is 0, it means you didn't connect to the database
successfully.

Coming at it from the other side, I modified examples/ssqls1.cpp, 
dropping an 'x' in at the end of the query string, and got this message:

	Query error: Table 'mysql_cpp_data.stockx' doesn't exist

That indicates that the query error is being detected correctly and 
throwing the right exception.

Try to modify one of the examples to show your symptom, or boil your 
code down to something very short that shows the symptom using the 
sample database.

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

Thread
Query::storein does not throw exception correctlyDaniel Rivin27 Jun
  • Re: Query::storein does not throw exception correctlyWarren Young27 Jun
    • RE: Query::storein does not throw exception correctlyDaniel Rivin27 Jun
      • Re: Query::storein does not throw exception correctlyWarren Young30 Jun