mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-16 23:02:26 +03:00
Add tests so that the "coverage-sorter" test permutation covers all branches in vdbesort.c. Fix a few minor problems in the same file.
FossilOrigin-Name: bde28b702dabd02269e333535cc41481351c5efc
This commit is contained in:
@@ -533,12 +533,14 @@ foreach {tn mmap_limit} {
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
foreach {tn mmap_limit nWorker tmpstore coremutex fakeheap} {
|
||||
1 0 3 file true false
|
||||
2 0 3 file true true
|
||||
3 0 0 file true false
|
||||
4 1000000 3 file true false
|
||||
5 0 0 memory false true
|
||||
foreach {tn mmap_limit nWorker tmpstore coremutex fakeheap softheaplimit} {
|
||||
1 0 3 file true false 0
|
||||
2 0 3 file true true 0
|
||||
3 0 0 file true false 0
|
||||
4 1000000 3 file true false 0
|
||||
5 0 0 memory false true 0
|
||||
6 0 0 file false true 1000000
|
||||
7 0 0 file false true 10000
|
||||
} {
|
||||
db close
|
||||
sqlite3_shutdown
|
||||
@@ -550,6 +552,7 @@ foreach {tn mmap_limit nWorker tmpstore coremutex fakeheap} {
|
||||
}
|
||||
sqlite3_initialize
|
||||
sorter_test_fakeheap $fakeheap
|
||||
sqlite3_soft_heap_limit $softheaplimit
|
||||
|
||||
reset_db
|
||||
sqlite3_test_control SQLITE_TESTCTRL_SORTER_MMAP db $mmap_limit
|
||||
@@ -558,8 +561,13 @@ foreach {tn mmap_limit nWorker tmpstore coremutex fakeheap} {
|
||||
set ten [string repeat X 10300]
|
||||
set one [string repeat y 200]
|
||||
|
||||
if {$softheaplimit} {
|
||||
execsql { PRAGMA cache_size = 20 };
|
||||
} else {
|
||||
execsql { PRAGMA cache_size = 5 };
|
||||
}
|
||||
|
||||
do_execsql_test 15.$tn.1 {
|
||||
PRAGMA cache_size = 5;
|
||||
WITH rr AS (
|
||||
SELECT 4, $ten UNION ALL
|
||||
SELECT 2, $one UNION ALL
|
||||
@@ -582,7 +590,6 @@ foreach {tn mmap_limit nWorker tmpstore coremutex fakeheap} {
|
||||
} {1 2 3 4 5 6}
|
||||
|
||||
do_execsql_test 15.$tn.3 {
|
||||
PRAGMA cache_size = 5;
|
||||
WITH rr AS (
|
||||
SELECT 4, $ten UNION ALL
|
||||
SELECT 2, $one
|
||||
@@ -601,6 +608,33 @@ set t(1) multithread
|
||||
set t(2) serialized
|
||||
sqlite3_config $t($sqlite_options(threadsafe))
|
||||
sqlite3_initialize
|
||||
sqlite3_soft_heap_limit 0
|
||||
|
||||
reset_db
|
||||
do_catchsql_test 16.1 {
|
||||
CREATE TABLE t1(a, b, c);
|
||||
INSERT INTO t1 VALUES(1, 2, 3);
|
||||
INSERT INTO t1 VALUES(1, NULL, 3);
|
||||
INSERT INTO t1 VALUES(NULL, 2, 3);
|
||||
INSERT INTO t1 VALUES(1, 2, NULL);
|
||||
INSERT INTO t1 VALUES(4, 5, 6);
|
||||
CREATE UNIQUE INDEX i1 ON t1(b, a, c);
|
||||
} {0 {}}
|
||||
reset_db
|
||||
do_catchsql_test 16.2 {
|
||||
CREATE TABLE t1(a, b, c);
|
||||
INSERT INTO t1 VALUES(1, 2, 3);
|
||||
INSERT INTO t1 VALUES(1, NULL, 3);
|
||||
INSERT INTO t1 VALUES(1, 2, 3);
|
||||
INSERT INTO t1 VALUES(1, 2, NULL);
|
||||
INSERT INTO t1 VALUES(4, 5, 6);
|
||||
CREATE UNIQUE INDEX i1 ON t1(b, a, c);
|
||||
} {1 {UNIQUE constraint failed: t1.b, t1.a, t1.c}}
|
||||
|
||||
reset_db
|
||||
do_execsql_test 17.1 {
|
||||
SELECT * FROM sqlite_master ORDER BY sql;
|
||||
} {}
|
||||
|
||||
finish_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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user