You don't test for an error on your close statement. I suspect that the Sqlite databases are not being closed because activity is not finalized. Your error pops up when you have a very large number of databases open.
JS

Costas Stergiou wrote:
Hello everyone,

I lately came upon a very strange error that occurs at random times. I
managed to trace down and produce a small piece of code to reproduce it.

I am using Delphi and the sqlite3.dll (latest) but I am sure that this error
is not related to something other than the engine. Here is a code that
produces this error (read almost like pseudo-code):

var

  i, j: Integer;

  s: String;

  db: pointer;

  MSG: pchar;

begin

  for i:=1 to 30 do begin

    s := 'testsqlite3_' + inttostr(i) + '.db3';

    deletefile(s);

  end;

  for i:=1 to 30 do begin

    s := 'testsqlite3_' + inttostr(i) + '.db3';

    sqlite3_open(pchar(s), db);

    //sql_exec(db, 'PRAGMA synchronous = off;');

    Assert( sqlite3_exec(db, pchar('create table t1(i1 int, i2 int)'), nil,
nil, msg) = SQLITE_OK );

    Assert( sqlite3_exec(db, pchar('create table t2(i1 int, i2 int)'), nil,
nil, msg) = SQLITE_OK );

    sqlite3_close(db);

  end;

end;

What I am doing here is just creating 20 test databases and creating 2
tables in each one of these. That's all.

To repeat this error, the code above may need to be repeated some times
(some time it gives the error, some other it doesn't). Between invocations
of the code it would be good to wait 1 second (I put it on a form and
associate it with a button; then I press the button repeatedly until I get
the error, usually in 2-3 clicks).

Now, if I uncomment the "PRAGMA synchronous=off" command, the error goes
away!

Also, if I remove the second create table command, I have no problem again
(the problem is not associated with the 'create table command' actually).

Any help or insight on the above will be very valuable since I am completely
stack with it.

Thanks,

Costas

Reply via email to