Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/test/fts4merge2.test # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / test / fts4merge2.test` 77 lines ยท 2265 bytes Raw Blame History 1 # 2012-03-29 2 # 3 # The author disclaims copyright to this source code. In place of 4 # a legal notice, here is a blessing: 5 # 6 # May you do good and not evil. 7 # May you find forgiveness for yourself and forgive others. 8 # May you share freely, never taking more than you give. 9 # 10 #************************************************************************* 11 # 12 13 set testdir [file dirname $argv0] 14 source $testdir/tester.tcl 15 source $testdir/fts3_common.tcl 16 source $testdir/malloc_common.tcl 17 set ::testprefix fts4merge2 18 19 # If SQLITE_ENABLE_FTS3 is defined, omit this file. 20 ifcapable !fts3 { 21 finish_test 22 return 23 } 24 25 do_test 1.0 { 26 fts3_build_db_1 1000 27 faultsim_save_and_close 28 } {} 29 30 do_faultsim_test 1.1 -faults oom-* -prep { 31 faultsim_restore_and_reopen 32 } -body { 33 execsql { INSERT INTO t1(t1) VALUES('merge=32,4') } 34 } -test { 35 faultsim_test_result {0 {}} 36 } 37 38 do_faultsim_test 1.2 -faults oom-t* -prep { 39 if {$iFail<100} {set iFail 803} 40 faultsim_restore_and_reopen 41 } -body { 42 execsql { INSERT INTO t1(t1) VALUES('merge=1,2') } 43 execsql { INSERT INTO t1(t1) VALUES('merge=1,2') } 44 } -test { 45 faultsim_test_result {0 {}} 46 } 47 48 #------------------------------------------------------------------------- 49 # An OOM while determining the output index of an incremental merge must 50 # not cause the merge to succeed having written its output over an 51 # existing segment. The database contains segments (0,0), (0,1) and (1,0). 52 # Merging the two level-0 segments must not overwrite segment (1,0), which 53 # contains 16 of the 18 documents. 54 # 55 reset_db 56 do_test 2.0 { 57 execsql { CREATE VIRTUAL TABLE t2 USING fts4(x) } 58 for {set i 0} {$i<18} {incr i} { 59 execsql { INSERT INTO t2 VALUES('w' || $i || ' common') } 60 } 61 execsql { SELECT level, idx FROM t2_segdir ORDER BY 1, 2 } 62 } {0 0 0 1 1 0} 63 faultsim_save_and_close 64 65 do_faultsim_test 2.1 -faults oom-t* -prep { 66 faultsim_restore_and_reopen 67 execsql { SELECT count(*) FROM t2 WHERE t2 MATCH 'nosuchterm' } 68 } -body { 69 execsql { INSERT INTO t2(t2) VALUES('merge=2,2') } 70 } -test { 71 faultsim_test_result {0 {}} 72 set n [db one { SELECT count(*) FROM t2 WHERE t2 MATCH 'common' }] 73 if {$n!=18} { error "merge rc=$testrc, $n of 18 documents remain" } 74 db eval { INSERT INTO t2(t2) VALUES('integrity-check') } 75 } 76 77 finish_test