I want to drop a table in my SQLite Database file named database.db. After using
NSLog(@"i show up in the console");
[db executeUpdate:@"DROP TABLE IF EXISTS `article`;"];
NSLog(@"i will not show up in the console");
the app stops at the position of the query. NSLog before the query is shown in console. NSlog directly after the query does not show up in the console window. Additionally a temporary file called database.db-journal is created and deleted continuously in the simulator app folder while the app is running. The app does NOT crash, does not giving any error and does not continue... Removing "IF EXISTS" in the query doesn't work, removing backticks doesn't work, removing semicolon doesn't work.
Enabling tracing of query only shows that FMDB is processing my query, nothing more shows up.
I'm really confused why this happens. I thought that the table has to be empty before it can be dropped and so I added a query to delete every record in it. But id doesn't matter, the app is still getting caught at the drop-query. Im running out of possibilities to resolve this error.
If I execute the drop command within SQLite Database Browser 2 everything works fine.
Further researches with the debugger showed that FMDB wrapper is going into an infinity loop because the return value of the statement equals to the SQLITE_LOCKED constant which means that the table I want to drop is locked. Sending "UNLOCK TABLES" in a previous query doesn't solve this. Why the table is locked? Why deleting records from a locked table will work?
I had the same issue, and got it solved by calling closeOpenResultSets
on the FMDB
instance just before the update, just like TRD said (though I didn't have to close and reopen the database completely)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With