Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: sql/error_delegate_util.cc

Issue 11141012: Move ErrorDelegate to its own file and add static utility functions to ErrorDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix win build Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sql/error_delegate_util.h ('k') | sql/sql.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sql/error_delegate_util.cc
diff --git a/sql/error_delegate_util.cc b/sql/error_delegate_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..37fe006947e0afcd8e8f329d62666fef5b287983
--- /dev/null
+++ b/sql/error_delegate_util.cc
@@ -0,0 +1,80 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sql/error_delegate_util.h"
+
+#include "third_party/sqlite/sqlite3.h"
+
+namespace sql {
+
+bool IsErrorCatastrophic(int error) {
+ switch (error) {
+ case SQLITE_DONE:
+ case SQLITE_OK:
+ // Theoretically, the wrapped delegate might have resolved the error, and
+ // we would end up here.
+ return false;
+
+ case SQLITE_CORRUPT:
+ case SQLITE_NOTADB:
+ // Highly unlikely we would ever recover from these.
+ return true;
+
+ case SQLITE_CANTOPEN:
+ // TODO(erikwright): Figure out what this means.
+ return false;
+
+ case SQLITE_IOERR:
+ // This could be broken blocks, in which case deleting the DB would be a
+ // good idea. But it might also be transient.
+ // TODO(erikwright): Figure out if we can distinguish between the two,
+ // or determine through metrics analysis to what extent these failures are
+ // transient.
+ return false;
+
+ case SQLITE_BUSY:
+ // Presumably transient.
+ return false;
+
+ case SQLITE_TOOBIG:
+ case SQLITE_FULL:
+ case SQLITE_NOMEM:
+ // Not a problem with the database.
+ return false;
+
+ case SQLITE_READONLY:
+ // Presumably either transient or we don't have the privileges to
+ // move/delete the file anyway.
+ return false;
+
+ case SQLITE_CONSTRAINT:
+ case SQLITE_ERROR:
+ // These probgably indicate a programming error or a migration failure
+ // that we prefer not to mask.
+ return false;
+
+ case SQLITE_LOCKED:
+ case SQLITE_INTERNAL:
+ case SQLITE_PERM:
+ case SQLITE_ABORT:
+ case SQLITE_INTERRUPT:
+ case SQLITE_NOTFOUND:
+ case SQLITE_PROTOCOL:
+ case SQLITE_EMPTY:
+ case SQLITE_SCHEMA:
+ case SQLITE_MISMATCH:
+ case SQLITE_MISUSE:
+ case SQLITE_NOLFS:
+ case SQLITE_AUTH:
+ case SQLITE_FORMAT:
+ case SQLITE_RANGE:
+ case SQLITE_ROW:
+ // None of these appear in error reports, so for now let's not try to
+ // guess at how to handle them.
+ return false;
+ }
+ return false;
+}
+
+} // namespace sql
« no previous file with comments | « sql/error_delegate_util.h ('k') | sql/sql.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698