Sqlite DatabaseLayer problem with Vc++ 6.0

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
Post Reply
gururamnath
Super wx Problem Solver
Super wx Problem Solver
Posts: 466
Joined: Sat Sep 18, 2004 2:49 am
Location: California, USA

Sqlite DatabaseLayer problem with Vc++ 6.0

Post by gururamnath »

In the function
PreparedStatement* SqliteDatabaseLayer::PrepareStatement(const wxString& strQuery)

the while statement (for ansi) is having some problem.

In Vc++ 6.0 the wxStrlen(szTail) > 0 is not evaluated to 0 if the szTail is an empty string(after we process a single line query once) .

Before the while I just add the following line and it is working for the time being.

Code: Select all

wxString strTail = szTail;
if (strTail.Length() < 1)
   break;
Please add necessary fix for this problem so that it can be compiled with Vc++ 6.0.

A new feature request : Is it possible to add Column information like Column Name, type and Size in the future release ?

Thanks,
Guru Kathiresan
jb_coder
Super wx Problem Solver
Super wx Problem Solver
Posts: 267
Joined: Mon Oct 18, 2004 10:55 am

Post by jb_coder »

Is this a compile time or runtime problem? The environments that I try to compile (and run unit tests) on before making releases are

Linux unicode and ansi
VC6 ansi
VC2003 unicode and ansi

If this is a runtime problem, can you provide a sample SQL statement to test this with please? I'd like to add a unit test so that the problem doesn't come back as a regression.


Eventually I would like to add something like the JDBC ResultSetMetaData and DatabaseMetaData interfaces which would most likely be the answer to your feature request. Unfortunately, I still have more bugs to hammer out of the existing feature set before adding more features.
toxicBunny
Super wx Problem Solver
Super wx Problem Solver
Posts: 424
Joined: Tue Jul 12, 2005 8:44 pm
Location: Alabama, USA

Post by toxicBunny »

I found the issue with the szTail variable. Because of the following calls

Code: Select all

wxCharBuffer sqlBuffer = ConvertToUnicodeStream(strSQL);
int nReturn = sqlite3_prepare(m_pDatabase, sqlBuffer, -1, &pStatement, &szTail);
szTail is left pointing to a position in the sqlBuffer variable, which goes out of scope at the end of the do loop where the length is evaluated. It appears that the length of szTail is not being evaluated correctly, but the data it's pointing to changes before the evaluation actually occurs. szTail is then left pointing to random data in memory that does not have a length of zero.

I think the correct fix is to move the declaration of the sqlBuffer outside of the do loop so that it remains in scope.

I tried to create a patch for this, but I can't seem to access the wxCode CVS server at the moment. I'll try to do it later today.

-Scott
jb_coder
Super wx Problem Solver
Super wx Problem Solver
Posts: 267
Joined: Mon Oct 18, 2004 10:55 am

Post by jb_coder »

The change which moves the declaration of sqlBuffer outside of the loop has been committed. I'm still trying to put together a unit test to verify the error though.
Post Reply