Commit Graph

221 Commits

Author SHA1 Message Date
Vasu Nori
02fc2b01a3 cleanup some of the STOPSHIP comments
removing a check no longer required.
bug:3143859

Change-Id: I6a2ed242d234a4eb78b116bde81efd31e82fafaf
2010-10-28 14:41:59 -07:00
Vasu Nori
6db925001e Merge "increase sql statement printed in finalier warnings from 100 to 1000" 2010-10-25 12:08:46 -07:00
Vasu Nori
b73cf1cc39 increase sql statement printed in finalier warnings from 100 to 1000
100 for sql statement seems too small for some apps (gmail is one example)

Change-Id: I4d29bffc0da5a854ca650d083b81df8769b35b77
2010-10-25 11:55:56 -07:00
Vasu Nori
74fb2685e2 when printing cache-full warning, print the sql statements in cache
this should help debug developers in idetifying the sql statements
taking up cache slots

Change-Id: Ibc0140c273adc5c8d58ab359d2c4d4ce14b6b63b
2010-10-25 11:50:56 -07:00
Vasu Nori
f0808f810e when printing requery on UI warning, include additional info
this hsould help figure out which module is doing query on UI thread.

Change-Id: If3062a35fa1fb50063b678c3c9311d6b1504fa9b
2010-10-08 14:48:48 -07:00
Vasu Nori
6d970255af STOPSHIP - add illegalStateException to catch potential deadlocks in db
database lock() should not be called from a synchronized methods
in database layer. add code to check.
this will catch potential deadlock situations sooner

Change-Id: I9d913f5e2af304f4d9ad5b2641c3a768c4bc97f9
2010-10-05 10:50:45 -07:00
Brad Fitzpatrick
e0ad63bf1e resolved conflicts for merge of 6718b365 to master
Change-Id: I32762a4a3b00856f6765d50667b667264a385fc6
2010-10-01 13:57:04 -07:00
Brad Fitzpatrick
6718b365bc am 32e60c79: Update StrictMode\'s public API.
Merge commit '32e60c7942eeba920ec5c27b372ec0899fd75a20' into gingerbread-plus-aosp

* commit '32e60c7942eeba920ec5c27b372ec0899fd75a20':
  Update StrictMode's public API.
2010-10-01 13:05:02 -07:00
Brad Fitzpatrick
32e60c7942 Update StrictMode's public API.
This makes it more future-proof and maintainable, not exposing the
internal bitpacking state.

The implementation is unchanged (the policy is still just an int we pass
around).

Also starts to introduce VmPolicy, for things which are process-wide,
not per-thread.  As an initial user, make SQLite's Cursor finalization
leak warnings use StrictMode.

Change-Id: Idedfba4e965716f5089a52036421460b1f383725
2010-10-01 12:54:10 -07:00
Vasu Nori
2467561ac2 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
2010-09-28 13:38:14 -07:00
Vasu Nori
587423afb5 fix this: closing database twice fails with IllegalStateException
Change-Id: Idda35e49d539845099b377872f9a6f0e0caa4626
2010-09-27 18:26:25 -07:00
Vasu Nori
8fef1b7520 reduce synchronization on SQLiteDatabase wherever possible
Change-Id: Ibb8617667752eab45d29b01d332b68c3547bdea8
2010-09-27 14:05:09 -07:00
Vasu Nori
ffe06127f6 remove public API setConnectionPoolSize()
because connection pool size is now settable by modifying config.xml
of the device.

Change-Id: I973cc11d7dc10c8d95ab83e2f691068f6019fa33
2010-09-27 13:30:49 -07:00
Vasu Nori
5a049b0fff temporarily comment out dbstats info code when doing adb bugreport
could this be causing bugs like bug:2990184

Change-Id: I315aaa93c1d71922ad4bc96ba0a14a9261a6f39a
2010-09-24 09:26:43 -07:00
Vasu Nori
b745ec9542 am 173ea091: Merge "DO NOT MERGE - use appropriate names on SQL numbers in \'adb bugreport\'" into gingerbread
Merge commit '173ea0912af296c6e80d14b764046534b316d21f' into gingerbread-plus-aosp

* commit '173ea0912af296c6e80d14b764046534b316d21f':
  DO NOT MERGE - use appropriate names on SQL numbers in 'adb bugreport'
