Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9423a656 authored by Steve Kondik's avatar Steve Kondik
Browse files

Revert "Revert forced WAL mode for SQLite databases."

This reverts commit f81ec953.
parent 1e83327e
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -101,6 +101,8 @@ static void dbopen(JNIEnv* env, jobject object, jstring pathString, jint flags)
    sqlite3_stmt * statement = NULL;
    char const * path8 = env->GetStringUTFChars(pathString, NULL);
    int sqliteFlags;
    // Error code handling for SQLite exec
    char* zErrMsg = NULL;

    // register the logging func on sqlite. needs to be done BEFORE any sqlite3 func is called.
    registerLoggingFunc(path8);
@@ -121,6 +123,22 @@ static void dbopen(JNIEnv* env, jobject object, jstring pathString, jint flags)
        goto done;
    }

    // Configure databases to run in WAL mode.
    err = sqlite3_exec(handle,"PRAGMA journal_mode = WAL;",
                       NULL, NULL,&zErrMsg);
    if (SQLITE_OK == err) {
        // Set autocheckpoint = 100 pages
        err = sqlite3_wal_autocheckpoint(handle,
                                         100);
        if (SQLITE_OK != err) {
            LOGE("sqlite3_exec to set WAL autocheckpoint failed\n");
            throw_sqlite3_exception(env, handle);
            goto done;
        }
    } else {
       LOGE("sqlite3_exec to set journal_mode = WAL failed\n");
    }

    // The soft heap limit prevents the page cache allocations from growing
    // beyond the given limit, no matter what the max page cache sizes are
    // set to. The limit does not, as of 3.5.0, affect any other allocations.