Commit Graph

260 Commits

Author SHA1 Message Date
Vasu Nori
3045bbaf58 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
2011-01-10 15:37:47 -08:00
Dianne Hackborn
247fe74c93 Implement issue # 3255887 could CursorLoader offer...
...to throttle contentobserver-based requeries

Why yes, I guess it could.

This also reworks AsyncTaskLoader to not generate multiple
concurrent tasks if it is getting change notifications before
the last background task is complete.

And removes some of the old APIs that had been deprecated but
need to be gone for final release.

And fixes a few little problems with applying the wrong theme
in system code.

Change-Id: Ic7a665b666d0fb9d348e5f23595532191065884f
2011-01-08 18:25:30 -08:00
Vasu Nori
324dbe508e in requery(), when exception is caught, print warning + stacktrace
Change-Id: Ifa03e2c4bcf09fbba5ac028d4c7a74e092450612
2011-01-06 17:45:32 -08:00
Vasu Nori
ca74897b24 in GB requery() didn't throw exceptions (mostly). replicate that in HC
bug:3302851
Change-Id: I56e0bd178b200472cb1dbcbd2e80b844690b8964
2011-01-06 16:35:37 -08:00
Vasu Nori
42edf0f8cf Merge "requery() should close cursorwindow insead of setting it to null." into honeycomb 2011-01-06 11:37:00 -08:00
Vasu Nori
0e453d1115 requery() should close cursorwindow insead of setting it to null.
just in case GC takes a while to kick in.

Change-Id: I3a00b52afe1303be0c7d6bb561e5c07734e4dcb3
2011-01-06 09:52:51 -08:00
Vasu Nori
a22d88493e set default mode of WAL to be off.
apps will have to enable WAL explicitly.

Change-Id: Iba5c47a40f465e668ef0d538282230e99fe04ce6
2011-01-06 09:18:47 -08:00
Vasu Nori
6a904bc65e Revert "treat 'can't open database file error' as 'database corruption error'"
This reverts commit c7fe777d63.

Change-Id: I9992d404394917537d5c22470efbd970605976ed
2011-01-05 18:38:15 -08:00
Brad Fitzpatrick
70588bf864 resolved conflicts for merge of 3a2c6bf0 to master
Change-Id: I1963d8fc391bb84de1054f2b20ce4e082d764cbe
2011-01-05 14:04:06 -08:00
Brad Fitzpatrick
3a2c6bf0fc am 69ea4e15: Documentation fixes found over vacation hacking.
* commit '69ea4e15e52c456537575d21443ac1efdb03a902':
  Documentation fixes found over vacation hacking.
2011-01-05 13:52:53 -08:00
Brad Fitzpatrick
69ea4e15e5 Documentation fixes found over vacation hacking.
Change-Id: I28900026465d66d950cf4f05f0c202b46c3c2d43
2011-01-05 13:07:34 -08:00
Eric Hassold
a5af5d6b12 Add support for downgrading database version in SQLiteOpenHelper
Provide an API to allow application to support downgrade in databases
managed with SQLiteOpenHelper. Since onUpgrade() is now called only
if requested version is newer than current one, this adds support for
a similar onDowngrade() method, so customers can implement graceful
downgrading. If no downgrade method is implemented by caller, this
fallback to current behavior by throwing an exception.

Bug: 1609474
Change-Id: I0e0166984d4a700b1c43ce780b91244bc2fc87a6
2011-01-04 16:55:27 -08:00
Vasu Nori
c7fe777d63 treat "can't open database file error" as "database corruption error"
bug:3083665
if sqlite can't open the database, delete it and create a new one.
what else is sqlite supposed to do?

Change-Id: I8b7c3b051fd1a146e4026f8f8acfdd099f9a70cf
2011-01-04 14:36:16 -08:00
Vasu Nori
36c4cec853 don't call methods doing database lock from a synchronized block
bug:3188552
Change-Id: I08a73f06aa0cbefddd282885f62b8dcc451b9deb
2011-01-04 13:15:56 -08:00
Vasu Nori
6141e13f6e when cursorwindow allocation fails, print the number of cursors left open
the reason for bug:3281533, bug:3127159 is probably too many cursors are left
un-closed in the process.
print the info on the number of cursors left open when the exception
"cursorwindow allocation failed" occurs.
This should help us figure out if that indeed is the reason
and which process is leaving the cursors open.

