summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2013-06-11 10:57:03 +0100
committerTorne (Richard Coles) <torne@google.com>2013-06-11 10:57:03 +0100
commit868fa2fe829687343ffae624259930155e16dbd8 (patch)
tree54d316199dd9739c57c3aacd131853bbd6554a94 /sql
parentbb1bdbd796f966b5bf11f40ecbea12621c7bfac9 (diff)
downloadchromium_org-868fa2fe829687343ffae624259930155e16dbd8.tar.gz
Merge from Chromium at DEPS revision r205460
This commit was generated by merge_to_master.py. Change-Id: I4a744a5e426bd3bb378d887cfa56fe054742a540
Diffstat (limited to 'sql')
-rw-r--r--sql/connection.cc50
-rw-r--r--sql/meta_table.cc2
-rw-r--r--sql/sql.target.darwin-arm.mk1
-rw-r--r--sql/sql.target.darwin-x86.mk1
-rw-r--r--sql/sql.target.linux-arm.mk1
-rw-r--r--sql/sql.target.linux-x86.mk1
-rw-r--r--sql/statement.cc6
-rw-r--r--sql/statement.h2
8 files changed, 42 insertions, 22 deletions
diff --git a/sql/connection.cc b/sql/connection.cc
index 09d8195df5..4eb060b879 100644
--- a/sql/connection.cc
+++ b/sql/connection.cc
@@ -11,10 +11,10 @@
#include "base/logging.h"
#include "base/metrics/histogram.h"
#include "base/metrics/sparse_histogram.h"
-#include "base/string_util.h"
-#include "base/stringprintf.h"
#include "base/strings/string_split.h"
-#include "base/utf_string_conversions.h"
+#include "base/strings/string_util.h"
+#include "base/strings/stringprintf.h"
+#include "base/strings/utf_string_conversions.h"
#include "sql/statement.h"
#include "third_party/sqlite/sqlite3.h"
@@ -631,6 +631,13 @@ bool Connection::OpenInternal(const std::string& file_name) {
return false;
}
+ // SQLite uses a lookaside buffer to improve performance of small mallocs.
+ // Chromium already depends on small mallocs being efficient, so we disable
+ // this to avoid the extra memory overhead.
+ // This must be called immediatly after opening the database before any SQL
+ // statements are run.
+ sqlite3_db_config(db_, SQLITE_DBCONFIG_LOOKASIDE, NULL, 0, 0);
+
// sqlite3_open() does not actually read the database file (unless a
// hot journal is found). Successfully executing this pragma on an
// existing database requires a valid header on page 1.
@@ -770,19 +777,36 @@ int Connection::OnSqliteError(int err, sql::Statement *stmt) {
// TODO(shess): Allow specifying integrity_check versus quick_check.
// TODO(shess): Allow specifying maximum results (default 100 lines).
bool Connection::IntegrityCheck(std::vector<std::string>* messages) {
- const char kSql[] = "PRAGMA integrity_check";
- sql::Statement stmt(GetUniqueStatement(kSql));
-
messages->clear();
- // The pragma appears to return all results (up to 100 by default)
- // as a single string. This doesn't appear to be an API contract,
- // it could return separate lines, so loop _and_ split.
- while (stmt.Step()) {
- std::string result(stmt.ColumnString(0));
- base::SplitString(result, '\n', messages);
+ // This has the side effect of setting SQLITE_RecoveryMode, which
+ // allows SQLite to process through certain cases of corruption.
+ // Failing to set this pragma probably means that the database is
+ // beyond recovery.
+ const char kWritableSchema[] = "PRAGMA writable_schema = ON";
+ if (!Execute(kWritableSchema))
+ return false;
+
+ bool ret = false;
+ {
+ const char kSql[] = "PRAGMA integrity_check";
+ sql::Statement stmt(GetUniqueStatement(kSql));
+
+ // The pragma appears to return all results (up to 100 by default)
+ // as a single string. This doesn't appear to be an API contract,
+ // it could return separate lines, so loop _and_ split.
+ while (stmt.Step()) {
+ std::string result(stmt.ColumnString(0));
+ base::SplitString(result, '\n', messages);
+ }
+ ret = stmt.Succeeded();
}
- return stmt.Succeeded();
+
+ // Best effort to put things back as they were before.
+ const char kNoWritableSchema[] = "PRAGMA writable_schema = OFF";
+ ignore_result(Execute(kNoWritableSchema));
+
+ return ret;
}
} // namespace sql
diff --git a/sql/meta_table.cc b/sql/meta_table.cc
index d1bf14c70d..c7e803c1cc 100644
--- a/sql/meta_table.cc
+++ b/sql/meta_table.cc
@@ -5,7 +5,7 @@
#include "sql/meta_table.h"
#include "base/logging.h"
-#include "base/string_util.h"
+#include "base/strings/string_util.h"
#include "sql/connection.h"
#include "sql/statement.h"
#include "sql/transaction.h"
diff --git a/sql/sql.target.darwin-arm.mk b/sql/sql.target.darwin-arm.mk
index 7f89750ab1..a303e79d23 100644
--- a/sql/sql.target.darwin-arm.mk
+++ b/sql/sql.target.darwin-arm.mk
@@ -71,7 +71,6 @@ MY_DEFS := \
'-DNO_TCMALLOC' \
'-DDISABLE_NACL' \
'-DCHROMIUM_BUILD' \
- '-DENABLE_DOUBLE_RESOURCE_LOAD_TIMING' \
'-DUSE_LIBJPEG_TURBO=1' \
'-DUSE_PROPRIETARY_CODECS' \
'-DENABLE_GPU=1' \
diff --git a/sql/sql.target.darwin-x86.mk b/sql/sql.target.darwin-x86.mk
index 108a4f4db7..64df7c8372 100644
--- a/sql/sql.target.darwin-x86.mk
+++ b/sql/sql.target.darwin-x86.mk
@@ -73,7 +73,6 @@ MY_DEFS := \
'-DNO_TCMALLOC' \
'-DDISABLE_NACL' \
'-DCHROMIUM_BUILD' \
- '-DENABLE_DOUBLE_RESOURCE_LOAD_TIMING' \
'-DUSE_LIBJPEG_TURBO=1' \
'-DUSE_PROPRIETARY_CODECS' \
'-DENABLE_GPU=1' \
diff --git a/sql/sql.target.linux-arm.mk b/sql/sql.target.linux-arm.mk
index 7f89750ab1..a303e79d23 100644
--- a/sql/sql.target.linux-arm.mk
+++ b/sql/sql.target.linux-arm.mk
@@ -71,7 +71,6 @@ MY_DEFS := \
'-DNO_TCMALLOC' \
'-DDISABLE_NACL' \
'-DCHROMIUM_BUILD' \
- '-DENABLE_DOUBLE_RESOURCE_LOAD_TIMING' \
'-DUSE_LIBJPEG_TURBO=1' \
'-DUSE_PROPRIETARY_CODECS' \
'-DENABLE_GPU=1' \
diff --git a/sql/sql.target.linux-x86.mk b/sql/sql.target.linux-x86.mk
index 108a4f4db7..64df7c8372 100644
--- a/sql/sql.target.linux-x86.mk
+++ b/sql/sql.target.linux-x86.mk
@@ -73,7 +73,6 @@ MY_DEFS := \
'-DNO_TCMALLOC' \
'-DDISABLE_NACL' \
'-DCHROMIUM_BUILD' \
- '-DENABLE_DOUBLE_RESOURCE_LOAD_TIMING' \
'-DUSE_LIBJPEG_TURBO=1' \
'-DUSE_PROPRIETARY_CODECS' \
'-DENABLE_GPU=1' \
diff --git a/sql/statement.cc b/sql/statement.cc
index fe0accb7b8..da2c58fd69 100644
--- a/sql/statement.cc
+++ b/sql/statement.cc
@@ -5,8 +5,8 @@
#include "sql/statement.h"
#include "base/logging.h"
-#include "base/string_util.h"
-#include "base/utf_string_conversions.h"
+#include "base/strings/string_util.h"
+#include "base/strings/utf_string_conversions.h"
#include "third_party/sqlite/sqlite3.h"
namespace sql {
@@ -308,7 +308,7 @@ bool Statement::CheckOk(int err) const {
int Statement::CheckError(int err) {
// Please don't add DCHECKs here, OnSqliteError() already has them.
succeeded_ = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE);
- if (!succeeded_ && ref_ && ref_->connection())
+ if (!succeeded_ && ref_.get() && ref_->connection())
return ref_->connection()->OnSqliteError(err, this);
return err;
}
diff --git a/sql/statement.h b/sql/statement.h
index bd00b0d68d..5fedc53a09 100644
--- a/sql/statement.h
+++ b/sql/statement.h
@@ -10,7 +10,7 @@
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
-#include "base/string16.h"
+#include "base/strings/string16.h"
#include "sql/connection.h"
#include "sql/sql_export.h"