Loading core/java/android/database/sqlite/DatabaseConnectionPool.java +2 −2 Original line number Diff line number Diff line Loading @@ -93,7 +93,7 @@ import java.util.Random; poolObj = mPool.get(0); } else { for (int i = 0; i < mMaxPoolSize; i++) { if (mPool.get(i).mDb.isSqlInStatementCache(sql)) { if (mPool.get(i).mDb.isInStatementCache(sql)) { poolObj = mPool.get(i); break; } Loading @@ -119,7 +119,7 @@ import java.util.Random; // there are free connections available. pick one // preferably a connection caching the pre-compiled statement of the given SQL for (int i = 0; i < poolSize; i++) { if (mPool.get(i).isFree() && mPool.get(i).mDb.isSqlInStatementCache(sql)) { if (mPool.get(i).isFree() && mPool.get(i).mDb.isInStatementCache(sql)) { poolObj = mPool.get(i); break; } Loading core/java/android/database/sqlite/SQLiteDatabase.java +10 −1 Original line number Diff line number Diff line Loading @@ -1048,6 +1048,9 @@ public class SQLiteDatabase extends SQLiteClosable { * Close the database. */ public void close() { if (!isOpen()) { return; } if (Log.isLoggable(TAG, Log.DEBUG)) { Log.i(TAG, "closing db: " + mPath + " (connection # " + mConnectionNum); } Loading Loading @@ -2174,12 +2177,18 @@ public class SQLiteDatabase extends SQLiteClosable { } } /* package */ boolean isSqlInStatementCache(String sql) { /* package */ boolean isInStatementCache(String sql) { synchronized (mCompiledQueries) { return mCompiledQueries.containsKey(sql); } } /* package */ boolean isInStatementCache(SQLiteCompiledSql sqliteCompiledSql) { synchronized (mCompiledQueries) { return mCompiledQueries.containsValue(sqliteCompiledSql); } } private synchronized int getCacheHitNum() { return mNumCacheHits; } Loading core/java/android/database/sqlite/SQLiteProgram.java +7 −9 Original line number Diff line number Diff line Loading @@ -188,8 +188,7 @@ public abstract class SQLiteProgram extends SQLiteClosable { // this SQL statement was never in cache mCompiledSql.releaseSqlStatement(); } else { synchronized(mDatabase.mCompiledQueries) { if (!mDatabase.mCompiledQueries.containsValue(mCompiledSql)) { if (!mDatabase.isInStatementCache(mCompiledSql)) { // it is NOT in compiled-sql cache. i.e., responsibility of // releasing this statement is on me. mCompiledSql.releaseSqlStatement(); Loading @@ -198,7 +197,6 @@ public abstract class SQLiteProgram extends SQLiteClosable { mCompiledSql.release(); } } } mCompiledSql = null; nStatement = 0; } Loading Loading
core/java/android/database/sqlite/DatabaseConnectionPool.java +2 −2 Original line number Diff line number Diff line Loading @@ -93,7 +93,7 @@ import java.util.Random; poolObj = mPool.get(0); } else { for (int i = 0; i < mMaxPoolSize; i++) { if (mPool.get(i).mDb.isSqlInStatementCache(sql)) { if (mPool.get(i).mDb.isInStatementCache(sql)) { poolObj = mPool.get(i); break; } Loading @@ -119,7 +119,7 @@ import java.util.Random; // there are free connections available. pick one // preferably a connection caching the pre-compiled statement of the given SQL for (int i = 0; i < poolSize; i++) { if (mPool.get(i).isFree() && mPool.get(i).mDb.isSqlInStatementCache(sql)) { if (mPool.get(i).isFree() && mPool.get(i).mDb.isInStatementCache(sql)) { poolObj = mPool.get(i); break; } Loading
core/java/android/database/sqlite/SQLiteDatabase.java +10 −1 Original line number Diff line number Diff line Loading @@ -1048,6 +1048,9 @@ public class SQLiteDatabase extends SQLiteClosable { * Close the database. */ public void close() { if (!isOpen()) { return; } if (Log.isLoggable(TAG, Log.DEBUG)) { Log.i(TAG, "closing db: " + mPath + " (connection # " + mConnectionNum); } Loading Loading @@ -2174,12 +2177,18 @@ public class SQLiteDatabase extends SQLiteClosable { } } /* package */ boolean isSqlInStatementCache(String sql) { /* package */ boolean isInStatementCache(String sql) { synchronized (mCompiledQueries) { return mCompiledQueries.containsKey(sql); } } /* package */ boolean isInStatementCache(SQLiteCompiledSql sqliteCompiledSql) { synchronized (mCompiledQueries) { return mCompiledQueries.containsValue(sqliteCompiledSql); } } private synchronized int getCacheHitNum() { return mNumCacheHits; } Loading
core/java/android/database/sqlite/SQLiteProgram.java +7 −9 Original line number Diff line number Diff line Loading @@ -188,8 +188,7 @@ public abstract class SQLiteProgram extends SQLiteClosable { // this SQL statement was never in cache mCompiledSql.releaseSqlStatement(); } else { synchronized(mDatabase.mCompiledQueries) { if (!mDatabase.mCompiledQueries.containsValue(mCompiledSql)) { if (!mDatabase.isInStatementCache(mCompiledSql)) { // it is NOT in compiled-sql cache. i.e., responsibility of // releasing this statement is on me. mCompiledSql.releaseSqlStatement(); Loading @@ -198,7 +197,6 @@ public abstract class SQLiteProgram extends SQLiteClosable { mCompiledSql.release(); } } } mCompiledSql = null; nStatement = 0; } Loading