2010-09-21 12:25:39 -07:00
Vasu Nori
9540a8d320 DO NOT MERGE - use appropriate names on SQL numbers in 'adb bugreport'
output now looks like the following
  SQL
                  heap:      551          MEMORY_USED:      551
    PAGECACHE_OVERFLOW:      113          MALLOC_SIZE:       50

 DATABASES
    pgsz   dbsz   Lookaside(b)  Dbname
       1    148           500  contacts2.db
       1      8             0    (attached) presence_db
       1     18            31  :memory:SQL

Change-Id: I8bb65a522fd9478ff2f6a8c27e69f9e6c10aef8a
2010-09-21 12:07:24 -07:00
Vasu Nori
4d76d0b832 STOPSHIP follow up to Change-Id: I392875b62ed270741633f5bffa519932e4a9f985
adding back an object that originally existed (when the bug appeared randomly)

Change-Id: Ie6fef529e7b366aaecaace5d3409f2cdc551c8ae
2010-09-21 11:28:49 -07:00
Vasu Nori
627b331b32 add new param to device config properties: db connection pool size
connection pool = number of database connections opened when the app opens
a database. These pooled connections are used by readers only and they
use the sqlite write-ahead-logging option to increase reader
concurrency.
The size of this connection pool depends on the number of CPUs, RAM etc.
On most single-core devices, this can be set to 1.
But on some multi-core devices with more RAM, pool size can be
more than 1.
On a device with more resources, here are the results of a test (in
coretests/src/android/database/sqlite/SQLiteDatabaseTest.java)
which measures the reader-parallelism achieved for different connection
pool sizes.
connpool-size = 1
  num xacts by writer = 467
  num-reads-in-xact/NOT-in-xact by reader1 = 1358/14542, by reader2 = 1431/14269
connpool-size = 2
  num xacts by writer = 473
  num-reads-in-xact/NOT-in-xact by reader1 = 5703/35227, by reader2 = 6222/35898
connpool-size = 3
  num xacts by writer = 542
  num-reads-in-xact/NOT-in-xact by reader1 = 6531/32329, by reader2 = 6252/32728
connpool-size = 4
  num xacts by writer = 578
  num-reads-in-xact/NOT-in-xact by reader1 = 6009/32701, by reader2 = 5977/32953
connpool-size = 5
  num xacts by writer = 547
  num-reads-in-xact/NOT-in-xact by reader1 = 6554/31186, by reader2 = 5318/31022
connpool-size = 6
  num xacts by writer = 534
  num-reads-in-xact/NOT-in-xact by reader1 = 5317/31463, by reader2 = 5413/31537
connpool-size = 7
  num xacts by writer = 549
  num-reads-in-xact/NOT-in-xact by reader1 = 5396/28004, by reader2 = 5214/28496

seems like connection pool size of 3 is optimal on this device.

Change-Id: I348ff5a31783c31b5e3e5ac78b7c2cea54ef114a
2010-09-21 11:05:39 -07:00
Vasu Nori
4e874edf69 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
2010-09-17 10:15:40 -07:00
Vasu Nori
23221192a0 change error message on cl I392875b62ed270741633f5bffa519932e4a9f985
Change-Id: I9eaf201822a9efd8afbdf5cd0e7ef2f01749b955
2010-09-16 13:59:31 -07:00
Vasu Nori
6728ebfa92 STOPSHIP some debugging code to help find reproducible testcases
sometimes mReferenceCount in SQLiteCloasable.java has some huge number
(a memory address probably)
this causes a database.close() or sqliteStatement.close() to randomly
fail and not release the object. and that usually causes a finalizer
warning or sqlite to return error "dbclose failed due to
unfinalised statements"

Change-Id: I392875b62ed270741633f5bffa519932e4a9f985
2010-09-16 09:57:42 -07:00
Vasu Nori
5e89ae29f0 fix compiled statement bugs, synchronization bugs
1. when LRU cache wants to remove the eldest entry, it may be finalizing
a statement that is still in use
2. a couple of synchronization issues.
3. a bit code refactoring in SQLiteCompiledSql
4. remove a bunch of unsed debug code from SQLiteDatabase

Change-Id: I45454dc2dbadd7d8842ba77dd2b0e9ff138ec6f4
2010-09-15 15:30:24 -07:00
Makoto Onuki
90bf7c7916 Add AbstractCursor.getNotificationUri.
We'll need it for some tests.

