Clear statement cache if schema changes
Bug: 183028015
If DDL statement is executed then the prepared statement cache must be
cleaned up on active connections, otherwise their column result
information can be outdated.
This is the same a previous commit for the bug with two additions:
1. acquirePreparedStatement() marks statements taken from the cache
as in-use. This ensures the statements will not be finalized until
they are released.
2. The prepared statement cache is protected by a lock. This is
required because the code that that detects a schema change may run
on a different thread than the one that owns the connection. Both
threads will attempt to manage the cache at the same time.
Note that under normal flow, there will never be contention on the
new lock, because SQLiteConnection management ensures almost all
operations are single-threaded.
Test: atest
* CtsDatabaseTestCases
* FrameworksCoreTests:android.database.sqlite
Change-Id: Ic29fe26e15d1218ede8f05a0c255b9115364df30
Loading
Please register or sign in to comment