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/SQLiteStatement.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/SQLiteStatement.java
|
d5064be3b5922ee6522a33f8b729ffee2e3d7b4b |
|
14-Dec-2011 |
Jeff Brown <jeffbrown@google.com> |
Make SQLiteQuery and SQLiteProgram final. We can do this because the classes already cannot be subclassed by applications due to the fact they only have package private constructors. One very nice consequence of this observation is that we can hide or delete several @deprecated protected members which are effectively inaccessible because applications cannot create subclasses! Change-Id: I2d3a0d2ad72b9289ebcdf907e4e4e6caf27f9076
/frameworks/base/core/java/android/database/sqlite/SQLiteStatement.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/SQLiteStatement.java
|
3045bbaf58574ad3168466b198b835b29d174c18 |
|
10-Jan-2011 |
Vasu Nori <vnori@google.com> |
bug:3330569 print better message to help debug the problem methods such as SQLiteStatement.simpleQueryForString() expect one and only row to be returned when the query is executed. if the application provides a query that doesn't return any data, then the error message printed is pretty confusing. make it less confusing and print the query itself to help debug the error. Change-Id: Ife2066f3a3eab0b98845a49e8f72b518458a7757
/frameworks/base/core/java/android/database/sqlite/SQLiteStatement.java
|
2467561ac2c7de870417e0405a138c857c9d5629 |
|
27-Sep-2010 |
Vasu Nori <vnori@google.com> |
SQLiteDatabase: fix inconsistent locking Synchronized blocks should never call lock() or any operation that does it. otherwise, bugs like bug:3032897 will occur. Remove synchronization on all methods in SQLiteStatement and SQLiteProgram because the caller is supposed to do the synchronization if the same SQLiteStatement or SQLiteQuery (which extends SQLiteProgram) object is used by more than one thread at the same time. (documentation on SQLiteStatement, SQLiteProgram mentions this note) Change-Id: Ifd6ee94d743c38c187e2eb778c57076da7a15073
/frameworks/base/core/java/android/database/sqlite/SQLiteStatement.java
|
4e874edf69ce9900eb847629dc4d3616972a3468 |
|
16-Sep-2010 |
Vasu Nori <vnori@google.com> |
don't compile statement for certain SQL statements SQL statements such as Create table, Pragma, Begin, Commit, Rollback etc don't need a compiled statement. Change-Id: I55f5e4e6cbb41cbe83e592e25ba852fe23e2b39f
/frameworks/base/core/java/android/database/sqlite/SQLiteStatement.java
|
d31211fd46e342cc1b762d2009149e12f48e4153 |
|
14-Sep-2010 |
Vasu Nori <vnori@google.com> |
sql statement with syntax errors can leave database lock in bad state bug:2995940 Change-Id: I8571943cb278bbc622b04549478badb56e5f7573
/frameworks/base/core/java/android/database/sqlite/SQLiteStatement.java
|
196663234ab1b67fdd88060701e8211f67fd7854 |
|
10-Sep-2010 |
Vasu Nori <vnori@google.com> |
remove unnecessary synchronization object from SQLiteClosable. and a couple of other minor SMP fixes Change-Id: I62bb4dd2fe43fc41074454a25bd84ad1fb4d004d
/frameworks/base/core/java/android/database/sqlite/SQLiteStatement.java
|
cc6f54910d2431e31af176163f61b34d50a33647 |
|
24-Aug-2010 |
Vasu Nori <vnori@google.com> |
SQLiteOpenHelper should discard closed singleton database objects bug:2943028 Change-Id: I4b6263cc25413995363158c976d3c723231cc050
/frameworks/base/core/java/android/database/sqlite/SQLiteStatement.java
|
a006b47298539d89dc7a06b54c070cb3e986352a |
|
14-Apr-2010 |
Bjorn Bringert <bringert@android.com> |
New API and implementation of DB and memory-backed FDs This depends on a kernel patch that implements read(2) in the ashmem driver. Bug http://b/issue?id=2595601 Change-Id: Ie3b10aa471aada21812b35e63954c1b2f0a7b042
/frameworks/base/core/java/android/database/sqlite/SQLiteStatement.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/SQLiteStatement.java
|
ce38b98feb1e7c9c1799eb270c40798d833aa9ae |
|
22-Jul-2010 |
Vasu Nori <vnori@google.com> |
do begin-end transaction before standalone insert/update/delete sql also fix bug# 2871037 Change-Id: I13325f8eabff4f218d3206905010803b61d8e2cd
/frameworks/base/core/java/android/database/sqlite/SQLiteStatement.java
|
fb16cbd9b2e86d6878d4bff820422bc09c8938de |
|
26-Jul-2010 |
Vasu Nori <vnori@google.com> |
add new API in SQLiteStatement to deprecate another. 1. SQLIteStatement.executeUpdateDelete() replaces execute() - and returns the number of rows changed. 2. let SQLiteDatabase.execSQL() call the above new API - which means all CRUD statements by execSQL() are stored in prepared statement cache. 3. remove the following from SQLiteDatabase lastrowId lastchangecount() native_execSQL() Change-Id: I4e93a09dc381f425c3ae6ccc331a7bf227491e22
/frameworks/base/core/java/android/database/sqlite/SQLiteStatement.java
|
e25539fdfdf884eee55107efbcc893f44e82e00e |
|
09-Jul-2010 |
Vasu Nori <vnori@google.com> |
reduce locking when using SQLiteStatement Do compiling of sql, binding of args and execution of the SQL statement within one single database lock period. This reduces the number of times the database lock needs to be acquired during the course of compilation, binding and execution of a SQLiteStatement. Change-Id: I22b090ec9e10fc0aa2532a93bafe610af2546b58
/frameworks/base/core/java/android/database/sqlite/SQLiteStatement.java
|
2827d6d974beabb12344040a002dcb52dd7106b5 |
|
04-Jul-2010 |
Vasu Nori <vnori@google.com> |
for WAL to work, can't keep prepared SQL stmt_id in SQLiteStatement Some (including the Contacts app) do the following: 1. Open database 2. As part of database_connection.onCreate(), Create some SQLiteStatement objects to cache them in the process 3. attach databases WAL doesn't work with attached databases. so, apps doing the above should enable WAL only if there are no attached databases. But we would like to enable WAL automatically for all apps after step #1 above and disable WAL if the app subsequently does 'attach database' SQL. this works only if there are no SQLiteStatement objects created in step # 2, because SQLiteStatements cwmaintain a hard-reference to the database connection for life and also to the prepared SQL statement id. It is quite difficult to disable WAL in step # 3 if it is enabled in step # 1 and then a connection pool gets used by step # 2 would make WAL disabling easier if SQLiteStatement refers to prepared SQL statement id only when it is needed (during binding and execute calls) and thus NOT tied to a spacific database conenction. also, from the standpoint of not blocking readers, it helps NOT to have SQLiteStatement be married to a database connection and prepared SQL statement id for life. Change-Id: I464d57042965a28d2bde88e0f44b66ec119b40dc
/frameworks/base/core/java/android/database/sqlite/SQLiteStatement.java
|
7501010b71d57264a06f82937f5fb29cb9f4b509 |
|
02-Jul-2010 |
Vasu Nori <vnori@google.com> |
some refactoring and multi-threading fixes Change-Id: I7a0497dc2ed7b1e21471d71532558ef243eb9f73
/frameworks/base/core/java/android/database/sqlite/SQLiteStatement.java
|
e407a608b0e2c7aad5cd6321426ec85d35f3bafa |
|
04-Jun-2010 |
Brad Fitzpatrick <bradfitz@android.com> |
resolved conflicts for merge of 7d6362de to master Change-Id: Ic26dd6d617f0edba549c992256511613df00caa6
|
cfda9f3a4756c71b3aadd1387419cb3b513dd400 |
|
03-Jun-2010 |
Brad Fitzpatrick <bradfitz@android.com> |
Sprinkle new BlockGuard around SQLiteDatabase. SQLite is JNI to native code and doesn't go via IFileSystem, so it needs custom sprinkling, at least for now. Change-Id: Ic7fded1b64a4f483dfc17b3a7b136c803df1e111
/frameworks/base/core/java/android/database/sqlite/SQLiteStatement.java
|
ccd954480c32e9f35357b66023ae912e7f3fa76b |
|
29-May-2010 |
Vasu Nori <vnori@google.com> |
cleanup some small but ugly things. all minor things. Change-Id: I6a3ea9ad563ea895e7f3c37647bdadd2cfa8fc29
/frameworks/base/core/java/android/database/sqlite/SQLiteStatement.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/SQLiteStatement.java
|
1a3b3d48413d9134738c9b457292fb2b71a5dfe4 |
|
13-May-2010 |
The Android Open Source Project <initial-contribution@android.com> |
merge from open-source master Change-Id: I51b4eccfde8e74c69ab8e0c051bb8ea718ee7101
|
f3ca9a5c7e87319c934b5815566054d2e5c2085f |
|
13-May-2010 |
Jeff Hamilton <jham@android.com> |
Add some documentation about the thread safety of Cursor and some of the SQLite* classes. Change-Id: Icae51052d1c942d7d60bb958d3703411da001079
/frameworks/base/core/java/android/database/sqlite/SQLiteStatement.java
|
c8e1f23891cff31a9da2bab412631ff770a92f56 |
|
14-Apr-2010 |
Vasu Nori <vnori@google.com> |
verify database state before calling sqlite. Bug:2593970 Change-Id: Id68365abccbdca572ad13c2b51162d53993ff540
/frameworks/base/core/java/android/database/sqlite/SQLiteStatement.java
|
5bf67247d2e299f0586de65b2d024f1f835657e0 |
|
16-Mar-2010 |
Vasu Nori <vnori@google.com> |
fix the way last insert rowid is returned if insert statement doesn't succeed, last inserted rowid shoudl return -1 - instead of returning rowid of the last successful insert that may have occurred years before this most recent insert statement failure. Change-Id: Ia517292afd58fdb600da900e0ee01fe051d6e618
/frameworks/base/core/java/android/database/sqlite/SQLiteStatement.java
|
6a353876178ca2fe4bc61f128130067d2c2574d1 |
|
12-Feb-2010 |
Brad Fitzpatrick <bradfitz@android.com> |
Measure walltime in ContentResolver and SQLiteDatabase operations logging. The forgotten parts from Id72f718c / d72f718c9c. Whoops. Tested by watching a device's logcat -b events and observing no huge or negative values. And this time with the right system.img file, even!
/frameworks/base/core/java/android/database/sqlite/SQLiteStatement.java
|
3ef94e25b4c896ecaa85aa2c12b8863ecdf98df0 |
|
05-Feb-2010 |
Vasu Nori <vnori@google.com> |
use sqlite 3.6.22 to print and profile the sql statetements instead of rolling our own trace/profile code in java, lets use sqlite 3.6.22 features. turns out sqlite does a good job of printing the sql statements - including the ones from the triggers.
/frameworks/base/core/java/android/database/sqlite/SQLiteStatement.java
|
4dd4ab4cc322e82401f380aeb877daa4a20d7069 |
|
30-Jan-2010 |
Vasu Nori <vnori@google.com> |
add instrumentation to log the sql statement + bindargs + databasename capture the sql statement along with the bindargs passed in. this will help one to see the sql statements being executed and hopefully will help debug incorrect-sql bugs.
/frameworks/base/core/java/android/database/sqlite/SQLiteStatement.java
|
12311959c6ec6898e3b40d4e8958b29ec0b72da9 |
|
23-Nov-2009 |
Dan Egnor <egnor@google.com> |
Expand db_operation logging to prepare for widespread sample collection: - always enable the log, but subsample for queries faster than 100ms - add information about whether it's blocking a main thread - log the entire sql (have not yet added quoted-string-stripping)
/frameworks/base/core/java/android/database/sqlite/SQLiteStatement.java
|
5a03f36ef845f73eb4473193dbb0f93dd12a51af |
|
21-Oct-2009 |
Vasu Nori <vnori@google.com> |
maintain cache of statementids returned by sqlite upon compiling a sql stmnt
/frameworks/base/core/java/android/database/sqlite/SQLiteStatement.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/SQLiteStatement.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/SQLiteStatement.java
|
076357b8567458d4b6dfdcf839ef751634cd2bfb |
|
03-Mar-2009 |
The Android Open Source Project <initial-contribution@android.com> |
auto import from //depot/cupcake/@132589
/frameworks/base/core/java/android/database/sqlite/SQLiteStatement.java
|
3dec7d563a2f3e1eb967ce2054a00b6620e3558c |
|
03-Mar-2009 |
The Android Open Source Project <initial-contribution@android.com> |
auto import from //depot/cupcake/@137055
/frameworks/base/core/java/android/database/sqlite/SQLiteStatement.java
|
d24b8183b93e781080b2c16c487e60d51c12da31 |
|
11-Feb-2009 |
The Android Open Source Project <initial-contribution@android.com> |
auto import from //branches/cupcake/...@130745
/frameworks/base/core/java/android/database/sqlite/SQLiteStatement.java
|
54b6cfa9a9e5b861a9930af873580d6dc20f773c |
|
21-Oct-2008 |
The Android Open Source Project <initial-contribution@android.com> |
Initial Contribution
/frameworks/base/core/java/android/database/sqlite/SQLiteStatement.java
|