Page 1 of 1

Bug in SQLite-Lib

Posted: Fri Apr 02, 2004 7:00 pm
by freedimension
Help!!!
I'm using El Chonis sqlite-lib together with the sqlite.dll v.2.8.13
In this constellation it constantly refuses to close a database before opening a new one.
I've done an abbreviated version for testing purposes:

Code: Select all

InitSQLite()
DBName.s = "test.db"

DBHandle = SQLiteOpen(DBName)
Debug SQLiteClose()

DBHandle = SQLiteOpen(DBName)
Debug SQLiteError(SQLiteExec("CREATE TABLE test (a, b)"))

Posted: Fri Apr 02, 2004 8:04 pm
by El_Choni
Works fine here. I'll download 2.8.13 just to check this, thanks for reporting.

EDIT: SQLiteClose() returns 0, it's normal and doesn't mean it failed.

Posted: Mon May 03, 2004 3:28 pm
by freedimension
I played around a little and came to the conclusion that the problem isn't the closing of the DB but the use of the same DB_Index in subsequent calls to SQLiteOpen().
So a nice work around for my project is to increment the used DB_Index each time SQLiteOpen is called.

Otherwise the following code

Code: Select all

InitSQLite()
DBName.s = "test.db"
DBHandle = SQLiteOpen(1, DBName)
Debug SQLiteError(SQLiteGetTable("SELECT * FROM test"))
SQLiteClose(1)
DBHandle = SQLiteOpen(1, DBName)
Debug SQLiteError(SQLiteGetTable("SELECT * FROM test"))
End
returns
not an error
library routine called out of sequence
while the first debug is ok, the second is just queer.

This one though does the trick:

Code: Select all

InitSQLite()
DBName.s = "test.db"
DBHandle = SQLiteOpen(1, DBName)
Debug SQLiteError(SQLiteGetTable("SELECT * FROM test"))
SQLiteClose(1)
DBHandle = SQLiteOpen(2, DBName)
Debug SQLiteError(SQLiteGetTable("SELECT * FROM test"))
End

Posted: Mon May 03, 2004 4:03 pm
by El_Choni
Yep, bug. It's fixed in next version.

Posted: Mon May 03, 2004 5:09 pm
by freedimension
I wanted you to know that I've found a way around, so it's ok for me if you need a little bit longer. So you don't have to have a bad conscience :D