interplane.Get Omega
Read in your language

sqlite

[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.

Brought by drakestapleton

branch master Branches Tags History

sqlite / ext / vec1 / test / vec1faultA.test

61 lines · 1593 bytes Raw Blame History
1# 2026-10-19
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# OOM tests for vec1.
13#
14
15source [file join [file dirname [info script]] vec1_common.tcl]
16set testprefix vec1faultA
17vec1_load db
18
19foreach {tn model} {
20 1 { '{index:"flat"}' }
21 2 { (SELECT vec1_train(v, '{codesize:8}') FROM t1) }
22 3 { (SELECT vec1_train(v, '{codesize:8, nbucket:4}') FROM t1) }
23} {
24 reset_db
25 vec1_load db
26
27 do_execsql_test $tn.0 {
28 CREATE VIRTUAL TABLE t1 USING vec1(v, b);
29 WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<600 )
30 INSERT INTO t1(rowid, v, b) SELECT i, rvec(32, i), 'b'||i FROM s;
31 }
32 do_execsql_test $tn.1 "
33 INSERT INTO t1(cmd, arg) VALUES('rebuild', $model);
34 "
35
36 faultsim_save_and_close
37
38 do_faultsim_test $tn -faults oom* -prep {
39 faultsim_restore_and_reopen
40 vec1_load db
41 execsql {
42 BEGIN;
43 INSERT INTO t1(rowid, v, b) VALUES(1001, rvec(32, 5000), 'new');
44 UPDATE t1 SET v = rvec(32, 5001) WHERE rowid=7;
45 }
46 } -body {
47 execsql {
48 SELECT count(*) FROM t1(rvec(32, 5000), '{K:5}') WHERE rowid=1001;
49 }
50 } -test {
51 faultsim_test_result {0 1} {1 {out of memory}}
52 catchsql COMMIT
53
54 set ic [db one { PRAGMA integrity_check }]
55 if {$ic!="ok"} {
56 error "integrity-check failed: $ic"
57 }
58 }
59}
60
61finish_test