OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "sql/connection.h" | 5 #include "sql/connection.h" |
6 | 6 |
7 #include <limits.h> | 7 #include <limits.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 13 matching lines...) Expand all Loading... | |
24 #include "base/metrics/sparse_histogram.h" | 24 #include "base/metrics/sparse_histogram.h" |
25 #include "base/single_thread_task_runner.h" | 25 #include "base/single_thread_task_runner.h" |
26 #include "base/strings/string_split.h" | 26 #include "base/strings/string_split.h" |
27 #include "base/strings/string_util.h" | 27 #include "base/strings/string_util.h" |
28 #include "base/strings/stringprintf.h" | 28 #include "base/strings/stringprintf.h" |
29 #include "base/strings/utf_string_conversions.h" | 29 #include "base/strings/utf_string_conversions.h" |
30 #include "base/synchronization/lock.h" | 30 #include "base/synchronization/lock.h" |
31 #include "base/threading/thread_task_runner_handle.h" | 31 #include "base/threading/thread_task_runner_handle.h" |
32 #include "base/trace_event/memory_dump_manager.h" | 32 #include "base/trace_event/memory_dump_manager.h" |
33 #include "sql/connection_memory_dump_provider.h" | 33 #include "sql/connection_memory_dump_provider.h" |
34 #include "sql/error_delegate_util.h" | |
34 #include "sql/meta_table.h" | 35 #include "sql/meta_table.h" |
35 #include "sql/statement.h" | 36 #include "sql/statement.h" |
36 #include "third_party/sqlite/sqlite3.h" | 37 #include "third_party/sqlite/sqlite3.h" |
37 | 38 |
38 #if defined(OS_IOS) && defined(USE_SYSTEM_SQLITE) | 39 #if defined(OS_IOS) && defined(USE_SYSTEM_SQLITE) |
39 #include "base/ios/ios_util.h" | 40 #include "base/ios/ios_util.h" |
40 #include "third_party/sqlite/src/ext/icu/sqliteicu.h" | 41 #include "third_party/sqlite/src/ext/icu/sqliteicu.h" |
41 #endif | 42 #endif |
42 | 43 |
43 namespace { | 44 namespace { |
(...skipping 1649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1693 err = sqlite3_extended_result_codes(db_, 1); | 1694 err = sqlite3_extended_result_codes(db_, 1); |
1694 DCHECK_EQ(err, SQLITE_OK) << "Could not enable extended result codes"; | 1695 DCHECK_EQ(err, SQLITE_OK) << "Could not enable extended result codes"; |
1695 | 1696 |
1696 // sqlite3_open() does not actually read the database file (unless a | 1697 // sqlite3_open() does not actually read the database file (unless a |
1697 // hot journal is found). Successfully executing this pragma on an | 1698 // hot journal is found). Successfully executing this pragma on an |
1698 // existing database requires a valid header on page 1. | 1699 // existing database requires a valid header on page 1. |
1699 // TODO(shess): For now, just probing to see what the lay of the | 1700 // TODO(shess): For now, just probing to see what the lay of the |
1700 // land is. If it's mostly SQLITE_NOTADB, then the database should | 1701 // land is. If it's mostly SQLITE_NOTADB, then the database should |
1701 // be razed. | 1702 // be razed. |
1702 err = ExecuteAndReturnErrorCode("PRAGMA auto_vacuum"); | 1703 err = ExecuteAndReturnErrorCode("PRAGMA auto_vacuum"); |
1703 if (err != SQLITE_OK) | 1704 if (err != SQLITE_OK) { |
1704 UMA_HISTOGRAM_SPARSE_SLOWLY("Sqlite.OpenProbeFailure", err); | 1705 UMA_HISTOGRAM_SPARSE_SLOWLY("Sqlite.OpenProbeFailure", err); |
1706 if (IsErrorCatastrophic(err)) { | |
1707 OnSqliteError(err, nullptr, "PRAGMA auto_vacuum"); | |
1708 return false; | |
afakhry
2016/08/09 21:36:17
shess@, I need your advice about this code.
The r
Scott Hess - ex-Googler
2016/08/10 17:16:19
I'm not sure what your question is. I wouldn't ex
afakhry
2016/08/11 17:32:54
I'm forcing a corruption in the Web Data file on a
| |
1709 } | |
1710 } | |
1705 | 1711 |
1706 #if defined(OS_IOS) && defined(USE_SYSTEM_SQLITE) | 1712 #if defined(OS_IOS) && defined(USE_SYSTEM_SQLITE) |
1707 // The version of SQLite shipped with iOS doesn't enable ICU, which includes | 1713 // The version of SQLite shipped with iOS doesn't enable ICU, which includes |
1708 // REGEXP support. Add it in dynamically. | 1714 // REGEXP support. Add it in dynamically. |
1709 err = sqlite3IcuInit(db_); | 1715 err = sqlite3IcuInit(db_); |
1710 DCHECK_EQ(err, SQLITE_OK) << "Could not enable ICU support"; | 1716 DCHECK_EQ(err, SQLITE_OK) << "Could not enable ICU support"; |
1711 #endif // OS_IOS && USE_SYSTEM_SQLITE | 1717 #endif // OS_IOS && USE_SYSTEM_SQLITE |
1712 | 1718 |
1713 // If indicated, lock up the database before doing anything else, so | 1719 // If indicated, lock up the database before doing anything else, so |
1714 // that the following code doesn't have to deal with locking. | 1720 // that the following code doesn't have to deal with locking. |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1974 ignore_result(Execute(kNoWritableSchema)); | 1980 ignore_result(Execute(kNoWritableSchema)); |
1975 | 1981 |
1976 return ret; | 1982 return ret; |
1977 } | 1983 } |
1978 | 1984 |
1979 base::TimeTicks TimeSource::Now() { | 1985 base::TimeTicks TimeSource::Now() { |
1980 return base::TimeTicks::Now(); | 1986 return base::TimeTicks::Now(); |
1981 } | 1987 } |
1982 | 1988 |
1983 } // namespace sql | 1989 } // namespace sql |
OLD | NEW |