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

125 lines · 4008 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 vec1config
16vec1_load db
17
18do_execsql_test 1.0 { SELECT vec1_config('nthread'); } {1}
19do_execsql_test 1.1 { SELECT vec1_config('nprobe'); } {0.05}
20
21do_catchsql_test 1.2 {
22 SELECT vec1_config('nosuch');
23} {1 {vec1: no such parameter: nosuch}}
24
25do_catchsql_test 1.3.1 {
26 SELECT vec1_config('nthread', 0);
27} {1 {vec1: nthread requires an integer value between 1 and 128}}
28do_catchsql_test 1.3.2 {
29 SELECT vec1_config('nthread', 129);
30} {1 {vec1: nthread requires an integer value between 1 and 128}}
31do_test 1.3.3 {
32 catch { execsql { SELECT vec1_config('nthread', 128) } }
33} {0}
34do_catchsql_test 1.3.4 {
35 SELECT vec1_config('nthread', 1);
36} {0 1}
37
38do_catchsql_test 1.4.1 {
39 SELECT vec1_config('nprobe', -1);
40} {1 {vec1: nprobe must be a numeric value greater than 0.0}}
41do_catchsql_test 1.4.2 {
42 SELECT vec1_config('nprobe', 0.0);
43} {1 {vec1: nprobe must be a numeric value greater than 0.0}}
44do_catchsql_test 1.4.3 {
45 SELECT vec1_config('nprobe', 4.0);
46} {0 4.0}
47do_catchsql_test 1.4.4 {
48 SELECT vec1_config('nprobe', 'hello');
49} {1 {vec1: nprobe must be a numeric value greater than 0.0}}
50do_catchsql_test 1.4.5 {
51 SELECT vec1_config('nprobe', '1hello');
52} {1 {vec1: nprobe must be a numeric value greater than 0.0}}
53do_catchsql_test 1.4.6 {
54 SELECT vec1_config('nprobe', NULL);
55} {1 {vec1: nprobe must be a numeric value greater than 0.0}}
56
57do_catchsql_test 1.5.1 {
58 SELECT vec1_config('nthread', 'notaninteger');
59} {1 {vec1: nthread requires an integer value between 1 and 128}}
60
61#-------------------------------------------------------------------------
62
63do_execsql_test 2.0 {
64 CREATE VIRTUAL TABLE x1 USING vec1(v);
65}
66
67do_catchsql_test 2.1.1 {
68 SELECT * FROM x1(random_vector(8), '{nprobe: -1, K: 500}')
69} {1 {vec1: nprobe must be a numeric value greater than 0.0}}
70do_catchsql_test 2.1.2 {
71 SELECT * FROM x1(random_vector(8), '{nprobe: 0.0, K: 500}')
72} {1 {vec1: nprobe must be a numeric value greater than 0.0}}
73do_catchsql_test 2.1.3 {
74 SELECT * FROM x1(random_vector(8), '{nprobe: "world", K: 500}')
75} {1 {vec1: nprobe must be a numeric value greater than 0.0}}
76do_catchsql_test 2.1.4 {
77 SELECT * FROM x1(random_vector(8), '{nprobe: "2world", K: 500}')
78} {1 {vec1: nprobe must be a numeric value greater than 0.0}}
79do_catchsql_test 2.1.5 {
80 SELECT * FROM x1(random_vector(8), '{nprobe: 0.5, K: 500}')
81} {0 {}}
82
83do_catchsql_test 2.2.1 {
84 SELECT * FROM x1(random_vector(8), '{nprobe: 0.2, K: -1}')
85} {1 {vec1: K must be an integer value between 0 and 33554432}}
86
87do_catchsql_test 2.2.2 {
88 SELECT * FROM x1(random_vector(8), -1)
89} {1 {vec1: K must be an integer value between 0 and 33554432}}
90do_catchsql_test 2.2.3 {
91 SELECT * FROM x1(random_vector(8), '1hello')
92} {1 {malformed JSON}}
93do_catchsql_test 2.2.4 {
94 SELECT * FROM x1(random_vector(8), '5')
95} {0 {}}
96do_catchsql_test 2.2.5 {
97 SELECT * FROM x1(random_vector(8), 5.0)
98} {0 {}}
99do_catchsql_test 2.2.6 {
100 SELECT * FROM x1(random_vector(8), '64.0')
101} {0 {}}
102do_catchsql_test 2.2.7 {
103 SELECT * FROM x1(random_vector(8), 4.5)
104} {1 {vec1: K must be an integer value between 0 and 33554432}}
105
106do_catchsql_test 2.2.8 {
107 SELECT * FROM x1(random_vector(8), '{K:4.5}')
108} {1 {vec1: K must be an integer value between 0 and 33554432}}
109
110#-------------------------------------------------------------------------
111#
112reset_db
113vec1_load db
114
115do_execsql_test 3.0 {
116 CREATE VIRTUAL TABLE v USING vec1(v);
117 INSERT INTO v_config(id, val) VALUES(2, 1073741825);
118}
119
120do_catchsql_test 3.1 {
121 INSERT INTO v(v) VALUES(zeroblob(4));
122} {1 {invalid vector size in config}}
123
124finish_test
125