Loading core/java/android/database/sqlite/SQLiteDatabase.java +47 −44 Original line number Diff line number Diff line Loading @@ -2386,37 +2386,39 @@ public class SQLiteDatabase extends SQLiteClosable { * @return true if write-ahead-logging is set. false otherwise */ public boolean enableWriteAheadLogging() { // make sure the database is not READONLY. WAL doesn't make sense for readonly-databases. if (isReadOnly()) { // turn off WAL until lockingprotocolerror bug and diskIO bug are fixed return false; } // acquire lock - no that no other thread is enabling WAL at the same time lock(); try { if (mConnectionPool != null) { // already enabled return true; } if (mPath.equalsIgnoreCase(MEMORY_DB_PATH)) { Log.i(TAG, "can't enable WAL for memory databases."); return false; } // make sure this database has NO attached databases because sqlite's write-ahead-logging // doesn't work for databases with attached databases if (mHasAttachedDbs) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "this database: " + mPath + " has attached databases. can't enable WAL."); } return false; } mConnectionPool = new DatabaseConnectionPool(this); setJournalMode(mPath, "WAL"); return true; } finally { unlock(); } // // make sure the database is not READONLY. WAL doesn't make sense for readonly-databases. // if (isReadOnly()) { // return false; // } // // acquire lock - no that no other thread is enabling WAL at the same time // lock(); // try { // if (mConnectionPool != null) { // // already enabled // return true; // } // if (mPath.equalsIgnoreCase(MEMORY_DB_PATH)) { // Log.i(TAG, "can't enable WAL for memory databases."); // return false; // } // // // make sure this database has NO attached databases because sqlite's write-ahead-logging // // doesn't work for databases with attached databases // if (mHasAttachedDbs) { // if (Log.isLoggable(TAG, Log.DEBUG)) { // Log.d(TAG, // "this database: " + mPath + " has attached databases. can't enable WAL."); // } // return false; // } // mConnectionPool = new DatabaseConnectionPool(this); // setJournalMode(mPath, "WAL"); // return true; // } finally { // unlock(); // } } /** Loading @@ -2424,19 +2426,20 @@ public class SQLiteDatabase extends SQLiteClosable { * @hide */ public void disableWriteAheadLogging() { // grab database lock so that writeAheadLogging is not disabled from 2 different threads // at the same time lock(); try { if (mConnectionPool == null) { return; // already disabled } mConnectionPool.close(); setJournalMode(mPath, "TRUNCATE"); mConnectionPool = null; } finally { unlock(); } return; // // grab database lock so that writeAheadLogging is not disabled from 2 different threads // // at the same time // lock(); // try { // if (mConnectionPool == null) { // return; // already disabled // } // mConnectionPool.close(); // setJournalMode(mPath, "TRUNCATE"); // mConnectionPool = null; // } finally { // unlock(); // } } /* package */ SQLiteDatabase getDatabaseHandle(String sql) { Loading Loading
core/java/android/database/sqlite/SQLiteDatabase.java +47 −44 Original line number Diff line number Diff line Loading @@ -2386,37 +2386,39 @@ public class SQLiteDatabase extends SQLiteClosable { * @return true if write-ahead-logging is set. false otherwise */ public boolean enableWriteAheadLogging() { // make sure the database is not READONLY. WAL doesn't make sense for readonly-databases. if (isReadOnly()) { // turn off WAL until lockingprotocolerror bug and diskIO bug are fixed return false; } // acquire lock - no that no other thread is enabling WAL at the same time lock(); try { if (mConnectionPool != null) { // already enabled return true; } if (mPath.equalsIgnoreCase(MEMORY_DB_PATH)) { Log.i(TAG, "can't enable WAL for memory databases."); return false; } // make sure this database has NO attached databases because sqlite's write-ahead-logging // doesn't work for databases with attached databases if (mHasAttachedDbs) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "this database: " + mPath + " has attached databases. can't enable WAL."); } return false; } mConnectionPool = new DatabaseConnectionPool(this); setJournalMode(mPath, "WAL"); return true; } finally { unlock(); } // // make sure the database is not READONLY. WAL doesn't make sense for readonly-databases. // if (isReadOnly()) { // return false; // } // // acquire lock - no that no other thread is enabling WAL at the same time // lock(); // try { // if (mConnectionPool != null) { // // already enabled // return true; // } // if (mPath.equalsIgnoreCase(MEMORY_DB_PATH)) { // Log.i(TAG, "can't enable WAL for memory databases."); // return false; // } // // // make sure this database has NO attached databases because sqlite's write-ahead-logging // // doesn't work for databases with attached databases // if (mHasAttachedDbs) { // if (Log.isLoggable(TAG, Log.DEBUG)) { // Log.d(TAG, // "this database: " + mPath + " has attached databases. can't enable WAL."); // } // return false; // } // mConnectionPool = new DatabaseConnectionPool(this); // setJournalMode(mPath, "WAL"); // return true; // } finally { // unlock(); // } } /** Loading @@ -2424,19 +2426,20 @@ public class SQLiteDatabase extends SQLiteClosable { * @hide */ public void disableWriteAheadLogging() { // grab database lock so that writeAheadLogging is not disabled from 2 different threads // at the same time lock(); try { if (mConnectionPool == null) { return; // already disabled } mConnectionPool.close(); setJournalMode(mPath, "TRUNCATE"); mConnectionPool = null; } finally { unlock(); } return; // // grab database lock so that writeAheadLogging is not disabled from 2 different threads // // at the same time // lock(); // try { // if (mConnectionPool == null) { // return; // already disabled // } // mConnectionPool.close(); // setJournalMode(mPath, "TRUNCATE"); // mConnectionPool = null; // } finally { // unlock(); // } } /* package */ SQLiteDatabase getDatabaseHandle(String sql) { Loading