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

Commit 44c529b6 authored by Sameer Thatte's avatar Sameer Thatte Committed by Steve Kondik
Browse files

Switch Databases to WAL mode. Set autocommit to 100.

Change-Id: I852f439e2565d1732a55548f1519cbd2c77ebd64
parent afef54ef
Loading
Loading
Loading
Loading
+20 −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,24 @@ 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) {
       LOGE("sqlite3_exec to set journal_mode = WAL failed\n");
       throw_sqlite3_exception(env, handle);
       goto done;
    }

    // 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;
    }

    // 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.