Mark Anderson wrote:
i = querystr.GetLength();
querystr2 = (char *) malloc (i);
querystr2 = querystr.GetBuffer (i);
sqlite3_exec (db, querystr2, NULL, 0, NULL);
You are leaking memory here.
Well I'm not leaking memory as I clean up at the end of the function,
I only pasted the relevate bits.
You can't possibly clean up with the code the way it is. You allocate
some memory with malloc and store the pointer in querystr2. On the very
next line, you overwrite it with a different pointer. The pointer
returned from malloc is irretrievably lost, there is no way for you to
call free() on it. The allocated memory is thus necessarily leaked.
The sqlite3_exec() call returns with a value of 5 (SQLITE_BUSY).
SQLITE_BUSY means that some other process or thread is already
running a query against the same database. Look at
sqlite_busy_handler and sqlite_busy_timeout.
Yes I know this, but perhaps I should have said that there aren't two
processes or threads querying the same database. This is happening in
a simple
one-thread command line program.
Perhaps you have outstanding 'select' statements still running. Make
sure that all prepared statements are either finalized (sqlite_finalize)
or reset (sqlite_reset) when you are done stepping through the
resultset. You won't be able to modify the database while there is a
select in progress.
Igor Tandetnik