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 » Overflow error in bool Sql::Fetch()
Overflow error in bool Sql::Fetch() [message #14083] Sat, 09 February 2008 15:01 Go to next message
zsolt is currently offline  zsolt
Messages: 698
Registered: December 2005
Location: Budapest, Hungary
Contributor
SQL apps, running on a PC booted weeks ago start dumping a lot of SQL logfiles.
The problem is, that session.traceslow is a very big number and result of this GetTickCount() arithmetic overflows. It is not a good idea to compare TickCount values.
The current code:
bool Sql::Fetch() {
	SqlSession& session = GetSession();
	session.PassStatus(ActivityStatus::FETCHING);
	int t0 = GetTickCount();
	bool b = cn->Fetch();
	int t = GetTickCount();
	if(!b) {
		session.GetStatus().Time(t - cn->starttime);
		session.PassStatus(ActivityStatus::END_FETCHING);
	}
	if(t - session.traceslow > cn->starttime)
		BugLog() << t - cn->starttime << " ms: " << cn->statement << '\n';
	else
	if(t - t0 > session.traceslow)
		BugLog() << t - t0 << " ms further fetch: " << cn->statement << '\n';
	cn->starttime = INT_MAX;
	return b;
}

should be patched:
bool Sql::Fetch() {
	SqlSession& session = GetSession();
	session.PassStatus(ActivityStatus::FETCHING);
	int t0 = GetTickCount();
	bool b = cn->Fetch();
	int t = GetTickCount();
	if(!b) {
		session.GetStatus().Time(t - cn->starttime);
		session.PassStatus(ActivityStatus::END_FETCHING);
	}
	if(t - session.traceslow - cn->starttime > 0)
		BugLog() << t - cn->starttime << " ms: " << cn->statement << '\n';
	else
	if(t - t0 - session.traceslow > 0)
		BugLog() << t - t0 << " ms further fetch: " << cn->statement << '\n';
	cn->starttime = INT_MAX;
	return b;
}
Re: Overflow error in bool Sql::Fetch() [message #14091 is a reply to message #14083] Sun, 10 February 2008 22:13 Go to previous message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
Indeed, thanks, applied.

Mirek
Previous Topic: error in example/SQLApp [FIXED]
Next Topic: updating/discarding table data on dialogs...
Goto Forum:
  


Current Time: Fri Jun 07 22:23:24 CEST 2024

Total time taken to generate the page: 0.02387 seconds