You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
idxType = pIndex->idxType; // vectorIndexCreate can update idxType to 4 (VECTOR INDEX)
126112
126115
#endif
126113
126116
126114
126117
/* Append the table key to the end of the index. For WITHOUT ROWID
@@ -212159,6 +212162,9 @@ int vectorIndexGetParameters(
212159
212162
int rc = SQLITE_OK;
212160
212163
212161
212164
static const char* zSelectSql = "SELECT metadata FROM " VECTOR_INDEX_GLOBAL_META_TABLE " WHERE name = ?";
212165
+
// zSelectSqlPekkaLegacy handles the case when user created DB before 04 July 2024 (https://discord.com/channels/933071162680958986/1225560924526477322/1258367912402489397)
212166
+
// when instead of table with binary parameters rigid schema was used for index settings
212167
+
// we should drop this eventually - but for now we postponed this decision
212162
212168
static const char* zSelectSqlPekkaLegacy = "SELECT vector_type, block_size, dims, distance_ops FROM libsql_vector_index WHERE name = ?";
* dump populates tables first and create indices after
212206
212212
* so we must omit them because shadow tables already filled
212207
212213
*
212208
-
* 1. if vector index must not be created: 0 returned and pIdx is unchanged
212209
-
* 2. if vector index must be created and refilled from base table: 0 returned and pIdx->idxType set to SQLITE_IDXTYPE_VECTOR
212210
-
* 3. if vector index must be created but refill must be skipped : 1 returned and pIdx->idxType set to SQLITE_IDXTYPE_VECTOR
212211
-
* 4. in case of any error :-1 returned (and pParse errMsg is populated with some error message)
212214
+
* 1. in case of any error :-1 returned (and pParse errMsg is populated with some error message)
212215
+
* 2. if vector index must not be created : 0 returned
212216
+
* 3. if vector index must be created but refill must be skipped : 1 returned
212217
+
* 4. if vector index must be created and refilled from base table: 2 returned
212212
212218
*/
212213
-
int vectorIndexCreate(Parse *pParse, Index *pIdx, const char *zDbSName, const IdList *pUsing) {
212219
+
int vectorIndexCreate(Parse *pParse, const Index *pIdx, const char *zDbSName, const IdList *pUsing) {
212220
+
static const int CREATE_FAIL = -1;
212221
+
static const int CREATE_IGNORE = 0;
212222
+
static const int CREATE_OK_SKIP_REFILL = 1;
212223
+
static const int CREATE_OK = 2;
212224
+
212214
212225
int i, rc = SQLITE_OK;
212215
212226
int dims, type;
212216
212227
int hasLibsqlVectorIdxFn = 0, hasCollation = 0;
212217
212228
const char *pzErrMsg;
212218
212229
212219
212230
if( IsVacuum(pParse->db) ){
212220
-
return SQLITE_OK;
212231
+
return CREATE_IGNORE;
212221
212232
}
212222
212233
212223
212234
assert( zDbSName != NULL );
@@ -212235,7 +212246,7 @@ int vectorIndexCreate(Parse *pParse, Index *pIdx, const char *zDbSName, const Id
212235
212246
if( pParse->eParseMode ){
212236
212247
// scheme can be re-parsed by SQLite for different reasons (for example, to check schema after
212237
212248
// ALTER COLUMN statements) - so we must skip creation in such cases
212238
-
goto ignore;
212249
+
return CREATE_IGNORE;
212239
212250
}
212240
212251
212241
212252
// backward compatibility: preserve old indices with deprecated syntax but forbid creation of new indices with this syntax
@@ -212245,15 +212256,15 @@ int vectorIndexCreate(Parse *pParse, Index *pIdx, const char *zDbSName, const Id
212245
212256
} else {
212246
212257
sqlite3ErrorMsg(pParse, "USING syntax is deprecated, please use plain CREATE INDEX: CREATE INDEX xxx ON yyy ( " VECTOR_INDEX_MARKER_FUNCTION "(zzz) )");
212247
212258
}
212248
-
goto fail;
212259
+
return CREATE_FAIL;
212249
212260
}
212250
212261
if( db->init.busy == 1 && pUsing != NULL ){
212251
-
goto ok;
212262
+
return CREATE_OK;
212252
212263
}
212253
212264
212254
212265
// vector index must have expressions over column
212255
212266
if( pIdx->aColExpr == NULL ) {
212256
-
goto ignore;
212267
+
return CREATE_IGNORE;
212257
212268
}
212258
212269
212259
212270
pListItem = pIdx->aColExpr->a;
@@ -212268,94 +212279,86 @@ int vectorIndexCreate(Parse *pParse, Index *pIdx, const char *zDbSName, const Id
212268
212279
}
212269
212280
}
212270
212281
if( !hasLibsqlVectorIdxFn ) {
212271
-
goto ignore;
212282
+
return CREATE_IGNORE;
212272
212283
}
212273
212284
if( hasCollation ){
212274
212285
sqlite3ErrorMsg(pParse, "vector index can't have collation");
212275
-
goto fail;
212286
+
return CREATE_FAIL;
212276
212287
}
212277
212288
if( pIdx->aColExpr->nExpr != 1 ) {
212278
212289
sqlite3ErrorMsg(pParse, "vector index must contain exactly one column wrapped into the " VECTOR_INDEX_MARKER_FUNCTION " function");
212279
-
goto fail;
212290
+
return CREATE_FAIL;
212280
212291
}
212281
212292
// we are able to support this but I doubt this works for now - more polishing required to make this work
212282
212293
if( pIdx->pPartIdxWhere != NULL ) {
212283
212294
sqlite3ErrorMsg(pParse, "partial vector index is not supported");
212284
-
goto fail;
212295
+
return CREATE_FAIL;
212285
212296
}
212286
212297
212287
212298
pArgsList = pIdx->aColExpr->a[0].pExpr->x.pList;
212288
212299
pListItem = pArgsList->a;
212289
212300
212290
212301
if( pArgsList->nExpr < 1 ){
212291
212302
sqlite3ErrorMsg(pParse, VECTOR_INDEX_MARKER_FUNCTION " must contain at least one argument");
212292
-
goto fail;
212303
+
return CREATE_FAIL;
212293
212304
}
212294
212305
if( pListItem[0].pExpr->op != TK_COLUMN ) {
212295
212306
sqlite3ErrorMsg(pParse, VECTOR_INDEX_MARKER_FUNCTION " first argument must be a column token");
212296
-
goto fail;
212307
+
return CREATE_FAIL;
212297
212308
}
212298
212309
iEmbeddingColumn = pListItem[0].pExpr->iColumn;
212299
212310
if( iEmbeddingColumn < 0 ) {
212300
212311
sqlite3ErrorMsg(pParse, VECTOR_INDEX_MARKER_FUNCTION " first argument must be column with vector type");
0 commit comments