diff options
author | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-17 16:06:47 +0000 |
---|---|---|
committer | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-17 16:06:47 +0000 |
commit | 4e179ba6e49ca1dc79516986d08bccb9c0eeef59 (patch) | |
tree | c7a341172254cc2128dd09c443ab4373428876e9 /sql | |
parent | 24f5a96345c5c2a9daf3dc77e2ad6ea361175e85 (diff) | |
download | chromium_src-4e179ba6e49ca1dc79516986d08bccb9c0eeef59.zip chromium_src-4e179ba6e49ca1dc79516986d08bccb9c0eeef59.tar.gz chromium_src-4e179ba6e49ca1dc79516986d08bccb9c0eeef59.tar.bz2 |
Persist SQLite journal files.
The default is DELETE mode, in which the delete commits the
transaction. PERSIST keeps the files around, but zeros out the
header.
journal_mode has been in SQLite since 3.5.9 (2008), so even very old
versions of Chromium should interact well.
BUG=118470
TEST=none
Review URL: http://codereview.chromium.org/9702092
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127366 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sql')
-rw-r--r-- | sql/connection.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/sql/connection.cc b/sql/connection.cc index 07e6af2..378e014 100644 --- a/sql/connection.cc +++ b/sql/connection.cc @@ -108,6 +108,11 @@ bool Connection::OpenInMemory() { } void Connection::Close() { + // TODO(shess): Calling "PRAGMA journal_mode = DELETE" at this point + // will delete the -journal file. For ChromiumOS or other more + // embedded systems, this is probably not appropriate, whereas on + // desktop it might make some sense. + // sqlite3_close() needs all prepared statements to be finalized. // Release all cached statements, then assert that the client has // released all statements. @@ -408,6 +413,17 @@ bool Connection::OpenInternal(const std::string& file_name) { DLOG(FATAL) << "Could not set locking mode: " << GetErrorMessage(); } + // http://www.sqlite.org/pragma.html#pragma_journal_mode + // DELETE (default) - delete -journal file to commit. + // TRUNCATE - truncate -journal file to commit. + // PERSIST - zero out header of -journal file to commit. + // journal_size_limit provides size to trim to in PERSIST. + // TODO(shess): Figure out if PERSIST and journal_size_limit really + // matter. In theory, it keeps pages pre-allocated, so if + // transactions usually fit, it should be faster. + ignore_result(Execute("PRAGMA journal_mode = PERSIST")); + ignore_result(Execute("PRAGMA journal_size_limit = 16384")); + const base::TimeDelta kBusyTimeout = base::TimeDelta::FromSeconds(kBusyTimeoutSeconds); |