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

Commit 8d111038 authored by Vasu Nori's avatar Vasu Nori
Browse files

if attach database sql statement is exec'ed, disable write WAL

an app can execute 'attach database..' statement anytime after WAL is
enabled. since WAL doesn't work with atatched databases,
disable WAL whenever the caller executes 'attach database'
sql statement.

Change-Id: I77dfcb744b59476c357d44296c14d63455985a7b
parent 433517b0
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -1861,6 +1861,11 @@ public class SQLiteDatabase extends SQLiteClosable {
     * @throws SQLException If the SQL string is invalid for some reason
     */
    public void execSQL(String sql) throws SQLException {
        sql = sql.trim();
        String prefix = sql.substring(0, 6);
        if (prefix.equalsIgnoreCase("ATTACH")) {
            disableWriteAheadLogging();
        }
        verifyDbIsOpen();
        BlockGuard.getThreadPolicy().onWriteToDisk();
        long timeStart = SystemClock.uptimeMillis();
@@ -2345,6 +2350,14 @@ public class SQLiteDatabase extends SQLiteClosable {
        return true;
    }

    private synchronized void disableWriteAheadLogging() {
        if (mConnectionPool == null) {
            return;
        }
        mConnectionPool.close();
        mConnectionPool = null;
    }

    /**
     * Sets the database connection handle pool size to the given value.
     * Database connection handle pool is enabled when the app calls