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 / fts5faultG.test
| 1 | # 2010 June 15 |
| 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 | source [file join [file dirname [info script]] fts5_common.tcl] |
| 14 | source $testdir/malloc_common.tcl |
| 15 | set testprefix fts5faultG |
| 16 | |
| 17 | # If SQLITE_ENABLE_FTS5 is not defined, omit this file. |
| 18 | ifcapable !fts5 { |
| 19 | finish_test |
| 20 | return |
| 21 | } |
| 22 | |
| 23 | set ::testprefix fts5faultG |
| 24 | |
| 25 | |
| 26 | do_execsql_test 1.0 { |
| 27 | CREATE VIRTUAL TABLE t1 USING fts5(a); |
| 28 | INSERT INTO t1 VALUES('test renaming the table'); |
| 29 | INSERT INTO t1 VALUES(' after it has been written'); |
| 30 | INSERT INTO t1 VALUES(' actually other stuff instead'); |
| 31 | } |
| 32 | faultsim_save_and_close |
| 33 | do_faultsim_test 1 -faults oom* -prep { |
| 34 | faultsim_restore_and_reopen |
| 35 | execsql { |
| 36 | BEGIN; |
| 37 | DELETE FROM t1 WHERE rowid=2; |
| 38 | } |
| 39 | } -body { |
| 40 | execsql { |
| 41 | DELETE FROM t1; |
| 42 | } |
| 43 | } -test { |
| 44 | catchsql { COMMIT } |
| 45 | faultsim_integrity_check |
| 46 | faultsim_test_result {0 {}} |
| 47 | } |
| 48 | |
| 49 | reset_db |
| 50 | do_execsql_test 2.0 { |
| 51 | CREATE VIRTUAL TABLE t1 USING fts5(a, content=, contentless_delete=1); |
| 52 | BEGIN; |
| 53 | INSERT INTO t1 VALUES('here''s some text'); |
| 54 | INSERT INTO t1 VALUES('useful stuff, text'); |
| 55 | INSERT INTO t1 VALUES('what would we do without text!'); |
| 56 | COMMIT; |
| 57 | } |
| 58 | faultsim_save_and_close |
| 59 | do_faultsim_test 2 -faults oom* -prep { |
| 60 | faultsim_restore_and_reopen |
| 61 | execsql { |
| 62 | BEGIN; |
| 63 | DELETE FROM t1 WHERE rowid=2; |
| 64 | } |
| 65 | } -body { |
| 66 | execsql { |
| 67 | INSERT INTO t1(t1) VALUES('optimize'); |
| 68 | } |
| 69 | } -test { |
| 70 | faultsim_integrity_check |
| 71 | faultsim_test_result {0 {}} |
| 72 | } |
| 73 | |
| 74 | |
| 75 | |
| 76 | finish_test |