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 / vec1 / test / vec1fault8.test
| 1 | # 2026-04-01 |
| 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 | |
| 14 | source [file join [file dirname [info script]] vec1_common.tcl] |
| 15 | set testprefix vec1fault8 |
| 16 | vec1_load db |
| 17 | |
| 18 | do_execsql_test 1 { |
| 19 | CREATE VIRTUAL TABLE t1 USING vec1(v, b); |
| 20 | INSERT INTO t1(cmd, arg) VALUES('rebuild', '{index:"flat"}'); |
| 21 | } |
| 22 | |
| 23 | faultsim_save_and_close |
| 24 | do_faultsim_test 1 -faults oom* -prep { |
| 25 | faultsim_restore_and_reopen |
| 26 | vec1_load db |
| 27 | } -body { |
| 28 | execsql { |
| 29 | BEGIN; |
| 30 | INSERT INTO t1 VALUES( random_vector(4), 1.5 ); |
| 31 | INSERT INTO t1 VALUES( random_vector(4), 2.5 ); |
| 32 | INSERT INTO t1 VALUES( random_vector(4), 3.5 ); |
| 33 | INSERT INTO t1 VALUES( random_vector(4), 4.5 ); |
| 34 | COMMIT; |
| 35 | } |
| 36 | } -test { |
| 37 | faultsim_test_result {0 {}} |
| 38 | } |
| 39 | |
| 40 | reset_db |
| 41 | vec1_load db |
| 42 | do_execsql_test 2.0 { |
| 43 | CREATE VIRTUAL TABLE t1 USING vec1(v, b); |
| 44 | INSERT INTO t1(cmd, arg) VALUES('rebuild', '{index:"flat"}'); |
| 45 | INSERT INTO t1 VALUES( random_vector(10), -10_000_000_000 ); |
| 46 | } |
| 47 | |
| 48 | faultsim_save_and_close |
| 49 | do_faultsim_test 2 -faults oom* -prep { |
| 50 | faultsim_restore_and_reopen |
| 51 | vec1_load db |
| 52 | } -body { |
| 53 | execsql { |
| 54 | DELETE FROM t1 WHERE rowid=1; |
| 55 | } |
| 56 | } -test { |
| 57 | faultsim_test_result {0 {}} |
| 58 | } |
| 59 | |
| 60 | #-------------------------------------------------------------------------- |
| 61 | reset_db |
| 62 | vec1_load db |
| 63 | do_execsql_test 3.0 { |
| 64 | CREATE VIRTUAL TABLE t1 USING vec1(v, b); |
| 65 | INSERT INTO t1(cmd, arg) VALUES('rebuild', '{index:"flat"}'); |
| 66 | INSERT INTO t1 VALUES( random_vector(10), 'hello'); |
| 67 | INSERT INTO t1 VALUES( random_vector(10), 'world'); |
| 68 | INSERT INTO t1 VALUES( random_vector(10), 'today'); |
| 69 | } |
| 70 | |
| 71 | do_execsql_test 3.1 { |
| 72 | SELECT rowid, length(v), length(v) FROM t1(random_vector(10), 5) |
| 73 | WHERE b IN ('hello', 'world', 'today') |
| 74 | ORDER BY 1 |
| 75 | } {1 40 40 2 40 40 3 40 40} |
| 76 | |
| 77 | faultsim_save_and_close |
| 78 | do_faultsim_test 3.1 -faults oom* -prep { |
| 79 | faultsim_restore_and_reopen |
| 80 | vec1_load db |
| 81 | } -body { |
| 82 | execsql { |
| 83 | SELECT rowid, length(v) FROM t1(random_vector(10), 5) |
| 84 | WHERE b IN ('hello', 'world', 'today') |
| 85 | ORDER BY 1 |
| 86 | } |
| 87 | } -test { |
| 88 | faultsim_test_result {0 {1 40 2 40 3 40}} |
| 89 | } |
| 90 | |
| 91 | do_faultsim_test 3.3 -faults oom* -prep { |
| 92 | faultsim_restore_and_reopen |
| 93 | vec1_load db |
| 94 | } -body { |
| 95 | execsql { |
| 96 | SELECT rowid, length(distance) BETWEEN 60 AND 80, b FROM t1; |
| 97 | } |
| 98 | } -test { |
| 99 | faultsim_test_result {0 {1 1 hello 2 1 world 3 1 today}} |
| 100 | } |
| 101 | |
| 102 | do_faultsim_test 3.4 -faults oom* -prep { |
| 103 | faultsim_restore_and_reopen |
| 104 | vec1_load db |
| 105 | } -body { |
| 106 | execsql { |
| 107 | SELECT rowid, b FROM t1(random_vector(10), 5) ORDER BY 1; |
| 108 | } |
| 109 | } -test { |
| 110 | faultsim_test_result {0 {1 hello 2 world 3 today}} |
| 111 | } |
| 112 | |
| 113 | reset_db |
| 114 | vec1_load db |
| 115 | do_faultsim_test 4 -faults oom* -body { |
| 116 | execsql { |
| 117 | SELECT vec1_info() IS NOT NULL |
| 118 | } |
| 119 | } -test { |
| 120 | faultsim_test_result {0 1} |
| 121 | } |
| 122 | |
| 123 | finish_test |
| 124 |