Skip to content

Support for NSSQLitePragmasOption generally, WAL specifically #212

@patrickhartling

Description

@patrickhartling

Has anyone worked on adding support for NSSQLitePragmasOption, particularly so that write-ahead logging (WAL) can be enabled? I have tried but am having only limited success. It's not so hard to extend ECD to execute the PRAGMA SQLite statements from the dictionary associated with NSSQLitePragmasOption in the persistent store options. Migrating between managed object model versions is proving terribly difficult, however.

The one (more or less) related Stack Overflow post I ran across has a down-voted answer that indirectly refers to an Apple Technical Q&A. That Q&A post doesn't strike me as being truly relevant, particularly because the approach of disabling WAL before migrating does not make any difference for me. As far as I can tell, Apple's Core Data code is fully WAL-aware as long as the right options are supplied consistently. The challenge lies in ensuring that ECD handles WAL correctly.

It seems very much like the EncryptedStore object has to be deallocated to prevent possible corruption of the -wal file and/or the encrypted store by the EncryptedStore object allocated for the newer version of the managed object model. That seems sensible to me, but there is an unexpected wrinkle. When I do ensure that the EncryptedStore object is deallocated, the -wal and -shm files are removed. Is that a normal side effect for sqlite3_close()? I'm still working my way through the sqlcipher source to understand what to expect.

If I execute the same code using NSSQLiteStoreType instead of EncryptedStoreType, the -wal and -shm files remain on disk after I execute steps to remove the persistent store from its coordinator. Perhaps the NSIncrementalStore subclass for NSSQLiteStoreType cleans up after itself differently than EncryptedStore does?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions