On Tue, Jun 22, 2010 at 10:13 AM, Pavel Ivanov <paiva...@gmail.com> wrote:

> > No, I did not.  I am not storing any blobs right now, but...  Is the busy
> > handler going to kick in?  I know the busy handler is not the sole answer
> to
> > the problem, but it does seem to catch most of my SQLITE_BUSY issues
> since
> > all data is pretty small.
>
> No, this SQLITE_BUSY result is not related to database locking and so
> busy handler is not called. You can force connection closing in case
> of SQLITE_BUSY result by forcible finalizing of all statements. Use
> http://www.sqlite.org/c3ref/next_stmt.html for iterating all
> statements and sqlite3_finalize on each of them. After that
> sqlite3_close should complete successfully.
>

Pavel,

So would you agree with this as a solution to deal with the close being
busy:

void CSQLiteDB::Close()
{
    if(m_db)
    {
        sqlite3 *db = m_db;
        m_db = NULL;
        int rc = sqlite3_close(db);

        while( rc == SQLITE_BUSY)
        {
            // set rc to something that will exit the while loop
            rc = SQLITE_OK;
            sqlite3_stmt * stmt = sqlite3_next_stmt(db, NULL);

            if(stmt != NULL)
            {
                rc = sqlite3_finalize(stmt);
                if(rc == SQLITE_OK)
                {
                    rc = sqlite3_close(db);
                }
            }
        }
    }
}

Sam
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to