SQLite 3.7的新特性.db-shm和.db-wal(转)

I am seeing some strange behavior with my application and the state of its database file after running some tests that close the database, delete it, and replace it with a test fixture. When I examine the database file with a tool on my debugging PC, it doesn’t match what the application itself seems to be reporting. It’s possible that this strange behavior is related to this bug.

我看到一些奇怪的行为和我的应用程序和数据库文件的状态运行一些测试后关闭数据库,删除,替换测试夹具。

当我检查数据库文件与一个工具在我调试电脑,它不匹配应用程序本身似乎是报告。

有可能这个奇怪的行为是与此相关的缺陷。

I noticed that there are two files with the same base name as the database (with the normal . db extension.) The file extensions are . db-shm and . db-wal, and each is newer than the . db file’s timestamp.

我注意到有两个文件相同的基本名称数据库(正常。db扩展)。

文件扩展名.db-shm和.db-wal,每个比的更新。数据库文件的时间戳。

I assume that these are some type of temporary files. However, I am wondering if the application is terminated, shouldn’t they be deleted? More importantly, I assume whatever data is stored in them is updated inside the . db file before the application is terminated by the operating system. Is this correct?

我认为这些都是某种类型的临时文件。但是,我想知道如果应用程序终止,他们不应该被删除?

更重要的是,我认为无论数据存储在它们内部的更新。

db文件之前,应用程序终止的操作系统。

这是正确的吗?

@satur9nine that’s really odd.. I was asked to update someone else’s code.. and during testing i realized that his use of core data worked just fine with iOS 6.x.. but then when I tested it on iOS 7.x.. it resulted in the above . db-shm and .db-wal.. did this happen to anyone else? – abbood Nov 11 ’13 at 10:59

@satur9nine很奇怪. .我被要求更新其他人的代码. .在测试过程中我意识到他使用核心数据与iOS 6. x很好. .但当我测试了它在iOS 7. x . .它导致了上面的。db-shm和.db-wal . .这发生在任何人吗?

On iOS 7 these appear to contain all the transactions. The db file is an empty database for me. I need to grab all three files to see the “real” contents of the db. – Ryan Booker Jan 15 ’14 at 3:39

在iOS 7这些似乎包含的所有事务。

对我来说是一个空数据库的db文件。

我需要抓住这三个文件的“真正的”数据库的内容。

You are correct, these are temporary files created by SQLite. If you are manually deleting the main db you should probably delete these too. From what I can gather the WAL is a replacement for the rollback journal that enables SQLite to rollback changes when a transaction fails. How SQLite uses them and why they are kept around for so long is up to the authors of SQLite but in general SQLite seems pretty rock solid so I wouldn’t worry too much about them. For more info take a look here:

你是正确的,这些是SQLite创建的临时文件。如果你手动删除主db你也应该删除这些。我可以收集细胞膜是一个替代《回滚,使SQLite回滚事务失败时变化。SQLite如何使用他们,为什么他们都这么久的作者SQLite但总的来说SQLite似乎相当坚如磐石的所以我不会过于担心他们。更多信息在这里看一看:

http://www.sqlite.org/fileformat2.html#walindexformat

http://www.sqlite.org/fileformat2.html walindexformat

These files are a new feature of SQLite 3.7. I’m not sure if their existence relates to the bug you point out but the bug report suggests a work-around anyway.

这些文件是一个SQLite 3.7的新特性。

我不知道它们的存在与你指出的错误,但错误报告显示一个变通方法。

参考文档

SQLite 3.7的新特性.db-shm和.db-wal

    原文作者:静心多想
    原文地址: https://www.jianshu.com/p/9a35fe6eb845
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