Thanks to DRH for the quick answer. So I would infer that the sqlite file header would normally be in a consistent state, and only be in an inconsistent or otherwise incorrect state in the following cases: 1. modification (write) is in progress (until the sqlite3 code has a chance to finish the modification) 2. application crashed or otherwise terminated without finishing the modification (until the application or some other sqlite program opens the database again) 3. rogue code writes data to the file descriptor in use by sqlite 4. other causes described in http://www.sqlite.org/howtocorrupt.html such as rogue code, rogue process, rogue script, OS bug, dishonest hardware, etc.
My understanding is that iOS applications with shared databases can be especially sensitive to sqlite headers as discussed in: - https://developer.apple.com/library/content/technotes/tn2408/_index.html - note referenced by SQLCipher project, not sure if I can understand it 100% - https://github.com/sqlcipher/sqlcipher/issues/255#issuecomment-355063368 - discovery that iOS checks header of shared SQLite databases, with special handling of sqlite databases in WAL mode I still have the following questions: - Am I correct to say "that the sqlite file header would normally be in a consistent state"? - Am I missing anything or otherwise mistaken here? - How likely would the header continue to indicate that the database is an sqlite database in case 1 or 2 above? - How likely would the header continue to indicate whether the database is in WAL or any other journal mode in case 1 or 2 above? - Any recommended explanations or resources that explain how iOS handles shared sqlite databases (in more detail, with simpler terms)? - Any recommended explanations or resources to understand how and when sqlite header may be in inconsistent or otherwise incorrect state? - Any recommended explanations or resources to understand how it may be possible to obtain the correct sqlite database information (such as WAL or other journal mode, actual database size, number of pages, page/cache size, etc.)? On Tue, Feb 13, 2018 at 9:10 AM, Richard Hipp <d...@sqlite.org> wrote: > > On 2/13/18, Chris Brody <chris.br...@gmail.com> wrote: > > I was wondering what would happen if there would be an application crash, > > system crash, or power failure while SQLite is updating the file header? > > > > Did I miss an explanation somewhere? > > The content is replicated either in the rollback-journal or in the > write-head log (depending on whether or not you are in WAL mode) and > will be recovered automatically when the database is first opened > after power has been restored. See > https://www.sqlite.org/atomiccommit.html for further information. > -- > D. Richard Hipp > d...@sqlite.org > _______________________________________________ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users