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/vec1update.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 / vec1update.test` 124 lines ยท 2974 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 14 source [file join [file dirname [info script]] vec1_common.tcl] 15 set testprefix vec1update 16 vec1_load db 17 18 do_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 INSERT INTO v1(cmd, v) VALUES('rebuild', '{index:"flat"}'); 24 } 25 26 do_execsql_test 1.1 { 27 PRAGMA integrity_check 28 } {ok} 29 30 do_catchsql_test 1.2.1 { 31 UPDATE v1 SET v = random_vector(9) WHERE rowid=12; 32 } {1 {vec1: unexpected vector blob size 36 bytes, expected 32}} 33 34 do_execsql_test 1.2.2 { 35 PRAGMA integrity_check 36 } {ok} 37 38 do_execsql_test 1.2.3 { 39 SELECT rowid, length(v) from v1; 40 } {11 32 12 32} 41 42 do_execsql_test 1.3.1 { 43 BEGIN; 44 INSERT INTO v1(rowid, v) VALUES(13, random_vector(8)); 45 } {} 46 47 do_catchsql_test 1.3.2 { 48 UPDATE v1 SET v = random_vector(9) WHERE rowid=12; 49 } {1 {vec1: unexpected vector blob size 36 bytes, expected 32}} 50 51 do_execsql_test 1.3.3 { 52 COMMIT; 53 PRAGMA integrity_check; 54 } {ok} 55 56 do_execsql_test 1.3.4 { 57 SELECT rowid, length(v) from v1; 58 } {11 32 12 32 13 32} 59 60 do_execsql_test 1.3.5 { 61 SELECT rowid, length(v) from v1; 62 } {11 32 12 32 13 32} 63 64 #------------------------------------------------------------------------- 65 reset_db 66 vec1_load db 67 68 do_execsql_test 2.0 { 69 CREATE VIRTUAL TABLE v1 USING vec1(v); 70 INSERT INTO v1(rowid, v) VALUES(11, random_vector(8)); 71 INSERT INTO v1(rowid, v) VALUES(12, random_vector(8)); 72 73 INSERT INTO v1(cmd, v) VALUES('rebuild', '{index:"flat"}'); 74 } 75 76 # explain_i { UPDATE v1 SET rowid=11 WHERE rowid=12; } 77 78 do_execsql_test 2.1 { 79 BEGIN; 80 INSERT INTO v1(rowid, v) VALUES(13, random_vector(8)); 81 } 82 do_catchsql_test 2.2 { 83 UPDATE v1 SET rowid=11 WHERE rowid=12; 84 } {1 {constraint failed}} 85 86 do_execsql_test 2.3 { 87 COMMIT; 88 PRAGMA integrity_check 89 } {ok} 90 91 do_execsql_test 2.4 { 92 SELECT rowid, length(v) FROM v1 93 } {11 32 12 32 13 32} 94 95 #------------------------------------------------------------------------- 96 reset_db 97 vec1_load db 98 99 do_execsql_test 3.0 { 100 CREATE VIRTUAL TABLE v1 USING vec1(v, t); 101 WITH s(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<1000) 102 INSERT INTO v1 SELECT random_vector(16), '' FROM s; 103 104 INSERT INTO v1(cmd, arg) VALUES('rebuild', ( 105 SELECT vec1_train(v, '{quantizer:"bq", nbucket: 1}') FROM v1 106 )); 107 } 108 109 do_execsql_test 3.1 { SELECT count(distance) FROM v1 } {1000} 110 111 do_execsql_test 3.2 { 112 UPDATE v1 SET t='text510' WHERE rowid IN (412, 667, 2); 113 } 114 115 do_execsql_test 3.3 { 116 PRAGMA integrity_check 117 } {ok} 118 119 do_execsql_test 3.4 { 120 SELECT rowid FROM v1(random_vector(16), 100) WHERE t='text510' ORDER BY 1 121 } {2 412 667} 122 123 finish_test 124