diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/busy2.test | 1 | ||||
-rw-r--r-- | test/csv01.test | 39 | ||||
-rw-r--r-- | test/dbpagefault.test | 52 | ||||
-rw-r--r-- | test/fts3corrupt4.test | 435 | ||||
-rw-r--r-- | test/fts3fault.test | 8 | ||||
-rw-r--r-- | test/fts3fault2.test | 5 | ||||
-rw-r--r-- | test/join.test | 30 | ||||
-rw-r--r-- | test/join8.test | 15 | ||||
-rw-r--r-- | test/joinD.test | 2 | ||||
-rw-r--r-- | test/malloc_common.tcl | 1 | ||||
-rw-r--r-- | test/malloctraceviewer.tcl | 2 | ||||
-rw-r--r-- | test/memjournal2.test | 1 | ||||
-rw-r--r-- | test/merge1.test | 2 | ||||
-rw-r--r-- | test/permutations.test | 4 | ||||
-rw-r--r-- | test/regexp1.test | 66 | ||||
-rw-r--r-- | test/round1.test | 1 | ||||
-rw-r--r-- | test/rowvalue.test | 31 | ||||
-rw-r--r-- | test/select3.test | 8 | ||||
-rw-r--r-- | test/temptable2.test | 3 | ||||
-rw-r--r-- | test/tester.tcl | 4 | ||||
-rw-r--r-- | test/testrunner.tcl | 705 | ||||
-rw-r--r-- | test/vacuum6.test | 1 | ||||
-rw-r--r-- | test/vacuummem.test | 1 | ||||
-rw-r--r-- | test/view.test | 35 | ||||
-rw-r--r-- | test/view3.test | 60 | ||||
-rw-r--r-- | test/wal3.test | 1 | ||||
-rw-r--r-- | test/walsetlk.test | 2 | ||||
-rw-r--r-- | test/walvfs.test | 1 | ||||
-rwxr-xr-x | test/wapptest.tcl | 15 | ||||
-rw-r--r-- | test/win32lock.test | 2 |
30 files changed, 1491 insertions, 42 deletions
diff --git a/test/busy2.test b/test/busy2.test index 61fb8496a..ec420c8b2 100644 --- a/test/busy2.test +++ b/test/busy2.test @@ -10,6 +10,7 @@ #*********************************************************************** # This file test the busy handler # +# TESTRUNNER: slow set testdir [file dirname $argv0] diff --git a/test/csv01.test b/test/csv01.test index 9ba04206b..ecb1a968d 100644 --- a/test/csv01.test +++ b/test/csv01.test @@ -237,4 +237,43 @@ do_execsql_test 5.4 { SELECT *, '|' FROM t5_1; } {1 2 3 4 | one two three four | 5 6 7 8 |} +#------------------------------------------------------------------------- + +proc randomtext {n} { + string range [db one {SELECT hex(randomblob($n))}] 1 $n +} + +for {set ii 0} {$ii < 200} {incr ii} { + reset_db + load_static_extension db csv + set fd [open csv.data w] + puts $fd "a,b" + puts $fd "[randomtext $ii],abcd" + close $fd + do_execsql_test 6.$ii.1 { + CREATE VIRTUAL TABLE abc USING csv(filename='csv.data', header=true); + } + do_execsql_test 6.$ii.2 { + SELECT count(*) FROM abc + } 1 +} + +for {set ii 0} {$ii < 20} {incr ii} { + reset_db + load_static_extension db csv + set T [randomtext $ii] + set fd [open csv.data w] + puts $fd "a,b" + puts -nonewline $fd "abcd,$T" + close $fd + do_execsql_test 7.$ii.1 { + CREATE VIRTUAL TABLE abc USING csv(filename='csv.data', header=true); + } + breakpoint + do_execsql_test 7.$ii.2 { + SELECT * FROM abc + } [list abcd $T] +} + + finish_test diff --git a/test/dbpagefault.test b/test/dbpagefault.test new file mode 100644 index 000000000..550a56712 --- /dev/null +++ b/test/dbpagefault.test @@ -0,0 +1,52 @@ +# 2022 July 06 +# +# 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/lock_common.tcl +source $testdir/malloc_common.tcl + +if {[permutation] == "inmemory_journal"} { + finish_test + return +} + +set testprefix dbpagefault + + +faultsim_save_and_close +do_faultsim_test 1 -prep { + faultsim_restore_and_reopen + execsql { ATTACH 'test.db2' AS aux; } +} -body { + execsql { + CREATE VIRTUAL TABLE t1 USING sqlite_dbpage(); + } +} -test { + execsql { PRAGMA journal_mode = off } + faultsim_test_result {0 {}} +} + +do_faultsim_test 2 -prep { + sqlite3 db "xyz.db" -vfs memdb + execsql { ATTACH 'test.db2' AS aux; } +} -body { + execsql { + CREATE VIRTUAL TABLE t1 USING sqlite_dbpage(); + INSERT INTO t1 DEFAULT VALUES; + } +} -test { + execsql { PRAGMA journal_mode = off } + faultsim_test_result {1 {no such schema}} {1 {SQL logic error}} +} + +finish_test diff --git a/test/fts3corrupt4.test b/test/fts3corrupt4.test index f0b83a390..f8e89b3a7 100644 --- a/test/fts3corrupt4.test +++ b/test/fts3corrupt4.test @@ -7033,6 +7033,8 @@ set sqlite_fts3_enable_parentheses $saved #------------------------------------------------------------------------- # +set saved $sqlite_fts3_enable_parentheses +set sqlite_fts3_enable_parentheses 1 reset_db do_test 52.0 { sqlite3 db {} @@ -7228,5 +7230,438 @@ do_catchsql_test 52.1 { SELECT * FROM t1, t2; } {1 {database disk image is malformed}} +#------------------------------------------------------------------------- +# +reset_db +do_test 53.0 { + sqlite3 db {} + db deserialize [decode_hexdb { +.open --hexdb +| size 8192 pagesize 1024 filename crash-7bc.txt.db +| page 1 offset 0 +| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3. +| 16: 04 00 01 01 00 40 20 20 00 00 00 00 00 00 00 08 .....@ ........ +| 32: 00 00 00 00 00 00 00 00 00 00 00 06 00 00 00 04 ................ +| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................ +| 96: 00 00 00 00 0d 02 f3 00 07 01 51 00 03 c8 03 63 ..........Q....c +| 112: 02 fb 02 0a 02 c0 01 a8 01 51 00 00 00 00 00 00 .........Q...... +| 336: 00 55 07 07 17 1b 1b 01 81 01 74 61 62 6c 65 74 .U........tablet +| 352: 31 5f 73 74 61 74 74 31 5f 73 74 61 74 07 43 52 1_statt1_stat.CR +| 368: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 EATE TABLE 't1_s +| 384: 74 61 74 27 28 69 64 20 49 4e 54 45 47 45 52 20 tat'(id INTEGER +| 400: 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 61 6c PRIMARY KEY, val +| 416: 75 65 20 42 4c 4f 42 29 60 06 07 17 21 21 01 81 ue BLOB)`...!!.. +| 432: 0b 74 61 62 6c 65 74 31 5f 64 6f 63 73 69 7a 65 .tablet1_docsize +| 448: 74 31 5f 64 6f 63 73 69 7a 65 06 43 52 45 41 54 t1_docsize.CREAT +| 464: 45 20 54 41 42 4c 45 20 27 74 31 5f 64 6f 63 73 E TABLE 't1_docs +| 480: 69 7a 65 27 28 64 6f 63 69 64 20 49 4e 54 45 47 ize'(docid INTEG +| 496: 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 ER PRIMARY KEY, +| 512: 73 69 7a 65 20 42 4c 4f 42 29 81 33 04 07 17 1f size BLOB).3.... +| 528: 1f 01 82 35 74 61 62 6c 65 74 31 5f 73 65 67 64 ...5tablet1_segd +| 544: 69 72 74 31 5f 73 65 67 64 69 72 04 43 52 45 41 irt1_segdir.CREA +| 560: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 TE TABLE 't1_seg +| 576: 64 69 72 27 28 6c 65 76 65 6c 20 49 4e 54 45 47 dir'(level INTEG +| 592: 45 52 2c 69 64 78 20 49 4e 54 45 47 45 52 2c 73 ER,idx INTEGER,s +| 608: 74 61 72 74 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 tart_block INTEG +| 624: 45 52 2c 6c 65 61 76 65 73 5f 65 6e 64 5f 62 6c ER,leaves_end_bl +| 640: 6f 63 6b 20 49 4e 54 45 47 45 52 2c 65 6e 64 5f ock INTEGER,end_ +| 656: 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 2c 72 6f block INTEGER,ro +| 672: 6f 74 20 42 4c 4f 42 2c 50 52 49 4d 41 52 59 20 ot BLOB,PRIMARY +| 688: 4b 45 59 28 6c 65 76 65 6c 2c 20 69 64 78 29 29 KEY(level, idx)) +| 704: 31 05 06 17 45 1f 01 00 69 6e 64 65 78 73 71 6c 1...E...indexsql +| 720: 69 74 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 ite_autoindex_t1 +| 736: 5f 73 65 67 64 69 72 5f 31 74 31 5f 73 65 67 64 _segdir_1t1_segd +| 752: 69 72 05 00 00 00 08 00 00 00 00 66 03 07 17 23 ir.........f...# +| 768: 23 01 81 13 74 61 62 6c 65 74 31 5f 73 65 67 6d #...tablet1_segm +| 784: 65 6e 74 73 74 31 5f 73 65 67 6d 65 6e 74 73 03 entst1_segments. +| 800: 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 CREATE TABLE 't1 +| 816: 5f 73 65 67 6d 65 6e 74 73 27 28 62 6c 6f 63 6b _segments'(block +| 832: 69 64 20 49 4e 53 45 47 45 52 20 50 52 49 4d 41 id INSEGER PRIMA +| 848: 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c RY KEY, block BL +| 864: 4f 42 29 63 02 07 17 21 21 01 81 11 74 61 62 6c OB)c...!!...tabl +| 880: 65 74 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f et1_contentt1_co +| 896: 6e 74 65 6e 74 02 43 52 45 41 54 45 20 54 41 42 ntent.CREATE TAB +| 912: 4c 45 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 LE 't1_content'( +| 928: 64 6f 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 docid INTEGER PR +| 944: 49 4d 41 52 59 20 4b 45 59 2c 20 27 63 30 30 27 IMARY KEY, 'c00' +| 960: 2c 20 27 63 31 62 27 29 36 01 06 17 11 11 08 5b , 'c1b')6......[ +| 976: 74 61 62 6c 65 74 31 74 31 43 52 45 41 54 45 20 tablet1t1CREATE +| 992: 56 49 52 54 55 41 4c 20 54 41 42 4c 45 20 74 31 VIRTUAL TABLE t1 +| 1008: 20 55 53 49 4e 47 20 66 74 73 34 28 30 2c 62 29 USING fts4(0,b) +| page 2 offset 1024 +| 0: 0d 00 00 00 03 00 0f 00 00 23 00 16 00 0f 00 05 .........#...... +| 16: 03 04 00 08 0f 61 0b 02 04 00 08 1b 41 54 45 20 .....a......ATE +| 32: 32 3a 50 87 5a 01 05 00 08 8f 37 66 30 30 30 30 2:P.Z.....7f0000 +| 48: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 64: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 80: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 96: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 112: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 128: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 144: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 160: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 176: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 192: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 208: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 224: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 240: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 256: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 272: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 288: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 304: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 320: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 336: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 352: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 368: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 384: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 400: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 416: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 432: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 448: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 464: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 480: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 496: 30 40 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0@00000000000000 +| 512: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 528: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 544: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 560: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 576: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 592: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 608: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 624: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 640: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 656: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 672: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 688: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 704: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 720: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 736: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 752: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 768: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 784: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 800: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 816: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 832: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 848: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 864: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 880: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 896: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 912: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 928: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 944: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 960: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 976: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 992: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 1008: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| page 3 offset 2048 +| 0: 0d 00 00 00 02 03 86 00 03 f4 03 86 00 00 00 00 ................ +| 896: 00 00 00 00 00 00 87 62 02 04 00 8f 48 00 d5 07 .......b....H... +| 912: 66 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 f000000000000000 +| 928: 30 30 30 30 3a 30 30 30 30 30 30 30 30 30 30 30 0000:00000000000 +| 944: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 960: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 976: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 992: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 1008: 00 00 00 08 0a 01 03 00 1a 00 01 30 03 01 02 00 ...........0.... +| page 4 offset 3072 +| 0: 0d 00 00 00 03 03 9e 00 03 ed 03 bc 03 9e 00 00 ................ +| 912: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1c 03 ................ +| 928: 07 08 01 08 08 15 2c 02 30 20 31 36 00 01 30 03 ......,.0 16..0. +| 944: 03 02 00 00 01 61 05 03 01 01 02 00 2f 02 07 08 .....a....../... +| 960: 09 08 08 15 54 30 20 33 36 00 01 30 03 02 02 00 ....T0 36..0.... +| 976: 00 01 32 05 02 01 01 03 00 00 03 61 74 65 05 02 ..2........ate.. +| 992: 01 01 02 00 00 01 70 05 02 01 01 04 00 11 01 07 ......p......... +| 1008: 08 08 09 01 17 14 02 32 20 39 39 37 01 01 01 66 .......2 997...f +| page 5 offset 4096 +| 0: 0a 00 00 00 03 03 ee 00 03 fb 03 f5 03 ee 00 00 ................ +| 992: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 04 ................ +| 1008: 08 01 01 02 03 05 04 08 09 01 02 04 04 08 08 09 ................ +| page 6 offset 5120 +| 0: 0d 00 00 00 03 03 eb 00 00 00 00 00 00 00 00 00 ................ +| 992: 00 00 00 00 00 00 00 00 00 00 00 05 03 03 00 10 ................ +| 1008: 01 01 05 02 03 00 10 01 03 05 01 03 00 10 01 01 ................ +| page 7 offset 6144 +| 0: 0d 00 00 00 01 03 f6 00 03 f6 00 00 00 00 00 00 ................ +| 1008: 00 00 00 00 00 00 08 00 03 00 16 03 08 c5 e0 07 ................ +| page 8 offset 7168 +| 0: 00 00 00 00 30 30 30 30 30 30 30 30 30 30 30 30 ....000000000000 +| 16: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 32: 30 30 30 30 30 30 30 30 30 30 30 30 30 bc 30 30 0000000000000.00 +| 48: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 64: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 80: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 96: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 112: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 128: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 144: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 160: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 176: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 192: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 c0 30 00000000000000.0 +| 208: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 224: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 240: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 256: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 272: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 288: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 304: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 320: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 336: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 352: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 368: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 384: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 400: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 416: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 432: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 448: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 464: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 480: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 496: 30 30 30 30 30 30 30 30 30 30 30 40 30 30 30 30 00000000000@0000 +| 512: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 528: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 544: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 560: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 576: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 592: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 608: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 624: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 640: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 656: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 672: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 688: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 704: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 720: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 736: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 752: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 768: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 784: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 800: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 816: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 832: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 848: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 864: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 880: 30 30 30 30 30 30 30 30 30 05 01 00 00 00 00 00 000000000....... +| end crash-7bc.txt.db +}]} {} + +do_execsql_test 53.1 { + SELECT*FROM t1 WHERE t1 MATCH'ATE"0"OR"2D:P"""ATE"0"OR"2:P"""'; +} {0 {ATE 2:P}} +set sqlite_fts3_enable_parentheses $saved + +#------------------------------------------------------------------------- +# +reset_db +do_test 54.0 { + sqlite3 db {} + db deserialize [decode_hexdb { +.open --hexdb +| size 8192 pagesize 1024 filename crash-365.txt.db +| page 1 offset 0 +| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3. +| 16: 04 00 01 01 00 40 20 20 00 00 00 00 00 00 00 08 .....@ ........ +| 32: 00 00 00 00 00 00 00 00 00 00 00 06 00 00 00 04 ................ +| 96: 00 00 00 00 0d 02 f3 00 07 01 51 00 03 c8 03 63 ..........Q....c +| 112: 02 fb 02 0a 02 c0 01 a8 01 51 00 00 00 00 00 00 .........Q...... +| 336: 00 55 07 07 17 1b 1b 01 81 01 74 61 62 6c 65 74 .U........tablet +| 352: 31 5f 73 74 61 74 74 31 5f 73 74 61 74 07 43 52 1_statt1_stat.CR +| 368: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 EATE TABLE 't1_s +| 384: 74 61 74 27 28 69 64 20 49 4e 54 45 47 45 52 20 tat'(id INTEGER +| 400: 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 61 6c PRIMARY KEY, val +| 416: 75 65 20 42 4c 4f 42 29 60 06 07 17 21 21 01 81 ue BLOB)`...!!.. +| 432: 0b 74 61 62 6c 65 74 31 5f 64 6f 63 73 69 7a 65 .tablet1_docsize +| 448: 74 31 5f 64 6f 63 73 69 7a 65 06 43 52 45 41 54 t1_docsize.CREAT +| 464: 45 20 54 41 42 4c 45 20 27 74 31 5f 64 6f 63 73 E TABLE 't1_docs +| 480: 69 7a 65 27 28 64 6f 63 69 64 20 49 4e 54 45 47 ize'(docid INTEG +| 496: 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 ER PRIMARY KEY, +| 512: 73 69 7a 65 20 42 4c 4f 42 29 81 33 04 07 17 1f size BLOB).3.... +| 528: 1f 01 82 35 74 61 62 6c 65 74 31 5f 73 65 67 64 ...5tablet1_segd +| 544: 69 72 74 31 5f 73 65 67 64 69 72 04 43 52 45 41 irt1_segdir.CREA +| 560: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 TE TABLE 't1_seg +| 576: 64 69 72 27 28 6c 65 76 65 6c 20 49 4e 54 45 47 dir'(level INTEG +| 592: 45 52 2c 69 64 78 20 49 4e 54 45 47 45 52 2c 73 ER,idx INTEGER,s +| 608: 74 61 72 74 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 tart_block INTEG +| 624: 45 52 2c 6c 65 61 76 65 73 5f 65 6e 64 5f 62 6c ER,leaves_end_bl +| 640: 6f 63 6b 20 49 4e 54 45 47 45 52 2c 65 6e 64 5f ock INTEGER,end_ +| 656: 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 2c 72 6f block INTEGER,ro +| 672: 6f 74 20 42 4c 4f 42 2c 50 52 49 4d 41 52 59 20 ot BLOB,PRIMARY +| 688: 4b 45 59 28 6c 65 76 65 6c 2c 20 69 64 78 29 29 KEY(level, idx)) +| 704: 31 05 06 17 45 1f 01 00 69 6e 64 65 78 73 71 6c 1...E...indexsql +| 720: 69 74 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 ite_autoindex_t1 +| 736: 5f 73 65 67 64 69 72 5f 31 74 31 5f 73 65 67 64 _segdir_1t1_segd +| 752: 69 72 05 00 00 00 08 00 00 00 00 66 03 07 17 23 ir.........f...# +| 768: 23 01 81 13 74 61 62 6c 65 74 31 5f 73 65 67 6d #...tablet1_segm +| 784: 65 6e 74 73 74 31 5f 73 65 67 6d 65 6e 74 73 03 entst1_segments. +| 800: 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 CREATE TABLE 't1 +| 816: 5f 73 65 67 6d 65 6e 74 73 27 28 62 6c 6f 63 6b _segments'(block +| 832: 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 id INTEGER PRIMA +| 848: 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c RY KEY, block BL +| 864: 4f 42 29 63 02 07 17 21 21 01 81 11 74 61 62 6c OB)c...!!...tabl +| 880: 65 74 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f et1_contentt1_co +| 896: 6e 74 65 6e 74 02 43 52 45 41 54 45 20 54 41 42 ntent.CREATE TAB +| 912: 4c 45 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 LE 't1_content'( +| 928: 64 6f 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 docid INTEGER PR +| 944: 49 4d 41 52 59 20 4b 45 59 2c 20 27 63 30 30 27 IMARY KEY, 'c00' +| 960: 2c 20 27 63 31 62 27 29 36 01 06 17 11 11 08 5b , 'c1b')6......[ +| 976: 74 61 62 6c 65 74 31 74 31 43 52 45 41 54 45 20 tablet1t1CREATE +| 992: 56 49 52 54 55 41 4c 20 54 41 42 4c 45 20 74 31 VIRTUAL TABLE t1 +| 1008: 20 55 53 49 4e 47 20 66 74 73 34 28 30 2c 62 29 USING fts4(0,b) +| page 2 offset 1024 +| 0: 0d 00 00 00 03 00 0f 00 00 23 00 16 00 0f 00 05 .........#...... +| 16: 03 04 00 08 0f 61 0b 02 04 00 08 1b 41 54 45 20 .....a......ATE +| 32: 32 3a 50 87 5a 01 05 00 08 8f 37 66 30 30 30 30 2:P.Z.....7f0000 +| 48: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 64: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 80: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 96: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 112: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 128: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 144: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 160: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 176: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 192: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 208: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 224: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 240: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 256: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 272: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 288: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 304: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 320: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 336: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 352: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 368: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 384: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 400: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 416: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 432: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 448: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 464: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 480: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 496: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 512: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 528: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 544: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 560: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 576: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 592: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 608: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 624: 30 30 30 30 30 30 30 30 30 30 1b 30 30 30 30 30 0000000000.00000 +| 640: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 656: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 672: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 688: 30 30 30 30 30 30 30 30 2f 30 30 30 30 30 30 30 00000000/0000000 +| 704: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 720: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 736: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 752: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 768: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 784: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 800: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 816: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 832: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 848: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 864: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 880: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 896: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 912: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 928: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 944: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 960: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 976: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 992: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 1008: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| page 3 offset 2048 +| 0: 0d 00 00 00 02 03 86 00 03 f4 03 86 00 00 00 00 ................ +| 896: 00 00 00 00 00 00 87 62 02 04 00 8f 48 00 d5 07 .......b....H... +| 912: 66 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 f000000000000000 +| 928: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 944: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 960: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 976: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 992: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 1008: 00 00 00 08 0a 01 03 00 1a 00 01 30 03 01 02 00 ...........0.... +| page 4 offset 3072 +| 0: 0d 00 00 00 03 03 9e 00 03 ed 03 bc 03 9e 00 01 ................ +| 912: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1c 03 ................ +| 928: 07 08 01 08 08 15 2c 02 30 20 31 36 00 01 30 03 ......,.0 16..0. +| 944: 03 02 00 00 01 61 05 03 01 01 02 00 2f 02 07 08 .....a....../... +| 960: 09 08 08 15 54 30 20 33 36 00 01 30 03 02 02 00 ....T0 36..0.... +| 976: 00 01 32 05 02 01 01 03 00 00 03 61 74 65 05 02 ..2........ate.. +| 992: 01 01 02 00 00 01 70 05 02 01 01 04 00 11 01 07 ......p......... +| 1008: 08 08 09 01 17 14 02 32 20 39 39 37 01 01 01 66 .......2 997...f +| page 5 offset 4096 +| 0: 0a 00 00 00 03 03 ee 00 03 fb 03 f5 03 ee 00 00 ................ +| 992: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 04 ................ +| 1008: 08 01 01 02 03 05 04 08 09 01 02 04 04 08 08 09 ................ +| page 6 offset 5120 +| 0: 0d 00 00 00 03 03 eb 00 03 f9 03 f2 00 00 00 00 ................ +| 992: 00 00 00 00 00 00 00 00 00 00 00 05 03 03 00 10 ................ +| 1008: 01 01 05 02 03 00 10 01 03 05 01 03 00 10 01 01 ................ +| page 7 offset 6144 +| 0: 0d 00 00 00 01 03 f6 00 03 f6 00 00 00 00 00 00 ................ +| 1008: 00 00 00 00 00 00 08 00 03 00 16 03 03 05 e0 07 ................ +| page 8 offset 7168 +| 0: 00 00 00 00 30 30 30 30 30 30 30 30 30 30 30 30 ....000000000000 +| 16: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 32: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 48: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 64: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 80: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 96: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 112: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 128: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 144: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 160: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 176: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 192: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 208: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 224: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 240: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 256: 30 30 30 30 30 2f 30 30 30 30 30 30 30 30 30 30 00000/0000000000 +| 272: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 288: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 304: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 320: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 336: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 352: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 368: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 384: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 400: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 416: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 432: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 448: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 464: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 480: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 496: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 512: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 528: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 544: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 560: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 576: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 592: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 608: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 624: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 640: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 656: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 672: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 688: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 704: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 720: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 736: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 752: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 768: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 784: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 800: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 816: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 832: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 848: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 864: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000 +| 880: 30 30 30 30 30 30 30 30 30 05 01 01 01 02 00 00 000000000....... +| end crash-365.txt.db +}]} {} + +do_execsql_test 54.1 { + SELECT rowid, quote(matchinfo(t1,'pcxybspcxybs')) FROM t1 WHERE t1 MATCH'ATE"0"OR"2:P"""'; +} finish_test diff --git a/test/fts3fault.test b/test/fts3fault.test index 707e884fa..21defd282 100644 --- a/test/fts3fault.test +++ b/test/fts3fault.test @@ -18,6 +18,10 @@ set ::testprefix fts3fault # If SQLITE_ENABLE_FTS3 is not defined, omit this file. ifcapable !fts3 { finish_test ; return } +set ::TMPDBERROR [list 1 \ + {unable to open a temporary database file for storing temporary tables} +] + # Test error handling in the sqlite3Fts3Init() function. This is the # function that registers the FTS3 module and various support functions # with SQLite. @@ -49,7 +53,7 @@ do_faultsim_test 2 -prep { } -body { execsql { ALTER TABLE t1 RENAME TO t2 } } -test { - faultsim_test_result {0 {}} + faultsim_test_result {0 {}} $::TMPDBERROR } # Test error handling in the special case where a single prefix query @@ -194,7 +198,7 @@ do_faultsim_test 8.2 -faults oom-t* -prep { } -body { execsql { SELECT mit(matchinfo(t8, 's')) FROM t8 WHERE t8 MATCH 'a b c' } } -test { - faultsim_test_result {0 3} + faultsim_test_result {0 3} $::TMPDBERROR } do_faultsim_test 8.3 -prep { faultsim_restore_and_reopen diff --git a/test/fts3fault2.test b/test/fts3fault2.test index 5c182d73c..913f9baa0 100644 --- a/test/fts3fault2.test +++ b/test/fts3fault2.test @@ -215,12 +215,15 @@ do_faultsim_test 8.1 -faults oom* -prep { faultsim_test_result {0 {}} } +set ::TMPDBERROR [list 1 \ + {unable to open a temporary database file for storing temporary tables} +] do_faultsim_test 8.2 -faults oom* -prep { faultsim_restore_and_reopen } -body { execsql { ALTER TABLE t8 RENAME TO t8ii } } -test { - faultsim_test_result {0 {}} + faultsim_test_result {0 {}} $::TMPDBERROR } #------------------------------------------------------------------------- diff --git a/test/join.test b/test/join.test index 38143c056..82dbd447f 100644 --- a/test/join.test +++ b/test/join.test @@ -762,7 +762,37 @@ do_execsql_test join-14.4 { CREATE TABLE t1(c PRIMARY KEY, a TEXT(10000), b TEXT(10000)); SELECT * FROM (SELECT 111) LEFT JOIN (SELECT c+222 FROM t1) GROUP BY 1; } {111 {}} +do_execsql_test join-14.4b { + SELECT * FROM (SELECT 111) LEFT JOIN (SELECT c+222 FROM t1); +} {111 {}} do_execsql_test join-14.5 { + SELECT * FROM (SELECT 111 AS x UNION ALL SELECT 222) + LEFT JOIN (SELECT c+333 AS y FROM t1) ON x=y GROUP BY 1; +} {111 {} 222 {}} +do_execsql_test join-14.5b { + SELECT count(*) + FROM (SELECT 111 AS x UNION ALL SELECT 222) + LEFT JOIN (SELECT c+333 AS y FROM t1) ON x=y; +} {2} +do_execsql_test join-14.5c { + SELECT count(*) + FROM (SELECT c+333 AS y FROM t1) + RIGHT JOIN (SELECT 111 AS x UNION ALL SELECT 222) ON x=y; +} {2} +do_execsql_test join-14.6 { + SELECT * FROM (SELECT 111 AS x UNION ALL SELECT 111) + LEFT JOIN (SELECT c+333 AS y FROM t1) ON x=y GROUP BY 1; +} {111 {}} +do_execsql_test join-14.7 { + SELECT * FROM (SELECT 111 AS x UNION ALL SELECT 111 UNION ALL SELECT 222) + LEFT JOIN (SELECT c+333 AS y FROM t1) ON x=y GROUP BY 1; +} {111 {} 222 {}} +do_execsql_test join-14.8 { + INSERT INTO t1(c) VALUES(-111); + SELECT * FROM (SELECT 111 AS x UNION ALL SELECT 111 UNION ALL SELECT 222) + LEFT JOIN (SELECT c+333 AS y FROM t1) ON x=y GROUP BY 1; +} {111 {} 222 222} +do_execsql_test join-14.9 { DROP TABLE IF EXISTS t1; CREATE TABLE t1(c PRIMARY KEY) WITHOUT ROWID; SELECT * FROM (SELECT 111) LEFT JOIN (SELECT c+222 FROM t1) GROUP BY 1; diff --git a/test/join8.test b/test/join8.test index 97b0fe13d..481430556 100644 --- a/test/join8.test +++ b/test/join8.test @@ -786,4 +786,19 @@ do_execsql_test join8-25020 { SELECT 1 FROM t1 LEFT JOIN t2 ON true JOIN t3 ON (b2 IN (a1)) FULL JOIN t4 ON true; } {1} +# 2022-07-13 +# forum/forumpost/174afeae57 +# +reset_db +db null - +do_execsql_test join8-26000 { + CREATE TABLE t1(a INT); + CREATE TABLE t2(b INT, c INT); + CREATE VIEW t3(d) AS SELECT NULL FROM t2 FULL OUTER JOIN t1 ON c=a UNION ALL SELECT b FROM t2; + INSERT INTO t1(a) VALUES (NULL); + INSERT INTO t2(b, c) VALUES (99, NULL); + SELECT DISTINCT b, c, d FROM t2, t3 WHERE b<>0 + UNION SELECT DISTINCT b, c, d FROM t2, t3 WHERE b ISNULL; +} {99 - - 99 - 99} + finish_test diff --git a/test/joinD.test b/test/joinD.test index c520d6a28..e4e4553b6 100644 --- a/test/joinD.test +++ b/test/joinD.test @@ -10,6 +10,8 @@ # #*********************************************************************** # +# TESTRUNNER: slow +# # This file implements tests for JOINs that use Bloom filters. # # The test case output is (mostly) all generated by PostgreSQL 14. This diff --git a/test/malloc_common.tcl b/test/malloc_common.tcl index 2d0e57e4f..7d3c942f7 100644 --- a/test/malloc_common.tcl +++ b/test/malloc_common.tcl @@ -664,6 +664,7 @@ proc do_write_test {name tbl sql} { if {$::DO_MALLOC_TEST } { set answers [list {1 {out of memory}} {0 {}}] + lappend answers [list 1 {unable to open a temporary database file for storing temporary tables}] if {$::DO_MALLOC_TEST==1} { set modes {100000 persistent} } else { diff --git a/test/malloctraceviewer.tcl b/test/malloctraceviewer.tcl index 5bc22f34b..4517fdc36 100644 --- a/test/malloctraceviewer.tcl +++ b/test/malloctraceviewer.tcl @@ -47,7 +47,7 @@ proc populate_text_widget {db} { set line [$db one {SELECT line FROM frame WHERE frame = $frame}] if {$line ne ""} { - foreach {file line} [split $line :] {} + regexp {^([^:]*):([0-9]*)} $line -> file line set content [$db one "SELECT content FROM file WHERE name = '$file'"] $::O(text) delete 0.0 end diff --git a/test/memjournal2.test b/test/memjournal2.test index 97d35a98d..ec5ba56da 100644 --- a/test/memjournal2.test +++ b/test/memjournal2.test @@ -10,6 +10,7 @@ #*********************************************************************** # Tests focused on the in-memory journal. # +# TESTRUNNER: slow set testdir [file dirname $argv0] source $testdir/tester.tcl diff --git a/test/merge1.test b/test/merge1.test index 36969e8fc..7ec4dab10 100644 --- a/test/merge1.test +++ b/test/merge1.test @@ -141,3 +141,5 @@ do_eqp_test 111 { `--RIGHT `--SCAN generate_series VIRTUAL TABLE INDEX 23: } + +finish_test diff --git a/test/permutations.test b/test/permutations.test index f2710da0f..c5044e1a6 100644 --- a/test/permutations.test +++ b/test/permutations.test @@ -132,6 +132,10 @@ set allquicktests [test_set $alltests -exclude { rtree4.test sessionbig.test + + writecrash.test view3.test + fts5dlidx.test fts5ac.test fts4merge3.test fts5prefix.test + sessionB.test }] if {[info exists ::env(QUICKTEST_INCLUDE)]} { set allquicktests [concat $allquicktests $::env(QUICKTEST_INCLUDE)] diff --git a/test/regexp1.test b/test/regexp1.test index 1eb56c672..102c1280c 100644 --- a/test/regexp1.test +++ b/test/regexp1.test @@ -239,4 +239,70 @@ do_execsql_test regexp1-2.22 { SELECT 'abc$¢€xyz' REGEXP '^abc[^\u0025-X][^ -\u007f][^\u20ab]xyz$' } {1} +# 2022-07-03 +# https://sqlite.org/forum/forumpost/96692f8ba5 +# The REGEXP extension mishandles the prefix search optimization when +# the prefix contains 3-byte UTF8 characters. +# +reset_db +load_static_extension db regexp +do_execsql_test regexp1-3.1 { + CREATE TABLE t1(id INTEGER PRIMARY KEY, a TEXT); + INSERT INTO t1(id, a) VALUES(1, '日本語'); + SELECT a, hex(a), length(a) FROM t1; +} {日本語 E697A5E69CACE8AA9E 3} +do_execsql_test regexp1-3.2 { + SELECT * FROM t1 WHERE a='日本語'; +} {1 日本語} +do_execsql_test regexp1-3.3 { + SELECT * FROM t1 WHERE a LIKE '日本語'; +} {1 日本語} +do_execsql_test regexp1-3.4 { + SELECT * FROM t1 wHERE a REGEXP '日本語'; +} {1 日本語} + +# 2022-07-03 +# https://sqlite.org/forum/forumpost/96692f8ba5 Issue #2 +# The '$' token in REGEXP contained within other elements. +# +do_execsql_test regexp1-4.1 {SELECT 'xab' REGEXP 'a(b$|cd)';} {1} +do_execsql_test regexp1-4.1b {SELECT 'xab' REGEXP '(b$|cd)';} {1} +do_execsql_test regexp1-4.2 {SELECT 'xaby' REGEXP 'a(b$|cd)';} {0} +do_execsql_test regexp1-4.3 {SELECT 'xacd' REGEXP 'a(b$|cd)';} {1} +do_execsql_test regexp1-4.4 {SELECT 'xacdy' REGEXP 'a(b$|cd)';} {1} +do_execsql_test regexp1-4.5 {SELECT 'xab' REGEXP 'a(cd|b$)';} {1} +do_execsql_test regexp1-4.6 {SELECT 'xaby' REGEXP 'a(cd|b$)';} {0} +do_execsql_test regexp1-4.7 {SELECT 'xacd' REGEXP 'a(cd|b$)';} {1} +do_execsql_test regexp1-4.8 {SELECT 'xacdy' REGEXP 'a(cd|b$)';} {1} +do_execsql_test regexp1-4.9 {SELECT 'xab' REGEXP 'a(cd|b$|e)';} {1} +do_execsql_test regexp1-4.10 {SELECT 'xaby' REGEXP 'a(cd|b$|e)';} {0} +do_execsql_test regexp1-4.11 {SELECT 'xacd' REGEXP 'a(cd|b$|e)';} {1} +do_execsql_test regexp1-4.12 {SELECT 'xacdy' REGEXP 'a(cd|b$|e)';} {1} + +# 2022-07-18 +# https://sqlite.org/forum/forumpost/57cbaf1d0e +# Incorrect bytecode for {M,N} when M is zero. +# +do_execsql_test regexp1-5.1 {SELECT 'fooX' REGEXP '^[a-z][a-z0-9]{0,30}$';} {0} +do_execsql_test regexp1-5.2 {SELECT 'fooX' REGEXP '^[a-z][a-z0-9]{0,30}X$';} {1} +do_execsql_test regexp1-5.3 {SELECT 'fooX' REGEXP '^[a-z][a-z0-9]{0,2}X$';} {1} +do_execsql_test regexp1-5.4 {SELECT 'foooX' REGEXP '^[a-z][a-z0-9]{0,2}X$';} {0} +do_execsql_test regexp1-5.5 {SELECT 'foooX' REGEXP '^[a-z][a-z0-9]{0,3}X$';} {1} + +# 2022-07-18 +# https://sqlite.org/forum/forumpost/18f87fdcdf +# Allow "^" to occur inside of "(..)" +# +do_execsql_test regexp1-6.1 {SELECT 'foo' REGEXP '[a-z]';} {1} +do_execsql_test regexp1-6.2 {SELECT 'foo' REGEXP '^[a-z]+$';} {1} +do_execsql_test regexp1-6.3 {SELECT 'foo' REGEXP '^([a-z]+)$';} {1} +do_execsql_test regexp1-6.4 {SELECT 'foo' REGEXP '(^[a-z]+)$';} {1} +do_execsql_test regexp1-6.5 {SELECT 'foo' REGEXP '(^[a-z]+$)';} {1} +do_execsql_test regexp1-6.6 {SELECT 'abc' REGEXP '(^abc|def)';} {1} +do_execsql_test regexp1-6.7 {SELECT 'xabc' REGEXP '(^abc|def)';} {0} +do_execsql_test regexp1-6.8 {SELECT 'def' REGEXP '(^abc|def)';} {1} +do_execsql_test regexp1-6.9 {SELECT 'xdef' REGEXP '(^abc|def)';} {1} + + + finish_test diff --git a/test/round1.test b/test/round1.test index ba2c79eab..2244a399a 100644 --- a/test/round1.test +++ b/test/round1.test @@ -10,6 +10,7 @@ #*********************************************************************** # Test cases for rounding behavior of floating point values. # +# TESTRUNNER: slow set testdir [file dirname $argv0] source $testdir/tester.tcl diff --git a/test/rowvalue.test b/test/rowvalue.test index 12fee8237..59b44d938 100644 --- a/test/rowvalue.test +++ b/test/rowvalue.test @@ -751,4 +751,35 @@ do_execsql_test 32.1 { WHERE a=1234 OR a<=567; } {500 502} +# 2022-07-15 +# https://sqlite.org/forum/forumpost/3607259d3c +# +reset_db +do_execsql_test 33.1 { + CREATE TABLE t1(a INT, b INT PRIMARY KEY) WITHOUT ROWID; + INSERT INTO t1(a, b) VALUES (0, 1),(15,-7),(3,100); + ANALYZE; +} {} +do_execsql_test 33.2 { + SELECT * FROM t1 WHERE (b,a) BETWEEN (0,5) AND (99,-2); +} {0 1} +do_execsql_test 33.3 { + SELECT * FROM t1 WHERE (b,a) BETWEEN (-8,5) AND (0,-2); +} {15 -7} +do_execsql_test 33.3 { + SELECT * FROM t1 WHERE (b,a) BETWEEN (3,5) AND (100,4); +} {3 100} +do_execsql_test 33.3 { + SELECT * FROM t1 WHERE (b,a) BETWEEN (3,5) AND (100,2); +} {} +do_execsql_test 33.3 { + SELECT * FROM t1 WHERE (a,b) BETWEEN (-2,99) AND (1,0); +} {0 1} +do_execsql_test 33.3 { + SELECT * FROM t1 WHERE (a,b) BETWEEN (14,99) AND (16,0); +} {15 -7} +do_execsql_test 33.3 { + SELECT * FROM t1 WHERE (a,b) BETWEEN (2,99) AND (4,0); +} {3 100} + finish_test diff --git a/test/select3.test b/test/select3.test index 690514b49..809b54902 100644 --- a/test/select3.test +++ b/test/select3.test @@ -118,10 +118,18 @@ do_test select3-2.14 { } {1 {near ";": syntax error}} # Cannot have a HAVING without a GROUP BY +# +# Update: As of 3.39.0, you can. # do_execsql_test select3-3.1 { SELECT log, count(*) FROM t1 HAVING log>=4 } {} +do_execsql_test select3-3.2 { + SELECT count(*) FROM t1 HAVING log>=4 +} {} +do_execsql_test select3-3.3 { + SELECT count(*) FROM t1 HAVING log!=400 +} {31} # Toss in some HAVING clauses # diff --git a/test/temptable2.test b/test/temptable2.test index d94021449..2ee4adb9f 100644 --- a/test/temptable2.test +++ b/test/temptable2.test @@ -8,6 +8,9 @@ # May you share freely, never taking more than you give. # #*********************************************************************** +# +# TESTRUNNER: slow +# set testdir [file dirname $argv0] source $testdir/tester.tcl diff --git a/test/tester.tcl b/test/tester.tcl index f65182885..5612311da 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -2171,13 +2171,13 @@ proc memdebug_log_sql {filename} { } set escaped "BEGIN; ${tbl}${tbl2}${tbl3}${sql} ; COMMIT;" - set escaped [string map [list "{" "\\{" "}" "\\}"] $escaped] + set escaped [string map [list "{" "\\{" "}" "\\}" "\\" "\\\\"] $escaped] set fd [open $filename w] puts $fd "set BUILTIN {" puts $fd $escaped puts $fd "}" - puts $fd {set BUILTIN [string map [list "\\{" "{" "\\}" "}"] $BUILTIN]} + puts $fd {set BUILTIN [string map [list "\\{" "{" "\\}" "}" "\\\\" "\\"] $BUILTIN]} set mtv [open $::testdir/malloctraceviewer.tcl] set txt [read $mtv] close $mtv diff --git a/test/testrunner.tcl b/test/testrunner.tcl new file mode 100644 index 000000000..da4efde26 --- /dev/null +++ b/test/testrunner.tcl @@ -0,0 +1,705 @@ + +#------------------------------------------------------------------------- +# Usage: +# +proc usage {} { + set a0 testrunner.tcl + + set ::argv [list] + uplevel [list source $::testdir/permutations.test] + + puts stderr "Usage: $a0 ?SWITCHES? ?PERMUTATION? ?PATTERNS?" + puts stderr "" + puts stderr "where SWITCHES are:" + puts stderr " --jobs NUMBER-OF-JOBS" + puts stderr "" + puts stderr "available PERMUTATION values are:" + set ii 0 + foreach name [lsort [array names ::testspec]] { + if {($ii % 3)==0} { puts -nonewline stderr " " } + puts -nonewline stderr [format "% -22s" $name] + if {($ii % 3)==2} { puts stderr "" } + incr ii + } + puts stderr "" + puts stderr "" + puts stderr "Examples:" + puts stderr " 1) Run the veryquick tests:" + puts stderr " $a0" + puts stderr " 2) Run all test scripts in the source tree:" + puts stderr " $a0 full" + puts stderr " 2) Run the 'memsubsys1' permutation:" + puts stderr " $a0 memsubsys1" + puts stderr " 3) Run all permutations usually run by \[make fulltest\]" + puts stderr " $a0 release" + puts stderr " 4) Run all scripts that match the pattern 'select%':" + puts stderr " $a0 select%" + puts stderr " $a0 all select%" + puts stderr " $a0 full select%" + puts stderr " 5) Run all scripts that are part of the veryquick permutation and match the pattern 'select%':" + puts stderr " $a0 veryquick select%" + puts stderr " 6) Run the 'memsubsys1' permutation, but just those scripts that match 'window%':" + puts stderr " $a0 memsubsys1 window%" + puts stderr " 7) Run all the permutations, but only the scripts that match either 'fts5%' or 'rtree%':" + puts stderr " $a0 release fts5% rtree%" + + exit 1 +} +#------------------------------------------------------------------------- + +#------------------------------------------------------------------------- +# The database schema used by the testrunner.db database. +# +set R(schema) { + DROP TABLE IF EXISTS script; + DROP TABLE IF EXISTS msg; + DROP TABLE IF EXISTS malloc; + + CREATE TABLE script( + config TEXT, + filename TEXT, -- full path to test script + slow BOOLEAN, -- true if script is "slow" + state TEXT CHECK( state IN ('ready', 'running', 'done') ), + testfixtureid, -- Id of process that ran script + time INTEGER, -- Time in ms + nerr INTEGER, -- if 'done', the number of errors + ntest INTEGER, -- if 'done', the number of tests + output TEXT, -- full output of test script + PRIMARY KEY(config, filename) + ); + + CREATE TABLE malloc( + id INTEGER PRIMARY KEY, + nmalloc INTEGER, + nbyte INTEGER, + leaker TEXT + ); + + CREATE TABLE msg( + id INTEGER PRIMARY KEY, + msg TEXT + ); +} +#------------------------------------------------------------------------- + +#------------------------------------------------------------------------- +# Try to estimate a the number of processes to use. +# +# Command [guess_number_of_cores] attempts to glean the number of logical +# cores. Command [default_njob] returns the default value for the --jobs +# switch. +# +proc guess_number_of_cores {} { + set ret 4 + + if {$::tcl_platform(os)=="Darwin"} { + set cmd "sysctl -n hw.logicalcpu" + } else { + set cmd "nproc" + } + catch { + set fd [open "|$cmd" r] + set ret [gets $fd] + close $fd + set ret [expr $ret] + } + return $ret +} + +proc default_njob {} { + set nCore [guess_number_of_cores] + set nHelper [expr int($nCore*0.75)] + expr $nHelper>0 ? $nHelper : 1 +} +#------------------------------------------------------------------------- + + +set R(dbname) [file normalize testrunner.db] +set R(logname) [file normalize testrunner.log] +set R(info_script) [file normalize [info script]] +set R(timeout) 10000 ;# Default busy-timeout for testrunner. +set R(nJob) [default_njob] ;# Default number of helper processes +set R(leaker) "" ;# Name of first script to leak memory + +set R(patternlist) [list] + +set testdir [file dirname $argv0] + +# Parse the command line options. There are two ways to invoke this +# script - to create a helper or coordinator process. If there are +# no helper processes, the coordinator runs test scripts. +# +# To create a helper process: +# +# testrunner.tcl helper ID +# +# where ID is an integer greater than 0. The process will create and +# run tests in the "testdir$ID" directory. Helper processes are only +# created by coordinators - there is no need for a user to create +# helper processes manually. +# +# If the first argument is anything other than "helper", then a coordinator +# process is started. See the implementation of the [usage] proc above for +# details. +# +switch -- [lindex $argv 0] { + helper { + set R(helper) 1 + set R(helper_id) [lindex $argv 1] + set argv [list --testdir=testdir$R(helper_id)] + } + + default { + set R(helper) 0 + set R(helper_id) 0 + + } +} +if {$R(helper)==0} { + for {set ii 0} {$ii < [llength $argv]} {incr ii} { + set a [lindex $argv $ii] + set n [string length $a] + + if {[string range $a 0 0]=="-"} { + if {($n>2 && [string match "$a*" --jobs]) || $a=="-j"} { + incr ii + set R(nJob) [lindex $argv $ii] + } else { + usage + } + } else { + lappend R(patternlist) [string map {% *} $a] + } + } + + set argv [list] +} +source $testdir/permutations.test + +#------------------------------------------------------------------------- +# Return a list of tests to run. Each element of the list is itself a +# list of two elements - the name of a permuations.test configuration +# followed by the full path to a test script. i.e.: +# +# {CONFIG FILENAME} {CONFIG FILENAME} ... +# +proc testset_patternlist {patternlist} { + + set first [lindex $patternlist 0] + if {$first=="all"} { set first "full" } + + if {$first=="release"} { + + # The following mirrors the set of test suites invoked by "all.test". + # + set clist { + full + no_optimization memsubsys1 memsubsys2 singlethread + multithread onefile utf16 exclusive persistent_journal + persistent_journal_error no_journal no_journal_error + autovacuum_ioerr no_mutex_try fullmutex journaltest + inmemory_journal pcache0 pcache10 pcache50 pcache90 + pcache100 prepare mmap + } + ifcapable rbu { lappend clist rbu } + if {$::tcl_platform(platform)=="unix"} { + ifcapable !default_autovacuum { + lappend clist autovacuum_crash + } + } + set patternlist [lrange $patternlist 1 end] + + } elseif {[info exists ::testspec($first)]} { + set clist $first + set patternlist [lrange $patternlist 1 end] + } elseif { [llength $patternlist]==0 } { + set clist veryquick + } else { + set clist full + } + + set testset [list] + + foreach config $clist { + catch { array unset O } + array set O $::testspec($config) + foreach f $O(-files) { + if {[file pathtype $f]!="absolute"} { + set f [file join $::testdir $f] + } + lappend testset [list $config [file normalize $f]] + } + } + + if {[llength $patternlist]>0} { + foreach t $testset { + set tail [file tail [lindex $t 1]] + foreach p $patternlist { + if {[string match $p $tail]} { + lappend ret $t + break; + } + } + } + } else { + set ret $testset + } + + set ret +} +#-------------------------------------------------------------------------- + + +proc r_write_db {tcl} { + global R + + sqlite3_test_control_pending_byte 0x010000 + sqlite3 db $R(dbname) + db timeout $R(timeout) + db eval { BEGIN EXCLUSIVE } + + uplevel $tcl + + db eval { COMMIT } + db close +} + +proc make_new_testset {} { + global R + + set tests [testset_patternlist $R(patternlist)] + r_write_db { + db eval $R(schema) + foreach t $tests { + foreach {c s} $t {} + set slow 0 + + set fd [open $s] + for {set ii 0} {$ii<100 && ![eof $fd]} {incr ii} { + set line [gets $fd] + if {[string match -nocase *testrunner:* $line]} { + regexp -nocase {.*testrunner:(.*)} $line -> properties + foreach p $properties { + if {$p=="slow"} { set slow 1 } + } + } + } + close $fd + + db eval { + INSERT INTO script(config, filename, slow, state) + VALUES ($c, $s, $slow, 'ready') + } + } + } +} + +# Find the next job in the database and mark it as 'running'. Then return +# a list consisting of the +# +# CONFIG FILENAME +# +# pair for the test. +# +proc get_next_test {} { + global R + set myid $R(helper_id) + + r_write_db { + set f "" + set c "" + db eval { + SELECT config, filename FROM script WHERE state='ready' + ORDER BY + (slow * (($myid+1) % 2)) DESC, + config!='full', + config, + filename + LIMIT 1 + } { + set c $config + set f $filename + } + if {$f!=""} { + db eval { + UPDATE script SET state='running', testfixtureid=$myid + WHERE (config, filename) = ($c, $f) + } + } + } + + if {$f==""} { return "" } + list $c $f +} + +proc r_testname {config filename} { + set name [file tail $filename] + if {$config!="" && $config!="full" && $config!="veryquick"} { + set name "$config-$name" + } + return $name +} + +proc r_set_test_result {config filename ms nerr ntest output} { + global R + + set f [r_testname $config $filename] + if {$nerr==0} { + set msg "$f... Ok" + } else { + set msg "$f... FAILED - $nerr errors of $ntest tests" + } + append msg " (${ms}ms)" + if {$R(helper)} { + append msg " (helper $R(helper_id))" + } + + sqlite3_shutdown + set nMalloc [lindex [sqlite3_status SQLITE_STATUS_MALLOC_COUNT 0] 1] + set nByte [sqlite3_memory_used] + if {($nByte>0 || $nMalloc>0) && $R(leaker)==""} { + set R(leaker) $f + } + + r_write_db { + db eval { + UPDATE script + SET state='done', output=$output, nerr=$nerr, ntest=$ntest, time=$ms + WHERE (config, filename)=($config, $filename); + + INSERT INTO msg(msg) VALUES ($msg); + } + } +} + +set R(iNextMsg) 1 +proc r_get_messages {{db ""}} { + global R + + sqlite3_test_control_pending_byte 0x010000 + + if {$db==""} { + sqlite3 rgmhandle $R(dbname) + set dbhandle rgmhandle + $dbhandle timeout $R(timeout) + } else { + set dbhandle $db + } + + $dbhandle transaction { + set next $R(iNextMsg) + set ret [$dbhandle eval {SELECT msg FROM msg WHERE id>=$next}] + set R(iNextMsg) [$dbhandle one {SELECT COALESCE(max(id), 0)+1 FROM msg}] + } + + if {$db==""} { + rgmhandle close + } + + set ret +} + +# This is called after all tests have been run to write the leaked memory +# report into the malloc table of testrunner.db. +# +proc r_memory_report {} { + global R + + sqlite3_shutdown + + set nMalloc [lindex [sqlite3_status SQLITE_STATUS_MALLOC_COUNT 0] 1] + set nByte [sqlite3_memory_used] + set id $R(helper_id) + set leaker $R(leaker) + + r_write_db { + db eval { + INSERT INTO malloc(id, nMalloc, nByte, leaker) + VALUES($id, $nMalloc, $nByte, $leaker) + } + } +} + + +#-------------------------------------------------------------------------- +# +set ::R_INSTALL_PUTS_WRAPPER { + proc puts_sts_wrapper {args} { + set n [llength $args] + if {$n==1 || ($n==2 && [string first [lindex $args 0] -nonewline]==0)} { + uplevel puts_into_caller $args + } else { + # A channel was explicitly specified. + uplevel puts_sts_original $args + } + } + rename puts puts_sts_original + proc puts {args} { uplevel puts_sts_wrapper $args } +} + +proc r_install_puts_wrapper {} $::R_INSTALL_PUTS_WRAPPER +proc r_uninstall_puts_wrapper {} { + rename puts "" + rename puts_sts_original puts +} + +proc slave_test_script {script} { + + # Create the interpreter used to run the test script. + interp create tinterp + + # Populate some global variables that tester.tcl expects to see. + foreach {var value} [list \ + ::argv0 $::argv0 \ + ::argv {} \ + ::SLAVE 1 \ + ] { + interp eval tinterp [list set $var $value] + } + + # The alias used to access the global test counters. + tinterp alias set_test_counter set_test_counter + + # Set up an empty ::cmdlinearg array in the slave. + interp eval tinterp [list array set ::cmdlinearg [array get ::cmdlinearg]] + + # Set up the ::G array in the slave. + interp eval tinterp [list array set ::G [array get ::G]] + interp eval tinterp [list set ::G(runner.tcl) 1] + + interp eval tinterp $::R_INSTALL_PUTS_WRAPPER + tinterp alias puts_into_caller puts_into_caller + + # Load the various test interfaces implemented in C. + load_testfixture_extensions tinterp + + # Run the test script. + set rc [catch { interp eval tinterp $script } msg opt] + if {$rc} { + puts_into_caller $msg + puts_into_caller [dict get $opt -errorinfo] + incr ::TC(errors) + } + + # Check if the interpreter call [run_thread_tests] + if { [interp eval tinterp {info exists ::run_thread_tests_called}] } { + set ::run_thread_tests_called 1 + } + + # Delete the interpreter used to run the test script. + interp delete tinterp +} + +proc slave_test_file {zFile} { + set tail [file tail $zFile] + + # Remember the value of the shared-cache setting. So that it is possible + # to check afterwards that it was not modified by the test script. + # + ifcapable shared_cache { set scs [sqlite3_enable_shared_cache] } + + # Run the test script in a slave interpreter. + # + unset -nocomplain ::run_thread_tests_called + reset_prng_state + set ::sqlite_open_file_count 0 + set time [time { slave_test_script [list source $zFile] }] + set ms [expr [lindex $time 0] / 1000] + + r_install_puts_wrapper + + # Test that all files opened by the test script were closed. Omit this + # if the test script has "thread" in its name. The open file counter + # is not thread-safe. + # + if {[info exists ::run_thread_tests_called]==0} { + do_test ${tail}-closeallfiles { expr {$::sqlite_open_file_count>0} } {0} + } + set ::sqlite_open_file_count 0 + + # Test that the global "shared-cache" setting was not altered by + # the test script. + # + ifcapable shared_cache { + set res [expr {[sqlite3_enable_shared_cache] == $scs}] + do_test ${tail}-sharedcachesetting [list set {} $res] 1 + } + + # Add some info to the output. + # + output2 "Time: $tail $ms ms" + show_memstats + + r_uninstall_puts_wrapper + return $ms +} + +proc puts_into_caller {args} { + global R + if {[llength $args]==1} { + append R(output) [lindex $args 0] + append R(output) "\n" + } else { + append R(output) [lindex $args 1] + } +} + +#------------------------------------------------------------------------- +# +proc r_final_report {} { + global R + + sqlite3_test_control_pending_byte 0x010000 + sqlite3 db $R(dbname) + + db timeout $R(timeout) + + set errcode 0 + + # Create the text log file. This is just the concatenation of the + # 'output' column of the database for every script that was run. + set fd [open $R(logname) w] + db eval {SELECT output FROM script ORDER BY config!='full',config,filename} { + puts $fd $output + } + close $fd + + # Check if any scripts reported errors. If so, print one line noting + # how many errors, and another identifying the scripts in which they + # occured. Or, if no errors occurred, print out "no errors at all!". + sqlite3 db $R(dbname) + db timeout $R(timeout) + db eval { SELECT sum(nerr) AS nerr, sum(ntest) AS ntest FROM script } { } + puts "$nerr errors from $ntest tests." + if {$nerr>0} { + db eval { SELECT config, filename FROM script WHERE nerr>0 } { + lappend errlist [r_testname $config $filename] + } + puts "Errors in: $errlist" + set errcode 1 + } + + # Check if any scripts were not run or did not finish. Print out a + # line identifying them if there are any. + set errlist [list] + db eval { SELECT config, filename FROM script WHERE state!='done' } { + lappend errlist [r_testname $config $filename] + } + if {$errlist!=[list]} { + puts "Tests DID NOT FINISH (crashed?): $errlist" + set errcode 1 + } + + set bLeak 0 + db eval { + SELECT id, nmalloc, nbyte, leaker FROM malloc + WHERE nmalloc>0 OR nbyte>0 + } { + if {$id==0} { + set line "This process " + } else { + set line "Helper $id " + } + append line "leaked $nbyte byte in $nmalloc allocations" + if {$leaker!=""} { append line " (perhaps in [file tail $leaker])" } + puts $line + set bLeak 1 + } + if {$bLeak==0} { + puts "No leaks - all allocations freed." + } + + db close + + puts "Test database is $R(dbname)" + puts "Test log file is $R(logname)" + if {$errcode} { + puts "This test has FAILED." + } + return $errcode +} + + +if {$R(helper)==0} { + make_new_testset +} + +set R(nHelperRunning) 0 +if {$R(helper)==0 && $R(nJob)>1} { + cd $cmdlinearg(TESTFIXTURE_HOME) + for {set ii 1} {$ii <= $R(nJob)} {incr ii} { + set cmd "[info nameofexec] $R(info_script) helper $ii 2>@1" + puts "Launching helper $ii ($cmd)" + set chan [open "|$cmd" r] + fconfigure $chan -blocking false + fileevent $chan readable [list r_helper_readable $ii $chan] + incr R(nHelperRunning) + } + cd $cmdlinearg(testdir) +} + +proc r_helper_readable {id chan} { + set data [gets $chan] + if {$data!=""} { puts "helper $id:$data" } + if {[eof $chan]} { + puts "helper $id is finished" + incr ::R(nHelperRunning) -1 + close $chan + } +} + +if {$R(nHelperRunning)==0} { + while { ""!=[set t [get_next_test]] } { + set R(output) "" + set TC(count) 0 + set TC(errors) 0 + + foreach {config filename} $t {} + + array set O $::testspec($config) + set ::G(perm:name) $config + set ::G(perm:prefix) $O(-prefix) + set ::G(isquick) 1 + set ::G(perm:dbconfig) $O(-dbconfig) + set ::G(perm:presql) $O(-presql) + + eval $O(-initialize) + set ms [slave_test_file $filename] + eval $O(-shutdown) + + unset -nocomplain ::G(perm:sqlite3_args) + unset ::G(perm:name) + unset ::G(perm:prefix) + unset ::G(perm:dbconfig) + unset ::G(perm:presql) + + r_set_test_result $config $filename $ms $TC(errors) $TC(count) $R(output) + + if {$R(helper)==0} { + foreach msg [r_get_messages] { puts $msg } + } + } + + # Tests are finished - write a record into testrunner.db describing + # any memory leaks. + r_memory_report + +} else { + set TTT 0 + sqlite3 db $R(dbname) + db timeout $R(timeout) + while {$R(nHelperRunning)>0} { + after 250 { incr TTT } + vwait TTT + foreach msg [r_get_messages db] { puts $msg } + } + db close +} + +set errcode 0 +if {$R(helper)==0} { + set errcode [r_final_report] +} + +exit $errcode + diff --git a/test/vacuum6.test b/test/vacuum6.test index e9a1542f2..f80ff7546 100644 --- a/test/vacuum6.test +++ b/test/vacuum6.test @@ -11,6 +11,7 @@ # # This file implements a test for VACUUM on attached databases. # +# TESTRUNNER: slow set testdir [file dirname $argv0] source $testdir/tester.tcl diff --git a/test/vacuummem.test b/test/vacuummem.test index 0f77c1b40..9668b0ea9 100644 --- a/test/vacuummem.test +++ b/test/vacuummem.test @@ -12,6 +12,7 @@ # focus of this file is testing that the VACUUM statement correctly # frees any memory used for a temporary cache. # +# TESTRUNNER: slow set testdir [file dirname $argv0] source $testdir/tester.tcl diff --git a/test/view.test b/test/view.test index 85202d7d0..b0b6da268 100644 --- a/test/view.test +++ b/test/view.test @@ -649,41 +649,6 @@ do_test view-20.1 { } } {} -# Ticket [d58ccbb3f1b]: Prevent Table.nRef overflow. -db close -sqlite3 db :memory: -do_test view-21.1 { - catchsql { - CREATE TABLE t1(x); - INSERT INTO t1 VALUES(5); - CREATE VIEW v1 AS SELECT x*2 FROM t1; - CREATE VIEW v2 AS SELECT * FROM v1 UNION SELECT * FROM v1; - CREATE VIEW v4 AS SELECT * FROM v2 UNION SELECT * FROM v2; - CREATE VIEW v8 AS SELECT * FROM v4 UNION SELECT * FROM v4; - CREATE VIEW v16 AS SELECT * FROM v8 UNION SELECT * FROM v8; - CREATE VIEW v32 AS SELECT * FROM v16 UNION SELECT * FROM v16; - CREATE VIEW v64 AS SELECT * FROM v32 UNION SELECT * FROM v32; - CREATE VIEW v128 AS SELECT * FROM v64 UNION SELECT * FROM v64; - CREATE VIEW v256 AS SELECT * FROM v128 UNION SELECT * FROM v128; - CREATE VIEW v512 AS SELECT * FROM v256 UNION SELECT * FROM v256; - CREATE VIEW v1024 AS SELECT * FROM v512 UNION SELECT * FROM v512; - CREATE VIEW v2048 AS SELECT * FROM v1024 UNION SELECT * FROM v1024; - CREATE VIEW v4096 AS SELECT * FROM v2048 UNION SELECT * FROM v2048; - CREATE VIEW v8192 AS SELECT * FROM v4096 UNION SELECT * FROM v4096; - CREATE VIEW v16384 AS SELECT * FROM v8192 UNION SELECT * FROM v8192; - CREATE VIEW v32768 AS SELECT * FROM v16384 UNION SELECT * FROM v16384; - SELECT * FROM v32768 UNION SELECT * FROM v32768; - } -} {1 {too many references to "v1": max 65535}} -ifcapable progress { - do_test view-21.2 { - db progress 1000 {expr 1} - catchsql { - SELECT * FROM v32768; - } - } {1 interrupted} -} - db close sqlite3 db :memory: do_execsql_test view-22.1 { diff --git a/test/view3.test b/test/view3.test new file mode 100644 index 000000000..60dd694bf --- /dev/null +++ b/test/view3.test @@ -0,0 +1,60 @@ +# 2022 July 19 +# +# 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. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. The +# focus of this file is testing VIEW statements. +# +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +# Omit this entire file if the library is not configured with views enabled. +ifcapable !view { + finish_test + return +} +set testprefix view3 + +# Ticket [d58ccbb3f1b]: Prevent Table.nRef overflow. +db close +sqlite3 db :memory: +do_test 1.1 { + catchsql { + CREATE TABLE t1(x); + INSERT INTO t1 VALUES(5); + CREATE VIEW v1 AS SELECT x*2 FROM t1; + CREATE VIEW v2 AS SELECT * FROM v1 UNION SELECT * FROM v1; + CREATE VIEW v4 AS SELECT * FROM v2 UNION SELECT * FROM v2; + CREATE VIEW v8 AS SELECT * FROM v4 UNION SELECT * FROM v4; + CREATE VIEW v16 AS SELECT * FROM v8 UNION SELECT * FROM v8; + CREATE VIEW v32 AS SELECT * FROM v16 UNION SELECT * FROM v16; + CREATE VIEW v64 AS SELECT * FROM v32 UNION SELECT * FROM v32; + CREATE VIEW v128 AS SELECT * FROM v64 UNION SELECT * FROM v64; + CREATE VIEW v256 AS SELECT * FROM v128 UNION SELECT * FROM v128; + CREATE VIEW v512 AS SELECT * FROM v256 UNION SELECT * FROM v256; + CREATE VIEW v1024 AS SELECT * FROM v512 UNION SELECT * FROM v512; + CREATE VIEW v2048 AS SELECT * FROM v1024 UNION SELECT * FROM v1024; + CREATE VIEW v4096 AS SELECT * FROM v2048 UNION SELECT * FROM v2048; + CREATE VIEW v8192 AS SELECT * FROM v4096 UNION SELECT * FROM v4096; + CREATE VIEW v16384 AS SELECT * FROM v8192 UNION SELECT * FROM v8192; + CREATE VIEW v32768 AS SELECT * FROM v16384 UNION SELECT * FROM v16384; + SELECT * FROM v32768 UNION SELECT * FROM v32768; + } +} {1 {too many references to "v1": max 65535}} +ifcapable progress { + do_test 1.2 { + db progress 1000 {expr 1} + catchsql { + SELECT * FROM v32768; + } + } {1 interrupted} +} + + +finish_test diff --git a/test/wal3.test b/test/wal3.test index 56f40ab53..cb28d0f0b 100644 --- a/test/wal3.test +++ b/test/wal3.test @@ -12,6 +12,7 @@ # focus of this file is testing the operation of the library in # "PRAGMA journal_mode=WAL" mode. # +# TESTRUNNER: slow set testdir [file dirname $argv0] source $testdir/tester.tcl diff --git a/test/walsetlk.test b/test/walsetlk.test index 8c0a9659f..2f2f90ce3 100644 --- a/test/walsetlk.test +++ b/test/walsetlk.test @@ -9,6 +9,8 @@ # #*********************************************************************** # +# TESTRUNNER: slow +# set testdir [file dirname $argv0] source $testdir/tester.tcl diff --git a/test/walvfs.test b/test/walvfs.test index d6c58656f..d32cbd73f 100644 --- a/test/walvfs.test +++ b/test/walvfs.test @@ -12,6 +12,7 @@ # focus of this file is testing the operation of the library in # "PRAGMA journal_mode=WAL" mode. # +# TESTRUNNER: slow set testdir [file dirname $argv0] source $testdir/tester.tcl diff --git a/test/wapptest.tcl b/test/wapptest.tcl index b7e16e722..fa28ec760 100755 --- a/test/wapptest.tcl +++ b/test/wapptest.tcl @@ -8,6 +8,7 @@ source [file join [file dirname [info script]] wapp.tcl] # Variables set by the "control" form: # # G(platform) - User selected platform. +# G(cfgglob) - Glob pattern that all configurations must match # G(test) - Set to "Normal", "Veryquick", "Smoketest" or "Build-Only". # G(keep) - Boolean. True to delete no files after each test. # G(msvc) - Boolean. True to use MSVC as the compiler. @@ -15,6 +16,7 @@ source [file join [file dirname [info script]] wapp.tcl] # G(jobs) - How many sub-processes to run simultaneously. # set G(platform) $::tcl_platform(os)-$::tcl_platform(machine) +set G(cfgglob) * set G(test) Normal set G(keep) 1 set G(msvc) 0 @@ -29,7 +31,7 @@ set G(stdout) 0 proc wapptest_init {} { global G - set lSave [list platform test keep msvc tcl jobs debug noui stdout] + set lSave [list platform test keep msvc tcl jobs debug noui stdout cfgglob] foreach k $lSave { set A($k) $G($k) } array unset G foreach k $lSave { set G($k) $A($k) } @@ -117,6 +119,10 @@ proc set_test_array {} { if {$G(debug)==0} { set debug "-nodebug"} foreach {config target} [releasetest_data tests $debug $G(platform)] { + # All configuration names must match $g(cfgglob), which defaults to * + # + if {![string match -nocase $G(cfgglob) $config]} continue + # If using MSVC, do not run sanitize or valgrind tests. Or the # checksymbols test. if {$G(msvc) && ( @@ -785,6 +791,7 @@ default it uses "wapp" to provide an interactive interface. Supported command line options (all optional) are: --platform PLATFORM (which tests to run) + --config GLOB (only run configurations matching GLOB) --smoketest (run "make smoketest" only) --veryquick (run veryquick.test only) --buildonly (build executables, do not run tests) @@ -876,6 +883,12 @@ for {set i 0} {$i < [llength $lTestArg]} {incr i} { set G(stdout) 1 } + -config { + if {$i==[llength $lTestArg]-1} { wapptest_usage } + incr i + set G(cfgglob) [lindex $lTestArg $i] + } + -stdout { set G(stdout) 1 } diff --git a/test/win32lock.test b/test/win32lock.test index d1f3d1a06..fbb2dd13c 100644 --- a/test/win32lock.test +++ b/test/win32lock.test @@ -12,6 +12,8 @@ # focus of this script is recovery from transient manditory locks # that sometimes appear on database files due to anti-virus software. # +# TESTRUNNER: slow +# if {$tcl_platform(platform)!="windows"} return |