summaryrefslogtreecommitdiffstats
path: root/app/sql
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-18 04:40:43 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-18 04:40:43 +0000
commit658f8339d68e71ff85fbfe0510e008e56c9daf24 (patch)
tree029f0627d5a506b4a635cdd0b02d5656fef45a50 /app/sql
parent39f5848f56811d459ad1a122a5fa032e505e06e9 (diff)
downloadchromium_src-658f8339d68e71ff85fbfe0510e008e56c9daf24.zip
chromium_src-658f8339d68e71ff85fbfe0510e008e56c9daf24.tar.gz
chromium_src-658f8339d68e71ff85fbfe0510e008e56c9daf24.tar.bz2
Enable extended error codes for SQLite.
This will only apply to app/sql Connection and Statement objects for now. BUG=none TEST=none Review URL: http://codereview.chromium.org/3467001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59897 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/sql')
-rw-r--r--app/sql/connection.cc8
-rw-r--r--app/sql/diagnostic_error_delegate.h3
2 files changed, 11 insertions, 0 deletions
diff --git a/app/sql/connection.cc b/app/sql/connection.cc
index c5f991f..0b9021f 100644
--- a/app/sql/connection.cc
+++ b/app/sql/connection.cc
@@ -277,6 +277,14 @@ bool Connection::OpenInternal(const std::string& file_name) {
return false;
}
+ // Enable extended result codes to provide more color on I/O errors.
+ // Not having extended result codes is not a fatal problem, as
+ // Chromium code does not attempt to handle I/O errors anyhow. The
+ // current implementation always returns SQLITE_OK, the DCHECK is to
+ // quickly notify someone if SQLite changes.
+ err = sqlite3_extended_result_codes(db_, 1);
+ DCHECK_EQ(err, SQLITE_OK) << "Could not enable extended result codes";
+
if (page_size_ != 0) {
if (!Execute(StringPrintf("PRAGMA page_size=%d", page_size_).c_str()))
NOTREACHED() << "Could not set page size";
diff --git a/app/sql/diagnostic_error_delegate.h b/app/sql/diagnostic_error_delegate.h
index 32f747f..c9de8ee 100644
--- a/app/sql/diagnostic_error_delegate.h
+++ b/app/sql/diagnostic_error_delegate.h
@@ -35,6 +35,9 @@ class DiagnosticErrorDelegate : public ErrorDelegate {
private:
static void RecordErrorInHistogram(int error) {
+ // Trim off the extended error codes.
+ error &= 0xff;
+
// The histogram values from sqlite result codes go currently from 1 to
// 26 currently but 50 gives them room to grow.
UMA_HISTOGRAM_ENUMERATION(UniqueT::name(), error, 50);