diff options
author | Paul Westbrook <pwestbro@google.com> | 2011-02-17 13:14:22 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-02-17 13:14:22 -0800 |
commit | 754537cf9fc49ff741f3bd6953a262984aaa99d6 (patch) | |
tree | 2ca4b8eae670eaf782950d5935e087a975b56153 /core | |
parent | 0a56e4ecda2e4566450b30d0046e3119de748203 (diff) | |
parent | dae6d3705d34a45a4ffe2fe411e6de644ef78e47 (diff) | |
download | frameworks_base-754537cf9fc49ff741f3bd6953a262984aaa99d6.zip frameworks_base-754537cf9fc49ff741f3bd6953a262984aaa99d6.tar.gz frameworks_base-754537cf9fc49ff741f3bd6953a262984aaa99d6.tar.bz2 |
Merge "Revert "turn off sqlite WAL until bugs bug:3024421 and bug:3353077 are fixed""
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/database/sqlite/SQLiteDatabase.java | 91 |
1 files changed, 44 insertions, 47 deletions
diff --git a/core/java/android/database/sqlite/SQLiteDatabase.java b/core/java/android/database/sqlite/SQLiteDatabase.java index 891a5d9..2e43eef 100644 --- a/core/java/android/database/sqlite/SQLiteDatabase.java +++ b/core/java/android/database/sqlite/SQLiteDatabase.java @@ -2354,39 +2354,37 @@ public class SQLiteDatabase extends SQLiteClosable { * @return true if write-ahead-logging is set. false otherwise */ public boolean enableWriteAheadLogging() { - // turn off WAL until lockingprotocolerror bug and diskIO bug are fixed - return false; -// // 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(); -// } + // 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(); + } } /** @@ -2394,20 +2392,19 @@ public class SQLiteDatabase extends SQLiteClosable { * @hide */ public void disableWriteAheadLogging() { - 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(); -// } + // 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) { |