Skip to content

Commit c5dbc8c

Browse files
committed
fix integrity check for vector indices
1 parent 243bd75 commit c5dbc8c

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

libsql-sqlite3/src/insert.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2699,10 +2699,11 @@ int sqlite3OpenTableAndIndices(
26992699
* As vector index creates empty B-tree index - it's safe to issue
27002700
* OP_OpenRead command for it
27012701
*
2702-
* TODO: with current implementation, integrity_check will output error
2703-
* for vector index as rows will be missed in it
2704-
* It's better to remove this error in future - but for now it's unclear
2705-
* how to do that with minimal code changes
2702+
* In order to not produce integrity check errors we skip vector indices
2703+
* from integrity checks in pragma.c implementation
2704+
*
2705+
* Note, that it's dangerous to skip some indices in this code as sqlite3 rely
2706+
* on the fact that cursors will be opened for every index in order
27062707
*/
27072708
#ifndef SQLITE_OMIT_VECTOR
27082709
if( IsVectorIndex(pIdx) && op == OP_OpenWrite ){

libsql-sqlite3/src/pragma.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2023,6 +2023,7 @@ void sqlite3Pragma(
20232023
int kk;
20242024
int ckUniq = sqlite3VdbeMakeLabel(pParse);
20252025
if( pPk==pIdx ) continue;
2026+
if( IsVectorIndex(pIdx) ) continue;
20262027
r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 0, &jmp3,
20272028
pPrior, r1);
20282029
pPrior = pIdx;
@@ -2107,6 +2108,7 @@ void sqlite3Pragma(
21072108
sqlite3VdbeLoadString(v, 2, "wrong # of entries in index ");
21082109
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
21092110
if( pPk==pIdx ) continue;
2111+
if( IsVectorIndex(pIdx) ) continue;
21102112
sqlite3VdbeAddOp2(v, OP_Count, iIdxCur+j, 3);
21112113
addr = sqlite3VdbeAddOp3(v, OP_Eq, 8+j, 0, 3); VdbeCoverage(v);
21122114
sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);

libsql-sqlite3/test/libsql_vector_index.test

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ do_execsql_test vector-pragmas {
3737
PRAGMA integrity_check;
3838
PRAGMA index_list='t_pragmas';
3939
} {
40-
{row 1 missing from index t_pragmas_idx}
41-
{wrong # of entries in index t_pragmas_idx}
40+
{ok}
4241
0 t_pragmas_idx 0 c 0
4342
}
4443

0 commit comments

Comments
 (0)