Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix DELETE and UPDATE operations on fts5 tables. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | fts5 |
Files: | files | file ages | folders |
SHA1: |
d44d3a8518ff7a1a3e2c0ab97493aa59 |
User & Date: | dan 2014-07-21 15:45:26.584 |
Context
2014-07-23
| ||
19:31 | Add a snippet() function to fts5. (check-in: bdc58fd28a user: dan tags: fts5) | |
2014-07-21
| ||
15:45 | Fix DELETE and UPDATE operations on fts5 tables. (check-in: d44d3a8518 user: dan tags: fts5) | |
14:22 | Add the xTokenize extension API. (check-in: 8c6b0aff34 user: dan tags: fts5) | |
Changes
Changes to ext/fts5/fts5.c.
︙ | ︙ | |||
547 548 549 550 551 552 553 | Fts5Config *pConfig = pTab->pConfig; int eType0; /* value_type() of apVal[0] */ int eConflict; /* ON CONFLICT for this DML */ int rc = SQLITE_OK; /* Return code */ assert( nArg==1 || nArg==(2 + pConfig->nCol + 1) ); | | | 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 | Fts5Config *pConfig = pTab->pConfig; int eType0; /* value_type() of apVal[0] */ int eConflict; /* ON CONFLICT for this DML */ int rc = SQLITE_OK; /* Return code */ assert( nArg==1 || nArg==(2 + pConfig->nCol + 1) ); if( nArg>1 && SQLITE_NULL!=sqlite3_value_type(apVal[2 + pConfig->nCol]) ){ return fts5SpecialCommand(pTab, apVal[2 + pConfig->nCol]); } eType0 = sqlite3_value_type(apVal[0]); eConflict = sqlite3_vtab_on_conflict(pConfig->db); assert( eType0==SQLITE_INTEGER || eType0==SQLITE_NULL ); |
︙ | ︙ |
Changes to ext/fts5/fts5_storage.c.
︙ | ︙ | |||
227 228 229 230 231 232 233 | if( rc==SQLITE_OK ) sqlite3Fts5DropTable(p->pConfig, "docsize"); } sqlite3_free(p); return rc; } | < < < < < < < < | 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | if( rc==SQLITE_OK ) sqlite3Fts5DropTable(p->pConfig, "docsize"); } sqlite3_free(p); return rc; } typedef struct Fts5InsertCtx Fts5InsertCtx; struct Fts5InsertCtx { Fts5Storage *pStorage; int iCol; int szCol; /* Size of column value in tokens */ }; |
︙ | ︙ | |||
297 298 299 300 301 302 303 304 305 306 307 308 309 310 | } rc2 = sqlite3_reset(pSeek); if( rc==SQLITE_OK ) rc = rc2; } return rc; } /* ** Insert a record into the %_docsize table. Specifically, do: ** ** INSERT OR REPLACE INTO %_docsize(id, sz) VALUES(iRowid, pBuf); */ static int fts5StorageInsertDocsize( | > | 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | } rc2 = sqlite3_reset(pSeek); if( rc==SQLITE_OK ) rc = rc2; } return rc; } /* ** Insert a record into the %_docsize table. Specifically, do: ** ** INSERT OR REPLACE INTO %_docsize(id, sz) VALUES(iRowid, pBuf); */ static int fts5StorageInsertDocsize( |
︙ | ︙ | |||
374 375 376 377 378 379 380 381 382 383 384 385 386 387 | rc = sqlite3Fts5IndexSetAverages(p->pIndex, buf.p, buf.n); } sqlite3_free(buf.p); return rc; } /* ** Insert a new row into the FTS table. */ int sqlite3Fts5StorageInsert( Fts5Storage *p, /* Storage module to write to */ sqlite3_value **apVal, /* Array of values passed to xUpdate() */ | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 | rc = sqlite3Fts5IndexSetAverages(p->pIndex, buf.p, buf.n); } sqlite3_free(buf.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. */ int sqlite3Fts5StorageInsert( Fts5Storage *p, /* Storage module to write to */ sqlite3_value **apVal, /* Array of values passed to xUpdate() */ |
︙ | ︙ |
Changes to test/fts5aa.test.
︙ | ︙ | |||
237 238 239 240 241 242 243 244 245 246 | set rowid [expr int(rand() * 100)] execsql { REPLACE INTO t1(rowid,x,y,z) VALUES($rowid, $x, $y, $z) } } execsql { INSERT INTO t1(t1) VALUES('integrity-check'); } } {} if {[set_test_counter errors]} break } finish_test | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | set rowid [expr int(rand() * 100)] execsql { REPLACE INTO t1(rowid,x,y,z) VALUES($rowid, $x, $y, $z) } } execsql { INSERT INTO t1(t1) VALUES('integrity-check'); } } {} if {[set_test_counter errors]} break } #------------------------------------------------------------------------- # reset_db do_execsql_test 10.0 { CREATE VIRTUAL TABLE t1 USING fts5(x,y); } set d10 { 1 {g f d b f} {h h e i a} 2 {f i g j e} {i j c f f} 3 {e e i f a} {e h f d f} 4 {h j f j i} {h a c f j} 5 {d b j c g} {f e i b e} 6 {a j a e e} {j d f d e} 7 {g i j c h} {j d h c a} 8 {j j i d d} {e e d f b} 9 {c j j d c} {h j i f g} 10 {b f h i a} {c f b b j} } foreach {rowid x y} $d10 { do_execsql_test 10.1.$rowid.1 { INSERT INTO t1 VALUES($x, $y) } do_execsql_test 10.1.$rowid.2 { INSERT INTO t1(t1) VALUES('integrity-check') } } foreach rowid {5 9 8 1 2 4 10 7 3 5 6} { do_execsql_test 10.2.$rowid.1 { DELETE FROM t1 WHERE rowid = $rowid } do_execsql_test 10.2.$rowid.2 { INSERT INTO t1(t1) VALUES('integrity-check') } } foreach {rowid x y} $d10 { do_execsql_test 10.3.$rowid.1 { INSERT INTO t1 VALUES($x, $y) } do_execsql_test 10.3.$rowid.2 { INSERT INTO t1(t1) VALUES('integrity-check') } } do_execsql_test 10.4.1 { DELETE FROM t1 } do_execsql_test 10.4.2 { INSERT INTO t1(t1) VALUES('integrity-check') } finish_test |