1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "sql/error_delegate_util.h" 6 7 #include "third_party/sqlite/sqlite3.h" 8 9 namespace sql { 10 11 bool IsErrorCatastrophic(int error) { 12 switch (error) { 13 case SQLITE_DONE: 14 case SQLITE_OK: 15 // Theoretically, the wrapped delegate might have resolved the error, and 16 // we would end up here. 17 return false; 18 19 case SQLITE_CORRUPT: 20 case SQLITE_NOTADB: 21 // Highly unlikely we would ever recover from these. 22 return true; 23 24 case SQLITE_CANTOPEN: 25 // TODO(erikwright): Figure out what this means. 26 return false; 27 28 case SQLITE_IOERR: 29 // This could be broken blocks, in which case deleting the DB would be a 30 // good idea. But it might also be transient. 31 // TODO(erikwright): Figure out if we can distinguish between the two, 32 // or determine through metrics analysis to what extent these failures are 33 // transient. 34 return false; 35 36 case SQLITE_BUSY: 37 // Presumably transient. 38 return false; 39 40 case SQLITE_TOOBIG: 41 case SQLITE_FULL: 42 case SQLITE_NOMEM: 43 // Not a problem with the database. 44 return false; 45 46 case SQLITE_READONLY: 47 // Presumably either transient or we don't have the privileges to 48 // move/delete the file anyway. 49 return false; 50 51 case SQLITE_CONSTRAINT: 52 case SQLITE_ERROR: 53 // These probgably indicate a programming error or a migration failure 54 // that we prefer not to mask. 55 return false; 56 57 case SQLITE_LOCKED: 58 case SQLITE_INTERNAL: 59 case SQLITE_PERM: 60 case SQLITE_ABORT: 61 case SQLITE_INTERRUPT: 62 case SQLITE_NOTFOUND: 63 case SQLITE_PROTOCOL: 64 case SQLITE_EMPTY: 65 case SQLITE_SCHEMA: 66 case SQLITE_MISMATCH: 67 case SQLITE_MISUSE: 68 case SQLITE_NOLFS: 69 case SQLITE_AUTH: 70 case SQLITE_FORMAT: 71 case SQLITE_RANGE: 72 case SQLITE_ROW: 73 // None of these appear in error reports, so for now let's not try to 74 // guess at how to handle them. 75 return false; 76 } 77 return false; 78 } 79 80 } // namespace sql 81