Index: third_party/sqlite/src/test/filefmt.test |
diff --git a/third_party/sqlite/src/test/filefmt.test b/third_party/sqlite/src/test/filefmt.test |
index 07cc5ca2b857d9c6dcb31b4d7f8930d1533d18b3..72edbeebc79b844d4cd01099ba27f0413c8b60a3 100644 |
--- a/third_party/sqlite/src/test/filefmt.test |
+++ b/third_party/sqlite/src/test/filefmt.test |
@@ -16,6 +16,12 @@ |
set testdir [file dirname $argv0] |
source $testdir/tester.tcl |
+ |
+# Do not use a codec for tests in this file, as the database file is |
+# manipulated directly using tcl scripts (using the [hexio_write] command). |
+# |
+do_not_use_codec |
+ |
db close |
file delete -force test.db test.db-journal |
@@ -111,5 +117,100 @@ ifcapable pager_pragmas { |
} {1 {file is encrypted or is not a database}} |
} |
+#------------------------------------------------------------------------- |
+# The following block of tests - filefmt-2.* - test that versions 3.7.0 |
+# and later can read and write databases that have been modified or created |
+# by 3.6.23.1 and earlier. The difference difference is that 3.7.0 stores |
+# the size of the database in the database file header, whereas 3.6.23.1 |
+# always derives this from the size of the file. |
+# |
+db close |
+file delete -force test.db |
+ |
+set a_string_counter 1 |
+proc a_string {n} { |
+ incr ::a_string_counter |
+ string range [string repeat "${::a_string_counter}." $n] 1 $n |
+} |
+sqlite3 db test.db |
+db func a_string a_string |
+ |
+do_execsql_test filefmt-2.1.1 { |
+ PRAGMA page_size = 1024; |
+ PRAGMA auto_vacuum = 0; |
+ CREATE TABLE t1(a); |
+ CREATE INDEX i1 ON t1(a); |
+ INSERT INTO t1 VALUES(a_string(3000)); |
+ CREATE TABLE t2(a); |
+ INSERT INTO t2 VALUES(1); |
+} {} |
+do_test filefmt-2.1.2 { |
+ hexio_read test.db 28 4 |
+} {00000009} |
+ |
+do_test filefmt-2.1.3 { |
+ sql36231 { INSERT INTO t1 VALUES(a_string(3000)) } |
+} {} |
+ |
+do_execsql_test filefmt-2.1.4 { INSERT INTO t2 VALUES(2) } {} |
+integrity_check filefmt-2.1.5 |
+do_test filefmt-2.1.6 { hexio_read test.db 28 4 } {00000010} |
+ |
+db close |
+file delete -force test.db |
+sqlite3 db test.db |
+db func a_string a_string |
+ |
+do_execsql_test filefmt-2.2.1 { |
+ PRAGMA page_size = 1024; |
+ PRAGMA auto_vacuum = 0; |
+ CREATE TABLE t1(a); |
+ CREATE INDEX i1 ON t1(a); |
+ INSERT INTO t1 VALUES(a_string(3000)); |
+ CREATE TABLE t2(a); |
+ INSERT INTO t2 VALUES(1); |
+} {} |
+do_test filefmt-2.2.2 { |
+ hexio_read test.db 28 4 |
+} {00000009} |
+ |
+do_test filefmt-2.2.3 { |
+ sql36231 { INSERT INTO t1 VALUES(a_string(3000)) } |
+} {} |
+ |
+do_execsql_test filefmt-2.2.4 { |
+ PRAGMA integrity_check; |
+ BEGIN; |
+ INSERT INTO t2 VALUES(2); |
+ SAVEPOINT a; |
+ INSERT INTO t2 VALUES(3); |
+ ROLLBACK TO a; |
+} {ok} |
+ |
+integrity_check filefmt-2.2.5 |
+do_execsql_test filefmt-2.2.6 { COMMIT } {} |
+db close |
+sqlite3 db test.db |
+integrity_check filefmt-2.2.7 |
+ |
+#-------------------------------------------------------------------------- |
+# Check that ticket 89b8c9ac54 is fixed. Before the fix, the SELECT |
+# statement would return SQLITE_CORRUPT. The database file was not actually |
+# corrupted, but SQLite was reporting that it was. |
+# |
+db close |
+forcedelete test.db |
+sqlite3 db test.db |
+do_execsql_test filefmt-3.1 { |
+ PRAGMA auto_vacuum = 1; |
+ CREATE TABLE t1(a, b); |
+} {} |
+do_test filefmt-3.2 { |
+ sql36231 { DROP TABLE t1 } |
+} {} |
+do_execsql_test filefmt-3.3 { |
+ SELECT * FROM sqlite_master; |
+ PRAGMA integrity_check; |
+} {ok} |
finish_test |