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 / vec1fault9.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 vec1fault9 |
| 16 | vec1_load db |
| 17 | |
| 18 | do_faultsim_test 1 -faults oom* -body { |
| 19 | execsql { |
| 20 | SELECT vec1_to_json( vec1_from_json('[1,2,3,4,5,6,7,8,9,10]') ); |
| 21 | } |
| 22 | } -test { |
| 23 | faultsim_test_result {0 {{[1,2,3,4,5,6,7,8,9,10]}}} |
| 24 | } |
| 25 | |
| 26 | do_execsql_test 2 { |
| 27 | CREATE VIRTUAL TABLE x1 USING vec1(v, b); |
| 28 | WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<20 ) |
| 29 | INSERT INTO x1 |
| 30 | SELECT rvec(12, i), CASE WHEN i%2 THEN 'one' ELSE 'two' END FROM s; |
| 31 | INSERT INTO x1(cmd, arg) VALUES('rebuild', '{index:"flat"}'); |
| 32 | } |
| 33 | |
| 34 | do_faultsim_test 2 -faults oom* -body { |
| 35 | sqlite3 db test.db |
| 36 | sqlite3_db_config_lookaside db 0 0 0 |
| 37 | vec1_load db |
| 38 | set one one |
| 39 | execsql { |
| 40 | SELECT rowid FROM x1(rvec(12, 4000), 200) WHERE b=$one ORDER BY 1 |
| 41 | } |
| 42 | } -test { |
| 43 | faultsim_test_result \ |
| 44 | {0 {1 3 5 7 9 11 13 15 17 19}} \ |
| 45 | {1 {}} \ |
| 46 | {1 {error during initialization: }} |
| 47 | } |
| 48 | |
| 49 | #------------------------------------------------------------------------- |
| 50 | reset_db |
| 51 | vec1_load db |
| 52 | |
| 53 | do_execsql_test 3 { |
| 54 | CREATE VIRTUAL TABLE x1 USING vec1(v, b); |
| 55 | WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<20 ) |
| 56 | INSERT INTO x1(cmd, arg) VALUES('rebuild', '{index:"flat"}'); |
| 57 | } |
| 58 | |
| 59 | faultsim_save_and_close |
| 60 | |
| 61 | breakpoint |
| 62 | do_faultsim_test 3 -faults oom* -prep { |
| 63 | faultsim_restore_and_reopen |
| 64 | sqlite3_db_config_lookaside db 0 0 0 |
| 65 | vec1_load db |
| 66 | } -body { |
| 67 | set value "this_is_a_good_value" |
| 68 | execsql { |
| 69 | INSERT INTO x1 VALUES( rvec(44, 156), $value ); |
| 70 | } |
| 71 | } -test { |
| 72 | if {$testrc==0} { |
| 73 | set r [db one { |
| 74 | SELECT rowid FROM x1(rvec(44, 13), 10) WHERE b='this_is_a_good_value'; |
| 75 | }] |
| 76 | if {$r!=1} { error "unexected!" } |
| 77 | } |
| 78 | faultsim_test_result {0 {}} |
| 79 | } |
| 80 | |
| 81 | finish_test |
| 82 |