1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-01 06:27:03 +03:00

Fix DELETE and UPDATE operations on fts5 tables.

FossilOrigin-Name: d44d3a8518ff7a1a3e2c0ab97493aa590676ee8c
This commit is contained in:
dan
2014-07-21 15:45:26 +00:00
parent 5c1b820460
commit a5983da6e1
5 changed files with 86 additions and 18 deletions

View File

@ -551,7 +551,7 @@ static int fts5UpdateMethod(
assert( nArg==1 || nArg==(2 + pConfig->nCol + 1) );
if( SQLITE_NULL!=sqlite3_value_type(apVal[2 + pConfig->nCol]) ){
if( nArg>1 && SQLITE_NULL!=sqlite3_value_type(apVal[2 + pConfig->nCol]) ){
return fts5SpecialCommand(pTab, apVal[2 + pConfig->nCol]);
}

View File

@ -231,14 +231,6 @@ int sqlite3Fts5StorageClose(Fts5Storage *p, int bDestroy){
return rc;
}
/*
** Remove a row from the FTS table.
*/
int sqlite3Fts5StorageDelete(Fts5Storage *p, i64 iDel){
assert( !"do this" );
return SQLITE_OK;
}
typedef struct Fts5InsertCtx Fts5InsertCtx;
struct Fts5InsertCtx {
Fts5Storage *pStorage;
@ -302,6 +294,7 @@ static int fts5StorageDeleteFromIndex(Fts5Storage *p, i64 iDel){
return rc;
}
/*
** Insert a record into the %_docsize table. Specifically, do:
**
@ -378,6 +371,47 @@ static int fts5StorageSaveTotals(Fts5Storage *p){
return rc;
}
/*
** Remove a row from the FTS table.
*/
int sqlite3Fts5StorageDelete(Fts5Storage *p, i64 iDel){
int rc;
sqlite3_stmt *pDel;
rc = fts5StorageLoadTotals(p);
/* Delete the index records */
if( rc==SQLITE_OK ){
rc = fts5StorageDeleteFromIndex(p, iDel);
}
/* Delete the %_docsize record */
if( rc==SQLITE_OK ){
rc = fts5StorageGetStmt(p, FTS5_STMT_DELETE_DOCSIZE, &pDel);
}
if( rc==SQLITE_OK ){
sqlite3_bind_int64(pDel, 1, iDel);
sqlite3_step(pDel);
rc = sqlite3_reset(pDel);
}
/* Delete the %_content record */
if( rc==SQLITE_OK ){
rc = fts5StorageGetStmt(p, FTS5_STMT_DELETE_CONTENT, &pDel);
}
if( rc==SQLITE_OK ){
sqlite3_bind_int64(pDel, 1, iDel);
sqlite3_step(pDel);
rc = sqlite3_reset(pDel);
}
/* Write the averages record */
if( rc==SQLITE_OK ){
rc = fts5StorageSaveTotals(p);
}
return rc;
}
/*
** Insert a new row into the FTS table.