aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/analyzer1.test9
-rw-r--r--test/autovacuum.test17
-rw-r--r--test/backcompat.test13
-rw-r--r--test/backup4.test5
-rw-r--r--test/bc_common.tcl5
-rw-r--r--test/bestindex1.test7
-rw-r--r--test/bestindex2.test5
-rw-r--r--test/close.test4
-rw-r--r--test/corrupt2.test44
-rw-r--r--test/corrupt3.test7
-rw-r--r--test/corrupt4.test7
-rw-r--r--test/corrupt6.test7
-rw-r--r--test/corrupt7.test7
-rw-r--r--test/corruptE.test7
-rw-r--r--test/corruptG.test7
-rw-r--r--test/corruptH.test8
-rw-r--r--test/corruptI.test8
-rw-r--r--test/corruptJ.test8
-rw-r--r--test/crash8.test1
-rw-r--r--test/e_uri.test2
-rw-r--r--test/e_vacuum.test58
-rw-r--r--test/e_walauto.test5
-rw-r--r--test/eqp.test66
-rw-r--r--test/filefmt.test16
-rw-r--r--test/fts4growth.test40
-rw-r--r--test/fts4langid.test2
-rw-r--r--test/fts4merge.test26
-rw-r--r--test/fts4merge3.test6
-rw-r--r--test/fts4opt.test213
-rw-r--r--test/in5.test35
-rw-r--r--test/incrblob.test23
-rw-r--r--test/incrblob_err.test4
-rw-r--r--test/io.test2
-rw-r--r--test/memsubsys1.test2
-rw-r--r--test/mmap1.test6
-rw-r--r--test/mmap3.test3
-rw-r--r--test/nan.test80
-rw-r--r--test/nolock.test32
-rw-r--r--test/pager1.test85
-rw-r--r--test/pageropt.test5
-rw-r--r--test/permutations.test4
-rw-r--r--test/pragma.test126
-rw-r--r--test/pragma3.test1
-rw-r--r--test/select4.test37
-rw-r--r--test/shell1.test10
-rw-r--r--test/shell2.test10
-rw-r--r--test/shell3.test10
-rw-r--r--test/shell4.test10
-rw-r--r--test/shell5.test10
-rw-r--r--test/spellfix3.test11
-rw-r--r--test/stat.test4
-rw-r--r--test/superlock.test25
-rw-r--r--test/tclsqlite.test5
-rw-r--r--test/tester.tcl42
-rw-r--r--test/tkt4018.test1
-rw-r--r--test/unixexcl.test1
-rw-r--r--test/vtab6.test4
-rw-r--r--test/wal.test2
-rw-r--r--test/wal2.test2
-rw-r--r--test/wal5.test7
-rw-r--r--test/wal8.test1
-rw-r--r--test/walbak.test2
-rw-r--r--test/walro.test2
-rw-r--r--test/where2.test11
-rw-r--r--test/zerodamage.test1
65 files changed, 838 insertions, 388 deletions
diff --git a/test/analyzer1.test b/test/analyzer1.test
index ac46704fb..51b5f8b6a 100644
--- a/test/analyzer1.test
+++ b/test/analyzer1.test
@@ -25,9 +25,12 @@ if {$tcl_platform(platform)=="windows"} {
set PROG "./sqlite3_analyzer"
}
if {![file exe $PROG]} {
- puts "analyzer1 cannot run because $PROG is not available"
- finish_test
- return
+ set PROG [file normalize [file join $::cmdlinearg(TESTFIXTURE_HOME) $PROG]]
+ if {![file exe $PROG]} {
+ puts "analyzer1 cannot run because $PROG is not available"
+ finish_test
+ return
+ }
}
db close
forcedelete test.db test.db-journal test.db-wal
diff --git a/test/autovacuum.test b/test/autovacuum.test
index 9ee2cd0fa..5c14ed85d 100644
--- a/test/autovacuum.test
+++ b/test/autovacuum.test
@@ -269,7 +269,7 @@ do_test autovacuum-2.4.3 {
} {3 4 5 6 7 8 9 10}
# Right now there are 5 free pages in the database. Consume and then free
-# a 520 pages. Then create 520 tables. This ensures that at least some of the
+# all 520 pages. Then create 520 tables. This ensures that at least some of the
# desired root-pages reside on the second free-list trunk page, and that the
# trunk itself is required at some point.
do_test autovacuum-2.4.4 {
@@ -280,9 +280,20 @@ do_test autovacuum-2.4.4 {
} {}
set root_page_list [list]
set pending_byte_page [expr ($::sqlite_pending_byte / 1024) + 1]
+
+# unusable_pages
+# These are either the pending_byte page or the pointer map pages
+#
+unset -nocomplain unusable_page
+if {[sqlite3 -has-codec]} {
+ array set unusable_page {205 1 408 1}
+} else {
+ array set unusable_page {207 1 412 1}
+}
+set unusable_page($pending_byte_page) 1
+
for {set i 3} {$i<=532} {incr i} {
- # 207 and 412 are pointer-map pages.
- if { $i!=207 && $i!=412 && $i != $pending_byte_page} {
+ if {![info exists unusable_page($i)]} {
lappend root_page_list $i
}
}
diff --git a/test/backcompat.test b/test/backcompat.test
index ea7e6a9ee..87ffc4b3e 100644
--- a/test/backcompat.test
+++ b/test/backcompat.test
@@ -63,7 +63,7 @@ proc do_backcompat_test {rv bin1 bin2 script} {
set v [split [db version] .]
if {[llength $v]==3} {lappend v 0}
set ::sqlite_libversion [format \
- "%d%.2d%.2d%2d" [lindex $v 0] [lindex $v 1] [lindex $v 2] [lindex $v 3]
+ "%d%.2d%.2d%.2d" [lindex $v 0] [lindex $v 1] [lindex $v 2] [lindex $v 3]
]
}
}
@@ -85,7 +85,8 @@ proc do_allbackcompat_test {script} {
set nErr [set_test_counter errors]
foreach dir {0 1} {
- set bintag [string map {testfixture {}} $bin]
+ set bintag $bin
+ regsub {.*testfixture\.} $bintag {} bintag
set bintag [string map {\.exe {}} $bintag]
if {$bintag == ""} {set bintag self}
set ::bcname ".$bintag.$dir."
@@ -420,6 +421,12 @@ ifcapable fts3 {
if {[code1 { set ::sqlite_libversion }] >=3071200
&& [code2 { set ::sqlite_libversion }] >=3071200
} {
+ if {[code1 { set ::sqlite_libversion }]<3120000} {
+ set res {0 {0 1} 1 0}
+ } else {
+ set res {1 0}
+ }
+
do_test backcompat-3.9 {
sql1 { INSERT INTO t2(t2) VALUES('merge=100,4'); }
sql2 { INSERT INTO t2(t2) VALUES('merge=100,4'); }
@@ -428,7 +435,7 @@ ifcapable fts3 {
sql2 {
SELECT level, group_concat(idx, ' ') FROM t2_segdir GROUP BY level;
}
- } {0 {0 1} 1 0}
+ } $res
do_test backcompat-3.10 {
sql1 { INSERT INTO t2(t2) VALUES('integrity-check') }
diff --git a/test/backup4.test b/test/backup4.test
index 417df80e5..2756995c3 100644
--- a/test/backup4.test
+++ b/test/backup4.test
@@ -23,6 +23,11 @@ set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix backup4
+# The codec logic does not work for zero-length database files. A database
+# file must contain at least one page in order to be recognized as an
+# encrypted database.
+do_not_use_codec
+
#-------------------------------------------------------------------------
# At one point this test was failing because [db] was using an out of
# date schema in test case 1.2.
diff --git a/test/bc_common.tcl b/test/bc_common.tcl
index 78010dfa4..c47f99681 100644
--- a/test/bc_common.tcl
+++ b/test/bc_common.tcl
@@ -7,7 +7,7 @@ proc bc_find_binaries {zCaption} {
# against.
#
set binaries [list]
- set self [file tail [info nameofexec]]
+ set self [info nameofexec]
set pattern "$self?*"
if {$::tcl_platform(platform)=="windows"} {
set pattern [string map {\.exe {}} $pattern]
@@ -52,7 +52,8 @@ proc do_bc_test {bin script} {
code1 { sqlite3 db test.db }
code2 { sqlite3 db test.db }
- set bintag [string map {testfixture {}} $bin]
+ set bintag $bin
+ regsub {.*testfixture\.} $bintag {} bintag
set bintag [string map {\.exe {}} $bintag]
if {$bintag == ""} {set bintag self}
set saved_prefix $::testprefix
diff --git a/test/bestindex1.test b/test/bestindex1.test
index fffb7aebe..97ae4b0f8 100644
--- a/test/bestindex1.test
+++ b/test/bestindex1.test
@@ -15,6 +15,11 @@ set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix bestindex1
+ifcapable !vtab {
+ finish_test
+ return
+}
+
register_tcl_module db
proc vtab_command {method args} {
@@ -161,5 +166,3 @@ foreach {tn mode} {
}
finish_test
-
-
diff --git a/test/bestindex2.test b/test/bestindex2.test
index 7ccd61640..8bc3fbc32 100644
--- a/test/bestindex2.test
+++ b/test/bestindex2.test
@@ -13,6 +13,10 @@ set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix bestindex2
+ifcapable !vtab {
+ finish_test
+ return
+}
#-------------------------------------------------------------------------
# Virtual table callback for table named $tbl, with the columns specified
@@ -135,4 +139,3 @@ do_eqp_test 1.7.2 {
}
finish_test
-
diff --git a/test/close.test b/test/close.test
index d5d6391ae..1b789bc77 100644
--- a/test/close.test
+++ b/test/close.test
@@ -17,6 +17,10 @@ set testdir [file dirname $argv0]
source $testdir/tester.tcl
set ::testprefix close
+# This module bypasses the "-key" logic in tester.tcl, so it cannot run
+# with the codec enabled.
+do_not_use_codec
+
do_execsql_test 1.0 {
CREATE TABLE t1(x);
INSERT INTO t1 VALUES('one');
diff --git a/test/corrupt2.test b/test/corrupt2.test
index 9bd29cf90..efeb26bc8 100644
--- a/test/corrupt2.test
+++ b/test/corrupt2.test
@@ -346,27 +346,29 @@ ifcapable autovacuum {
} {1 {database disk image is malformed}}
}
- corruption_test -sqlprep {
- PRAGMA auto_vacuum = 1;
- PRAGMA page_size = 1024;
- CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
- INSERT INTO t1 VALUES(1, randomblob(2500));
- DELETE FROM t1 WHERE a = 1;
- } -corrupt {
- set nAppend [expr 1024*207 - [file size corrupt.db]]
- set fd [open corrupt.db r+]
- seek $fd 0 end
- puts -nonewline $fd [string repeat x $nAppend]
- close $fd
- hexio_write corrupt.db 28 00000000
- } -test {
- do_test corrupt2-6.4 {
- catchsql "
- $::presql
- BEGIN EXCLUSIVE;
- COMMIT;
- "
- } {1 {database disk image is malformed}}
+ if {![nonzero_reserved_bytes]} {
+ corruption_test -sqlprep {
+ PRAGMA auto_vacuum = 1;
+ PRAGMA page_size = 1024;
+ CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, randomblob(2500));
+ DELETE FROM t1 WHERE a = 1;
+ } -corrupt {
+ set nAppend [expr 1024*207 - [file size corrupt.db]]
+ set fd [open corrupt.db r+]
+ seek $fd 0 end
+ puts -nonewline $fd [string repeat x $nAppend]
+ close $fd
+ hexio_write corrupt.db 28 00000000
+ } -test {
+ do_test corrupt2-6.4 {
+ catchsql "
+ $::presql
+ BEGIN EXCLUSIVE;
+ COMMIT;
+ "
+ } {1 {database disk image is malformed}}
+ }
}
}
diff --git a/test/corrupt3.test b/test/corrupt3.test
index 436a46618..85139420b 100644
--- a/test/corrupt3.test
+++ b/test/corrupt3.test
@@ -18,10 +18,9 @@
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
+# This module uses hard-coded offsets which do not work if the reserved_bytes
+# value is nonzero.
+if {[nonzero_reserved_bytes]} {finish_test; return;}
# These tests deal with corrupt database files
#
diff --git a/test/corrupt4.test b/test/corrupt4.test
index 24db60fd5..55969c6a8 100644
--- a/test/corrupt4.test
+++ b/test/corrupt4.test
@@ -18,10 +18,9 @@
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
+# This module uses hard-coded offsets which do not work if the reserved_bytes
+# value is nonzero.
+if {[nonzero_reserved_bytes]} {finish_test; return;}
# These tests deal with corrupt database files
#
diff --git a/test/corrupt6.test b/test/corrupt6.test
index 7d90c4a3b..dd773c926 100644
--- a/test/corrupt6.test
+++ b/test/corrupt6.test
@@ -19,10 +19,9 @@
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
+# This module uses hard-coded offsets which do not work if the reserved_bytes
+# value is nonzero.
+if {[nonzero_reserved_bytes]} {finish_test; return;}
# These tests deal with corrupt database files
#
diff --git a/test/corrupt7.test b/test/corrupt7.test
index 7ebebd94e..aa66cc7ec 100644
--- a/test/corrupt7.test
+++ b/test/corrupt7.test
@@ -19,10 +19,9 @@
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
+# This module uses hard-coded offsets which do not work if the reserved_bytes
+# value is nonzero.
+if {[nonzero_reserved_bytes]} {finish_test; return;}
# These tests deal with corrupt database files
#
diff --git a/test/corruptE.test b/test/corruptE.test
index 78cabbec8..54aa420f4 100644
--- a/test/corruptE.test
+++ b/test/corruptE.test
@@ -18,10 +18,9 @@
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
+# This module uses hard-coded offsets which do not work if the reserved_bytes
+# value is nonzero.
+if {[nonzero_reserved_bytes]} {finish_test; return;}
# These tests deal with corrupt database files
#
diff --git a/test/corruptG.test b/test/corruptG.test
index af920edf4..94480340a 100644
--- a/test/corruptG.test
+++ b/test/corruptG.test
@@ -14,10 +14,9 @@ set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix corruptG
-# 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
+# This module uses hard-coded offsets which do not work if the reserved_bytes
+# value is nonzero.
+if {[nonzero_reserved_bytes]} {finish_test; return;}
# These tests deal with corrupt database files
#
diff --git a/test/corruptH.test b/test/corruptH.test
index 0e1a1d442..9ba752242 100644
--- a/test/corruptH.test
+++ b/test/corruptH.test
@@ -14,10 +14,10 @@ set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix corruptH
-# 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
+# This module uses hard-coded offsets which do not work if the reserved_bytes
+# value is nonzero.
+if {[nonzero_reserved_bytes]} {finish_test; return;}
+
database_may_be_corrupt
# The corruption migrations tested by the code in this file are not detected
diff --git a/test/corruptI.test b/test/corruptI.test
index 9f46efb74..cdcb94201 100644
--- a/test/corruptI.test
+++ b/test/corruptI.test
@@ -19,10 +19,10 @@ if {[permutation]=="mmap"} {
return
}
-# 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
+# This module uses hard-coded offsets which do not work if the reserved_bytes
+# value is nonzero.
+if {[nonzero_reserved_bytes]} {finish_test; return;}
+
database_may_be_corrupt
# Initialize the database.
diff --git a/test/corruptJ.test b/test/corruptJ.test
index c08e628e2..732adb085 100644
--- a/test/corruptJ.test
+++ b/test/corruptJ.test
@@ -22,10 +22,10 @@ if {[permutation]=="mmap"} {
return
}
-# 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
+# This module uses hard-coded offsets which do not work if the reserved_bytes
+# value is nonzero.
+if {[nonzero_reserved_bytes]} {finish_test; return;}
+
database_may_be_corrupt
# Initialize the database.
diff --git a/test/crash8.test b/test/crash8.test
index 930834a96..f3b6f6e24 100644
--- a/test/crash8.test
+++ b/test/crash8.test
@@ -25,6 +25,7 @@ ifcapable !crashtest {
finish_test
return
}
+do_not_use_codec
do_test crash8-1.1 {
execsql {
diff --git a/test/e_uri.test b/test/e_uri.test
index 7a7f2559e..95b53f1d6 100644
--- a/test/e_uri.test
+++ b/test/e_uri.test
@@ -13,7 +13,7 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix e_uri
-
+do_not_use_codec
db close
proc parse_uri {uri} {
diff --git a/test/e_vacuum.test b/test/e_vacuum.test
index 99b31aaca..1113a1fb6 100644
--- a/test/e_vacuum.test
+++ b/test/e_vacuum.test
@@ -159,35 +159,37 @@ do_test e_vacuum-1.3.1.2 {
execsql { PRAGMA page_size ; PRAGMA auto_vacuum }
} {1024 1}
-# EVIDENCE-OF: R-08570-19916 However, when not in write-ahead log mode,
-# the page_size and/or auto_vacuum properties of an existing database
-# may be changed by using the page_size and/or pragma auto_vacuum
-# pragmas and then immediately VACUUMing the database.
-#
-do_test e_vacuum-1.3.2.1 {
- execsql { PRAGMA journal_mode = delete }
- execsql { PRAGMA page_size = 2048 }
- execsql { PRAGMA auto_vacuum = NONE }
- execsql VACUUM
- execsql { PRAGMA page_size ; PRAGMA auto_vacuum }
-} {2048 0}
-
-# EVIDENCE-OF: R-48521-51450 When in write-ahead log mode, only the
-# auto_vacuum support property can be changed using VACUUM.
-#
-ifcapable wal {
-do_test e_vacuum-1.3.3.1 {
- execsql { PRAGMA journal_mode = wal }
- execsql { PRAGMA page_size ; PRAGMA auto_vacuum }
-} {2048 0}
-do_test e_vacuum-1.3.3.2 {
- execsql { PRAGMA page_size = 1024 }
- execsql { PRAGMA auto_vacuum = FULL }
- execsql VACUUM
- execsql { PRAGMA page_size ; PRAGMA auto_vacuum }
-} {2048 1}
+if {![nonzero_reserved_bytes]} {
+ # EVIDENCE-OF: R-08570-19916 However, when not in write-ahead log mode,
+ # the page_size and/or auto_vacuum properties of an existing database
+ # may be changed by using the page_size and/or pragma auto_vacuum
+ # pragmas and then immediately VACUUMing the database.
+ #
+ do_test e_vacuum-1.3.2.1 {
+ execsql { PRAGMA journal_mode = delete }
+ execsql { PRAGMA page_size = 2048 }
+ execsql { PRAGMA auto_vacuum = NONE }
+ execsql VACUUM
+ execsql { PRAGMA page_size ; PRAGMA auto_vacuum }
+ } {2048 0}
+
+ # EVIDENCE-OF: R-48521-51450 When in write-ahead log mode, only the
+ # auto_vacuum support property can be changed using VACUUM.
+ #
+ ifcapable wal {
+ do_test e_vacuum-1.3.3.1 {
+ execsql { PRAGMA journal_mode = wal }
+ execsql { PRAGMA page_size ; PRAGMA auto_vacuum }
+ } {2048 0}
+ do_test e_vacuum-1.3.3.2 {
+ execsql { PRAGMA page_size = 1024 }
+ execsql { PRAGMA auto_vacuum = FULL }
+ execsql VACUUM
+ execsql { PRAGMA page_size ; PRAGMA auto_vacuum }
+ } {2048 1}
+ }
}
-
+
# EVIDENCE-OF: R-38001-03952 VACUUM only works on the main database. It
# is not possible to VACUUM an attached database file.
forcedelete test.db2
diff --git a/test/e_walauto.test b/test/e_walauto.test
index 093b13f94..7665b1bf7 100644
--- a/test/e_walauto.test
+++ b/test/e_walauto.test
@@ -24,6 +24,11 @@ if {$tcl_platform(os) == "OpenBSD"} {
return
}
+# This module uses hard-coded offsets which do not work if the reserved_bytes
+# value is nonzero.
+if {[nonzero_reserved_bytes]} {finish_test; return;}
+
+
proc read_nbackfill {} {
seek $::shmfd 96
binary scan [read $::shmfd 4] n nBackfill
diff --git a/test/eqp.test b/test/eqp.test
index 046088c9c..c955a80c2 100644
--- a/test/eqp.test
+++ b/test/eqp.test
@@ -516,45 +516,47 @@ det 5.13 "SELECT a FROM t1 EXCEPT SELECT d FROM t2 ORDER BY 1" {
}
-#-------------------------------------------------------------------------
-# The following tests - eqp-6.* - test that the example C code on
-# documentation page eqp.html works. The C code is duplicated in test1.c
-# and wrapped in Tcl command [print_explain_query_plan]
-#
-set boilerplate {
- proc explain_query_plan {db sql} {
- set stmt [sqlite3_prepare_v2 db $sql -1 DUMMY]
- print_explain_query_plan $stmt
- sqlite3_finalize $stmt
+if {![nonzero_reserved_bytes]} {
+ #-------------------------------------------------------------------------
+ # The following tests - eqp-6.* - test that the example C code on
+ # documentation page eqp.html works. The C code is duplicated in test1.c
+ # and wrapped in Tcl command [print_explain_query_plan]
+ #
+ set boilerplate {
+ proc explain_query_plan {db sql} {
+ set stmt [sqlite3_prepare_v2 db $sql -1 DUMMY]
+ print_explain_query_plan $stmt
+ sqlite3_finalize $stmt
+ }
+ sqlite3 db test.db
+ explain_query_plan db {%SQL%}
+ db close
+ exit
}
- sqlite3 db test.db
- explain_query_plan db {%SQL%}
- db close
- exit
-}
-
-# Do a "Print Explain Query Plan" test.
-proc do_peqp_test {tn sql res} {
- set fd [open script.tcl w]
- puts $fd [string map [list %SQL% $sql] $::boilerplate]
- close $fd
-
- uplevel do_test $tn [list {
- set fd [open "|[info nameofexec] script.tcl"]
- set data [read $fd]
+
+ # Do a "Print Explain Query Plan" test.
+ proc do_peqp_test {tn sql res} {
+ set fd [open script.tcl w]
+ puts $fd [string map [list %SQL% $sql] $::boilerplate]
close $fd
- set data
- }] [list $res]
-}
-
-do_peqp_test 6.1 {
- SELECT a, b FROM t1 EXCEPT SELECT d, 99 FROM t2 ORDER BY 1
-} [string trimleft {
+
+ uplevel do_test $tn [list {
+ set fd [open "|[info nameofexec] script.tcl"]
+ set data [read $fd]
+ close $fd
+ set data
+ }] [list $res]
+ }
+
+ do_peqp_test 6.1 {
+ SELECT a, b FROM t1 EXCEPT SELECT d, 99 FROM t2 ORDER BY 1
+ } [string trimleft {
1 0 0 SCAN TABLE t1 USING COVERING INDEX i2
2 0 0 SCAN TABLE t2
2 0 0 USE TEMP B-TREE FOR ORDER BY
0 0 0 COMPOUND SUBQUERIES 1 AND 2 (EXCEPT)
}]
+}
#-------------------------------------------------------------------------
# The following tests - eqp-7.* - test that queries that use the OP_Count
diff --git a/test/filefmt.test b/test/filefmt.test
index 2df142443..087a955c3 100644
--- a/test/filefmt.test
+++ b/test/filefmt.test
@@ -144,9 +144,11 @@ do_execsql_test filefmt-2.1.1 {
CREATE TABLE t2(a);
INSERT INTO t2 VALUES(1);
} {}
-do_test filefmt-2.1.2 {
- hexio_read test.db 28 4
-} {00000009}
+if {![nonzero_reserved_bytes]} {
+ 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)) }
@@ -170,9 +172,11 @@ do_execsql_test filefmt-2.2.1 {
CREATE TABLE t2(a);
INSERT INTO t2 VALUES(1);
} {}
-do_test filefmt-2.2.2 {
- hexio_read test.db 28 4
-} {00000009}
+if {![nonzero_reserved_bytes]} {
+ 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)) }
diff --git a/test/fts4growth.test b/test/fts4growth.test
index e4b5f19ec..4dc221246 100644
--- a/test/fts4growth.test
+++ b/test/fts4growth.test
@@ -59,11 +59,11 @@ do_test 1.4 {
INSERT INTO x1(x1) VALUES('merge=4,4');
SELECT level, end_block, length(root) FROM x1_segdir;
}
-} {0 {0 110} 110 0 {0 132} 132 0 {0 129} 129 1 {128 658} 2}
+} {1 {224 921} 2}
do_execsql_test 1.5 {
SELECT length(block) FROM x1_segments;
-} {658 {}}
+} {921 {}}
do_test 1.6 {
foreach L {
@@ -71,27 +71,33 @@ do_test 1.6 {
{That perched above Dead Man's Creek, beside the mountain road.}
{He turned the cycle down the hill and mounted for the fray,}
{But 'ere he'd gone a dozen yards it bolted clean away.}
+
{It left the track, and through the trees, just like a silver steak,}
{It whistled down the awful slope towards the Dead Man's Creek.}
{It shaved a stump by half an inch, it dodged a big white-box:}
{The very wallaroos in fright went scrambling up the rocks,}
+
{The wombats hiding in their caves dug deeper underground,}
{As Mulga Bill, as white as chalk, sat tight to every bound.}
{It struck a stone and gave a spring that cleared a fallen tree,}
{It raced beside a precipice as close as close could be;}
+
{And then as Mulga Bill let out one last despairing shriek}
{It made a leap of twenty feet into the Dead Man's Creek.}
+ {It shaved a stump by half an inch, it dodged a big white-box:}
+ {The very wallaroos in fright went scrambling up the rocks,}
+ {The wombats hiding in their caves dug deeper underground,}
} {
execsql { INSERT INTO x1 VALUES($L) }
}
execsql {
SELECT level, end_block, length(root) FROM x1_segdir;
}
-} {1 {128 658} 2 1 {130 1377} 6 0 {0 117} 117}
+} {1 {224 921} 2 1 {226 1230} 7 0 {0 98} 98}
do_execsql_test 1.7 {
- SELECT sum(length(block)) FROM x1_segments WHERE blockid IN (129, 130);
-} {1377}
+ SELECT sum(length(block)) FROM x1_segments WHERE blockid IN (224,225,226)
+} {1230}
#-------------------------------------------------------------------------
#
@@ -131,24 +137,24 @@ do_execsql_test 2.5 {
SELECT end_block FROM x2_segdir WHERE level=3;
INSERT INTO x2(x2) VALUES('merge=4,4');
SELECT end_block FROM x2_segdir WHERE level=3;
-} {{3828 -3430} {3828 -10191} {3828 -14109}}
+} {{5588 -3950} {5588 -11766} {5588 -15541}}
do_execsql_test 2.6 {
SELECT sum(length(block)) FROM x2_segdir, x2_segments WHERE
blockid BETWEEN start_block AND leaves_end_block
AND level=3
-} {14109}
+} {15541}
do_execsql_test 2.7 {
INSERT INTO x2(x2) VALUES('merge=1000,4');
SELECT end_block FROM x2_segdir WHERE level=3;
-} {{3828 86120}}
+} {{5588 127563}}
do_execsql_test 2.8 {
SELECT sum(length(block)) FROM x2_segdir, x2_segments WHERE
blockid BETWEEN start_block AND leaves_end_block
AND level=3
-} {86120}
+} {127563}
#--------------------------------------------------------------------------
# Test that delete markers are removed from FTS segments when possible.
@@ -391,7 +397,7 @@ do_execsql_test 7.2 {
} {
0 0 {118 117483} 0 1 {238 118006} 0 2 {358 118006}
0 3 {478 118006} 0 4 {598 118006} 0 5 {718 118006}
- 1 0 {16014 -51226}
+ 1 0 {23694 -69477}
}
do_execsql_test 7.3 {
@@ -400,7 +406,7 @@ do_execsql_test 7.3 {
} {
0 0 {118 117483} 0 1 {238 118006} 0 2 {358 118006}
0 3 {478 118006} 0 4 {598 118006} 0 5 {718 118006}
- 1 0 16014
+ 1 0 23694
}
do_execsql_test 7.4 {
@@ -409,28 +415,26 @@ do_execsql_test 7.4 {
} {
0 0 {118 117483} 0 1 {238 118006} 0 2 {358 118006}
0 3 {478 118006} 0 4 {598 118006} 0 5 {718 118006}
- 1 0 16014
+ 1 0 23694
}
do_execsql_test 7.5 {
INSERT INTO x6(x6) VALUES('merge=2500,4');
- SELECT level, idx, end_block FROM x6_segdir;
+ SELECT level, idx, start_block, leaves_end_block, end_block FROM x6_segdir;
} {
- 0 0 {598 118006} 0 1 {718 118006} 1 0 16014
+ 1 0 719 1171 23694
}
do_execsql_test 7.6 {
INSERT INTO x6(x6) VALUES('merge=2500,2');
SELECT level, idx, start_block, leaves_end_block, end_block FROM x6_segdir;
} {
- 2 0 23695 24147 {41262 633507}
+ 1 0 719 1171 23694
}
do_execsql_test 7.7 {
SELECT sum(length(block)) FROM x6_segments
- WHERE blockid BETWEEN 23695 AND 24147
-} {633507}
-
+} {635247}
finish_test
diff --git a/test/fts4langid.test b/test/fts4langid.test
index eb3602b4b..fdb1876be 100644
--- a/test/fts4langid.test
+++ b/test/fts4langid.test
@@ -481,6 +481,6 @@ foreach lid [list 4 [expr 1<<30]] {
do_execsql_test 5.4.$lid.5 {
SELECT count(*) FROM t6_segdir;
SELECT count(*) FROM t6_segments;
- } {4 4}
+ } {1 2}
}
finish_test
diff --git a/test/fts4merge.test b/test/fts4merge.test
index fabb651e6..eac18311d 100644
--- a/test/fts4merge.test
+++ b/test/fts4merge.test
@@ -55,8 +55,6 @@ foreach mod {fts3 fts4} {
do_execsql_test 1.3 {
SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level
} {
- 0 {0 1 2 3}
- 1 {0 1 2 3 4 5 6}
2 {0 1 2 3}
}
@@ -71,7 +69,6 @@ foreach mod {fts3 fts4} {
do_execsql_test 1.5 {
SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level
} {
- 2 {0 1}
3 0
}
@@ -89,7 +86,6 @@ foreach mod {fts3 fts4} {
5 {merge=6,%}
6 {merge=6,six}
7 {merge=6,1}
- 8 {merge=6,0}
} {
do_catchsql_test 2.$tn {
INSERT INTO t2(t2) VALUES($arg);
@@ -119,11 +115,7 @@ foreach mod {fts3 fts4} {
INSERT INTO t2(t2) VALUES('merge=1000000,2');
SELECT level, group_concat(idx, ' ') FROM t2_segdir GROUP BY level
} {
- 0 0
- 2 0
- 3 0
4 0
- 6 0
}
#-------------------------------------------------------------------------
@@ -203,28 +195,27 @@ foreach mod {fts3 fts4} {
INSERT INTO t1(t1) VALUES('merge=1,5');
SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level;
} {
- 0 {0 1 2}
1 {0 1 2 3 4 5 6 7 8 9 10 11 12 13 14}
2 {0 1 2 3}
}
- do_execsql_test 5.4 {SELECT quote(value) from t1_stat WHERE rowid=1} {X'0105'}
+ do_execsql_test 5.4 {SELECT quote(value) from t1_stat WHERE rowid=1} {X'010F'}
do_test 5.5 {
foreach docid [execsql {SELECT docid FROM t1}] {
execsql {INSERT INTO t1 SELECT * FROM t1 WHERE docid=$docid}
}
} {}
- do_execsql_test 5.6 {SELECT quote(value) from t1_stat WHERE rowid=1} {X'0105'}
+ do_execsql_test 5.6 {SELECT quote(value) from t1_stat WHERE rowid=1} {X'010F'}
do_execsql_test 5.7 {
SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level;
SELECT quote(value) from t1_stat WHERE rowid=1;
} {
- 0 {0 1 2 3 4 5 6 7 8 9 10}
+ 0 {0 1 2 3 4 5 6 7}
1 {0 1 2 3 4 5 6 7 8 9 10 11 12}
- 2 {0 1 2 3 4 5 6 7}
- X'0105'
+ 2 {0 1 2 3 4 5 6 7}
+ X'010F'
}
do_execsql_test 5.8 {
@@ -233,9 +224,8 @@ foreach mod {fts3 fts4} {
SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level;
SELECT quote(value) from t1_stat WHERE rowid=1;
} {
- 0 {0 1 2 3 4}
1 {0 1 2 3 4 5 6 7 8 9 10 11 12 13}
- 2 {0 1 2 3 4 5 6 7 8} X'0106'
+ 2 {0 1 2 3 4 5 6 7 8} X'010E'
}
do_test 5.8.1 { fts3_integrity_check t1 } ok
@@ -253,7 +243,7 @@ foreach mod {fts3 fts4} {
SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level;
SELECT quote(value) from t1_stat WHERE rowid=1;
} {
- 0 0 1 {0 1} 2 0 3 0 X'0106'
+ 0 {0 1 2 3 4 5 6 7 8 9 10 11} 1 0 2 0 3 0 X'010E'
}
do_execsql_test 5.11 {
@@ -261,7 +251,7 @@ foreach mod {fts3 fts4} {
SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level;
SELECT quote(value) from t1_stat WHERE rowid=1;
} {
- 0 0 1 {0 1} 2 0 3 0 X''
+ 1 {0 1} 2 0 3 0 X'010E'
}
#-------------------------------------------------------------------------
diff --git a/test/fts4merge3.test b/test/fts4merge3.test
index 329b4d2cc..08b68b97d 100644
--- a/test/fts4merge3.test
+++ b/test/fts4merge3.test
@@ -62,7 +62,7 @@ do_all_bc_test {
do_test 1.7 { sql2 {
SELECT level, count(*) FROM t2_segdir GROUP BY level ORDER BY 1
- } } [list 0 1 2 18 3 5]
+ } } {2 15 3 5}
# Using the old connection, insert many rows.
do_test 1.8 {
@@ -73,7 +73,7 @@ do_all_bc_test {
do_test 1.9 { sql2 {
SELECT level, count(*) FROM t2_segdir GROUP BY level ORDER BY 1
- } } [list 0 13 1 13 2 5 3 6]
+ } } [list 0 12 1 13 2 4 3 6]
# Run a big incr-merge operation on the db.
do_test 1.10 { sql1 { INSERT INTO t2(t2) VALUES('merge=2000,2') } } {}
@@ -97,7 +97,7 @@ do_all_bc_test {
do_test 1.15 { sql2 {
SELECT level, count(*) FROM t2_segdir GROUP BY level ORDER BY 1
- } } {6 1}
+ } } {4 1}
}
}
diff --git a/test/fts4opt.test b/test/fts4opt.test
new file mode 100644
index 000000000..0d0ed9f4f
--- /dev/null
+++ b/test/fts4opt.test
@@ -0,0 +1,213 @@
+# 2016 March 8
+#
+# 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
+source $testdir/fts3_common.tcl
+set ::testprefix fts4opt
+
+# If SQLITE_ENABLE_FTS3 is defined, omit this file.
+ifcapable !fts3 {
+ finish_test
+ return
+}
+
+# Create the fts_kjv_genesis procedure which fills and FTS3/4 table
+# with the complete text of the Book of Genesis.
+#
+source $testdir/genesis.tcl
+
+do_execsql_test 1.0 { CREATE TABLE t1(docid, words) }
+fts_kjv_genesis
+
+#-------------------------------------------------------------------------
+# Argument $db is an open database handle. $tbl is the name of an FTS3/4
+# table with the database. This command rearranges the contents of the
+# %_segdir table so that all segments within each index are on the same
+# level. This means that the 'merge' command can then be used for an
+# incremental optimize routine.
+#
+proc prepare_for_optimize {db tbl} {
+ $db eval [string map [list % $tbl] {
+ BEGIN;
+ CREATE TEMP TABLE tmp_segdir(
+ level, idx, start_block, leaves_end_block, end_block, root
+ );
+
+ INSERT INTO temp.tmp_segdir
+ SELECT
+ 1024*(o.level / 1024) + 32, -- level
+ sum(o.level<i.level OR (o.level=i.level AND o.idx>i.idx)), -- idx
+ o.start_block, o.leaves_end_block, o.end_block, o.root -- other
+ FROM %_segdir o, %_segdir i
+ WHERE (o.level / 1024) = (i.level / 1024)
+ GROUP BY o.level, o.idx;
+
+ DELETE FROM %_segdir;
+ INSERT INTO %_segdir SELECT * FROM temp.tmp_segdir;
+ DROP TABLE temp.tmp_segdir;
+
+ COMMIT;
+ }]
+}
+
+do_test 1.1 {
+ execsql { CREATE VIRTUAL TABLE t2 USING fts4(words, prefix="1,2,3") }
+ foreach {docid words} [db eval { SELECT * FROM t1 }] {
+ execsql { INSERT INTO t2(docid, words) VALUES($docid, $words) }
+ }
+} {}
+
+do_execsql_test 1.2 {
+ SELECT level, count(*) FROM t2_segdir GROUP BY level
+} {
+ 0 13 1 15 2 5
+ 1024 13 1025 15 1026 5
+ 2048 13 2049 15 2050 5
+ 3072 13 3073 15 3074 5
+}
+
+do_execsql_test 1.3 { INSERT INTO t2(t2) VALUES('integrity-check') }
+prepare_for_optimize db t2
+do_execsql_test 1.4 { INSERT INTO t2(t2) VALUES('integrity-check') }
+
+do_execsql_test 1.5 {
+ SELECT level, count(*) FROM t2_segdir GROUP BY level
+} {
+ 32 33
+ 1056 33
+ 2080 33
+ 3104 33
+}
+
+do_test 1.6 {
+ while 1 {
+ set tc1 [db total_changes]
+ execsql { INSERT INTO t2(t2) VALUES('merge=5,2') }
+ set tc2 [db total_changes]
+ if {($tc2 - $tc1) < 2} break
+ }
+ execsql { SELECT level, count(*) FROM t2_segdir GROUP BY level }
+} {33 1 1057 1 2081 1 3105 1}
+do_execsql_test 1.7 { INSERT INTO t2(t2) VALUES('integrity-check') }
+
+do_execsql_test 1.8 {
+ INSERT INTO t2(words) SELECT words FROM t1;
+ SELECT level, count(*) FROM t2_segdir GROUP BY level;
+} {0 2 1024 2 2048 2 3072 2}
+
+#-------------------------------------------------------------------------
+
+do_execsql_test 2.0 {
+ DELETE FROM t2;
+}
+do_test 2.1 {
+ foreach {docid words} [db eval { SELECT * FROM t1 }] {
+ execsql { INSERT INTO t2(docid, words) VALUES($docid, $words) }
+ }
+
+ set i 0
+ foreach {docid words} [db eval { SELECT * FROM t1 }] {
+ if {[incr i] % 2} { execsql { DELETE FROM t2 WHERE docid = $docid } }
+ }
+
+ set i 0
+ foreach {docid words} [db eval { SELECT * FROM t1 }] {
+ if {[incr i] % 3} {
+ execsql { INSERT OR REPLACE INTO t2(docid, words) VALUES($docid, $words) }
+ }
+ }
+} {}
+
+do_execsql_test 2.2 {
+ SELECT level, count(*) FROM t2_segdir GROUP BY level
+} {
+ 0 10 1 15 2 12
+ 1024 10 1025 15 1026 12
+ 2048 10 2049 15 2050 12
+ 3072 10 3073 15 3074 12
+}
+
+do_execsql_test 2.3 { INSERT INTO t2(t2) VALUES('integrity-check') }
+prepare_for_optimize db t2
+do_execsql_test 2.4 { INSERT INTO t2(t2) VALUES('integrity-check') }
+
+do_execsql_test 2.5 {
+ SELECT level, count(*) FROM t2_segdir GROUP BY level
+} {
+ 32 37
+ 1056 37
+ 2080 37
+ 3104 37
+}
+
+do_test 2.6 {
+ while 1 {
+ set tc1 [db total_changes]
+ execsql { INSERT INTO t2(t2) VALUES('merge=5,2') }
+ set tc2 [db total_changes]
+ if {($tc2 - $tc1) < 2} break
+ }
+ execsql { SELECT level, count(*) FROM t2_segdir GROUP BY level }
+} {33 1 1057 1 2081 1 3105 1}
+do_execsql_test 2.7 { INSERT INTO t2(t2) VALUES('integrity-check') }
+
+do_execsql_test 2.8 {
+ INSERT INTO t2(words) SELECT words FROM t1;
+ SELECT level, count(*) FROM t2_segdir GROUP BY level;
+} {0 2 1024 2 2048 2 3072 2}
+
+#-------------------------------------------------------------------------
+# Check that 'optimize' works when there is data in the in-memory hash
+# table, but no segments at all on disk.
+#
+do_execsql_test 3.1 {
+ CREATE VIRTUAL TABLE fts USING fts4 (t);
+ INSERT INTO fts (fts) VALUES ('optimize');
+}
+do_execsql_test 3.2 {
+ INSERT INTO fts(fts) VALUES('integrity-check');
+ SELECT count(*) FROM fts_segdir;
+} {0}
+do_execsql_test 3.3 {
+ BEGIN;
+ INSERT INTO fts (rowid, t) VALUES (2, 'test');
+ INSERT INTO fts (fts) VALUES ('optimize');
+ COMMIT;
+ SELECT level, idx FROM fts_segdir;
+} {0 0}
+do_execsql_test 3.4 {
+ INSERT INTO fts(fts) VALUES('integrity-check');
+ SELECT rowid FROM fts WHERE fts MATCH 'test';
+} {2}
+do_execsql_test 3.5 {
+ INSERT INTO fts (fts) VALUES ('optimize');
+ INSERT INTO fts(fts) VALUES('integrity-check');
+}
+do_test 3.6 {
+ set c1 [db total_changes]
+ execsql { INSERT INTO fts (fts) VALUES ('optimize') }
+ expr {[db total_changes] - $c1}
+} {1}
+do_test 3.7 {
+ execsql { INSERT INTO fts (rowid, t) VALUES (3, 'xyz') }
+ set c1 [db total_changes]
+ execsql { INSERT INTO fts (fts) VALUES ('optimize') }
+ expr {([db total_changes] - $c1) > 1}
+} {1}
+do_test 3.8 {
+ set c1 [db total_changes]
+ execsql { INSERT INTO fts (fts) VALUES ('optimize') }
+ expr {[db total_changes] - $c1}
+} {1}
+
+finish_test
diff --git a/test/in5.test b/test/in5.test
index 67d212589..b49c93e15 100644
--- a/test/in5.test
+++ b/test/in5.test
@@ -183,4 +183,39 @@ do_execsql_test 6.3.1 {
SELECT count(*) FROM x2 WHERE b IN (SELECT DISTINCT a FROM x1 LIMIT 2);
} {2}
+#-------------------------------------------------------------------------
+# Test to confirm that bug [5e3c886796e5] is fixed.
+#
+do_execsql_test 7.1 {
+ CREATE TABLE y1(a, b);
+ CREATE TABLE y2(c);
+
+ INSERT INTO y1 VALUES(1, 'one');
+ INSERT INTO y1 VALUES('two', 'two');
+ INSERT INTO y1 VALUES(3, 'three');
+
+ INSERT INTO y2 VALUES('one');
+ INSERT INTO y2 VALUES('two');
+ INSERT INTO y2 VALUES('three');
+} {}
+
+do_execsql_test 7.2.1 {
+ SELECT a FROM y1 WHERE b NOT IN (SELECT a FROM y2);
+} {1 3}
+do_execsql_test 7.2.2 {
+ SELECT a FROM y1 WHERE b IN (SELECT a FROM y2);
+} {two}
+
+do_execsql_test 7.3.1 {
+ CREATE INDEX y2c ON y2(c);
+ SELECT a FROM y1 WHERE b NOT IN (SELECT a FROM y2);
+} {1 3}
+do_execsql_test 7.3.2 {
+ SELECT a FROM y1 WHERE b IN (SELECT a FROM y2);
+} {two}
+
+finish_test
+
+
+
finish_test
diff --git a/test/incrblob.test b/test/incrblob.test
index 4277e5c4c..c56689ee1 100644
--- a/test/incrblob.test
+++ b/test/incrblob.test
@@ -126,6 +126,11 @@ foreach AutoVacuumMode [list 0 1] {
execsql "PRAGMA mmap_size = 0"
execsql "PRAGMA auto_vacuum = $AutoVacuumMode"
+ # Extra value added to size answers
+ set ib2_extra 0
+ if {$AutoVacuumMode} {incr ib2_extra}
+ if {[nonzero_reserved_bytes]} {incr ib2_extra}
+
do_test incrblob-2.$AutoVacuumMode.1 {
set ::str [string repeat abcdefghij 2900]
execsql {
@@ -136,7 +141,7 @@ foreach AutoVacuumMode [list 0 1] {
COMMIT;
}
expr [file size test.db]/1024
- } [expr 31 + $AutoVacuumMode]
+ } [expr 31 + $ib2_extra]
ifcapable autovacuum {
do_test incrblob-2.$AutoVacuumMode.2 {
@@ -163,7 +168,7 @@ foreach AutoVacuumMode [list 0 1] {
# sqlite uses the ptrmap pages to avoid reading the other pages.
#
nRead db
- } [expr $AutoVacuumMode ? 4 : 30]
+ } [expr $AutoVacuumMode ? 4 : 30+$ib2_extra]
do_test incrblob-2.$AutoVacuumMode.4 {
string range [db one {SELECT v FROM blobs}] end-19 end
@@ -187,7 +192,7 @@ foreach AutoVacuumMode [list 0 1] {
# sqlite uses the ptrmap pages to avoid reading the other pages.
#
nRead db
- } [expr $AutoVacuumMode ? 4 : 30]
+ } [expr $AutoVacuumMode ? 4 : 30 + $ib2_extra]
# Pages 1 (the write-counter) and 32 (the blob data) were written.
do_test incrblob-2.$AutoVacuumMode.6 {
@@ -210,7 +215,7 @@ foreach AutoVacuumMode [list 0 1] {
do_test incrblob-2.$AutoVacuumMode.9 {
nRead db
- } [expr $AutoVacuumMode ? 4 : 30]
+ } [expr $AutoVacuumMode ? 4 : 30 + $ib2_extra]
}
sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)
@@ -384,7 +389,7 @@ ifcapable vtab {
ifcapable attach {
do_test incrblob-5.1 {
forcedelete test2.db test2.db-journal
- set ::size [expr [file size [info script]]]
+ set ::size [expr [file size $::cmdlinearg(INFO_SCRIPT)]]
execsql {
ATTACH 'test2.db' AS aux;
CREATE TABLE aux.files(name, text);
@@ -392,16 +397,16 @@ ifcapable attach {
}
set fd [db incrblob aux files text 1]
fconfigure $fd -translation binary
- set fd2 [open [info script]]
+ set fd2 [open $::cmdlinearg(INFO_SCRIPT)]
fconfigure $fd2 -translation binary
puts -nonewline $fd [read $fd2]
close $fd
close $fd2
set ::text [db one {select text from aux.files}]
string length $::text
- } [file size [info script]]
+ } [file size $::cmdlinearg(INFO_SCRIPT)]
do_test incrblob-5.2 {
- set fd2 [open [info script]]
+ set fd2 [open $::cmdlinearg(INFO_SCRIPT)]
fconfigure $fd2 -translation binary
set ::data [read $fd2]
close $fd2
@@ -576,7 +581,7 @@ foreach {tn arg} {1 "" 2 -readonly} {
}
-set fd [open [info script]]
+set fd [open $::cmdlinearg(INFO_SCRIPT)]
fconfigure $fd -translation binary
set ::data [read $fd 14000]
close $fd
diff --git a/test/incrblob_err.test b/test/incrblob_err.test
index a08bea3e4..0db8b0dcb 100644
--- a/test/incrblob_err.test
+++ b/test/incrblob_err.test
@@ -24,12 +24,12 @@ ifcapable {!incrblob || !memdebug || !tclvar} {
source $testdir/malloc_common.tcl
unset -nocomplain ::fd ::data
-set ::fd [open [info script]]
+set ::fd [open $::cmdlinearg(INFO_SCRIPT)]
set ::data [read $::fd]
close $::fd
do_malloc_test 1 -tclprep {
- set bytes [file size [info script]]
+ set bytes [file size $::cmdlinearg(INFO_SCRIPT)]
execsql {
CREATE TABLE blobs(k, v BLOB);
INSERT INTO blobs VALUES(1, zeroblob($::bytes));
diff --git a/test/io.test b/test/io.test
index c5086c10e..e1af808a3 100644
--- a/test/io.test
+++ b/test/io.test
@@ -424,7 +424,7 @@ ifcapable pager_pragmas {
# The COMMIT requires a single fsync() - to the database file.
execsql { COMMIT }
list [file size test.db] [nSync]
- } {39936 1}
+ } "[expr {[nonzero_reserved_bytes]?40960:39936}] 1"
}
#----------------------------------------------------------------------
diff --git a/test/memsubsys1.test b/test/memsubsys1.test
index 8265ce631..e9a4cf08a 100644
--- a/test/memsubsys1.test
+++ b/test/memsubsys1.test
@@ -255,7 +255,7 @@ do_test memsubsys1-7.4 {
} 0
do_test memsubsys1-7.5 {
set maxreq [lindex [sqlite3_status SQLITE_STATUS_MALLOC_SIZE 0] 2]
- expr {$maxreq<4100}
+ expr {$maxreq<4100 + 4200*[nonzero_reserved_bytes]}
} 1
do_test memsubsys1-7.6 {
set s_used [lindex [sqlite3_status SQLITE_STATUS_SCRATCH_USED 0] 2]
diff --git a/test/mmap1.test b/test/mmap1.test
index 199a05875..c7c72c0ab 100644
--- a/test/mmap1.test
+++ b/test/mmap1.test
@@ -88,7 +88,7 @@ foreach {t mmap_size nRead c2init} {
sql2 { DELETE FROM t1 WHERE rowid%2; }
do_test $t.$tn.2 {
sql1 "SELECT count(*) FROM t1; PRAGMA integrity_check ; PRAGMA page_count"
- } {16 ok 42}
+ } "16 ok [expr {42+[nonzero_reserved_bytes]}]"
# Have connection 2 grow the file. Check connection 1 can still read it.
sql2 { INSERT INTO t1 SELECT rblob(500), rblob(500) FROM t1 }
@@ -104,7 +104,9 @@ foreach {t mmap_size nRead c2init} {
# Check that the number of pages read by connection 1 indicates that the
# "PRAGMA mmap_size" command worked.
- do_test $t.$tn.5 { nRead db } $nRead
+ if {[nonzero_reserved_bytes]==0} {
+ do_test $t.$tn.5 { nRead db } $nRead
+ }
}
}
diff --git a/test/mmap3.test b/test/mmap3.test
index 07b515296..184dda5f8 100644
--- a/test/mmap3.test
+++ b/test/mmap3.test
@@ -19,6 +19,9 @@ ifcapable !mmap||!vtab {
source $testdir/lock_common.tcl
set testprefix mmap3
+# A codec shuts down memory-mapped I/O
+if {[nonzero_reserved_bytes]} {finish_test; return;}
+
do_test mmap3-1.0 {
load_static_extension db wholenumber
db eval {
diff --git a/test/nan.test b/test/nan.test
index df3f65b8e..27fa04a35 100644
--- a/test/nan.test
+++ b/test/nan.test
@@ -151,45 +151,47 @@ sqlite3_finalize $::STMT
# Then it reads the value of the database to verify it is converted into
# NULL.
#
-do_test nan-3.1 {
- db eval {
- DELETE FROM t1;
- INSERT INTO t1 VALUES(0.5);
- PRAGMA auto_vacuum=OFF;
- PRAGMA page_size=1024;
- VACUUM;
- }
- hexio_read test.db 2040 8
-} {3FE0000000000000}
-do_test nan-3.2 {
- db eval {
- SELECT x, typeof(x) FROM t1
- }
-} {0.5 real}
-do_test nan-3.3 {
- db close
- hexio_write test.db 2040 FFF8000000000000
- sqlite3 db test.db
- db eval {SELECT x, typeof(x) FROM t1}
-} {{} null}
-do_test nan-3.4 {
- db close
- hexio_write test.db 2040 7FF8000000000000
- sqlite3 db test.db
- db eval {SELECT x, typeof(x) FROM t1}
-} {{} null}
-do_test nan-3.5 {
- db close
- hexio_write test.db 2040 FFFFFFFFFFFFFFFF
- sqlite3 db test.db
- db eval {SELECT x, typeof(x) FROM t1}
-} {{} null}
-do_test nan-3.6 {
- db close
- hexio_write test.db 2040 7FFFFFFFFFFFFFFF
- sqlite3 db test.db
- db eval {SELECT x, typeof(x) FROM t1}
-} {{} null}
+if {![nonzero_reserved_bytes]} {
+ do_test nan-3.1 {
+ db eval {
+ DELETE FROM t1;
+ INSERT INTO t1 VALUES(0.5);
+ PRAGMA auto_vacuum=OFF;
+ PRAGMA page_size=1024;
+ VACUUM;
+ }
+ hexio_read test.db 2040 8
+ } {3FE0000000000000}
+ do_test nan-3.2 {
+ db eval {
+ SELECT x, typeof(x) FROM t1
+ }
+ } {0.5 real}
+ do_test nan-3.3 {
+ db close
+ hexio_write test.db 2040 FFF8000000000000
+ sqlite3 db test.db
+ db eval {SELECT x, typeof(x) FROM t1}
+ } {{} null}
+ do_test nan-3.4 {
+ db close
+ hexio_write test.db 2040 7FF8000000000000
+ sqlite3 db test.db
+ db eval {SELECT x, typeof(x) FROM t1}
+ } {{} null}
+ do_test nan-3.5 {
+ db close
+ hexio_write test.db 2040 FFFFFFFFFFFFFFFF
+ sqlite3 db test.db
+ db eval {SELECT x, typeof(x) FROM t1}
+ } {{} null}
+ do_test nan-3.6 {
+ db close
+ hexio_write test.db 2040 7FFFFFFFFFFFFFFF
+ sqlite3 db test.db
+ db eval {SELECT x, typeof(x) FROM t1}
+ } {{} null}
+}
# Verify that the sqlite3AtoF routine is able to handle extreme
# numbers.
diff --git a/test/nolock.test b/test/nolock.test
index 331af08ad..fdaef6ef0 100644
--- a/test/nolock.test
+++ b/test/nolock.test
@@ -182,4 +182,36 @@ do_test nolock-3.12 {
db2 close
db close
tvfs delete
+
+# 2016-03-11: Make sure all works when transitioning to WAL mode under nolock.
+#
+do_test nolock-4.1 {
+ forcedelete test.db
+ sqlite3 db file:test.db?nolock=1 -uri 1
+ db eval {
+ PRAGMA journal_mode=WAL;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES('youngling');
+ SELECT * FROM t1;
+ }
+} {delete youngling}
+db close
+
+do_test nolock-4.2 {
+ forcedelete test.db
+ sqlite3 db test.db
+ db eval {
+ PRAGMA journal_mode=WAL;
+ CREATE TABLE t1(x);
+ INSERT INTO t1 VALUES('catbird');
+ SELECT * FROM t1;
+ }
+} {wal catbird}
+do_test nolock-4.3 {
+ db close
+ sqlite3 db file:test.db?nolock=1 -uri 1
+ set rc [catch {db eval {SELECT * FROM t1}} msg]
+ lappend rc $msg
+} {1 {unable to open database file}}
+
finish_test
diff --git a/test/pager1.test b/test/pager1.test
index bc9ad83fd..c25c837b6 100644
--- a/test/pager1.test
+++ b/test/pager1.test
@@ -1396,26 +1396,47 @@ do_test pager1-9.3.1 {
execsql { PRAGMA page_size = 1024 }
for {set ii 0} {$ii < 4} {incr ii} { execsql "CREATE TABLE t${ii}(a, b)" }
} {}
-do_test pager1-9.3.2 {
- sqlite3 db2 test.db2
-
- execsql {
- PRAGMA page_size = 4096;
- PRAGMA synchronous = OFF;
- CREATE TABLE t1(a, b);
- CREATE TABLE t2(a, b);
- } db2
-
- sqlite3_backup B db2 main db main
- B step 30
- list [B step 10000] [B finish]
-} {SQLITE_DONE SQLITE_OK}
-do_test pager1-9.3.3 {
- db2 close
- db close
- tv delete
- file size test.db2
-} [file size test.db]
+if {[nonzero_reserved_bytes]} {
+ # backup with a page size changes is not possible with the codec
+ #
+ do_test pager1-9.3.2codec {
+ sqlite3 db2 test.db2
+ execsql {
+ PRAGMA page_size = 4096;
+ PRAGMA synchronous = OFF;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+ } db2
+ sqlite3_backup B db2 main db main
+ B step 30
+ list [B step 10000] [B finish]
+ } {SQLITE_READONLY SQLITE_READONLY}
+ do_test pager1-9.3.3codec {
+ db2 close
+ db close
+ tv delete
+ file size test.db2
+ } [file size test.db2]
+} else {
+ do_test pager1-9.3.2 {
+ sqlite3 db2 test.db2
+ execsql {
+ PRAGMA page_size = 4096;
+ PRAGMA synchronous = OFF;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+ } db2
+ sqlite3_backup B db2 main db main
+ B step 30
+ list [B step 10000] [B finish]
+ } {SQLITE_DONE SQLITE_OK}
+ do_test pager1-9.3.3 {
+ db2 close
+ db close
+ tv delete
+ file size test.db2
+ } [file size test.db]
+}
do_test pager1-9.4.1 {
faultsim_delete_and_reopen
@@ -2447,13 +2468,23 @@ do_test pager1-29.1 {
}
file size test.db
} [expr 1024*3]
-do_test pager1-29.2 {
- execsql {
- PRAGMA page_size = 4096;
- VACUUM;
- }
- file size test.db
-} [expr 4096*3]
+if {[nonzero_reserved_bytes]} {
+ # VACUUM with size changes is not possible with the codec.
+ do_test pager1-29.2 {
+ catchsql {
+ PRAGMA page_size = 4096;
+ VACUUM;
+ }
+ } {1 {attempt to write a readonly database}}
+} else {
+ do_test pager1-29.2 {
+ execsql {
+ PRAGMA page_size = 4096;
+ VACUUM;
+ }
+ file size test.db
+ } [expr 4096*3]
+}
#-------------------------------------------------------------------------
# Test that if an empty database file (size 0 bytes) is opened in
diff --git a/test/pageropt.test b/test/pageropt.test
index 7191661ba..f58b8ee78 100644
--- a/test/pageropt.test
+++ b/test/pageropt.test
@@ -16,12 +16,17 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
+do_not_use_codec
ifcapable {!pager_pragmas||secure_delete||direct_read} {
finish_test
return
}
+# A non-zero reserved_bytes value changes the number of pages in the
+# database file, which messes up the results in this test.
+if {[nonzero_reserved_bytes]} {finish_test; return;}
+
# Run the SQL statement supplied by the argument and return
# the results. Prepend four integers to the beginning of the
# result which are
diff --git a/test/permutations.test b/test/permutations.test
index a3fef7f14..308d8bde7 100644
--- a/test/permutations.test
+++ b/test/permutations.test
@@ -1092,12 +1092,12 @@ proc help {} {
exit -1
}
-if {[info script] == $argv0} {
+if {[file tail $argv0] == "permutations.test"} {
proc main {argv} {
if {[llength $argv]==0} {
help
} else {
- set suite [lindex $argv 0]
+ set suite [file tail [lindex $argv 0]]
if {[info exists ::testspec($suite)]==0} help
set extra ""
if {[llength $argv]>1} { set extra [list -files [lrange $argv 1 end]] }
diff --git a/test/pragma.test b/test/pragma.test
index befa5cf54..acbe74599 100644
--- a/test/pragma.test
+++ b/test/pragma.test
@@ -1741,73 +1741,75 @@ forcedelete data_dir
} ;# endif windows
database_may_be_corrupt
+if {![nonzero_reserved_bytes]} {
-do_test 21.1 {
- # Create a corrupt database in testerr.db. And a non-corrupt at test.db.
- #
- db close
- forcedelete test.db
- sqlite3 db test.db
- execsql {
- PRAGMA page_size = 1024;
- PRAGMA auto_vacuum = 0;
- CREATE TABLE t1(a PRIMARY KEY, b);
- INSERT INTO t1 VALUES(1, 1);
- }
- for {set i 0} {$i < 10} {incr i} {
- execsql { INSERT INTO t1 SELECT a + (1 << $i), b + (1 << $i) FROM t1 }
- }
- db close
- forcecopy test.db testerr.db
- hexio_write testerr.db 15000 [string repeat 55 100]
-} {100}
-
-set mainerr {*** in database main ***
+ do_test 21.1 {
+ # Create a corrupt database in testerr.db. And a non-corrupt at test.db.
+ #
+ db close
+ forcedelete test.db
+ sqlite3 db test.db
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA auto_vacuum = 0;
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, 1);
+ }
+ for {set i 0} {$i < 10} {incr i} {
+ execsql { INSERT INTO t1 SELECT a + (1 << $i), b + (1 << $i) FROM t1 }
+ }
+ db close
+ forcecopy test.db testerr.db
+ hexio_write testerr.db 15000 [string repeat 55 100]
+ } {100}
+
+ set mainerr {*** in database main ***
Multiple uses for byte 672 of page 15}
-set auxerr {*** in database aux ***
+ set auxerr {*** in database aux ***
Multiple uses for byte 672 of page 15}
-
-set mainerr {/{\*\*\* in database main \*\*\*
+
+ set mainerr {/{\*\*\* in database main \*\*\*
Multiple uses for byte 672 of page 15}.*/}
-set auxerr {/{\*\*\* in database aux \*\*\*
+ set auxerr {/{\*\*\* in database aux \*\*\*
Multiple uses for byte 672 of page 15}.*/}
-
-do_test 22.2 {
- catch { db close }
- sqlite3 db testerr.db
- execsql { PRAGMA integrity_check }
-} $mainerr
-
-do_test 22.3.1 {
- catch { db close }
- sqlite3 db test.db
- execsql {
- ATTACH 'testerr.db' AS 'aux';
- PRAGMA integrity_check;
- }
-} $auxerr
-do_test 22.3.2 {
- execsql { PRAGMA main.integrity_check; }
-} {ok}
-do_test 22.3.3 {
- execsql { PRAGMA aux.integrity_check; }
-} $auxerr
-
-do_test 22.4.1 {
- catch { db close }
- sqlite3 db testerr.db
- execsql {
- ATTACH 'test.db' AS 'aux';
- PRAGMA integrity_check;
- }
-} $mainerr
-do_test 22.4.2 {
- execsql { PRAGMA main.integrity_check; }
-} $mainerr
-do_test 22.4.3 {
- execsql { PRAGMA aux.integrity_check; }
-} {ok}
-
+
+ do_test 22.2 {
+ catch { db close }
+ sqlite3 db testerr.db
+ execsql { PRAGMA integrity_check }
+ } $mainerr
+
+ do_test 22.3.1 {
+ catch { db close }
+ sqlite3 db test.db
+ execsql {
+ ATTACH 'testerr.db' AS 'aux';
+ PRAGMA integrity_check;
+ }
+ } $auxerr
+ do_test 22.3.2 {
+ execsql { PRAGMA main.integrity_check; }
+ } {ok}
+ do_test 22.3.3 {
+ execsql { PRAGMA aux.integrity_check; }
+ } $auxerr
+
+ do_test 22.4.1 {
+ catch { db close }
+ sqlite3 db testerr.db
+ execsql {
+ ATTACH 'test.db' AS 'aux';
+ PRAGMA integrity_check;
+ }
+ } $mainerr
+ do_test 22.4.2 {
+ execsql { PRAGMA main.integrity_check; }
+ } $mainerr
+ do_test 22.4.3 {
+ execsql { PRAGMA aux.integrity_check; }
+ } {ok}
+}
+
db close
forcedelete test.db test.db-wal test.db-journal
sqlite3 db test.db
diff --git a/test/pragma3.test b/test/pragma3.test
index b7ea4d3fc..1a67d7235 100644
--- a/test/pragma3.test
+++ b/test/pragma3.test
@@ -15,6 +15,7 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
+do_not_use_codec
do_execsql_test pragma3-100 {
PRAGMA data_version;
diff --git a/test/select4.test b/test/select4.test
index be8d0e0ab..1f29f2907 100644
--- a/test/select4.test
+++ b/test/select4.test
@@ -12,7 +12,6 @@
# focus of this file is testing UNION, INTERSECT and EXCEPT operators
# in SELECT statements.
#
-# $Id: select4.test,v 1.30 2009/04/16 00:24:24 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -936,4 +935,40 @@ do_execsql_test select4-15.1 {
ORDER BY 1;
} {1 33 456 2 33 789}
+# Enhancement (2016-03-15): Use a co-routine for subqueries if the
+# subquery is guaranteed to be the outer-most query
+#
+do_execsql_test select4-16.1 {
+ DROP TABLE IF EXISTS t1;
+ CREATE TABLE t1(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,
+ PRIMARY KEY(a,b DESC)) WITHOUT ROWID;
+
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
+ INSERT INTO t1(a,b,c,d)
+ SELECT x%10, x/10, x, printf('xyz%dabc',x) FROM c;
+
+ SELECT t3.c FROM
+ (SELECT a,max(b) AS m FROM t1 WHERE a>=5 GROUP BY a) AS t2
+ JOIN t1 AS t3
+ WHERE t2.a=t3.a AND t2.m=t3.b
+ ORDER BY t3.a;
+} {95 96 97 98 99}
+do_execsql_test select4-16.2 {
+ SELECT t3.c FROM
+ (SELECT a,max(b) AS m FROM t1 WHERE a>=5 GROUP BY a) AS t2
+ CROSS JOIN t1 AS t3
+ WHERE t2.a=t3.a AND t2.m=t3.b
+ ORDER BY t3.a;
+} {95 96 97 98 99}
+do_execsql_test select4-16.3 {
+ SELECT t3.c FROM
+ (SELECT a,max(b) AS m FROM t1 WHERE a>=5 GROUP BY a) AS t2
+ LEFT JOIN t1 AS t3
+ WHERE t2.a=t3.a AND t2.m=t3.b
+ ORDER BY t3.a;
+} {95 96 97 98 99}
+
+
+
+
finish_test
diff --git a/test/shell1.test b/test/shell1.test
index 1b9ea1d38..1f1f3de32 100644
--- a/test/shell1.test
+++ b/test/shell1.test
@@ -21,15 +21,7 @@
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
-if {$tcl_platform(platform)=="windows"} {
- set CLI "sqlite3.exe"
-} else {
- set CLI "./sqlite3"
-}
-if {![file executable $CLI]} {
- finish_test
- return
-}
+set CLI [test_find_cli]
db close
forcedelete test.db test.db-journal test.db-wal
sqlite3 db test.db
diff --git a/test/shell2.test b/test/shell2.test
index 616610bd4..9388b719b 100644
--- a/test/shell2.test
+++ b/test/shell2.test
@@ -20,15 +20,7 @@
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
-if {$tcl_platform(platform)=="windows"} {
- set CLI "sqlite3.exe"
-} else {
- set CLI "./sqlite3"
-}
-if {![file executable $CLI]} {
- finish_test
- return
-}
+set CLI [test_find_cli]
db close
forcedelete test.db test.db-journal test.db-wal
sqlite3 db test.db
diff --git a/test/shell3.test b/test/shell3.test
index ce1fd4ecb..3ded8f5cc 100644
--- a/test/shell3.test
+++ b/test/shell3.test
@@ -21,15 +21,7 @@
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
-if {$tcl_platform(platform)=="windows"} {
- set CLI "sqlite3.exe"
-} else {
- set CLI "./sqlite3"
-}
-if {![file executable $CLI]} {
- finish_test
- return
-}
+set CLI [test_find_cli]
db close
forcedelete test.db test.db-journal test.db-wal
sqlite3 db test.db
diff --git a/test/shell4.test b/test/shell4.test
index 18e7d7fdf..3e4ae5581 100644
--- a/test/shell4.test
+++ b/test/shell4.test
@@ -21,15 +21,7 @@
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
-if {$tcl_platform(platform)=="windows"} {
- set CLI "sqlite3.exe"
-} else {
- set CLI "./sqlite3"
-}
-if {![file executable $CLI]} {
- finish_test
- return
-}
+set CLI [test_find_cli]
db close
forcedelete test.db test.db-journal test.db-wal
sqlite3 db test.db
diff --git a/test/shell5.test b/test/shell5.test
index b921accca..bb2511a52 100644
--- a/test/shell5.test
+++ b/test/shell5.test
@@ -21,15 +21,7 @@
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
-if {$tcl_platform(platform)=="windows"} {
- set CLI "sqlite3.exe"
-} else {
- set CLI "./sqlite3"
-}
-if {![file executable $CLI]} {
- finish_test
- return
-}
+set CLI [test_find_cli]
db close
forcedelete test.db test.db-journal test.db-wal
diff --git a/test/spellfix3.test b/test/spellfix3.test
index ce002edd4..e24ea31ee 100644
--- a/test/spellfix3.test
+++ b/test/spellfix3.test
@@ -35,9 +35,18 @@ do_execsql_test 140 {
} {160}
do_execsql_test 200 {
SELECT spellfix1_scriptcode('+3.14159');
-} {999}
+} {215}
do_execsql_test 210 {
SELECT spellfix1_scriptcode('And God said: "Да будет свет"');
} {998}
+do_execsql_test 220 {
+ SELECT spellfix1_scriptcode('+3.14159 light');
+} {215}
+do_execsql_test 230 {
+ SELECT spellfix1_scriptcode('+3.14159 свет');
+} {220}
+do_execsql_test 240 {
+ SELECT spellfix1_scriptcode('וַיֹּ֥אמֶר +3.14159');
+} {125}
finish_test
diff --git a/test/stat.test b/test/stat.test
index 288153dbb..95586e94b 100644
--- a/test/stat.test
+++ b/test/stat.test
@@ -21,6 +21,10 @@ ifcapable !vtab||!compound {
return
}
+# This module uses hard-coded results that depend on exact measurements of
+# pages sizes at the byte level, and hence will not work if the reserved_bytes
+# value is nonzero.
+if {[nonzero_reserved_bytes]} {finish_test; return;}
set ::asc 1
proc a_string {n} { string range [string repeat [incr ::asc]. $n] 1 $n }
diff --git a/test/superlock.test b/test/superlock.test
index 8199d5218..704b0677a 100644
--- a/test/superlock.test
+++ b/test/superlock.test
@@ -15,6 +15,7 @@ source $testdir/tester.tcl
source $testdir/lock_common.tcl
set testprefix superlock
+do_not_use_codec
# Test organization:
#
@@ -238,13 +239,23 @@ db_swap test.db2 test.db
do_catchsql_test 6.9 { SELECT * FROM t1 } {0 {1 2 3 4}}
do_catchsql_test 6.10 { SELECT * FROM t2 } {1 {no such table: t2}}
-do_execsql_test 6.11 {
- PRAGMA journal_mode = delete;
- PRAGMA page_size = 512;
- VACUUM;
- PRAGMA journal_mode = wal;
- INSERT INTO t1 VALUES(5, 6);
-} {delete wal}
+if {[nonzero_reserved_bytes]} {
+ # Vacuum with a size change is not allowed with the codec
+ do_execsql_test 6.11codec {
+ PRAGMA journal_mode = delete;
+ VACUUM;
+ PRAGMA journal_mode = wal;
+ INSERT INTO t1 VALUES(5, 6);
+ } {delete wal}
+} else {
+ do_execsql_test 6.11 {
+ PRAGMA journal_mode = delete;
+ PRAGMA page_size = 512;
+ VACUUM;
+ PRAGMA journal_mode = wal;
+ INSERT INTO t1 VALUES(5, 6);
+ } {delete wal}
+}
db_swap test.db2 test.db
do_catchsql_test 6.12 { SELECT * FROM t1 } {1 {no such table: t1}}
diff --git a/test/tclsqlite.test b/test/tclsqlite.test
index 8ce8e9c42..44d5c5634 100644
--- a/test/tclsqlite.test
+++ b/test/tclsqlite.test
@@ -22,10 +22,9 @@ source $testdir/tester.tcl
# Check the error messages generated by tclsqlite
#
+set r "sqlite_orig HANDLE FILENAME ?-vfs VFSNAME? ?-readonly BOOLEAN? ?-create BOOLEAN? ?-nomutex BOOLEAN? ?-fullmutex BOOLEAN? ?-uri BOOLEAN?"
if {[sqlite3 -has-codec]} {
- set r "sqlite_orig HANDLE FILENAME ?-key CODEC-KEY?"
-} else {
- set r "sqlite_orig HANDLE FILENAME ?-vfs VFSNAME? ?-readonly BOOLEAN? ?-create BOOLEAN? ?-nomutex BOOLEAN? ?-fullmutex BOOLEAN? ?-uri BOOLEAN?"
+ append r " ?-key CODECKEY?"
}
do_test tcl-1.1 {
set v [catch {sqlite3 bogus} msg]
diff --git a/test/tester.tcl b/test/tester.tcl
index 47a71debe..dc0c73eab 100644
--- a/test/tester.tcl
+++ b/test/tester.tcl
@@ -374,6 +374,12 @@ proc do_not_use_codec {} {
reset_db
}
+# Return true if the "reserved_bytes" integer on database files is non-zero.
+#
+proc nonzero_reserved_bytes {} {
+ return [sqlite3 -has-codec]
+}
+
# Print a HELP message and exit
#
proc print_help_and_quit {} {
@@ -411,6 +417,8 @@ if {[info exists cmdlinearg]==0} {
# --match=$pattern
# --verbose=$val
# --output=$filename
+ # -q Reduce output
+ # --testdir=$dir Run tests in subdirectory $dir
# --help
#
set cmdlinearg(soft-heap-limit) 0
@@ -425,6 +433,7 @@ if {[info exists cmdlinearg]==0} {
set cmdlinearg(match) ""
set cmdlinearg(verbose) ""
set cmdlinearg(output) ""
+ set cmdlinearg(testdir) "testdir"
set leftover [list]
foreach a $argv {
@@ -454,6 +463,7 @@ if {[info exists cmdlinearg]==0} {
}
{^-+binarylog=.+$} {
foreach {dummy cmdlinearg(binarylog)} [split $a =] break
+ set cmdlinearg(binarylog) [file normalize $cmdlinearg(binarylog)]
}
{^-+soak=.+$} {
foreach {dummy cmdlinearg(soak)} [split $a =] break
@@ -486,6 +496,7 @@ if {[info exists cmdlinearg]==0} {
{^-+output=.+$} {
foreach {dummy cmdlinearg(output)} [split $a =] break
+ set cmdlinearg(output) [file normalize $cmdlinearg(output)]
if {$cmdlinearg(verbose)==""} {
set cmdlinearg(verbose) 2
}
@@ -498,6 +509,9 @@ if {[info exists cmdlinearg]==0} {
error "option --verbose= must be set to a boolean or to \"file\""
}
}
+ {^-+testdir=.*$} {
+ foreach {dummy cmdlinearg(testdir)} [split $a =] break
+ }
{.*help.*} {
print_help_and_quit
}
@@ -507,10 +521,18 @@ if {[info exists cmdlinearg]==0} {
}
default {
- lappend leftover $a
+ lappend leftover [file normalize $a]
}
}
}
+ set testdir [file normalize $testdir]
+ set cmdlinearg(TESTFIXTURE_HOME) [pwd]
+ set cmdlinearg(INFO_SCRIPT) [file normalize [info script]]
+ set argv0 [file normalize $argv0]
+ if {$cmdlinearg(testdir)!=""} {
+ file mkdir $cmdlinearg(testdir)
+ cd $cmdlinearg(testdir)
+ }
set argv $leftover
# Install the malloc layer used to inject OOM errors. And the 'automatic'
@@ -2120,6 +2142,24 @@ proc test_restore_config_pagecache {} {
sqlite3 db test.db
}
+# Find the name of the 'shell' executable (e.g. "sqlite3.exe") to use for
+# the tests in shell[1-5].test. If no such executable can be found, invoke
+# [finish_test ; return] in the callers context.
+#
+proc test_find_cli {} {
+ if {$::tcl_platform(platform)=="windows"} {
+ set ret "sqlite3.exe"
+ } else {
+ set ret "sqlite3"
+ }
+ set ret [file normalize [file join $::cmdlinearg(TESTFIXTURE_HOME) $ret]]
+ if {![file executable $ret]} {
+ finish_test
+ return -code return
+ }
+ return $ret
+}
+
# If the library is compiled with the SQLITE_DEFAULT_AUTOVACUUM macro set
# to non-zero, then set the global variable $AUTOVACUUM to 1.
set AUTOVACUUM $sqlite_options(default_autovacuum)
diff --git a/test/tkt4018.test b/test/tkt4018.test
index 2bc41d47a..77582a5c4 100644
--- a/test/tkt4018.test
+++ b/test/tkt4018.test
@@ -16,6 +16,7 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
+do_not_use_codec
proc testsql {sql} {
set fd [open tf_main.tcl w]
diff --git a/test/unixexcl.test b/test/unixexcl.test
index d6762178d..8e9c4644d 100644
--- a/test/unixexcl.test
+++ b/test/unixexcl.test
@@ -87,6 +87,7 @@ do_multiclient_test tn {
sql1 {
PRAGMA auto_vacuum = 0;
PRAGMA journal_mode = WAL;
+ PRAGMA synchronous = FULL;
CREATE TABLE t1(a, b);
INSERT INTO t1 VALUES(1, 2);
}
diff --git a/test/vtab6.test b/test/vtab6.test
index f8e0935a2..f4504b017 100644
--- a/test/vtab6.test
+++ b/test/vtab6.test
@@ -566,12 +566,12 @@ do_test vtab6-11.4.1 {
catchsql {
SELECT a, b, c FROM ab NATURAL JOIN bc;
}
-} {1 {table ab: xBestIndex returned an invalid plan}}
+} {1 {ab.xBestIndex malfunction}}
do_test vtab6-11.4.2 {
catchsql {
SELECT a, b, c FROM bc NATURAL JOIN ab;
}
-} {1 {table bc: xBestIndex returned an invalid plan}}
+} {1 {bc.xBestIndex malfunction}}
unset ::echo_module_ignore_usable
diff --git a/test/wal.test b/test/wal.test
index 92b65e66b..bb164bb76 100644
--- a/test/wal.test
+++ b/test/wal.test
@@ -1378,6 +1378,7 @@ do_test wal-21.3 {
#-------------------------------------------------------------------------
# Test reading and writing of databases with different page-sizes.
#
+incr ::do_not_use_codec
foreach pgsz {512 1024 2048 4096 8192 16384 32768 65536} {
do_multiclient_test tn [string map [list %PGSZ% $pgsz] {
do_test wal-22.%PGSZ%.$tn.1 {
@@ -1398,6 +1399,7 @@ foreach pgsz {512 1024 2048 4096 8192 16384 32768 65536} {
} {0}
}]
}
+incr ::do_not_use_codec -1
#-------------------------------------------------------------------------
# Test that when 1 or more pages are recovered from a WAL file,
diff --git a/test/wal2.test b/test/wal2.test
index 9d45444d6..4b9bbf315 100644
--- a/test/wal2.test
+++ b/test/wal2.test
@@ -1196,7 +1196,7 @@ foreach {tn sql reslist} {
} {
faultsim_delete_and_reopen
- execsql {PRAGMA auto_vacuum = 0}
+ execsql {PRAGMA auto_vacuum = 0; PRAGMA synchronous = FULL;}
execsql $sql
do_execsql_test wal2-14.$tn.0 { PRAGMA page_size = 4096 } {}
do_execsql_test wal2-14.$tn.1 { PRAGMA journal_mode = WAL } {wal}
diff --git a/test/wal5.test b/test/wal5.test
index 360d9c911..50c517286 100644
--- a/test/wal5.test
+++ b/test/wal5.test
@@ -18,6 +18,7 @@ source $testdir/tester.tcl
source $testdir/lock_common.tcl
source $testdir/wal_common.tcl
ifcapable !wal {finish_test ; return }
+do_not_use_codec
set testprefix wal5
@@ -140,13 +141,13 @@ foreach {testprefix do_wal_checkpoint} {
do_test 1.$tn.7 {
reopen_all
list [db_page_count] [wal_page_count] $::nBusyHandler
- } {7 0 0}
+ } [expr {[nonzero_reserved_bytes]?"/# # 0/":"7 0 0"}]
do_test 1.$tn.8 { sql2 { BEGIN ; SELECT x FROM t1 } } {1 2 3 4 5}
do_test 1.$tn.9 {
sql1 { INSERT INTO t1 VALUES(6, zeroblob(1200)) }
list [db_page_count] [wal_page_count] $::nBusyHandler
- } {7 5 0}
+ } [expr {[nonzero_reserved_bytes]?"/# # #/":"7 5 0"}]
do_test 1.$tn.10 { sql3 { BEGIN ; SELECT x FROM t1 } } {1 2 3 4 5 6}
set ::busy_handler_script {
@@ -157,7 +158,7 @@ foreach {testprefix do_wal_checkpoint} {
do_test 1.$tn.11 {
code1 { do_wal_checkpoint db -mode restart }
list [db_page_count] [wal_page_count] $::nBusyHandler
- } {10 5 8}
+ } [expr {[nonzero_reserved_bytes]?"/# # #/":"10 5 8"}]
do_test 1.$tn.12 { set ::db_file_size } 10
}
diff --git a/test/wal8.test b/test/wal8.test
index 0682fce35..3e5a0c261 100644
--- a/test/wal8.test
+++ b/test/wal8.test
@@ -27,6 +27,7 @@ set testdir [file dirname $argv0]
source $testdir/tester.tcl
set ::testprefix wal8
ifcapable !wal {finish_test ; return }
+do_not_use_codec
db close
forcedelete test.db test.db-wal
diff --git a/test/walbak.test b/test/walbak.test
index 303a628a8..0e0f99953 100644
--- a/test/walbak.test
+++ b/test/walbak.test
@@ -127,6 +127,7 @@ do_test walbak-2.1 {
}
} {}
do_test walbak-2.2 {
+ forcedelete abc.db
db backup abc.db
sqlite3 db2 abc.db
string compare [sig db] [sig db2]
@@ -239,6 +240,7 @@ foreach {tn setup} {
}
} {
+ if {$tn==4 && [sqlite3 -has-codec]} continue
foreach f [glob -nocomplain test.db*] { forcedelete $f }
eval $setup
diff --git a/test/walro.test b/test/walro.test
index 6d920b1e2..f46e44d4c 100644
--- a/test/walro.test
+++ b/test/walro.test
@@ -212,7 +212,7 @@ do_multiclient_test tn {
INSERT INTO t2 SELECT x||y, y||x FROM t2;
}
file size test.db-wal
- } {147800}
+ } [expr {[nonzero_reserved_bytes]?148848:147800}]
do_test 1.4.4.2 {
csql1 { SELECT * FROM t1 }
} {0 {a b c d e f g h i j k l 1 2 3 4 5 6}}
diff --git a/test/where2.test b/test/where2.test
index 434a7bcd9..0a0533506 100644
--- a/test/where2.test
+++ b/test/where2.test
@@ -765,4 +765,15 @@ do_execsql_test where2-13.1 {
SELECT * FROM t13 WHERE (1=2 AND a=3) OR a=4;
} {4 5}
+# https://www.sqlite.org/src/info/5e3c886796e5512e (2016-03-09)
+# Correlated subquery on the RHS of an IN operator
+#
+do_execsql_test where2-14.1 {
+ CREATE TABLE t14a(x INTEGER PRIMARY KEY);
+ INSERT INTO t14a(x) VALUES(1),(2),(3),(4);
+ CREATE TABLE t14b(y INTEGER PRIMARY KEY);
+ INSERT INTO t14b(y) VALUES(1);
+ SELECT x FROM t14a WHERE x NOT IN (SELECT x FROM t14b);
+} {}
+
finish_test
diff --git a/test/zerodamage.test b/test/zerodamage.test
index dccaba816..d781ab89a 100644
--- a/test/zerodamage.test
+++ b/test/zerodamage.test
@@ -112,6 +112,7 @@ ifcapable wal {
db close
sqlite3 db file:test.db?psow=FALSE -uri 1
db eval {
+ PRAGMA synchronous=FULL;
UPDATE t1 SET y=randomblob(50) WHERE x=124;
}
file size test.db-wal