diff options
author | Vasu Nori <vnori@google.com> | 2010-01-06 16:34:19 -0800 |
---|---|---|
committer | Vasu Nori <vnori@google.com> | 2010-01-14 15:22:58 -0800 |
commit | e495d1f74af13aec8d5d825e93e4cfe1e4fe7468 (patch) | |
tree | 598f4255c3068e244a15911423e375464f70f44d /tests | |
parent | f2275078bd5ba6bc0b184098573341c5958289ab (diff) | |
download | frameworks_base-e495d1f74af13aec8d5d825e93e4cfe1e4fe7468.zip frameworks_base-e495d1f74af13aec8d5d825e93e4cfe1e4fe7468.tar.gz frameworks_base-e495d1f74af13aec8d5d825e93e4cfe1e4fe7468.tar.bz2 |
fix a bug in compiled-sql caching & hide public api setMaxSqlCacheSize
this is a clone of https://android-git.corp.google.com/g/#change,35174.
if the cache is full to its capacity and if a new statement is to be cached,
one of the entries in the cache is thrown out to make room for the new one.
but the one that is thrown out doesn't get deallocated by SQLiteProgram
because it doesn't know that it should.
fixed this by having SQLiteProgram finalize its sql statement in
releaseReference*() methods, if the statement is not in cache.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/AndroidTests/src/com/android/unit_tests/DatabaseGeneralTest.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/AndroidTests/src/com/android/unit_tests/DatabaseGeneralTest.java b/tests/AndroidTests/src/com/android/unit_tests/DatabaseGeneralTest.java index 7a4d934..69d55c1 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/DatabaseGeneralTest.java +++ b/tests/AndroidTests/src/com/android/unit_tests/DatabaseGeneralTest.java @@ -987,4 +987,18 @@ public class DatabaseGeneralTest extends TestCase implements PerformanceTestCase ih.close(); } + @MediumTest + public void testDbCloseReleasingAllCachedSql() { + mDatabase.execSQL("CREATE TABLE test (_id INTEGER PRIMARY KEY, text1 TEXT, text2 TEXT, " + + "num1 INTEGER, num2 INTEGER, image BLOB);"); + final String statement = "DELETE FROM test WHERE _id=?;"; + SQLiteStatement statementDoNotClose = mDatabase.compileStatement(statement); + assertTrue(statementDoNotClose.getUniqueId() > 0); + int nStatement = statementDoNotClose.getUniqueId(); + assertTrue(statementDoNotClose.getUniqueId() == nStatement); + /* do not close statementDoNotClose object. + * That should leave it in SQLiteDatabase.mPrograms. + * mDatabase.close() in tearDown() should release it. + */ + } } |