Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/ext/vec1/test/vec1config.test # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers 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 14 source [file join [file dirname [info script]] vec1_common.tcl] 15 set testprefix vec1config 16 vec1_load db 17 18 do_execsql_test 1.0 { SELECT vec1_config('nthread'); } {1} 19 do_execsql_test 1.1 { SELECT vec1_config('nprobe'); } {0.05} 20 21 do_catchsql_test 1.2 { 22 SELECT vec1_config('nosuch'); 23 } {1 {vec1: no such parameter: nosuch}} 24 25 do_catchsql_test 1.3.1 { 26 SELECT vec1_config('nthread', 0); 27 } {1 {vec1: nthread requires an integer value between 1 and 128}} 28 do_catchsql_test 1.3.2 { 29 SELECT vec1_config('nthread', 129); 30 } {1 {vec1: nthread requires an integer value between 1 and 128}} 31 do_test 1.3.3 { 32 catch { execsql { SELECT vec1_config('nthread', 128) } } 33 } {0} 34 do_catchsql_test 1.3.4 { 35 SELECT vec1_config('nthread', 1); 36 } {0 1} 37 38 do_catchsql_test 1.4.1 { 39 SELECT vec1_config('nprobe', -1); 40 } {1 {vec1: nprobe must be a numeric value greater than 0.0}} 41 do_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}} 44 do_catchsql_test 1.4.3 { 45 SELECT vec1_config('nprobe', 4.0); 46 } {0 4.0} 47 do_catchsql_test 1.4.4 { 48 SELECT vec1_config('nprobe', 'hello'); 49 } {1 {vec1: nprobe must be a numeric value greater than 0.0}} 50 do_catchsql_test 1.4.5 { 51 SELECT vec1_config('nprobe', '1hello'); 52 } {1 {vec1: nprobe must be a numeric value greater than 0.0}} 53 do_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 57 do_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 63 do_execsql_test 2.0 { 64 CREATE VIRTUAL TABLE x1 USING vec1(v); 65 } 66 67 do_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}} 70 do_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}} 73 do_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}} 76 do_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}} 79 do_catchsql_test 2.1.5 { 80 SELECT * FROM x1(random_vector(8), '{nprobe: 0.5, K: 500}') 81 } {0 {}} 82 83 do_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 87 do_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`}} 90 do_catchsql_test 2.2.3 { 91 SELECT * FROM x1(random_vector(8), '1hello') 92 } {1 {malformed JSON}} 93 do_catchsql_test 2.2.4 { 94 SELECT * FROM x1(random_vector(8), '5') 95 } {0 {}} 96 do_catchsql_test 2.2.5 { 97 SELECT * FROM x1(random_vector(8), 5.0) 98 } {0 {}} 99 do_catchsql_test 2.2.6 { 100 SELECT * FROM x1(random_vector(8), '64.0') 101 } {0 {}} 102 do_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 106 do_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 # 112 reset_db 113 vec1_load db 114 115 do_execsql_test 3.0 { 116 CREATE VIRTUAL TABLE v USING vec1(v); 117 INSERT INTO v_config(id, val) VALUES(2, `1073741825`); 118 } 119 120 do_catchsql_test 3.1 { 121 INSERT INTO v(v) VALUES(zeroblob(4)); 122 } {1 {invalid vector size in config}} 123 124 finish_test 125