Change-Id: I4b46be63f5dfbe9b102ad7a9cf9dd21e70f71e14
2011-01-04 10:40:15 -08:00
Vasu Nori
34ad57f0e8 resubmitting Change-Id: I67b1d04a5c9fc18b0cd4da6184d0b814b64d89e9
Change-Id: I67b1d04a5c9fc18b0cd4da6184d0b814b64d89e9 was reverted
due to a bug. fixed the bug and resubmitting it here
2010-12-21 09:32:36 -08:00
Vasu Nori
5274e84e88 Revert "bug:2448371 cursorwindow size moved to resource xml file."
This reverts commit 2594bae1f5.
2010-12-20 14:23:48 -08:00
Vasu Nori
2594bae1f5 bug:2448371 cursorwindow size moved to resource xml file.
let cursor window size be set per device in device resources file.
default is 1MB.
for SR, it is 2MB.
it can be set to any value (in kB) in the device resource
strings.xml file

Change-Id: I67b1d04a5c9fc18b0cd4da6184d0b814b64d89e9
2010-12-20 13:08:08 -08:00
Vasu Nori
b438902369 if db close() fails due to un-closed sql statements, print useful msg
The current error message says "close failed due to unfinalised statements".
This CL fixes that message by incorporating one of the un-closed sql statements
should help developers debug the problem.

Change-Id: I2a24c6ba876caa008507b236052c5f03e8cbb27e
2010-11-29 14:10:46 -08:00
Vasu Nori
00e4017189 Revert "Merge "print certain rows from downloads.db when bugreports are taken""
This reverts commit 34878787f0, reversing
changes made to 5a2755d0c9.
2010-11-29 11:03:23 -08:00
Vasu Nori
624002b0d5 print certain rows from downloads.db when bugreports are taken
when downloads fail/get stuck, we need to look at the database state
for those downloads. and when the users report such problems, it is
a royal pain not to have that info and most users don't seem to bother
sending database dumps because it is a bit of work.

so lets just dump info about downloads that failed or
downloads from GSF (OTAs, for example)

helps debugging. there is STOP ship comment to not dump data once
HC is released.

Change-Id: Id1254982fd82b4c55f1816a2491f00966840f024
2010-11-22 11:59:04 -08:00
Jean-Baptiste Queru
8565a8ebbc resolved conflicts for merge of 1a2344b8 to master
Change-Id: I974f7f388ddc74d661f07fda1e308e7c15e00dfc
2010-11-17 17:31:25 -08:00
Jean-Baptiste Queru
1a2344b8b2 am 09e50cdb: Merge "Reorder lock acquision vs try."
* commit '09e50cdbc62938b178f4c9a66b3cec8a466daaa8':
  Reorder lock acquision vs try.
2010-11-17 17:16:06 -08:00
Jean-Baptiste Queru
09e50cdbc6 Merge "Reorder lock acquision vs try." 2010-11-17 17:03:10 -08:00
Jean-Baptiste Queru
0b92c44f8a am 7ee42771: Merge "resolved conflicts for merge of 8fc378f9 to gingerbread-plus-aosp" into gingerbread-plus-aosp
* commit '7ee427714d4621bd9a0b15364a073aff60ebf20c':
  Added buildQuery and buildUnionSubQuery methods without misleading selectionArgs parameter.
2010-11-17 16:54:39 -08:00
Jean-Baptiste Queru
f4072fcc14 resolved conflicts for merge of 8fc378f9 to gingerbread-plus-aosp
Change-Id: I938c0a66ad4271b33626d6b12406a2f6c6d1b6d8
2010-11-17 16:47:59 -08:00
Brian Muramatsu
46a8851360 Fix NPE in SQLiteDatabase#updateWithOnConflict
Bug 3188586

...to restore old behavior of throwing IllegalArgumentException
when values is null.

