Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ios7 sqlite database with WAL never syncs the main database file

I've read many threads about the new WAL default setting in ios7 SQLite / Core Data stack.

It looked like a good idea in the first place... Though I need to perform a database copy to a distant webservice from time to time according to my business needs. At the moment I only backup the SQLITE file and I can't add the 2 other files to the webservice operation I'm using. This means my backup is clearly not up-to-date thus pretty pointless.

Other people suggest that I should disable WAL using the journal_mode=DELETE (NSSQLitePragmasOption) which is, to me, an acceptable workaround. Still, I don't feel comfortable with this. It feels like I'm missing out on a pretty decent performance bump.

Ideally I'd like to be able to tell Core Data / SQLite to sync the SHM/WAL to the main data file and then perform the backup. Is there a way to do so without digging out crazy private or undocumented APIs ?

like image 304
vivien.destpern Avatar asked Oct 03 '22 20:10

vivien.destpern


1 Answers

To move the WAL data to the database file, open the database file and execute the SQL statement PRAGMA wal_checkpoint(RESTART).

like image 162
CL. Avatar answered Oct 07 '22 18:10

CL.