Index: third_party/sqlite/src/test/vacuum2.test |
diff --git a/third_party/sqlite/src/test/vacuum2.test b/third_party/sqlite/src/test/vacuum2.test |
index 3cd6165366e157fc06642b2c35439fa1ad121036..35524bb26c2d4b76d87fe28aa9a98833f3a7eb75 100644 |
--- a/third_party/sqlite/src/test/vacuum2.test |
+++ b/third_party/sqlite/src/test/vacuum2.test |
@@ -16,6 +16,11 @@ |
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 |
+ |
# If the VACUUM statement is disabled in the current build, skip all |
# the tests in this file. |
# |
@@ -182,4 +187,45 @@ ifcapable autovacuum { |
} {2} |
} |
+ |
+#------------------------------------------------------------------------- |
+# The following block of tests verify the behaviour of the library when |
+# a database is VACUUMed when there are one or more unfinalized SQL |
+# statements reading the same database using the same db handle. |
+# |
+db close |
+forcedelete test.db |
+sqlite3 db test.db |
+do_execsql_test vacuum2-5.1 { |
+ CREATE TABLE t1(a PRIMARY KEY, b UNIQUE); |
+ INSERT INTO t1 VALUES(1, randomblob(500)); |
+ INSERT INTO t1 SELECT a+1, randomblob(500) FROM t1; -- 2 |
+ INSERT INTO t1 SELECT a+2, randomblob(500) FROM t1; -- 4 |
+ INSERT INTO t1 SELECT a+4, randomblob(500) FROM t1; -- 8 |
+ INSERT INTO t1 SELECT a+8, randomblob(500) FROM t1; -- 16 |
+} {} |
+ |
+do_test vacuum2-5.2 { |
+ list [catch { |
+ db eval {SELECT a, b FROM t1} { if {$a == 8} { execsql VACUUM } } |
+ } msg] $msg |
+} {1 {cannot VACUUM - SQL statements in progress}} |
+ |
+do_test vacuum2-5.3 { |
+ list [catch { |
+ db eval {SELECT 1, 2, 3} { execsql VACUUM } |
+ } msg] $msg |
+} {1 {cannot VACUUM - SQL statements in progress}} |
+ |
+do_test vacuum2-5.4 { |
+ set res "" |
+ set res2 "" |
+ db eval {SELECT a, b FROM t1 WHERE a<=10} { |
+ if {$a==6} { set res [catchsql VACUUM] } |
+ lappend res2 $a |
+ } |
+ lappend res2 $res |
+} {1 2 3 4 5 6 7 8 9 10 {1 {cannot VACUUM - SQL statements in progress}}} |
+ |
+ |
finish_test |