summaryrefslogtreecommitdiffstats
path: root/sql/connection.h
Commit message (Collapse)AuthorAgeFilesLines
* Misc. cleanup found while mucking with search engines code:pkasting@chromium.org2014-04-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | * Don't handle DCHECK failure * Remove NOTREACHED()/LOG(ERROR) from cases that look like they could legitimately happen * All lines of args should begin at the same position * WebDataService::SetDefaultSearchProvider() doesn't actually need a full TemplateURL, just an ID * Use GetCachedStatement correctly, and in more places * Make KeywordTableTest a friend of KeywordTable to reduce FRIEND_TEST declarations and in preparation for making Add/Update/RemoveKeyword private * Data members should be private, not protected * Function declarations: all args on first line or one arg per line * Fix misspelling BUG=none TEST=none R=shess@chromium.org Review URL: https://codereview.chromium.org/217613002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260933 0039d316-1c4b-4281-b951-d872f2087c98
* [sql] Rewrite Connection::Preload() in terms of file reading.shess@chromium.org2013-12-211-12/+10
| | | | | | | | | | | | | | | r204860 rewrote sqlite3_preload() to read the file without placing the data in the SQLite cache to improve memory footprint. No reports of performance degradation ensued. This CL rewrites Connection::Preload() to use the SQLite file handle to read the data, and backs out the preload-cache.patch from third_party/sqlite/. BUG=243949 Review URL: https://codereview.chromium.org/116443004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242225 0039d316-1c4b-4281-b951-d872f2087c98
* AppCache: Run a quick integrity check on the sqlite database when opening. ↵michaeln@chromium.org2013-12-161-5/+14
| | | | | | | | | | | | If the test fails, delete the appcache directory and start afresh. NOTRY=true TBR=sky BUG=318544 Review URL: https://codereview.chromium.org/104593010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240937 0039d316-1c4b-4281-b951-d872f2087c98
* [sql] Log tag with sqlite errors.shess@chromium.org2013-09-261-3/+11
| | | | | | | | | | | | | | | Log lines like: ERROR:connection.cc(1007)] sqlite error 266, errno 5: disk I/O error would be ever so much more useful if they indicated which database they were associated with. This logs the histogram tag, which indicates the logical database (the code which owns this connection). [As opposed to the filesystem name.] BUG=none Review URL: https://codereview.chromium.org/24638002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225518 0039d316-1c4b-4281-b951-d872f2087c98
* Recover corrupt Favicon databases.shess@chromium.org2013-09-251-1/+6
| | | | | | | | | | | | | | | | | | | | Add sql::Recovery support to ThumbnailDatabase. Rearrange the schema setup to allow sharing with the recovery code. Unit test a few corruption cases. Add sql::Recovery::Rollback() to allow transitioning code to monitor failures for diagnostic purposes. It is possible/likely that that function can be removed if failure cases are infrequent enough (in which case it with Unrecoverable()). Expose sql::Connection::ShouldIgnore() to allow the error callback to support sql::ScopedErrorIgnorer for testing. BUG=240396 Review URL: https://chromiumcodereview.appspot.com/23533038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225144 0039d316-1c4b-4281-b951-d872f2087c98
* Refactor clearing thumbnail history.shess@chromium.org2013-08-161-0/+5
| | | | | | | | | | | | | Previously, ThumbnailDatabase exposed much internals knowledge. Push most of that down into the class and remove the schema hacks which are no longer necessary. BUG=272519 TEST=Unit tests. Review URL: https://chromiumcodereview.appspot.com/22898003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217993 0039d316-1c4b-4281-b951-d872f2087c98
* [sql] Scoped recovery framework.shess@chromium.org2013-07-191-6/+37
| | | | | | | | | | | | | | | | | | sql::Recovery is intended to be used within a sql::Connection error callback to either recover the database (*) or indicate that the database is unrecoverable and should be razed. The intend is that the code should either progress to a valid database which is composed of data recovered from the original (likely corrupt) database, or a valid database which is empty. This is just the framework without the SQLite-level data-recovery virtual table. BUG=109482 Review URL: https://chromiumcodereview.appspot.com/19281002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212607 0039d316-1c4b-4281-b951-d872f2087c98
* Adds a MemoryPressureListener to sql::Connection.rmcilroy@chromium.org2013-07-181-0/+6
| | | | | | | | | | | This will allow SQLite database to reduce their page cache memory on systems which provide a MemoryPressureListener signal. BUG=243769 Review URL: https://chromiumcodereview.appspot.com/17071007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212374 0039d316-1c4b-4281-b951-d872f2087c98
* [sql] Allow restricting database to user read access.shess@chromium.org2013-07-171-0/+7
| | | | | | | | | | | | | | By default POSIX umask is generally 0644. For some databases, it makes sense to restrict access to 0600. Use new setting for password database. BUG=258771 R=gbillock@chromium.org, isherman@chromium.org, jorgelo@chromium.org Review URL: https://codereview.chromium.org/5125579611308032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212106 0039d316-1c4b-4281-b951-d872f2087c98
* [sql] Retry Open() if error handler fixed things.shess@chromium.org2013-07-171-1/+8
| | | | | | | | | | | | Since the caller cannot have existing database-derived state before the database is opened, Open() can be safely retried after the error handler has razed the database. BUG=109482 Review URL: https://chromiumcodereview.appspot.com/18641004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211936 0039d316-1c4b-4281-b951-d872f2087c98
* [sql] Callback and scoped-ignore tests for sql::Statement.shess@chromium.org2013-07-121-0/+3
| | | | | | | | | | | | | | Test error callback and ScopedErrorIgnorer for running statements. Share error-callback test code between statement and connection tests. Test additional error-callback edge cases. Also fix callback use-after-free case. BUG=254584 Review URL: https://chromiumcodereview.appspot.com/17726002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211281 0039d316-1c4b-4281-b951-d872f2087c98
* Use a direct include of time headers in rlz/, skia/, sql/, sync/.avi@chromium.org2013-06-281-1/+1
| | | | | | | | | | BUG=254986 TEST=none TBR=ben@chromium.org Review URL: https://codereview.chromium.org/18031009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209152 0039d316-1c4b-4281-b951-d872f2087c98
* [sql] Static helper to delete database and all associated files.shess@chromium.org2013-06-241-0/+12
| | | | | | | | | | | Not all of the ad-hoc file_util::Delete() cases handle -journal, and if -wal was added all of them need to be tracked down. BUG=none Review URL: https://chromiumcodereview.appspot.com/17058004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208140 0039d316-1c4b-4281-b951-d872f2087c98
* [sql] Framework for allowing tests to handle errors.shess@chromium.org2013-06-181-0/+11
| | | | | | | | | | | | | | | | sql/ throws FATAL whenever it sees inappropriate calls, which makes production code to handle errors hard to test. ScopedErrorIgnorer provides a way for tests to signal that specific errors are expected and will be handled. As a first pass, code up some additional tests for some Raze() edge cases, and modify things to pass those tests. BUG=159490 Review URL: https://chromiumcodereview.appspot.com/16664005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207096 0039d316-1c4b-4281-b951-d872f2087c98
* Remove sql::ErrorDelegate.shess@chromium.org2013-06-141-45/+0
| | | | | | | | | | API cleanup. Replaced by ErrorCallback. BUG=none Review URL: https://chromiumcodereview.appspot.com/16788002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@206299 0039d316-1c4b-4281-b951-d872f2087c98
* Post integrity_check data for corrupt thumbnail databases.shess@chromium.org2013-05-221-0/+7
| | | | | | | | | | | | | | | | | | | | | Analyzing the results from DatabaseErrorCallback() show a lot of SQLITE_CORRUPT opening the database and setting up the meta table. Add additional diagnostic information for these cases to direct future development, and also dial down the amount of data uploaded to allow finding other cases more easily. For SQLITE_CORRUPT and SQLITE_READONLY, only give the chance to report on first encounter. Cross-platform results are inconsistent. On OSX, almost all of the SQLITE_CORRUPT cases are in initialization, whereas on Windows there are more in code which updates the database. For these errors, it is reasonable to expect any future call to return the error again, so it is pointless to let it get multiple attempts. BUG=240396 Review URL: https://chromiumcodereview.appspot.com/15327004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@201494 0039d316-1c4b-4281-b951-d872f2087c98
* Dump additional error info for thumbnail database.shess@chromium.org2013-05-171-0/+25
| | | | | | | | | | | | | The union of SQLite error messages and platform errno is a potentially large space which may not be reasonable to histogram. Instead, randomly dump a crash report with diagnostic information which can be correlated with histograms. BUG=240396 Review URL: https://chromiumcodereview.appspot.com/15131008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200759 0039d316-1c4b-4281-b951-d872f2087c98
* Histogram versions and extended error codes for SQLite databases.shess@chromium.org2013-05-151-7/+11
| | | | | | | | | | | | | | | | | | | Track database versions across the fleet for purposes of making decisions about whether old migration code can be removed. As part of this, refactor histogram code to key off a per-database tag rather than histogram name, and to log in a form which can be fanned out via the field trial logic in histograms.xml [FYI michaeln from webkit/OWNERS, erikwright from {chrome,content}/net/OWNERS, sky for chrome/browser/history/OWNERS] BUG=none TBR=michaeln@chromium.org, erikwright@chromium.org, sky@chromium.org Review URL: https://chromiumcodereview.appspot.com/14976003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200216 0039d316-1c4b-4281-b951-d872f2087c98
* Implement sql::Connection::RazeAndClose().shess@chromium.org2013-02-071-10/+39
| | | | | | | | | | | | | | | | | | | Raze() clears out the database, but cannot be called within a transaction. Close() can only be called once all statements have cleared. Error callbacks happen while executing statements (thus often in a transaction, and at least one statement is outstanding). RazeAndClose() forcibly breaks outstanding transactions, calls Raze() to clear the database, then calls Close() to close the handle. All future operations against the database should fail safely (without affecting storage and without crashing). BUG=166419, 136846 Review URL: https://chromiumcodereview.appspot.com/12096073 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181152 0039d316-1c4b-4281-b951-d872f2087c98
* Add FilePath to base namespace.brettw@chromium.org2013-02-021-2/+5
| | | | | | | This updates headers that forward-declare it and a few random places to use the namespace explicitly. There us a using declaration in file_path.h that makes the rest compile, which we can do in future passes. Review URL: https://codereview.chromium.org/12163003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180245 0039d316-1c4b-4281-b951-d872f2087c98
* Fixing null pointer dereference.glotov@chromium.org2013-01-171-2/+3
| | | | | | | | | | BUG=chromium:158178 TEST=units,make sure such SEGV doesnt happen on x86-generic-bot (where it pops periodically now) Review URL: https://chromiumcodereview.appspot.com/11886065 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177399 0039d316-1c4b-4281-b951-d872f2087c98
* Bake targeted error histogram support directly into sql::Connection.shess@chromium.org2013-01-031-0/+10
| | | | | | | | | | | | Previously there was a convoluted template system to unique histogram names for purposes of tracking database errors separately. This was needed due to the static cache used by the histogram macros. Instead, just log the histogram manually without using a static cache. Additionally, pull the histogram functionality right up into the connection, rather than requiring formalized delegation to get it. BUG=none Review URL: https://chromiumcodereview.appspot.com/11474030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175055 0039d316-1c4b-4281-b951-d872f2087c98
* Make sql::Connection::Raze() more robust against corruptions.shess@chromium.org2012-11-101-0/+13
| | | | | | | | | | | | | | Corruptions resulting from the first page showing a different database size than the filesystem shows cause very basic functions to fail. This does fewer queries against the corrupt database, and also enables a magic pragma to let it make better progress. BUG=159490 Review URL: https://chromiumcodereview.appspot.com/11369126 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167019 0039d316-1c4b-4281-b951-d872f2087c98
* Move ErrorDelegate to its own file and add static utility functions to ↵pkotwicz@chromium.org2012-10-181-7/+7
| | | | | | | | | | | | | ErrorDelegate BUG=151841 Test=None R=shess, erikwright TBR=cpu Review URL: https://chromiumcodereview.appspot.com/11141012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162647 0039d316-1c4b-4281-b951-d872f2087c98
* Remove ref counting on sql::ErrorDelegatepkotwicz@chromium.org2012-10-171-9/+6
| | | | | | | | | | | | BUG=151841 Test=None R=shess TBR=jamesr,erikwright Review URL: https://chromiumcodereview.appspot.com/11111021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162443 0039d316-1c4b-4281-b951-d872f2087c98
* Annotate calls to SQLite functions - they have to be executed on a thread ↵shess@chromium.org2012-07-271-0/+17
| | | | | | | | | | | | | | | | | | | | | | | allowing IO access. Also expanded scope of ScopedAllowIO in SQLiteServerBoundCertStore::Backend::Load() to cover SQLite functions. And added ScopedAllowIO to PasswordStoreFactory::BuildServiceInstanceFor() -- it calls LoginDatabase::Init() which should be executed on DB thread. This is a reland of https://src.chromium.org/viewvc/chrome?view=rev&revision=147309 which was reverted because of missing ScopedAllowIO in PasswordStoreFactory. Patch from Pavel Ivanov <paivanof@gmail.com> BUG=75232, 52909, 137961, 138903 TEST=no test fails with message "Function marked as IO-only was called from a thread that disallows IO!" Review URL: https://chromiumcodereview.appspot.com/10824008 Patch from Pavel Ivanov <paivanof@gmail.com>. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148788 0039d316-1c4b-4281-b951-d872f2087c98
* [sql] Refactor to remove use of const_cast<>.shess@chromium.org2012-07-241-1/+10
| | | | | | | | | | | | | | | The comments in these cases used incorrect reasoning for why the const_cast<> was safe. Whether the SQL statements modify the database is irrelevant. Add an internal helper to allow them to correctly accomplish things in a const situation. BUG=none TEST=none Review URL: https://chromiumcodereview.appspot.com/10736042 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148031 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 147309 - Annotate calls to SQLite functions - they have to be ↵shess@chromium.org2012-07-181-18/+1
| | | | | | | | | | | | | | | | | | | executed on a thread allowing IO access. Expand scope of ScopedAllowIO in the only place where SQLite functions are used on UI thread. Patch from Pavel Ivanov <paivanof@gmail.com> BUG=75232,52909,137961 TEST=no test fails with message "Function marked as IO-only was called from a thread that disallows IO!" Review URL: https://chromiumcodereview.appspot.com/10540155 Patch from Pavel Ivanov <paivanof@gmail.com>. TBR=shess@chromium.org Review URL: https://chromiumcodereview.appspot.com/10806025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147340 0039d316-1c4b-4281-b951-d872f2087c98
* Annotate calls to SQLite functions - they have to be executed on a thread ↵shess@chromium.org2012-07-181-1/+18
| | | | | | | | | | | | | | | | allowing IO access. Expand scope of ScopedAllowIO in the only place where SQLite functions are used on UI thread. Patch from Pavel Ivanov <paivanof@gmail.com> BUG=75232,52909 TEST=no test fails with message "Function marked as IO-only was called from a thread that disallows IO!" Review URL: https://chromiumcodereview.appspot.com/10540155 Patch from Pavel Ivanov <paivanof@gmail.com>. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147309 0039d316-1c4b-4281-b951-d872f2087c98
* Remove the rest of #pragma once in one big CL.ajwong@chromium.org2012-07-111-1/+0
| | | | | | | | | For context see this thread: https://groups.google.com/a/chromium.org/forum/?fromgroups#!topic/chromium-dev/RMcVNGjB4II TBR=thakis,pkasting,jam git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146163 0039d316-1c4b-4281-b951-d872f2087c98
* Implement sql::Connection::Raze() in terms of sqlite3_backup API.shess@chromium.org2012-04-061-0/+20
| | | | | | | | | | | | | | | | | | Wraps up the notion of reseting a database in a way which respects SQLite locking constraints and doesn't require closing the database. A similar outcome could be managed using filesystem operations, which requires coordination between clients of the database to make sure that no corruption occurs due to incorrect handling of -journal files. Also, Windows pins files until the last handle closes, making that approach challenging in some cases. BUG=none TEST=none Review URL: https://chromiumcodereview.appspot.com/9768006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131167 0039d316-1c4b-4281-b951-d872f2087c98
* [sql] WARN_UNUSED_RESULT on Execute().shess@chromium.org2011-12-231-5/+11
| | | | | | | | | | | | | | | | | | Goal is to encourage callers to handle errors, especially in cases like schema changes, where dropped errors can result in broken databases. Many CREATE INDEX calls where ignoring errors rather than checking if the index already existed before creating it. Recoded those to CREATE INDEX IF NOT EXISTS, which is for exactly this purpose. BUG=none TEST=none Review URL: http://codereview.chromium.org/9005036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115725 0039d316-1c4b-4281-b951-d872f2087c98
* AppCache INTERCEPT namespace.michaeln@google.com2011-12-131-0/+6
| | | | | | | | | | | | | | - Add support for a custom CHROMIUM CACHE MANIFEST signature. Other browsers should ignore files with this signature. - Parse intercept namespace entries out of the new CHROMIUM-INTERCEPT manifest section. Other browsers should ignore this entire section. - Store and retrieve the new kind of namespace records in the database layer. - Upgrade existing databases to the new schema. - Look for matches in the new namespaces when handling main and sub resource requests. - Add unit tests. BUG=101565 Review URL: http://codereview.chromium.org/8396013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114151 0039d316-1c4b-4281-b951-d872f2087c98
* Put debugging assertions into sql::Statement.shess@chromium.org2011-12-121-3/+13
| | | | | | | | | | | | | | | | | | | | | | | Pulls out the core of gbillock's http://codereview.chromium.org/8283002/ - Move NOTREACHED and similar checks into the sql:: implementation code. - Add malformed SQL checks to Connection::Execute. - Add SQL-checking convenience methods to Connection. The general idea is that the sql:: framework assumes valid statements, rather than having client code contain scattered ad-hoc (and thus inconsistent) checks. This version puts back Statement operator overloading and loosy-goosy Execute() calls to allow other code to be updated in small batches. R=gbillock@chromium.org,jhawkins@chromium.org,dhollowa@chromium.org BUG=none TEST=sql_unittests,unit_tests:*Table*.* Review URL: http://codereview.chromium.org/8899012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114118 0039d316-1c4b-4281-b951-d872f2087c98
* export StatementRefdpranke@chromium.org2011-11-121-1/+1
| | | | | | | | | | R=tony@chromium.org BUG=103987 TEST=sql_unittests compiles on the webkit win shared builder Review URL: http://codereview.chromium.org/8538031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109753 0039d316-1c4b-4281-b951-d872f2087c98
* build sql as a component - this will help ensure there is only one copydpranke@chromium.org2011-11-101-2/+3
| | | | | | | | | | of sqlite getting linked in. R=rsesek@chromium.org Review URL: http://codereview.chromium.org/8506027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109510 0039d316-1c4b-4281-b951-d872f2087c98
* Move app/sql/* files to sql/ directory.tfarina@chromium.org2011-07-191-0/+387
I can't remove app/app.gyp and app/app_base.gypi yet because they are referenced by third_party gyp files :( BUG=72317 TEST=None R=rsesek@chromium.org move app/sql to sql Review URL: http://codereview.chromium.org/7353026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93069 0039d316-1c4b-4281-b951-d872f2087c98