modernc.org/cc@v1.0.1/v2/testdata/_sqlite/ext/fts5/test/fts5faultA.test (about) 1 # 2016 February 2 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 # This file is focused on OOM errors. 13 # 14 15 source [file join [file dirname [info script]] fts5_common.tcl] 16 source $testdir/malloc_common.tcl 17 set testprefix fts5faultA 18 19 # If SQLITE_ENABLE_FTS3 is defined, omit this file. 20 ifcapable !fts5 { 21 finish_test 22 return 23 } 24 25 foreach_detail_mode $testprefix { 26 do_execsql_test 1.0 { 27 CREATE VIRTUAL TABLE o1 USING fts5(a, detail=%DETAIL%); 28 INSERT INTO o1(o1, rank) VALUES('pgsz', 32); 29 30 WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<300 ) 31 INSERT INTO o1 SELECT 'A B C' FROM s; 32 33 INSERT INTO o1 VALUES('A X C'); 34 35 WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<300 ) 36 INSERT INTO o1 SELECT 'A B C' FROM s; 37 } 38 39 do_faultsim_test 1 -faults oom* -prep { 40 sqlite3 db test.db 41 } -body { 42 execsql { SELECT rowid FROM o1('a NOT b') } 43 } -test { 44 faultsim_test_result {0 301} 45 } 46 } 47 48 do_execsql_test 2.0 { 49 CREATE VIRTUAL TABLE o2 USING fts5(a); 50 51 INSERT INTO o2 VALUES('A B C'); 52 WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<300 ) 53 INSERT INTO o2 SELECT group_concat('A B C ') FROM s; 54 } 55 56 do_faultsim_test 2 -faults oom* -prep { 57 sqlite3 db test.db 58 } -body { 59 execsql { SELECT rowid FROM o2('a+b+c NOT xyz') } 60 } -test { 61 faultsim_test_result {0 {1 2}} 62 } 63 finish_test