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

85 lines · 2240 bytes Raw Blame History
1# 2026-08-04
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 vec1error
16vec1_load db
17
18do_execsql_test 1.0 {
19 CREATE VIRTUAL TABLE v1 USING vec1(v);
20 INSERT INTO v1(rowid, v) VALUES(11, random_vector(8));
21 INSERT INTO v1(rowid, v) VALUES(12, random_vector(8));
22}
23
24do_catchsql_test 1.1 {
25 SELECT rowid FROM v1(random_vector(8), '{K:10, nprobes:10}');
26} {1 {unrecognized option 'nprobes', should be one of nprobe, K, streaming, or nprobe_slack}}
27
28do_catchsql_test 1.2 {
29 SELECT vec1_train(v, '{quantizer:"donuts"}') FROM v1;
30} {1 {unrecognized quantizer 'donuts', should be one of none, pq, opq, or bq}}
31
32do_catchsql_test 1.3 {
33 SELECT vec1_train(v, '{nthread:0}') FROM v1;
34} {1 {vec1: nthread must be set to an integer value between 1 and 128}}
35
36#-------------------------------------------------------------------------
37# Ensure that INSERT is not confused by a vector for which the squared
38# L2 is close to INFINITY for all centroids.
39#
40reset_db
41vec1_load db
42
43do_execsql_test 2.0 {
44 CREATE VIRTUAL TABLE v1 USING vec1(a);
45 WITH s(i) AS (
46 VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<1000
47 )
48 INSERT INTO v1(rowid, a) SELECT i, random_vector(4) FROM s;
49
50 INSERT INTO v1(cmd, arg) VALUES('rebuild', (
51 SELECT vec1_train(a, '{nbucket:8}') FROM v1
52 ));
53}
54
55do_execsql_test 2.1 {
56 INSERT INTO v1(a) VALUES( vec1_from_json('[1e30, 1e30, 1e30, 1e30]') );
57}
58
59#-------------------------------------------------------------------------
60#
61reset_db
62vec1_load db
63
64do_test 3.1 { sqlite3_db_config db TRUSTED_SCHEMA 0 } {0}
65
66do_execsql_test 3.2 {
67 CREATE VIRTUAL TABLE t1 USING vec1(x);
68 INSERT INTO t1 VALUES( random_vector(1024) );
69 INSERT INTO t1 VALUES( random_vector(1024) );
70
71 CREATE VIEW v1 AS SELECT rowid, x FROM t1;
72}
73
74do_execsql_test 3.3 {
75 SELECT rowid FROM t1
76} {1 2}
77
78do_execsql_test 3.4 {
79 SELECT rowid FROM v1
80} {1 2}
81
82
83
84finish_test
85