Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Tests and fixes for fts5 external content tables. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | fts5 |
Files: | files | file ages | folders |
SHA1: |
047aaf830d1e72f0fdad3832a0b617e7 |
User & Date: | dan 2015-01-05 20:41:39.791 |
Context
2015-01-06
| ||
14:38 | Further fixes and test cases related to external content tables. (check-in: ce6a899baf user: dan tags: fts5) | |
2015-01-05
| ||
20:41 | Tests and fixes for fts5 external content tables. (check-in: 047aaf830d user: dan tags: fts5) | |
2015-01-03
| ||
20:44 | Add support for external content tables to fts5. (check-in: 17ef5b59f7 user: dan tags: fts5) | |
Changes
Changes to ext/fts5/fts5.c.
︙ | |||
252 253 254 255 256 257 258 259 260 261 262 263 264 265 | 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | + + + + + + | break; } } #else # define fts5CheckTransactionState(x,y,z) #endif /* ** Return true if pTab is a contentless table. */ static int fts5IsContentless(Fts5Table *pTab){ return pTab->pConfig->eContent==FTS5_CONTENT_NONE; } /* ** Close a virtual table handle opened by fts5InitVtab(). If the bDestroy ** argument is non-zero, attempt delete the shadow tables from teh database */ static int fts5FreeVtab(Fts5Table *pTab, int bDestroy){ int rc = SQLITE_OK; |
︙ | |||
913 914 915 916 917 918 919 | 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 | - + + + | } } } }else{ /* This is either a full-table scan (ePlan==FTS5_PLAN_SCAN) or a lookup ** by rowid (ePlan==FTS5_PLAN_ROWID). */ int eStmt = fts5StmtType(idxNum); |
︙ | |||
991 992 993 994 995 996 997 | 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 | - + + + | static int fts5SeekCursor(Fts5Cursor *pCsr){ int rc = SQLITE_OK; /* If the cursor does not yet have a statement handle, obtain one now. */ if( pCsr->pStmt==0 ){ Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab); int eStmt = fts5StmtType(pCsr->idxNum); |
︙ | |||
1096 1097 1098 1099 1100 1101 1102 | 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 | - - - - - - - - - - - - + + + + + + + - - - + + + + + + + + + + + + + + + + + | ** 1. The "old" rowid, or NULL. ** 2. The "new" rowid. ** 3. Values for each of the nCol matchable columns. ** 4. Values for the two hidden columns (<tablename> and "rank"). */ assert( nArg==1 || nArg==(2 + pConfig->nCol + 2) ); |
︙ | |||
1324 1325 1326 1327 1328 1329 1330 1331 | 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 | + + + + + - - - - + + + + + | static int fts5ApiColumnText( Fts5Context *pCtx, int iCol, const char **pz, int *pn ){ int rc = SQLITE_OK; Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; if( fts5IsContentless((Fts5Table*)(pCsr->base.pVtab)) ){ *pz = 0; *pn = 0; }else{ |
︙ | |||
1562 1563 1564 1565 1566 1567 1568 | 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 | + - + | ** the row that the supplied cursor currently points to. */ static int fts5ColumnMethod( sqlite3_vtab_cursor *pCursor, /* Cursor to retrieve value from */ sqlite3_context *pCtx, /* Context for sqlite3_result_xxx() calls */ int iCol /* Index of column to read value from */ ){ Fts5Table *pTab = (Fts5Table*)(pCursor->pVtab); |
︙ | |||
1593 1594 1595 1596 1597 1598 1599 | 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 | - + | FTS5_PLAN(pCsr->idxNum)==FTS5_PLAN_MATCH || FTS5_PLAN(pCsr->idxNum)==FTS5_PLAN_SORTED_MATCH ){ if( pCsr->pRank || SQLITE_OK==(rc = fts5FindRankFunction(pCsr)) ){ fts5ApiInvoke(pCsr->pRank, pCsr, pCtx, pCsr->nRankArg, pCsr->apRankArg); } } |
︙ |
Changes to ext/fts5/fts5Int.h.
︙ | |||
72 73 74 75 76 77 78 | 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | - - - + + + + + + + + + | sqlite3 *db; /* Database handle */ char *zDb; /* Database holding FTS index (e.g. "main") */ char *zName; /* Name of FTS index */ int nCol; /* Number of columns */ char **azCol; /* Column names */ int nPrefix; /* Number of prefix indexes */ int *aPrefix; /* Sizes in bytes of nPrefix prefix indexes */ |
︙ | |||
397 398 399 400 401 402 403 | 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 | - + | int sqlite3Fts5CreateTable(Fts5Config*, const char*, const char*, int, char **); int sqlite3Fts5StorageDelete(Fts5Storage *p, i64); int sqlite3Fts5StorageInsert(Fts5Storage *p, sqlite3_value **apVal, int, i64*); int sqlite3Fts5StorageIntegrity(Fts5Storage *p); |
︙ |
Changes to ext/fts5/fts5_aux.c.
︙ | |||
218 219 220 221 222 223 224 | 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | + - - - + + + - - - - + + + + - - - - - - + + + + + + + | iCol = sqlite3_value_int(apVal[0]); memset(&ctx, 0, sizeof(HighlightContext)); ctx.zOpen = (const char*)sqlite3_value_text(apVal[1]); ctx.zClose = (const char*)sqlite3_value_text(apVal[2]); rc = pApi->xColumnText(pFts, iCol, &ctx.zIn, &ctx.nIn); if( ctx.zIn ){ |
︙ | |||
271 272 273 274 275 276 277 | 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | - | const char *zErr = "wrong number of arguments to function snippet()"; sqlite3_result_error(pCtx, zErr, -1); return; } memset(&ctx, 0, sizeof(HighlightContext)); iCol = sqlite3_value_int(apVal[0]); |
︙ | |||
324 325 326 327 328 329 330 | 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | + - - - + + + - - - - - - - + + + + + + + - - + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - + + + + + + + | if( rc==SQLITE_OK ){ rc = pApi->xColumnSize(pFts, iBestCol, &nColSize); } if( rc==SQLITE_OK ){ rc = pApi->xColumnText(pFts, iBestCol, &ctx.zIn, &ctx.nIn); } if( ctx.zIn ){ |
︙ |
Changes to ext/fts5/fts5_config.c.
︙ | |||
330 331 332 333 334 335 336 | 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | - + + + - - + + + + + + + | sqlite3_free(azArg); sqlite3_free(pDel); return rc; } if( sqlite3_strnicmp("content", zCmd, nCmd)==0 ){ int rc = SQLITE_OK; |
︙ | |||
469 470 471 472 473 474 475 | 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 | - + | ** already been allocated. Otherwise, allocate an instance of the default ** tokenizer (simple) now. */ if( rc==SQLITE_OK && pRet->pTok==0 ){ rc = fts5ConfigDefaultTokenizer(pGlobal, pRet); } /* If no zContent option was specified, fill in the default values. */ |
︙ |
Changes to ext/fts5/fts5_storage.c.
︙ | |||
50 51 52 53 54 55 56 | 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | - + + | ** Fts5Storage.pInsertDocsize - if they have not already been prepared. ** Return SQLITE_OK if successful, or an SQLite error code if an error ** occurs. */ static int fts5StorageGetStmt( Fts5Storage *p, /* Storage handle */ int eStmt, /* FTS5_STMT_XXX constant */ |
︙ | |||
113 114 115 116 117 118 119 120 121 122 123 124 125 126 | 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | + + + | } if( zSql==0 ){ rc = SQLITE_NOMEM; }else{ rc = sqlite3_prepare_v2(pC->db, zSql, -1, &p->aStmt[eStmt], 0); sqlite3_free(zSql); if( rc!=SQLITE_OK && pzErrMsg ){ *pzErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(pC->db)); } } } *ppStmt = p->aStmt[eStmt]; return rc; } |
︙ | |||
201 202 203 204 205 206 207 | 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | - + | memset(p, 0, nByte); p->aTotalSize = (i64*)&p[1]; p->pConfig = pConfig; p->pIndex = pIndex; if( bCreate ){ |
︙ | |||
250 251 252 253 254 255 256 | 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | + - + + | /* Finalize all SQL statements */ for(i=0; i<ArraySize(p->aStmt); i++){ sqlite3_finalize(p->aStmt[i]); } /* If required, remove the shadow tables from the database */ if( bDestroy ){ if( p->pConfig->eContent==FTS5_CONTENT_NORMAL ){ |
︙ | |||
294 295 296 297 298 299 300 | 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | - + | ** remove the %_content row at this time though. */ static int fts5StorageDeleteFromIndex(Fts5Storage *p, i64 iDel){ Fts5Config *pConfig = p->pConfig; sqlite3_stmt *pSeek; /* SELECT to read row iDel from %_data */ int rc; /* Return code */ |
︙ | |||
334 335 336 337 338 339 340 | 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 | - + | */ static int fts5StorageInsertDocsize( Fts5Storage *p, /* Storage module to write to */ i64 iRowid, /* id value */ Fts5Buffer *pBuf /* sz value */ ){ sqlite3_stmt *pReplace = 0; |
︙ | |||
420 421 422 423 424 425 426 | 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 | - + - + | /* Delete the index records */ if( rc==SQLITE_OK ){ rc = fts5StorageDeleteFromIndex(p, iDel); } /* Delete the %_docsize record */ if( rc==SQLITE_OK ){ |
︙ | |||
455 456 457 458 459 460 461 | 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | - + - + - + | i64 iDel, sqlite3_value **apVal ){ Fts5Config *pConfig = p->pConfig; int rc; sqlite3_stmt *pDel; |
︙ | |||
505 506 507 508 509 510 511 | 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | - + | ** Allocate a new rowid. This is used for "external content" tables when ** a NULL value is inserted into the rowid column. The new rowid is allocated ** by inserting a dummy row into the %_docsize table. The dummy will be ** overwritten later. */ static int fts5StorageNewRowid(Fts5Storage *p, i64 *piRowid){ sqlite3_stmt *pReplace = 0; |
︙ | |||
539 540 541 542 543 544 545 | 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 | - - + + - + | Fts5InsertCtx ctx; /* Tokenization callback context object */ Fts5Buffer buf; /* Buffer used to build up %_docsize blob */ memset(&buf, 0, sizeof(Fts5Buffer)); rc = fts5StorageLoadTotals(p, 1); /* Insert the new row into the %_content table. */ |
︙ | |||
678 679 680 681 682 683 684 | 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 | - + | aTotalSize = (i64*)sqlite3_malloc(pConfig->nCol * (sizeof(int)+sizeof(i64))); if( !aTotalSize ) return SQLITE_NOMEM; aColSize = (int*)&aTotalSize[pConfig->nCol]; memset(aTotalSize, 0, sizeof(i64) * pConfig->nCol); /* Generate the expected index checksum based on the contents of the ** %_content table. This block stores the checksum in ctx.cksum. */ |
︙ | |||
741 742 743 744 745 746 747 | 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 | - + + + + + + - + | return rc; } /* ** Obtain an SQLite statement handle that may be used to read data from the ** %_content table. */ |
︙ | |||
801 802 803 804 805 806 807 | 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 | - + | ** ** An SQLite error code is returned if an error occurs, or SQLITE_OK ** otherwise. */ int sqlite3Fts5StorageDocsize(Fts5Storage *p, i64 iRowid, int *aCol){ int nCol = p->pConfig->nCol; sqlite3_stmt *pLookup = 0; |
︙ | |||
869 870 871 872 873 874 875 | 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 | - + | int sqlite3Fts5StorageConfigValue( Fts5Storage *p, const char *z, sqlite3_value *pVal ){ sqlite3_stmt *pReplace = 0; |
︙ |
Added ext/fts5/test/fts5content.test.