summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-12 20:13:06 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-12 20:13:06 +0000
commit67361b3fcbd13d0ca74f4439e5a474a3867847b6 (patch)
tree10db345ad0f3a67e75c7ff9dbd3f30528fcc966b /app
parentce9eea60c922efff7c680a7a127480a799e06e94 (diff)
downloadchromium_src-67361b3fcbd13d0ca74f4439e5a474a3867847b6.zip
chromium_src-67361b3fcbd13d0ca74f4439e5a474a3867847b6.tar.gz
chromium_src-67361b3fcbd13d0ca74f4439e5a474a3867847b6.tar.bz2
Cleanup SQLite 3.6.18 import.
Get things spic-n-span for converting to the amalgamation, then SQLite 3.7.x. sqlite3Preload -> sqlite3_preload because in the amalgamation, sqlite3_ is the key bit to make sure things aren't marked static. AFAICT, SQLite 3.6.18 was not imported correctly last time, throwing up spurious deltas. Re-import and re-apply patches. Remove a bunch of Gears-related stuff. Quite some time ago the Chromium and Gears SQLite imports were brought into line, but they were never fully shared. Nowadays these are completely useless: - remove fts1 patches. - add a Chromium test to make sure fts1 doesn't sneak in. - drop the Symbian stuff. - drop database poisoning. Pull out the WebDatabase patch into a patch file. Move ICU shell changes into a distinct patch file. Pull out testing patches into a separate test.patch. BUG=71731 TEST=automated testing and watching closely. Review URL: http://codereview.chromium.org/6823057 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81296 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app')
-rw-r--r--app/app.gyp1
-rw-r--r--app/sql/connection.cc4
-rw-r--r--app/sql/sqlite_features_unittest.cc100
3 files changed, 103 insertions, 2 deletions
diff --git a/app/app.gyp b/app/app.gyp
index 8fd7315..1810938 100644
--- a/app/app.gyp
+++ b/app/app.gyp
@@ -46,6 +46,7 @@
'../ui/base/view_prop_unittest.cc',
'run_all_unittests.cc',
'sql/connection_unittest.cc',
+ 'sql/sqlite_features_unittest.cc',
'sql/statement_unittest.cc',
'sql/transaction_unittest.cc',
'test_suite.cc',
diff --git a/app/sql/connection.cc b/app/sql/connection.cc
index 003f7b2..445fa90 100644
--- a/app/sql/connection.cc
+++ b/app/sql/connection.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -133,7 +133,7 @@ void Connection::Preload() {
#if !defined(USE_SYSTEM_SQLITE)
// This function is only defined in Chromium's version of sqlite.
// Do not call it when using system sqlite.
- sqlite3Preload(db_);
+ sqlite3_preload(db_);
#endif
}
diff --git a/app/sql/sqlite_features_unittest.cc b/app/sql/sqlite_features_unittest.cc
new file mode 100644
index 0000000..0ee63be
--- /dev/null
+++ b/app/sql/sqlite_features_unittest.cc
@@ -0,0 +1,100 @@
+// Copyright (c) 2011 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 <string>
+
+#include "app/sql/connection.h"
+#include "app/sql/statement.h"
+#include "base/file_path.h"
+#include "base/file_util.h"
+#include "base/path_service.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/sqlite/sqlite3.h"
+
+// Test that certain features are/are-not enabled in our SQLite.
+
+namespace {
+
+
+class StatementErrorHandler : public sql::ErrorDelegate {
+ public:
+ StatementErrorHandler() : error_(SQLITE_OK) {}
+
+ virtual int OnError(int error, sql::Connection* connection,
+ sql::Statement* stmt) {
+ error_ = error;
+ const char* sql_txt = stmt ? stmt->GetSQLStatement() : NULL;
+ sql_text_ = sql_txt ? sql_txt : "no statement available";
+ return error;
+ }
+
+ int error() const { return error_; }
+
+ void reset_error() {
+ sql_text_.clear();
+ error_ = SQLITE_OK;
+ }
+
+ const char* sql_statement() const { return sql_text_.c_str(); }
+
+ private:
+ int error_;
+ std::string sql_text_;
+};
+
+class SQLiteFeaturesTest : public testing::Test {
+ public:
+ SQLiteFeaturesTest() : error_handler_(new StatementErrorHandler) {}
+
+ void SetUp() {
+ ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &path_));
+ path_ = path_.AppendASCII("SQLStatementTest.db");
+ file_util::Delete(path_, false);
+ ASSERT_TRUE(db_.Open(path_));
+ // The |error_handler_| will be called if any sqlite statement operation
+ // returns an error code.
+ db_.set_error_delegate(error_handler_);
+ }
+
+ void TearDown() {
+ // If any error happened the original sql statement can be found in
+ // error_handler_->sql_statement().
+ EXPECT_EQ(SQLITE_OK, error_handler_->error());
+ db_.Close();
+ // If this fails something is going on with cleanup and later tests may
+ // fail, so we want to identify problems right away.
+ ASSERT_TRUE(file_util::Delete(path_, false));
+ }
+
+ sql::Connection& db() { return db_; }
+
+ int sqlite_error() const { return error_handler_->error(); }
+ void reset_error() const { error_handler_->reset_error(); }
+
+ private:
+ FilePath path_;
+ sql::Connection db_;
+ scoped_refptr<StatementErrorHandler> error_handler_;
+};
+
+// Do not include fts1 support, it is not useful, and nobody is
+// looking at it.
+TEST_F(SQLiteFeaturesTest, NoFTS1) {
+ ASSERT_FALSE(db().Execute("CREATE VIRTUAL TABLE foo USING fts1(x)"));
+}
+
+// fts2 is used for older history files, so we're signed on for
+// keeping our version up-to-date.
+// TODO(shess): Think up a crazy way to get out from having to support
+// this forever.
+TEST_F(SQLiteFeaturesTest, FTS2) {
+ ASSERT_TRUE(db().Execute("CREATE VIRTUAL TABLE foo USING fts2(x)"));
+}
+
+// fts3 is used for current history files, and also for WebDatabase.
+TEST_F(SQLiteFeaturesTest, FTS3) {
+ ASSERT_TRUE(db().Execute("CREATE VIRTUAL TABLE foo USING fts3(x)"));
+}
+
+} // namespace