SQLite Forum

table locked when dropping a temp table
Login
The locked table is a separate and different problem, and is not a peculiarity of SQLite.

That is to say: There is something going on with your code in the process leading up to the locked table that is not clear to us, and very hard to guess at.  Put another way - If everything was done right, that should never happen - which leaves us only with the question of what exactly was done wrong?  This is not easy to tell from the post. I suppose a process breakdown and some actual code might help.

Best we can do is to tell you this: Some of the typical reasons why a table would be locked in a way that you cannot WRITE to it, are:

- because the database prepared some statement that intends to WRITE to that table (in the case of WAL journaling) or
- a read-transaction is in progress (non-WAL), or
- an immediate transaction was started or
- some command is complete (has run its course) but the statement is not yet finalized.

These may not cover ALL reasons even, but it is enough to show you that guessing on our part may take weeks without a very exact description of your code and process and concurrency model used.

I can tell you that the typical new-to-SQLite mistake is to forget to finalize a statement, typically one that returned an error and then the execution forks to some error handler that never finalizes the statement, or some such. If that's not it, then we need to see code to try and establish the reason - but I guarantee that there is a reason.