Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: third_party/sqlite/src/test/fallocate.test

Issue 6990047: Import SQLite 3.7.6.3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/sqlite/src/test/expr.test ('k') | third_party/sqlite/src/test/filectrl.test » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sqlite/src/test/fallocate.test
diff --git a/third_party/sqlite/src/test/fallocate.test b/third_party/sqlite/src/test/fallocate.test
new file mode 100644
index 0000000000000000000000000000000000000000..05aa2a81e5840ff02d19803147d134d8f1e745e8
--- /dev/null
+++ b/third_party/sqlite/src/test/fallocate.test
@@ -0,0 +1,146 @@
+# 2010 July 28
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+file_control_chunksize_test db main [expr 1024*1024]
+
+do_test fallocate-1.1 {
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA auto_vacuum = 1;
+ CREATE TABLE t1(a, b);
+ }
+ file size test.db
+} [expr 1*1024*1024]
+
+do_test fallocate-1.2 {
+ execsql { INSERT INTO t1 VALUES(1, zeroblob(1024*900)) }
+ file size test.db
+} [expr 1*1024*1024]
+
+do_test fallocate-1.3 {
+ execsql { INSERT INTO t1 VALUES(2, zeroblob(1024*900)) }
+ file size test.db
+} [expr 2*1024*1024]
+
+do_test fallocate-1.4 {
+ execsql { DELETE FROM t1 WHERE a = 1 }
+ file size test.db
+} [expr 1*1024*1024]
+
+do_test fallocate-1.5 {
+ execsql { DELETE FROM t1 WHERE a = 2 }
+ file size test.db
+} [expr 1*1024*1024]
+
+do_test fallocate-1.6 {
+ execsql { PRAGMA freelist_count }
+} {0}
+
+# Start a write-transaction and read the "database file size" field from
+# the journal file. This field should be set to the number of pages in
+# the database file based on the size of the file on disk, not the actual
+# logical size of the database within the file.
+#
+# We need to check this to verify that if in the unlikely event a rollback
+# causes a database file to grow, the database grows to its previous size
+# on disk, not to the minimum size required to hold the database image.
+#
+do_test fallocate-1.7 {
+ execsql { BEGIN; INSERT INTO t1 VALUES(1, 2); }
+ if {[permutation] != "inmemory_journal"} {
+ hexio_get_int [hexio_read test.db-journal 16 4]
+ } else {
+ set {} 1024
+ }
+} {1024}
+do_test fallocate-1.8 { execsql { COMMIT } } {}
+
+
+#-------------------------------------------------------------------------
+# The following tests - fallocate-2.* - test that things work in WAL
+# mode as well.
+#
+set skipwaltests [expr {
+ [permutation]=="journaltest" || [permutation]=="inmemory_journal"
+}]
+ifcapable !wal { set skipwaltests 1 }
+
+if {!$skipwaltests} {
+ db close
+ file delete -force test.db
+ sqlite3 db test.db
+ file_control_chunksize_test db main [expr 32*1024]
+
+ do_test fallocate-2.1 {
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA journal_mode = WAL;
+ CREATE TABLE t1(a, b);
+ }
+ file size test.db
+ } [expr 32*1024]
+
+ do_test fallocate-2.2 {
+ execsql { INSERT INTO t1 VALUES(1, zeroblob(35*1024)) }
+ execsql { PRAGMA wal_checkpoint }
+ file size test.db
+ } [expr 64*1024]
+
+ do_test fallocate-2.3 {
+ execsql { DELETE FROM t1 }
+ execsql { VACUUM }
+ file size test.db
+ } [expr 64*1024]
+
+ do_test fallocate-2.4 {
+ execsql { PRAGMA wal_checkpoint }
+ file size test.db
+ } [expr 32*1024]
+
+ do_test fallocate-2.5 {
+ execsql {
+ INSERT INTO t1 VALUES(2, randomblob(35*1024));
+ PRAGMA wal_checkpoint;
+ INSERT INTO t1 VALUES(3, randomblob(128));
+ DELETE FROM t1 WHERE a = 2;
+ VACUUM;
+ }
+ file size test.db
+ } [expr 64*1024]
+
+ do_test fallocate-2.6 {
+ sqlite3 db2 test.db
+ execsql { BEGIN ; SELECT count(a) FROM t1 } db2
+ execsql {
+ INSERT INTO t1 VALUES(4, randomblob(128));
+ PRAGMA wal_checkpoint;
+ }
+ file size test.db
+ } [expr 64*1024]
+
+ do_test fallocate-2.7 {
+ execsql { SELECT count(b) FROM t1 } db2
+ } {1}
+
+ do_test fallocate-2.8 {
+ execsql { COMMIT } db2
+ execsql { PRAGMA wal_checkpoint }
+ file size test.db
+ } [expr 32*1024]
+}
+
+
+finish_test
+
« no previous file with comments | « third_party/sqlite/src/test/expr.test ('k') | third_party/sqlite/src/test/filectrl.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698