Change-Id: Ic2df542b2cdbdb7571080eb7f0fc6a4fe1678446
2010-11-12 14:00:36 -08:00
Jonas Schwertfeger
8402903723 Added buildQuery and buildUnionSubQuery methods without misleading selectionArgs parameter.
The signatures of the existing buildQuery and buildUnionSubQuery methods include a selectionArgs
parameter that is not actually being used in the method implementations.  This parameter leads
to the misconception that SQL paramter substitution is carried out by these methods.  I added
new variants of these methods without that parameter and deprecated the old variants.

Change-Id: I1bf770d5c777649e9aac36d93aa93bd65bbcc2a3
2010-11-12 12:18:37 +01:00
Vasu Nori
8fcda30283 on readonly databases, don't set journal mode and don't allow WAL
nothing should be 'set' on readonly databases
bug:3173033

Change-Id: I1143971f6d06139a7e1ef9e73a92e46342264075
2010-11-08 13:48:45 -08:00
Vasu Nori
b642518e54 fix broken build
Change-Id: If1e5639f48d5155e141bce4bf5deef9de5668c27
2010-11-05 14:47:59 -07:00
Vasu Nori
7301a23fb2 Let cachefull-warning be under SQLiteDebug.DEBUG_SQL_CACHE flag
This warning doesn't really matter much. If a developer wants to
debug the cache usage, it can be done by turning on this flag.
adb bugreport also displays cachestats - which can be used as a debugging tool.

Change-Id: Ied173714d535c271133247ee4768f86d3be359cf
2010-11-05 11:55:57 -07:00
Jean-Baptiste Queru
b079e7d408 am c91e4673: am bbd212d7: Merge "Document per-implementation behaviors of native get* methods"
* commit 'c91e46730d14611fb85cd7b2d3e51dac5ce538a2':
  Document per-implementation behaviors of native get* methods
2010-11-03 10:59:44 -07:00
Jean-Baptiste Queru
ae60b8a132 am 0b5d57ab: am 715f8610: Merge "Clarify documentation of Cursor get* methods."
* commit '0b5d57ab7ea062af4502be5af2d51883d251c0bc':
  Clarify documentation of Cursor get* methods.
2010-11-03 10:59:36 -07:00
Jean-Baptiste Queru
c91e46730d am bbd212d7: Merge "Document per-implementation behaviors of native get* methods"
* commit 'bbd212d77852be155a815a0d2ad1da0df2c0dfe1':
  Document per-implementation behaviors of native get* methods
2010-11-02 14:18:07 -07:00
Jean-Baptiste Queru
0b5d57ab7e am 715f8610: Merge "Clarify documentation of Cursor get* methods."
* commit '715f86107763ee95e7d6558dd8da390a63da63e2':
  Clarify documentation of Cursor get* methods.
2010-11-02 14:18:02 -07:00
Vasu Nori
820e9b6b9c deperecate Cursor requery() and sa, Loader should be used instead
the warning printed currently "do requery on background thread"
is not that useful in processes such as gapps, acore.
to reduce the deluge of bugs assigned to me, I think a simple
deprecation warning is better.

Change-Id: I7a1129ea889f10e72895092a3cdd48cc96d0d1f0
2010-11-02 11:14:38 -07:00
Daniel Trebbien
adf4194458 Document per-implementation behaviors of native get* methods
Change-Id: I5d20d7796b85ce62750dd50dd79e47d76716b24c
2010-11-02 09:35:12 -07:00
Daniel Trebbien
65068b099e Clarify documentation of Cursor get* methods.
Make clear in the Javadoc comments of the `Cursor` get* methods that
implementations thereof can have implementation-defined behavior. In some cases,
these changes actually correct the documentation. For example, in the case of
`getShort` and the `SQLiteCursor` implementation thereof, non-numeric data is
*not* converted to a `short` via Short#valueOf or even in a functionally-
equivalent manner.

Change-Id: Ib2f81811a603680b52fc482eb9c0f3195447566f
2010-11-02 09:24:07 -07:00
Daniel Trebbien
38767b34ba Reorder lock acquision vs try.
In two places involving locking, reordered the code so that the lock
acquisition is performed outside of the `try` block and everything
else that needs to run while the lock is locked *within* the `try`
block.

Change-Id: I3dad2c4bbf60b219fc6db2aa35e2ed296cb39128
2010-11-01 14:13:56 -07:00
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