45be5633e90d9fa2e55d1754346c6f2090d261a3 |
|
09-Aug-2017 |
Fyodor Kupolov <fkupolov@google.com> |
Make SQLiteDirectCursorDriver @TestApi Test: cts/SQLiteDatabaseTest+SQLiteOpenHelperTest Bug: 64228388 Change-Id: Ic711069cfdc7df1affaecf26a3d01539f1a8e821
/frameworks/base/core/java/android/database/sqlite/SQLiteDirectCursorDriver.java
|
a7771df3696954f0e279407e8894a916a7cb26cc |
|
08-May-2012 |
Jeff Brown <jeffbrown@google.com> |
Move CancellationSignal to android.os package. Bug: 6427830 Change-Id: I39451bb1e1d4a8d976ed1c671234f0c8c61658dd
/frameworks/base/core/java/android/database/sqlite/SQLiteDirectCursorDriver.java
|
baefdfad6e77e772deb6474380dd85ac776293e8 |
|
05-Mar-2012 |
Jeff Brown <jeffbrown@google.com> |
Make SQLiteDatabase final. The SQLiteDatabase constructor is inaccessible so it is not possible for applications to subclass it. To remove all possible remaining temptation to do so, make the class final. Change-Id: I4148e9b06f0661ec22aab8e45afde38498d2375a
/frameworks/base/core/java/android/database/sqlite/SQLiteDirectCursorDriver.java
|
4c1241df8f8b7fd5ec3dff6c7e0f66271248e76e |
|
03-Feb-2012 |
Jeff Brown <jeffbrown@google.com> |
Rename CancellationSignal using preferred spelling. Bug: 5943637 Change-Id: I12a339f285f4db58e79acb5fd8ec2fc1acda5265
/frameworks/base/core/java/android/database/sqlite/SQLiteDirectCursorDriver.java
|
75ea64fc54f328d37b115cfb1ded1e45c30380ed |
|
26-Jan-2012 |
Jeff Brown <jeffbrown@google.com> |
Implement a cancelation mechanism for queries. Added new API to enable cancelation of SQLite and content provider queries by means of a CancelationSignal object. The application creates a CancelationSignal object and passes it as an argument to the query. The cancelation signal can then be used to cancel the query while it is executing. If the cancelation signal is raised before the query is executed, then it is immediately terminated. Change-Id: If2c76e9a7e56ea5e98768b6d4f225f0a1ca61c61
/frameworks/base/core/java/android/database/sqlite/SQLiteDirectCursorDriver.java
|
e5360fbf3efe85427f7e7f59afe7bbeddb4949ac |
|
01-Nov-2011 |
Jeff Brown <jeffbrown@google.com> |
Rewrite SQLite database wrappers. The main theme of this change is encapsulation. This change preserves all existing functionality but the implementation is now much cleaner. Instead of a "database lock", access to the database is treated as a resource acquisition problem. If a thread's owns a database connection, then it can access the database; otherwise, it must acquire a database connection first, and potentially wait for other threads to give up theirs. The SQLiteConnectionPool encapsulates the details of how connections are created, configured, acquired, released and disposed. One new feature is that SQLiteConnectionPool can make scheduling decisions about which thread should next acquire a database connection when there is contention among threads. The factors considered include wait queue ordering (fairness among peers), whether the connection is needed for an interactive operation (unfairness on behalf of the UI), and whether the primary connection is needed or if any old connection will do. Thus one goal of the new SQLiteConnectionPool is to improve the utilization of database connections. To emulate some quirks of the old "database lock," we introduce the concept of the primary database connection. The primary database connection is the one that is typically used to perform write operations to the database. When a thread holds the primary database connection, it effectively prevents other threads from modifying the database (although they can still read). What's more, those threads will block when they try to acquire the primary connection, which provides the same kind of mutual exclusion features that the old "database lock" had. (In truth, we probably don't need to be requiring use of the primary database connection in as many places as we do now, but we can seek to refine that behavior in future patches.) Another significant change is that native sqlite3_stmt objects (prepared statements) are fully encapsulated by the SQLiteConnection object that owns them. This ensures that the connection can finalize (destroy) all extant statements that belong to a database connection when the connection is closed. (In the original code, this was very complicated because the sqlite3_stmt objects were managed by SQLiteCompiledSql objects which had different lifetime from the original SQLiteDatabase that created them. Worse, the SQLiteCompiledSql finalizer method couldn't actually destroy the sqlite3_stmt objects because it ran on the finalizer thread and therefore could not guarantee that it could acquire the database lock in order to do the work. This resulted in some rather tortured logic involving a list of pending finalizable statements and a high change of deadlocks or leaks.) Because sqlite3_stmt objects never escape the confines of the SQLiteConnection that owns them, we can also greatly simplify the design of the SQLiteProgram, SQLiteQuery and SQLiteStatement objects. They no longer have to wrangle a native sqlite3_stmt object pointer and manage its lifecycle. So now all they do is hold bind arguments and provide a fancy API. All of the JNI glue related to managing database connections and performing transactions is now bound to SQLiteConnection (rather than being scattered everywhere). This makes sense because SQLiteConnection owns the native sqlite3 object, so it is the only class in the system that can interact with the native SQLite database directly. Encapsulation for the win. One particularly tricky part of this change is managing the ownership of SQLiteConnection objects. At any given time, a SQLiteConnection is either owned by a SQLiteConnectionPool or by a SQLiteSession. SQLiteConnections should never be leaked, but we handle that case too (and yell about it with CloseGuard). A SQLiteSession object is responsible for acquiring and releasing a SQLiteConnection object on behalf of a single thread as needed. For example, the session acquires a connection when a transaction begins and releases it when finished. If the session cannot acquire a connection immediately, then the requested operation blocks until a connection becomes available. SQLiteSessions are thread-local. A SQLiteDatabase assigns a distinct session to each thread that performs database operations. This is very very important. First, it prevents two threads from trying to use the same SQLiteConnection at the same time (because two threads can't share the same session). Second, it prevents a single thread from trying to acquire two SQLiteConnections simultaneously from the same database (because a single thread can't have two sessions for the same database which, in addition to being greedy, could result in a deadlock). There is strict layering between the various database objects, objects at lower layers are not aware of objects at higher layers. Moreover, objects at higher layers generally own objects at lower layers and are responsible for ensuring they are properly disposed when no longer needed (good for the environment). API layer: SQLiteDatabase, SQLiteProgram, SQLiteQuery, SQLiteStatement. Session layer: SQLiteSession. Connection layer: SQLiteConnectionPool, SQLiteConnection. Native layer: JNI glue. By avoiding cyclic dependencies between layers, we make the architecture much more intelligible, maintainable and robust. Finally, this change adds a great deal of new debugging information. It is now possible to view a list of the most recent database operations including how long they took to run using "adb shell dumpsys dbinfo". (Because most of the interesting work happens in SQLiteConnection, it is easy to add debugging instrumentation to track all database operations in one place.) Change-Id: Iffb4ce72d8bcf20b4e087d911da6aa84d2f15297
/frameworks/base/core/java/android/database/sqlite/SQLiteDirectCursorDriver.java
|
16057fad00d47e920fc20721b70c7cafb765f7f8 |
|
18-Mar-2011 |
Vasu Nori <vnori@google.com> |
fix broken logTimeStat stuff log time in the following 2 situations 1. all transactions. time measured = wall time between begin-commit 2. queries (which are not in tranactions) Change-Id: I67be9487a96072695aff3529ba4a257f4c8ec596
/frameworks/base/core/java/android/database/sqlite/SQLiteDirectCursorDriver.java
|
0732f7912ccec9a1cc379b535ac0b56ae50972b3 |
|
30-Jul-2010 |
Vasu Nori <vnori@google.com> |
random but useful stuff 1. move binding of args to one place - to SQLiteProgram 2. reduce locking time in SQLiteDatabase 3. reduce locking during time of binding of args 4. rmeove test for the deprecated ArrayListCursor 5. a couple of nits here and there Change-Id: I20c33c8ffe3325df67af655f1d20614f7f727cb7
/frameworks/base/core/java/android/database/sqlite/SQLiteDirectCursorDriver.java
|
65a8883f0e605bb8a73a692987b47ce5da632e72 |
|
17-Jul-2010 |
Vasu Nori <vnori@google.com> |
don't store mDatabase in SQLiteCursor as it is already in SQLiteQuery SQLiteCursor has two members: mQuery, mDatabase but mQuery already has mDatabase. there is no need for SQLiteCursor.mDatabase. and everytime SQLiteQuery.mDatabase is to be used, try to use a pooled database connection handle, if possible. Change-Id: I42b2376d714a1a4091c843e245a45b882bb7fee6
/frameworks/base/core/java/android/database/sqlite/SQLiteDirectCursorDriver.java
|
6f37f83a4802a0d411395f3abc5f24a2cfec025d |
|
19-May-2010 |
Vasu Nori <vnori@google.com> |
close() on anything other than database shouldn't acquire db lock. bug:2683001 implmentation details: 1.close() on any sql statement is should simply queued up for finalization to be performed later. caller doesn't acquire database lock. 2. the only effect of NOT close immediately is non-release of some memory. 3. all such queued-up-finalizations are performed whenever there is another execute() of some sql statement on that database from ANY thread in the process. 4. database close() automatically releases all unfinalized statements before closing the database. Change-Id: If4c9c7fde6b8945a41abc6c8b992aa8c69854512
/frameworks/base/core/java/android/database/sqlite/SQLiteDirectCursorDriver.java
|
9463f297ef51bd056626d0fb0708c83509f7ebd9 |
|
30-Apr-2010 |
Vasu Nori <vnori@google.com> |
sometimes database lock is not held before compiling a statement indirectly uncovered by bug:2631971 Change-Id: I71059b6b62bc21612fc98689aefd4534884c8e7c
/frameworks/base/core/java/android/database/sqlite/SQLiteDirectCursorDriver.java
|
d606b4bf2c1a2308b40785860853cfb95a77bf58 |
|
24-Feb-2010 |
Vasu Nori <vnori@google.com> |
in finalize() methods, log warnings if db lock is going to be held. this is to track bug:2463988 and bug:2457342
/frameworks/base/core/java/android/database/sqlite/SQLiteDirectCursorDriver.java
|
9066cfe9886ac131c34d59ed0e2d287b0e3c0087 |
|
04-Mar-2009 |
The Android Open Source Project <initial-contribution@android.com> |
auto import from //depot/cupcake/@135843
/frameworks/base/core/java/android/database/sqlite/SQLiteDirectCursorDriver.java
|
d83a98f4ce9cfa908f5c54bbd70f03eec07e7553 |
|
04-Mar-2009 |
The Android Open Source Project <initial-contribution@android.com> |
auto import from //depot/cupcake/@135843
/frameworks/base/core/java/android/database/sqlite/SQLiteDirectCursorDriver.java
|
54b6cfa9a9e5b861a9930af873580d6dc20f773c |
|
21-Oct-2008 |
The Android Open Source Project <initial-contribution@android.com> |
Initial Contribution
/frameworks/base/core/java/android/database/sqlite/SQLiteDirectCursorDriver.java
|