Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WAL support #20

Closed
wants to merge 1 commit into from
Closed

Conversation

plackemacher
Copy link

Adds WAL support using PRAGMAs. SQLCipher supports it but not through a Java method: sqlcipher/android-database-sqlcipher#163.

This should help with your latest comment in https://github.com/commonsguy/cwac-saferoom/issues/18#issuecomment-369350635.

As per your contribution guidelines, use as you wish but I figured it'd help get the ball rolling if there's some code to play with.

@commonsguy
Copy link
Owner

I had considered going this route, then put it aside, hoping that I'd be able to convince Zetitec to offer a first-class Java API for it. That might still happen, but that process is going to be glacial.

I'll look into adding this soonish. I need to read up on WAL. Many thanks!

commonsguy added a commit that referenced this pull request Apr 4, 2018
@commonsguy
Copy link
Owner

commonsguy commented Apr 4, 2018

OK, I implemented something that is in the spirit of your PR, with slight modifications. It's in v0.3.3.

The biggest functional difference is that your disable implementation switched the journal mode to TRUNCATE. The SQLite default seems to be DELETE, so I used that, to be more likely to revert to where things started. If you had a specific compatibility reason for using TRUNCATE, let me know.

Many thanks for the help!

@commonsguy commonsguy closed this Apr 4, 2018
@plackemacher
Copy link
Author

Great! I'm glad I was able to help.

Yes, I noticed SQLite's default was DELETE. I picked out TRUNCATE mainly because of it's reference within Room. They limited the JournalMode enum to only support TRUNCATE or WRITE_AHEAD_LOGGING for some reason. See here for the RoomDatabase.JournalMode code. Even though they have the TRUNCATE value for the enum, when a RoomDatabase is being initialized, if the journal mode is explicitly set to TRUNCATE it doesn't seem to actually set it to be so. It seemingly just ensures WAL is disabled through the framework classes. This is based on a dive through the framework SQLite classes so I'm not sure if there is some magic under the hood that actually keeps the journal_mode set to TRUNCATE if WAL is never enabled.

@commonsguy
Copy link
Owner

Hmmm... OK. I'll make a note to do more research on this, and I'll consider flipping my code over to TRUNCATE as well.

Thanks again!

@commonsguy
Copy link
Owner

I ran a test and concluded that the non-WAL mode in SQLiteDatabase is indeed TRUNCATE. v0.3.4 of CWAC-SafeRoom now uses TRUNCATE instead of DELETE.

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants