aboutsummaryrefslogtreecommitdiff
path: root/test/sortfault.test
diff options
context:
space:
mode:
Diffstat (limited to 'test/sortfault.test')
-rw-r--r--test/sortfault.test94
1 files changed, 87 insertions, 7 deletions
diff --git a/test/sortfault.test b/test/sortfault.test
index 2f746fcc2..4c199ab21 100644
--- a/test/sortfault.test
+++ b/test/sortfault.test
@@ -18,24 +18,32 @@ set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix sortfault
-
do_execsql_test 1.0 {
PRAGMA cache_size = 5;
}
-foreach {tn mmap_limit nWorker tmpstore threadsmode fakeheap} {
- 1 0 0 file multithread false
- 2 100000 0 file multithread false
- 3 100000 1 file multithread false
+foreach {tn mmap_limit nWorker tmpstore threadsmode fakeheap lookaside} {
+ 1 0 0 file multithread false false
+ 2 100000 0 file multithread false false
+ 3 100000 1 file multithread false false
+ 4 2000000 0 file singlethread false true
} {
+ if {$sqlite_options(threadsafe)} { set threadsmode singlethread }
+
catch { db close }
sqlite3_shutdown
sqlite3_config_worker_threads $nWorker
sqlite3_config $threadsmode
+ if { $lookaside } {
+ sqlite3_config_lookaside 100 500
+ } else {
+ sqlite3_config_lookaside 0 0
+ }
sqlite3_initialize
sorter_test_fakeheap $fakeheap
set str [string repeat a 1000]
+ puts $threadsmode
do_faultsim_test 1.$tn -prep {
sqlite3 db test.db
@@ -55,8 +63,7 @@ foreach {tn mmap_limit nWorker tmpstore threadsmode fakeheap} {
faultsim_test_result {0 {40 1000 40 1000 40 1000 40 1000 40 1000}}
}
-
- do_faultsim_test 2.$tn -prep {
+ do_faultsim_test 2.$tn -faults oom* -prep {
sqlite3 db test.db
sqlite3_test_control SQLITE_TESTCTRL_SORTER_MMAP db $::mmap_limit
add_test_utf16bin_collate db
@@ -75,6 +82,30 @@ foreach {tn mmap_limit nWorker tmpstore threadsmode fakeheap} {
faultsim_test_result {0 {20 1000 20 1000 20 1000 20 1000 20 1000}}
}
+ if {$mmap_limit > 1000000} {
+ set str2 [string repeat $str 10]
+
+ sqlite3_memdebug_vfs_oom_test 0
+ sqlite3 db test.db
+ sqlite3_test_control SQLITE_TESTCTRL_SORTER_MMAP db $::mmap_limit
+ execsql { PRAGMA cache_size = 5 }
+
+ do_faultsim_test 3.$tn -faults oom-trans* -body {
+ execsql {
+ WITH r(x,y) AS (
+ SELECT 300, $::str2
+ UNION ALL
+ SELECT x-1, $::str2 FROM r
+ LIMIT 300
+ )
+ SELECT count(x), length(y) FROM r GROUP BY y, (x%5)
+ }
+ } -test {
+ faultsim_test_result {0 {60 10000 60 10000 60 10000 60 10000 60 10000}}
+ }
+
+ sqlite3_memdebug_vfs_oom_test 1
+ }
}
catch { db close }
@@ -84,6 +115,55 @@ set t(0) singlethread
set t(1) multithread
set t(2) serialized
sqlite3_config $t($sqlite_options(threadsafe))
+sqlite3_config_lookaside 100 500
sqlite3_initialize
+
+#-------------------------------------------------------------------------
+#
+reset_db
+do_execsql_test 4.0 {
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(1, 2, 3);
+}
+do_test 4.1 {
+ for {set i 0} {$i < 256} {incr i} {
+ execsql {
+ INSERT INTO t1 SELECT
+ ((a<<3) + b) & 2147483647,
+ ((b<<3) + c) & 2147483647,
+ ((c<<3) + a) & 2147483647
+ FROM t1 ORDER BY rowid DESC LIMIT 1;
+ }
+ }
+} {}
+
+faultsim_save_and_close
+
+do_faultsim_test 4.2 -faults oom* -prep {
+ faultsim_restore_and_reopen
+} -body {
+ execsql { CREATE UNIQUE INDEX i1 ON t1(a,b,c) }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+#-------------------------------------------------------------------------
+#
+reset_db
+set a [string repeat a 500]
+set b [string repeat b 500]
+set c [string repeat c 500]
+do_execsql_test 5.0 {
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES($a, $b, $c);
+ INSERT INTO t1 VALUES($c, $b, $a);
+}
+
+do_faultsim_test 5.1 -faults oom* -body {
+ execsql { SELECT * FROM t1 ORDER BY a }
+} -test {
+ faultsim_test_result [list 0 [list $::a $::b $::c $::c $::b $::a]]
+}
+
finish_test