sqlite
[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.
Brought by drakestapleton
sqlite / ext / fts5 / test / fts5faultE.test
| 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 fts5faultE |
| 18 | |
| 19 | # If SQLITE_ENABLE_FTS5 is not defined, omit this file. |
| 20 | ifcapable !fts5 { |
| 21 | finish_test |
| 22 | return |
| 23 | } |
| 24 | |
| 25 | faultsim_save_and_close |
| 26 | do_faultsim_test 1 -prep { |
| 27 | faultsim_restore_and_reopen |
| 28 | } -body { |
| 29 | execsql { CREATE VIRTUAL TABLE t1 USING fts5(x, y, tokenize=trigram) } |
| 30 | } -test { |
| 31 | faultsim_test_result {0 {}} {1 {vtable constructor failed: t1}} |
| 32 | } |
| 33 | |
| 34 | reset_db |
| 35 | do_execsql_test 2.0 { |
| 36 | CREATE VIRTUAL TABLE t1 USING fts5(x, y, tokenize=trigram); |
| 37 | } |
| 38 | |
| 39 | faultsim_save_and_close |
| 40 | do_faultsim_test 2 -prep { |
| 41 | faultsim_restore_and_reopen |
| 42 | } -body { |
| 43 | execsql { |
| 44 | INSERT INTO t1 VALUES('abcdefghijklmnopqrstuvwxyz', NULL); |
| 45 | SELECT count(*) FROM t1 WHERE x LIKE '%mnop%' AND t1 MATCH 'jkl'; |
| 46 | } |
| 47 | } -test { |
| 48 | faultsim_test_result {0 1} {1 {vtable constructor failed: t1}} |
| 49 | } |
| 50 | |
| 51 | reset_db |
| 52 | do_execsql_test 3.0 { |
| 53 | CREATE VIRTUAL TABLE t1 USING fts5(x, y, tokenize=trigram, detail=none); |
| 54 | INSERT INTO t1 VALUES('abcdefghijklmnopqrstuvwxyz', NULL); |
| 55 | } |
| 56 | |
| 57 | faultsim_save_and_close |
| 58 | do_faultsim_test 3 -prep { |
| 59 | faultsim_restore_and_reopen |
| 60 | } -body { |
| 61 | execsql { |
| 62 | SELECT count(*) FROM t1 WHERE x LIKE '%mnopqrs%' AND t1 MATCH 'abc' |
| 63 | } |
| 64 | } -test { |
| 65 | faultsim_test_result {0 1} {1 {vtable constructor failed: t1}} |
| 66 | } |
| 67 | |
| 68 | |
| 69 | |
| 70 | finish_test |
| 71 |