summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sql/connection.cc27
-rw-r--r--sql/connection_unittest.cc23
-rw-r--r--third_party/sqlite/sqlite.gyp21
3 files changed, 55 insertions, 16 deletions
diff --git a/sql/connection.cc b/sql/connection.cc
index c7666f9..ea3dacb 100644
--- a/sql/connection.cc
+++ b/sql/connection.cc
@@ -200,12 +200,27 @@ bool Connection::Raze() {
// Get the page size from the current connection, then propagate it
// to the null database.
- Statement s(GetUniqueStatement("PRAGMA page_size"));
- if (!s.Step())
- return false;
- const std::string sql = StringPrintf("PRAGMA page_size=%d", s.ColumnInt(0));
- if (!null_db.Execute(sql.c_str()))
- return false;
+ {
+ Statement s(GetUniqueStatement("PRAGMA page_size"));
+ if (!s.Step())
+ return false;
+ const std::string sql = StringPrintf("PRAGMA page_size=%d",
+ s.ColumnInt(0));
+ if (!null_db.Execute(sql.c_str()))
+ return false;
+ }
+
+ // Get the value of auto_vacuum from the current connection, then propagate it
+ // to the null database.
+ {
+ Statement s(GetUniqueStatement("PRAGMA auto_vacuum"));
+ if (!s.Step())
+ return false;
+ const std::string sql = StringPrintf("PRAGMA auto_vacuum=%d",
+ s.ColumnInt(0));
+ if (!null_db.Execute(sql.c_str()))
+ return false;
+ }
// The page size doesn't take effect until a database has pages, and
// at this point the null database has none. Changing the schema
diff --git a/sql/connection_unittest.cc b/sql/connection_unittest.cc
index 565c12f..e50043f 100644
--- a/sql/connection_unittest.cc
+++ b/sql/connection_unittest.cc
@@ -142,10 +142,21 @@ TEST_F(SQLConnectionTest, Raze) {
ASSERT_TRUE(db().Execute(kCreateSql));
ASSERT_TRUE(db().Execute("INSERT INTO foo (value) VALUES (12)"));
+ int pragma_auto_vacuum = 0;
+ {
+ sql::Statement s(db().GetUniqueStatement("PRAGMA auto_vacuum"));
+ ASSERT_TRUE(s.Step());
+ pragma_auto_vacuum = s.ColumnInt(0);
+ ASSERT_TRUE(pragma_auto_vacuum == 0 || pragma_auto_vacuum == 1);
+ }
+
+ // If auto_vacuum is set, there's an extra page to maintain a freelist.
+ const int kExpectedPageCount = 2 + pragma_auto_vacuum;
+
{
sql::Statement s(db().GetUniqueStatement("PRAGMA page_count"));
ASSERT_TRUE(s.Step());
- EXPECT_EQ(2, s.ColumnInt(0));
+ EXPECT_EQ(kExpectedPageCount, s.ColumnInt(0));
}
{
@@ -154,7 +165,8 @@ TEST_F(SQLConnectionTest, Raze) {
EXPECT_EQ("table", s.ColumnString(0));
EXPECT_EQ("foo", s.ColumnString(1));
EXPECT_EQ("foo", s.ColumnString(2));
- EXPECT_EQ(2, s.ColumnInt(3));
+ // Table "foo" is stored in the last page of the file.
+ EXPECT_EQ(kExpectedPageCount, s.ColumnInt(3));
EXPECT_EQ(kCreateSql, s.ColumnString(4));
}
@@ -170,6 +182,13 @@ TEST_F(SQLConnectionTest, Raze) {
sql::Statement s(db().GetUniqueStatement("SELECT * FROM sqlite_master"));
ASSERT_FALSE(s.Step());
}
+
+ {
+ sql::Statement s(db().GetUniqueStatement("PRAGMA auto_vacuum"));
+ ASSERT_TRUE(s.Step());
+ // auto_vacuum must be preserved across a Raze.
+ EXPECT_EQ(pragma_auto_vacuum, s.ColumnInt(0));
+ }
}
// Test that Raze() maintains page_size.
diff --git a/third_party/sqlite/sqlite.gyp b/third_party/sqlite/sqlite.gyp
index 63aea03..cf9ce3b 100644
--- a/third_party/sqlite/sqlite.gyp
+++ b/third_party/sqlite/sqlite.gyp
@@ -34,11 +34,6 @@
],
},
],
- ['OS == "android"', {
- 'defines': [
- 'SQLITE_TEMP_STORE=3',
- ],
- }],
['use_system_sqlite', {
'type': 'none',
'direct_dependent_settings': {
@@ -55,7 +50,7 @@
],
},
}],
- ['os_posix == 1 and OS != "mac" and OS != "ios"', {
+ ['os_posix == 1 and OS != "mac" and OS != "ios" and OS != "android"', {
'direct_dependent_settings': {
'cflags': [
# This next command produces no output but it it will fail
@@ -128,7 +123,17 @@
],
},
}],
- ['os_posix == 1 and OS != "mac"', {
+ ['OS == "android"', {
+ 'defines': [
+ 'HAVE_USLEEP=1',
+ 'SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576',
+ 'SQLITE_DEFAULT_AUTOVACUUM=1',
+ 'SQLITE_TEMP_STORE=3',
+ 'SQLITE_ENABLE_FTS3_BACKWARDS',
+ 'DSQLITE_DEFAULT_FILE_FORMAT=4',
+ ],
+ }],
+ ['os_posix == 1 and OS != "mac" and OS != "android"', {
'cflags': [
# SQLite doesn't believe in compiler warnings,
# preferring testing.
@@ -157,7 +162,7 @@
},
],
'conditions': [
- ['os_posix == 1 and OS != "mac" and OS != "ios" and not use_system_sqlite', {
+ ['os_posix == 1 and OS != "mac" and OS != "ios" and OS != "android" and not use_system_sqlite', {
'targets': [
{
'target_name': 'sqlite_shell',