6969** src/test2.c
7070** src/test3.c
7171** src/test8.c
72+ ** src/vacuum.c
7273** src/vdbe.c
7374** src/vdbeInt.h
7475** src/vdbeapi.c
@@ -155950,6 +155951,10 @@ SQLITE_PRIVATE void sqlite3UpsertDoUpdate(
155950155951/* #include "sqliteInt.h" */
155951155952/* #include "vdbeInt.h" */
155952155953
155954+ #ifndef SQLITE_OMIT_VECTOR
155955+ /* #include "vectorIndexInt.h" */
155956+ #endif
155957+
155953155958#if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH)
155954155959
155955155960/*
@@ -156227,6 +156232,27 @@ SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3RunVacuum(
156227156232 if( rc!=SQLITE_OK ) goto end_of_vacuum;
156228156233 db->init.iDb = 0;
156229156234
156235+ #ifndef SQLITE_OMIT_VECTOR
156236+ // shadow tables for vector index will be populated automatically during CREATE INDEX command
156237+ // so we must skip them at this step
156238+ if( sqlite3FindTable(db, VECTOR_INDEX_GLOBAL_META_TABLE, zDbMain) != NULL ){
156239+ rc = execSqlF(db, pzErrMsg,
156240+ "SELECT'INSERT INTO vacuum_db.'||quote(name)"
156241+ "||' SELECT*FROM\"%w\".'||quote(name)"
156242+ "FROM vacuum_db.sqlite_schema "
156243+ "WHERE type='table'AND coalesce(rootpage,1)>0 AND name NOT IN (SELECT name||'_shadow' FROM " VECTOR_INDEX_GLOBAL_META_TABLE ")",
156244+ zDbMain
156245+ );
156246+ }else{
156247+ rc = execSqlF(db, pzErrMsg,
156248+ "SELECT'INSERT INTO vacuum_db.'||quote(name)"
156249+ "||' SELECT*FROM\"%w\".'||quote(name)"
156250+ "FROM vacuum_db.sqlite_schema "
156251+ "WHERE type='table'AND coalesce(rootpage,1)>0 AND name",
156252+ zDbMain
156253+ );
156254+ }
156255+ #else
156230156256 /* Loop through the tables in the main database. For each, do
156231156257 ** an "INSERT INTO vacuum_db.xxx SELECT * FROM main.xxx;" to copy
156232156258 ** the contents to the temporary database.
@@ -156238,6 +156264,7 @@ SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3RunVacuum(
156238156264 "WHERE type='table'AND coalesce(rootpage,1)>0",
156239156265 zDbMain
156240156266 );
156267+ #endif
156241156268 assert( (db->mDbFlags & DBFLAG_Vacuum)!=0 );
156242156269 db->mDbFlags &= ~DBFLAG_Vacuum;
156243156270 if( rc!=SQLITE_OK ) goto end_of_vacuum;
@@ -213656,11 +213683,6 @@ int vectorF64ParseSqliteBlob(
213656213683** VectorIdxParams utilities
213657213684****************************************************************************/
213658213685
213659- // VACUUM creates tables and indices first and only then populate data
213660- // we need to ignore inserts from 'INSERT INTO vacuum.t SELECT * FROM t' statements because
213661- // all shadow tables will be populated by VACUUM process during regular process of table copy
213662- #define IsVacuum(db) ((db->mDbFlags&DBFLAG_Vacuum)!=0)
213663-
213664213686void vectorIdxParamsInit(VectorIdxParams *pParams, u8 *pBinBuf, int nBinSize) {
213665213687 assert( nBinSize <= VECTOR_INDEX_PARAMS_BUF_SIZE );
213666213688
@@ -214379,10 +214401,6 @@ int vectorIndexDrop(sqlite3 *db, const char *zDbSName, const char *zIdxName) {
214379214401 // this is done to prevent unrecoverable situations where index were dropped but index parameters deletion failed and second attempt will fail on first step
214380214402 int rcIdx, rcParams;
214381214403
214382- if( IsVacuum(db) ){
214383- return SQLITE_OK;
214384- }
214385-
214386214404 assert( zDbSName != NULL );
214387214405
214388214406 rcIdx = diskAnnDropIndex(db, zDbSName, zIdxName);
@@ -214393,10 +214411,6 @@ int vectorIndexDrop(sqlite3 *db, const char *zDbSName, const char *zIdxName) {
214393214411int vectorIndexClear(sqlite3 *db, const char *zDbSName, const char *zIdxName) {
214394214412 assert( zDbSName != NULL );
214395214413
214396- if( IsVacuum(db) ){
214397- return SQLITE_OK;
214398- }
214399-
214400214414 return diskAnnClearIndex(db, zDbSName, zIdxName);
214401214415}
214402214416
@@ -214406,7 +214420,7 @@ int vectorIndexClear(sqlite3 *db, const char *zDbSName, const char *zIdxName) {
214406214420 * this made intentionally in order to natively support upload of SQLite dumps
214407214421 *
214408214422 * dump populates tables first and create indices after
214409- * so we must omit them because shadow tables already filled
214423+ * so we must omit index refill setp because shadow tables already filled
214410214424 *
214411214425 * 1. in case of any error :-1 returned (and pParse errMsg is populated with some error message)
214412214426 * 2. if vector index must not be created : 0 returned
@@ -214424,10 +214438,6 @@ int vectorIndexCreate(Parse *pParse, const Index *pIdx, const char *zDbSName, co
214424214438 int hasLibsqlVectorIdxFn = 0, hasCollation = 0;
214425214439 const char *pzErrMsg;
214426214440
214427- if( IsVacuum(pParse->db) ){
214428- return CREATE_IGNORE;
214429- }
214430-
214431214441 assert( zDbSName != NULL );
214432214442
214433214443 sqlite3 *db = pParse->db;
@@ -214577,7 +214587,6 @@ int vectorIndexSearch(
214577214587 VectorIdxParams idxParams;
214578214588 vectorIdxParamsInit(&idxParams, NULL, 0);
214579214589
214580- assert( !IsVacuum(db) );
214581214590 assert( zDbSName != NULL );
214582214591
214583214592 if( argc != 3 ){
@@ -214662,10 +214671,6 @@ int vectorIndexInsert(
214662214671 int rc;
214663214672 VectorInRow vectorInRow;
214664214673
214665- if( IsVacuum(pCur->db) ){
214666- return SQLITE_OK;
214667- }
214668-
214669214674 rc = vectorInRowAlloc(pCur->db, pRecord, &vectorInRow, pzErrMsg);
214670214675 if( rc != SQLITE_OK ){
214671214676 return rc;
@@ -214685,10 +214690,6 @@ int vectorIndexDelete(
214685214690){
214686214691 VectorInRow payload;
214687214692
214688- if( IsVacuum(pCur->db) ){
214689- return SQLITE_OK;
214690- }
214691-
214692214693 payload.pVector = NULL;
214693214694 payload.nKeys = r->nField - 1;
214694214695 payload.pKeyValues = r->aMem + 1;
0 commit comments