Change-Id: I5db9f570d8ff2f58c73654fbe4a6df881894f865
2010-09-15 13:21:51 -07:00
Vasu Nori
071df261ed change TAG value from "Cursor" to "SQLiteCursor"
it is confusing to figure out where the debug messages are coming from.
this TAG value change helps

Change-Id: I3a6f445fbced4a962cc13dbb8dd1d7968f9aec9d
2010-09-14 16:02:02 -07:00
Vasu Nori
b83cb7cda3 revert Change-Id: Ic610a0c38e7bd7c77006a08c7b82fa01957739e5
can't change return type from void to int.

Change-Id: Iec3d95c731f117aca20b29c719cef7bcc6356ac0
2010-09-14 13:36:01 -07:00
Vasu Nori
5402590f1c change return type from void to int on execSQL() methods
1. let execSQL() methods return the number of rows affected by the SQL
staement executed.
2. remove synchronized on 2 public methods. since public API is not
supposed to have synchronized, this was a mistake in previously submitted
CL

Change-Id: Ic610a0c38e7bd7c77006a08c7b82fa01957739e5
2010-09-14 12:14:26 -07:00
Vasu Nori
b729dcc8a9 Revert "caching code retooled to reduce locking + handle SMP"
This reverts commit 992f7d52fa.

Change-Id: Ia5b789d1b2195d6ce43baffe24296c857f9b30f6
2010-09-14 11:55:24 -07:00
Vasu Nori
d31211fd46 sql statement with syntax errors can leave database lock in bad state
bug:2995940
Change-Id: I8571943cb278bbc622b04549478badb56e5f7573
2010-09-13 15:47:49 -07:00
Vasu Nori
992f7d52fa caching code retooled to reduce locking + handle SMP
1. Moved all code related to compiled-sql statement cache to SQLiteCache.java
Removed all caching related code from everywhere else.
2. Moved all code related to compiling a sql statement and caching it to
SQLiteCompiledSql.java. There was some code in SQLiteProgram.java
releated to this. moved it out.
3. Added state to SQLiteCompiledSql. This is to help in debugging.
Change-Id: I63ab0c9c4419e964eb9796d284dd389985763d83
2010-09-13 14:38:24 -07:00
Vasu Nori
196663234a remove unnecessary synchronization object from SQLiteClosable.
and a couple of other minor SMP fixes

Change-Id: I62bb4dd2fe43fc41074454a25bd84ad1fb4d004d
2010-09-10 14:27:06 -07:00
Vasu Nori
b18f27dbf4 Return count of rows in a resultset only once (when startPos = 0)
If a query returns 100 rows and say only 10 rows fit in 1MB, then client
receiving the cursor from the ContentProvider needs to paginate.
ContentProvider returns count of total data everytime it returns a page
(= 1MB) of data to the client.
Returning total count causes reading (and skipping unwanted) data
from sqlite.
Instead, it should be sufficient to get total count once
and re-use the count value during the life of the cursor
until a requery is performed on the cursor.
(Count won't change unless data is changed - in which case
the cursor is asked to perform requery anyway. So doing count
once and reusing it should work)
Change-Id: I3520d94524dda07be9bcff56b6fbae5276af1d3b
2010-09-10 13:43:19 -07:00
Vasu Nori
441fcf13f3 remove some useless code and add some code to aid in debugging
Change-Id: Ie532848b82dde57cc7a7017661679ece06ca606e
2010-09-07 22:18:31 -07:00
Vasu Nori
422dad0f50 android change to handle Change-Id: Idbeed81b5b7349059e467b33a8641abf0b4aaeff
Change-Id: Icf221a8e8d4c281f7719875816835ad7dfe7f3d1
2010-09-07 12:56:57 -07:00
Vasu Nori
8eb1bfe0f6 Merge "fix isIntegrityCheck() & add a sample impl class and test for DatabaseErrorHandler" 2010-09-02 09:42:11 -07:00
Dmitri Plotnikov
9a9ce6067f Fixing an issue with convert... utility methods.
All these methods promise to do nothing
if the requested column is not present,
but in fact throw exception.

