FMDB executeUpdate DROP命令确实停止了该应用程序 [英] FMDB executeUpdate DROP command does halt the app

查看:111
本文介绍了FMDB executeUpdate DROP命令确实停止了该应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的SQLite数据库文件database.db中删除一个表。使用

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");

应用程序在查询位置停止。在控制台中显示查询之前的NSLog。查询后直接显示的NSlog不会显示在控制台窗口中。此外,在应用程序运行时,会在模拟器应用程序文件夹中连续创建和删除一个名为database.db-journal的临时文件,并将其连续删除。该应用程序不会崩溃,不会给出任何错误,并且不会继续...在查询中删除如果存在不起作用,删除反引号不起作用,删除分号也不起作用。

启用查询跟踪仅表明FMDB正在处理我的查询,什么也没有显示。

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.

我真的很困惑为什么会这样。我认为该表必须为空才能删除,因此我添加了一个查询以删除其中的每条记录。但是id并不重要,该应用仍会在drop查询中被捕获。我无法解决该错误。

如果我在SQLite数据库浏览器2中执行drop命令,一切正常。

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.

调试器显示FMDB包装器正在进入无限循环,因为该语句的返回值等于SQLITE_LOCKED常量,这意味着我要删除的表已锁定。在上一个查询中发送 UNLOCK TABLES并不能解决此问题。为什么桌子被锁住了?为什么从锁定的表中删除记录会起作用?

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?

推荐答案

我遇到了同样的问题,可以通过调用<$ c来解决就在更新之前,在 FMDB 实例上对$ c> closeOpenResultSets 进行操作,就像TRD所说的(尽管我不必关闭并重新打开数据库)完全)

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)

这篇关于FMDB executeUpdate DROP命令确实停止了该应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