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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user