OLD | NEW |
(Empty) | |
| 1 # 2016 February 17 |
| 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 fts5faultB |
| 18 |
| 19 # If SQLITE_ENABLE_FTS3 is defined, omit this file. |
| 20 ifcapable !fts5 { |
| 21 finish_test |
| 22 return |
| 23 } |
| 24 |
| 25 proc mit {blob} { |
| 26 set scan(littleEndian) i* |
| 27 set scan(bigEndian) I* |
| 28 binary scan $blob $scan($::tcl_platform(byteOrder)) r |
| 29 return $r |
| 30 } |
| 31 db func mit mit |
| 32 |
| 33 |
| 34 #------------------------------------------------------------------------- |
| 35 # Errors while registering the matchinfo() demo function. |
| 36 # |
| 37 do_faultsim_test 1 -faults oom* -prep { |
| 38 sqlite3 db test.db |
| 39 } -body { |
| 40 sqlite3_fts5_register_matchinfo db |
| 41 } -test { |
| 42 faultsim_test_result {0 {}} {1 SQLITE_ERROR} {1 SQLITE_NOMEM} |
| 43 } |
| 44 |
| 45 |
| 46 #------------------------------------------------------------------------- |
| 47 # Errors while executing the matchinfo() demo function. |
| 48 # |
| 49 reset_db |
| 50 sqlite3_fts5_register_matchinfo db |
| 51 db func mit mit |
| 52 do_execsql_test 2 { |
| 53 CREATE VIRTUAL TABLE t1 USING fts5(a, b); |
| 54 INSERT INTO t1 VALUES('x y z', '1 2 3'); |
| 55 INSERT INTO t1 VALUES('x', '1 2 3 4 5 6 7'); |
| 56 } |
| 57 |
| 58 do_faultsim_test 2.1 -faults oom* -body { |
| 59 execsql { SELECT mit(matchinfo(t1, 'a')) FROM t1('x') } |
| 60 } -test { |
| 61 faultsim_test_result {0 {{2 5} {2 5}}} |
| 62 } |
| 63 |
| 64 do_faultsim_test 2.2 -faults oom* -body { |
| 65 execsql { SELECT mit(matchinfo(t1, 'l')) FROM t1('x') } |
| 66 } -test { |
| 67 faultsim_test_result {0 {{3 3} {1 7}}} |
| 68 } |
| 69 |
| 70 do_execsql_test 2.3 { |
| 71 INSERT INTO t1 VALUES('a b c d e f', 'a b d e f c'); |
| 72 INSERT INTO t1 VALUES('l m b c a', 'n o a b c z'); |
| 73 } |
| 74 |
| 75 do_faultsim_test 2.4 -faults oom* -body { |
| 76 execsql { SELECT mit(matchinfo(t1, 's')) FROM t1('a b c') } |
| 77 } -test { |
| 78 faultsim_test_result {0 {{3 2} {2 3}}} |
| 79 } |
| 80 |
| 81 #------------------------------------------------------------------------- |
| 82 # |
| 83 reset_db |
| 84 do_execsql_test 3.0 { |
| 85 CREATE VIRTUAL TABLE x1 USING fts5(z); |
| 86 } |
| 87 |
| 88 do_faultsim_test 3.1 -faults oom* -body { |
| 89 execsql { |
| 90 SELECT rowid FROM x1('c') WHERE rowid>1; |
| 91 } |
| 92 } -test { |
| 93 faultsim_test_result {0 {}} |
| 94 } |
| 95 |
| 96 do_execsql_test 3.2 { |
| 97 INSERT INTO x1 VALUES('a b c'); |
| 98 INSERT INTO x1 VALUES('b c d'); |
| 99 INSERT INTO x1 VALUES('c d e'); |
| 100 INSERT INTO x1 VALUES('d e f'); |
| 101 } |
| 102 do_faultsim_test 3.3 -faults oom* -body { |
| 103 execsql { |
| 104 SELECT rowid FROM x1('c') WHERE rowid>1; |
| 105 } |
| 106 } -test { |
| 107 faultsim_test_result {0 {2 3}} |
| 108 } |
| 109 |
| 110 finish_test |
| 111 |
OLD | NEW |