Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » SQLite crashes
Re: SQLite crashes [message #16966 is a reply to message #16965] Wed, 23 July 2008 19:04 Go to previous message
mirek is currently offline  mirek
Messages: 13978
Registered: November 2005
Ultimate Member
Mindtraveller wrote on Wed, 23 July 2008 12:31

OK, I switched to MySQL from SQLite and have the same error.

Usually one checks Execute() before doing Fetch:
MySqlSession session;
String q = ".....";
if (!session.Connect(...))
	return;
Sql sql(session);
if (sql.Execute(q))
	while(sql.Fetch())
	{
		for (int i=0; i<sql.GetColumns(); ++i)
			ShowDBMessage(sql.GetColumnInfo(i).name + " : " + (String)sql[i]);
	}

But if you forget to check Execute() and start fetching, the Fetch() call will throw an exception:
sql.Execute(q);
while(sql.Fetch()) //<-- throws an exception if Execute() failed
{
	for (int i=0; i<sql.GetColumns(); ++i)
		ShowDBMessage(sql.GetColumnInfo(i).name + " : " + (String)sql[i]);
}


I think Fetch() should not throw an exception, instead it should return no results if latest Execute() failed.


Ah, this one. It is there since beginning and U++ being started as database interface library, it is perhaps the right thing to do.

Imagine impact if Fetch would actually return false. In that case, a lot of code would do wrong things and pretend everything is OK....

Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Difference between INT_ and INT?
Next Topic: underflow in bool Sql::fetch()
Goto Forum:
  


Current Time: Sun May 12 19:08:05 CEST 2024

Total time taken to generate the page: 0.02691 seconds