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/vec1fixed.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 / vec1fixed.test` 113 lines ยท 3034 bytes Raw Blame History 1 # 2026-04-02 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 # A vec1 table "fixes" the vector size when either: 13 # 14 # * the first vector is written to the table, or 15 # * the table is trained by a model that specifies a vector size. 16 # 17 # This file contains tests of these two cases. 18 # 19 20 source [file join [file dirname [info script]] vec1_common.tcl] 21 set testprefix vec1fixed 22 vec1_load db 23 24 do_execsql_test 1.0 { 25 CREATE VIRTUAL TABLE v1 USING vec1; 26 } 27 28 do_execsql_test 1.1 { 29 INSERT INTO v1(cmd, vector) VALUES('rebuild', ( 30 WITH s(i) AS ( 31 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<512 32 ) SELECT vec1_train( random_vector(128), '{nbucket:4}' ) FROM s 33 )); 34 } 35 36 do_catchsql_test 1.2 { 37 INSERT INTO v1 VALUES(random_vector(127)); 38 } {1 {vec1: unexpected vector blob size 508 bytes, expected 512}} 39 40 do_catchsql_test 1.3 { 41 INSERT INTO v1(cmd, vector) VALUES('rebuild', ( 42 WITH s(i) AS ( 43 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<512 44 ) SELECT vec1_train( random_vector(64), '{codesize:16}' ) FROM s 45 )); 46 } {1 {vec1: model/data vector size mismatch: 64/128}} 47 48 do_catchsql_test 1.4 { 49 SELECT rowid FROM v1(random_vector(129)) 50 } {1 {vec1: unexpected vector blob size 516 bytes, expected 512}} 51 52 #------------------------------------------------------------------------- 53 # Similar to tests 1.*, except fix the vector size by inserting a row. 54 # 55 reset_db 56 vec1_load db 57 58 do_execsql_test 2.0 { 59 CREATE VIRTUAL TABLE v1 USING vec1; 60 } 61 62 do_execsql_test 2.1 { 63 INSERT INTO v1 VALUES( random_vector(128) ); 64 } 65 66 do_catchsql_test 2.2 { 67 INSERT INTO v1 VALUES(random_vector(127)); 68 } {1 {vec1: unexpected vector blob size 508 bytes, expected 512}} 69 70 do_catchsql_test 2.3 { 71 INSERT INTO v1(cmd, vector) VALUES('rebuild', ( 72 WITH s(i) AS ( 73 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<512 74 ) SELECT vec1_train( random_vector(64), '{codesize:16}' ) FROM s 75 )); 76 } {1 {vec1: model/data vector size mismatch: 64/128}} 77 78 do_catchsql_test 2.4 { 79 SELECT rowid FROM v1(random_vector(129)) 80 } {1 {vec1: unexpected vector blob size 516 bytes, expected 512}} 81 82 do_execsql_test 2.5 { 83 INSERT INTO v1 VALUES( random_vector(128) ); 84 } 85 86 #------------------------------------------------------------------------- 87 # 88 reset_db 89 vec1_load db 90 91 do_execsql_test 3.0 { 92 CREATE VIRTUAL TABLE v1 USING vec1; 93 } 94 95 do_catchsql_test 3.1 { 96 INSERT INTO v1 VALUES( random_vector(1) ); 97 } {1 {vec1: invalid vector size: 4 bytes}} 98 do_catchsql_test 3.2 { 99 INSERT INTO v1 VALUES( random_vector(4097) ); 100 } {1 {vec1: invalid vector size: 16388 bytes}} 101 do_catchsql_test 3.3 { 102 INSERT INTO v1 VALUES( randomblob(207) ); 103 } {1 {vec1: invalid vector size: 207 bytes}} 104 105 106 107 do_execsql_test 3.4 { 108 INSERT INTO v1 VALUES( random_vector(4096) ); 109 } 110 111 112 finish_test 113