Change-Id: I0e528d53a0425b831b0083ba82c75ba5b41bfdfd
2010-09-02 09:21:28 -07:00
Vasu Nori
bfe1dc2794 fix isIntegrityCheck() & add a sample impl class and test for DatabaseErrorHandler
fixed a bug in SQLiteDatabase.isDatabaseIntegrityOk()
and added a new class to demonstrate use of
android.database.DatabaseErrorHandler
and a bunch of nits

Change-Id: Ia81870853fa3bd84074637f6d823a9fd22b66c7e
2010-08-30 10:28:47 -07:00
Jean-Baptiste Queru
a4ddf42673 resolved conflicts for merge of c64b916e to master
Change-Id: I31b84d72186a918f19e0c9dee8fdebc83f661cc1
2010-08-24 10:45:16 -07:00
Vasu Nori
cc6f54910d SQLiteOpenHelper should discard closed singleton database objects
bug:2943028
Change-Id: I4b6263cc25413995363158c976d3c723231cc050
2010-08-23 17:08:41 -07:00
Vasu Nori
9a8bc78da7 weird java bug. bug:2941509
Change-Id: I70edabbdb5c715018227958b74fa1ac4e4df3f88
2010-08-23 12:07:00 -07:00
Jean-Baptiste Queru
c64b916ef5 resolved conflicts for merge of e7731f0a to gingerbread-plus-aosp
Change-Id: I8001a95f8c44ef0343e0a50de4bd5b5a85d41c38
2010-08-20 18:19:03 -07:00
Christian Mehlmauer
e7731f0a7f Added overload methods for DatabaseUtils.queryNumEntries
Now you can filter the count statement with a selection
and selection args
UnitTests for this new methods are added to the cts project

Change-Id: Id9233aec0eaac08839041ae7cbaba203470ad3d8
2010-08-20 18:02:09 -07:00
Bjorn Bringert
a006b47298 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
2010-08-18 15:39:52 +01:00
Jeff Hamilton
f0cfe3438a Add a few helpful APIs.
Change-Id: Ie57aa71eb77a1e0fb058f4eb6f40d4144a6dfce7
2010-08-10 10:13:18 -05:00
Vasu Nori
0732f7912c 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
2010-08-03 10:48:14 -07:00
Vasu Nori
e7fa4aeb60 before shipping, remove stacktrace printing in requery-warning msg
this is to reduce log spamming
Change-Id: I9b6e08905fbf7f880e49144a4ffcf01550a521c9
2010-08-02 15:06:52 -07:00
Vasu Nori
ce38b98feb do begin-end transaction before standalone insert/update/delete sql
also fix bug# 2871037
Change-Id: I13325f8eabff4f218d3206905010803b61d8e2cd
2010-08-02 14:51:33 -07:00
Vasu Nori
dea9713387 expose more sqlite errors as exceptions
this should help developers figure out what various sqlite errors mean
and possibly programmatically handle them.

Change-Id: I5c313be1b17b6c5171929bf04e19a16ea92bb357
2010-07-29 14:57:08 -07:00
Brad Fitzpatrick
c3a8c8a767 am a4ab2651: am 4d544376: am 86c035f0: Merge "COMMENT ONLY change to clarify ContentProvider documentation." into froyo
Merge commit 'a4ab26513426bf86c51c3c9419efb148be3aca8e'

* commit 'a4ab26513426bf86c51c3c9419efb148be3aca8e':
  COMMENT ONLY change to clarify ContentProvider documentation.
2010-07-27 17:02:56 -07:00
Brad Fitzpatrick
a4ab265134 am 4d544376: am 86c035f0: Merge "COMMENT ONLY change to clarify ContentProvider documentation." into froyo
Merge commit '4d5443762bd2b44b28edc2f2f75728911d70eac1' into gingerbread-plus-aosp

* commit '4d5443762bd2b44b28edc2f2f75728911d70eac1':
  COMMENT ONLY change to clarify ContentProvider documentation.
2010-07-27 16:54:40 -07:00
Brad Fitzpatrick
4d5443762b am 86c035f0: Merge "COMMENT ONLY change to clarify ContentProvider documentation." into froyo
Merge commit '86c035f0d176be9cb06b1e4f2390c25701417586' into gingerbread

* commit '86c035f0d176be9cb06b1e4f2390c25701417586':
  COMMENT ONLY change to clarify ContentProvider documentation.
2010-07-27 16:52:12 -07:00