On Fri, Dec 13, 2013 at 1:18 PM, Nelson, Erik - 2 <
[email protected]> wrote:

> In my app that embeds sqlite version 3.7.14, I'm running into a database
> locking problem that happens when detaching a database.  If I execute
>
> attach database 'file:dbtest.db?mode=ro' as prism
>
> the attachment happens okay, but when I execute
>
> detach database prism
>
> I get the error 'database prism is locked'
>
> I assumed that this is a duplicate of the question at
>
> http://goo.gl/k3raLi
>
> http://stackoverflow.com/questions/15531498/sqlite-why-cant-i-detach-a-database-when-the-main-db-has-an-open-statement
>
> but I'm having trouble finding the statement in question... I'm tracking
> all my calls to sqlite3_prepare_v2() and sqlite3_finalize() and it seems
> like the all prepared statements are being finalized.  I'm not using any
> explicit transactions or sqlite3_blobs, and the app is single threaded.
>
> I looked through the transaction page at
> http://www.sqlite.org/lang_transaction.html and didn't see anything
> obvious that I'm tripping on.
>
> Is there some way to find out what is causing the lock?  I've looked
> through the C interface documentation and didn't notice anything promising.
>  If I could find the statement that's causing the lock that would be most
> helpful, if that's the problem.  Or maybe there's something else it could
> be?  Any suggestions would be welcome.
>


The first thing I would do is use the sqlite3_next_stmt() interface (
http://www.sqlite.org/c3ref/next_stmt.html) to double-check that there were
no unreset and unfinalized prepared statements.


-- 
D. Richard Hipp
[email protected]
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to