1

I would like to ship my app with an SQL datastore, but now, since Apple has introduced a WAL journaling, that makes 3 files instead of one, so I wonder if I should ship all 3 of them, or I can try to force SQL to make a checkpoint, merging it all into one .sql file.

I would really like to go with this new iOS 7 feature, so going back to rollback journaling is not a way for me.

Nikita Pestrov
  • 5,876
  • 4
  • 31
  • 66

2 Answers2

3

To force SQLite to make a checkpoint, execute PRAGMA wal_checkpoint.

Alternatively, ship the database with journal_mode = DELETE, and change the mode after the file has been installed.

In any case, there is no problem with just shipping all files. (The -shm file does not contain permanent data and could be ignored.)

CL.
  • 173,858
  • 17
  • 217
  • 259
2

You don't have to use WAL, that's just the default. You can switch to a different mode. When adding the persistent store, set the options argument to something like

NSDictionary *options = @{ @"journal_mode": @"DELETE" };

Then you'll get the same journal behavior as in earlier versions of iOS. Use this when creating your pre-populated data store and you won't need to deal with the extra journal files.

Tom Harrington
  • 69,312
  • 10
  • 146
  • 170
  • Thank you for the answer, but, as I have mentioned in my question, I want to use the benefits of this mode, since concurrent reader and writer could be utilized by me in the app, so going back to 2004 like behavior is not the way. – Nikita Pestrov Nov 04 '13 at 06:35