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 / vec1fault4.test

149 lines · 3401 bytes Raw Blame History
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
14source [file join [file dirname [info script]] vec1_common.tcl]
15set testprefix vec1fault4
16vec1_load db
17
18do_execsql_test 1.0 {
19 CREATE VIRTUAL TABLE t1 USING vec1(a, b);
20 INSERT INTO t1(cmd, arg) VALUES('rebuild', '{index:"flat"}');
21 WITH s(i) AS (
22 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<10000
23 )
24 INSERT INTO t1 SELECT random_vector(13), i+0.5 FROM s;
25}
26faultsim_save_and_close
27
28do_faultsim_test 1 -faults oom* -prep {
29 faultsim_restore_and_reopen
30 vec1_load db
31 db eval { PRAGMA table_info = t1 }
32} -body {
33 execsql {
34 SELECT count(*) FROM t1(random_vector(13), 13);
35 }
36} -test {
37 faultsim_test_result {0 13}
38}
39
40do_faultsim_test 2 -faults oom* -prep {
41 faultsim_restore_and_reopen
42 vec1_load db
43 db eval { PRAGMA table_info = t1 }
44} -body {
45 execsql {
46 SELECT count(*) FROM t1(random_vector(13), '{K:5000,streaming:true}');
47 }
48} -test {
49 faultsim_test_result {0 10000}
50}
51
52do_execsql_test 2.1 {
53 INSERT INTO t1(cmd, arg) VALUES('rebuild', (
54 SELECT vec1_train(a, '{nbucket:8}') FROM t1 WHERE rowid<1000
55 ));
56}
57faultsim_save_and_close
58
59do_faultsim_test 2.2 -faults oom* -prep {
60 faultsim_restore_and_reopen
61 vec1_load db
62 db eval { PRAGMA table_info = t1 }
63} -body {
64 execsql {
65 SELECT count(*) FROM t1(
66 random_vector(13), '{K:5000,streaming:true,nprobe:2}'
67 );
68 }
69} -test {
70 faultsim_test_result {0 10000}
71}
72
73
74faultsim_restore_and_reopen
75vec1_load db
76do_execsql_test 3.0 {
77 INSERT INTO t1(cmd, arg) VALUES('rebuild', (
78 SELECT vec1_train(a, '{codesize:13}') FROM t1 WHERE rowid<1000
79 ));
80}
81faultsim_save_and_close
82
83breakpoint
84do_faultsim_test 3 -faults oom-t* -prep {
85 faultsim_restore_and_reopen
86 vec1_load db
87 db eval { PRAGMA table_info = t1 }
88} -body {
89 execsql {
90 SELECT count(*) FROM t1(random_vector(13), 13);
91 }
92} -test {
93 faultsim_test_result {0 13}
94}
95
96#-------------------------------------------------------------------------
97reset_db
98vec1_load db
99
100do_execsql_test 4.0 {
101 CREATE VIRTUAL TABLE t1 USING vec1(a, b);
102 INSERT INTO t1(cmd, arg) VALUES('rebuild', '{index:"flat"}');
103 INSERT INTO t1(a, b) VALUES( random_vector(13), 1.123 );
104}
105faultsim_save_and_close
106
107do_faultsim_test 4 -faults oom-t* -prep {
108 faultsim_restore_and_reopen
109 vec1_load db
110 db eval { PRAGMA table_info = t1 }
111} -body {
112 execsql {
113 INSERT INTO t1(a, b) VALUES( random_vector(13), 'text' );
114 }
115} -test {
116 faultsim_test_result {0 {}}
117}
118
119#-------------------------------------------------------------------------
120reset_db
121vec1_load db
122
123do_execsql_test 5.0 {
124 CREATE TABLE t1(a);
125 WITH s(i) AS (
126 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100
127 )
128 INSERT INTO t1 SELECT random_vector(12) FROM s;
129}
130
131proc progress {args} {}
132
133faultsim_save_and_close
134do_faultsim_test 5 -faults oom-t* -prep {
135 faultsim_restore_and_reopen
136 vec1_load db
137 db func progress progress
138 db eval { SELECT count(*) FROM t1 }
139} -body {
140 execsql {
141 SELECT length( vec1_train(a, '{nbucket:8, progress:"progress"}') ) FROM t1
142 }
143} -test {
144 faultsim_test_result {0 408}
145}
146
147
148finish_test
149