Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Have fts5 store rowids in ascending order. Query speed is virtually the same regardless of rowid order, and ascending order makes some insert optimizations easier. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | fts5 |
Files: | files | file ages | folders |
SHA1: |
5206ca6005bfa9dfc7346d4b89430c97 |
User & Date: | dan 2015-01-24 19:57:03.097 |
Context
2015-01-27
| ||
20:41 | Fix a problem with fts5 doclist-indexes that occured if the first rowid of the first non-term page of a doclist is zero. (check-in: f704bc059e user: dan tags: fts5) | |
2015-01-24
| ||
19:57 | Have fts5 store rowids in ascending order. Query speed is virtually the same regardless of rowid order, and ascending order makes some insert optimizations easier. (check-in: 5206ca6005 user: dan tags: fts5) | |
2015-01-23
| ||
17:43 | Fix compression of keys stored on internal segment b-tree nodes by fts5. (check-in: 51444f67c0 user: dan tags: fts5) | |
Changes
Changes to ext/fts5/fts5.c.
︙ | |||
501 502 503 504 505 506 507 | 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 | - + | } *ppCsr = (sqlite3_vtab_cursor*)pCsr; return rc; } static int fts5StmtType(int idxNum){ if( FTS5_PLAN(idxNum)==FTS5_PLAN_SCAN ){ |
︙ | |||
648 649 650 651 652 653 654 | 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 | - + | } break; } return rc; } |
︙ | |||
676 677 678 679 680 681 682 | 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 | - + | ** table, saving it creates a circular reference. ** ** If SQLite a built-in statement cache, this wouldn't be a problem. */ zSql = sqlite3_mprintf("SELECT rowid, rank FROM %Q.%Q ORDER BY %s(%s%s%s) %s", pConfig->zDb, pConfig->zName, zRank, pConfig->zName, (zRankArgs ? ", " : ""), (zRankArgs ? zRankArgs : ""), |
︙ | |||
702 703 704 705 706 707 708 | 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 | - + - + | sqlite3_free(pSorter); pCsr->pSorter = 0; } return rc; } |
︙ | |||
869 870 871 872 873 874 875 | 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 | - + - + - + - + | int idxNum, /* Strategy index */ const char *idxStr, /* Unused */ int nVal, /* Number of elements in apVal */ sqlite3_value **apVal /* Arguments for the indexing scheme */ ){ Fts5Table *pTab = (Fts5Table*)(pCursor->pVtab); Fts5Cursor *pCsr = (Fts5Cursor*)pCursor; |
︙ |
Changes to ext/fts5/fts5Int.h.
︙ | |||
225 226 227 228 229 230 231 | 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | - + | typedef struct Fts5Index Fts5Index; typedef struct Fts5IndexIter Fts5IndexIter; /* ** Values used as part of the flags argument passed to IndexQuery(). */ #define FTS5INDEX_QUERY_PREFIX 0x0001 /* Prefix query */ |
︙ | |||
361 362 363 364 365 366 367 368 369 370 371 372 373 374 | 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 | + + + + + + + | **************************************************************************/ /************************************************************************** ** Interface to code in fts5_hash.c. */ typedef struct Fts5Hash Fts5Hash; typedef struct Fts5Data Fts5Data; struct Fts5Data { u8 *p; /* Pointer to buffer containing record */ int n; /* Size of record in bytes */ int nRef; /* Ref count */ }; /* ** Create a hash table, free a hash table. */ int sqlite3Fts5HashNew(Fts5Hash**, int *pnSize); void sqlite3Fts5HashFree(Fts5Hash*); int sqlite3Fts5HashWrite( |
︙ | |||
391 392 393 394 395 396 397 398 399 400 401 402 403 404 | 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | + + + + + | Fts5Hash*, void *pCtx, int (*xTerm)(void*, const char*, int), int (*xEntry)(void*, i64, const u8*, int), int (*xTermDone)(void*) ); int sqlite3Fts5HashQuery( Fts5Hash*, /* Hash table to query */ const char *pTerm, int nTerm, /* Query term */ Fts5Data **ppData /* OUT: Query result */ ); /* ** End of interface to code in fts5_hash.c. **************************************************************************/ /************************************************************************** |
︙ | |||
466 467 468 469 470 471 472 | 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | - + - + | Fts5Config *pConfig, const char *zExpr, Fts5Expr **ppNew, char **pzErr ); /* |
︙ |
Changes to ext/fts5/fts5_expr.c.
︙ | |||
28 29 30 31 32 33 34 | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | - + | void *sqlite3Fts5ParserAlloc(void *(*mallocProc)(size_t)); void sqlite3Fts5ParserFree(void*, void (*freeProc)(void*)); void sqlite3Fts5Parser(void*, int, Fts5Token, Fts5Parse*); struct Fts5Expr { Fts5Index *pIndex; Fts5ExprNode *pRoot; |
︙ | |||
596 597 598 599 600 601 602 | 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 | - - - + + + - + - + - + | } } return SQLITE_OK; } /* |
︙ | |||
652 653 654 655 656 657 658 | 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 | - - - - + + + + - + + - + | ){ Fts5ExprNearset *pNear = pNode->pNear; int rc = SQLITE_OK; int i, j; /* Phrase and token index, respectively */ i64 iLast; /* Lastest rowid any iterator points to */ int bMatch; /* True if all terms are at the same rowid */ |
︙ | |||
770 771 772 773 774 775 776 | 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 | - + | for(i=0; rc==SQLITE_OK && i<pNear->nPhrase; i++){ pPhrase = pNear->apPhrase[i]; for(j=0; j<pPhrase->nTerm; j++){ pTerm = &pPhrase->aTerm[j]; rc = sqlite3Fts5IndexQuery( pExpr->pIndex, pTerm->zTerm, strlen(pTerm->zTerm), (pTerm->bPrefix ? FTS5INDEX_QUERY_PREFIX : 0) | |
︙ | |||
806 807 808 809 810 811 812 | 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 | - + | static int fts5NodeCompare( Fts5Expr *pExpr, Fts5ExprNode *p1, Fts5ExprNode *p2 ){ if( p2->bEof ) return -1; if( p1->bEof ) return +1; |
︙ | |||
907 908 909 910 911 912 913 | 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 | - - - + + - + - + | break; } case FTS5_AND: { Fts5ExprNode *p1 = pNode->pLeft; Fts5ExprNode *p2 = pNode->pRight; |
︙ | |||
999 1000 1001 1002 1003 1004 1005 | 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 | - - - + + + - + - + | return rc; } /* ** Begin iterating through the set of documents in index pIdx matched by |
︙ |
Changes to ext/fts5/fts5_hash.c.
︙ | |||
51 52 53 54 55 56 57 | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | - + + + + + + + + + + + | ** nData: ** Bytes of data written since iRowidOff. */ struct Fts5HashEntry { Fts5HashEntry *pNext; /* Next hash entry with same hash-key */ int nAlloc; /* Total size of allocation */ |
︙ | |||
157 158 159 160 161 162 163 | 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | - - - - - - - - - - - - - - - - - - - - + | sqlite3_free(apOld); pHash->nSlot = nNew; pHash->aSlot = apNew; return SQLITE_OK; } |
︙ | |||
210 211 212 213 214 215 216 | 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 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 249 250 251 252 253 254 255 256 | - + + + - - + - + + + - - - + + + | p = (Fts5HashEntry*)sqlite3_malloc(nByte); if( !p ) return SQLITE_NOMEM; memset(p, 0, sizeof(Fts5HashEntry)); p->nAlloc = nByte; memcpy(p->zKey, pToken, nToken); p->zKey[nToken] = '\0'; |
︙ | |||
375 376 377 378 379 380 381 | 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 | - - - - - - + + + + + + + + + + + + - - - - - + + + + + + + - - + - - - - - - + + + + - - - - | int rc; rc = fts5HashEntrySort(pHash, &pList); if( rc==SQLITE_OK ){ while( pList ){ Fts5HashEntry *pNext = pList->pNext; if( rc==SQLITE_OK ){ |
Changes to ext/fts5/fts5_index.c.
︙ | |||
40 41 42 43 44 45 46 | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | - + | ** incremental merge operations. ** */ #define FTS5_OPT_WORK_UNIT 1000 /* Number of leaf pages per optimize step */ #define FTS5_WORK_UNIT 64 /* Number of leaf pages in unit of work */ |
︙ | |||
266 267 268 269 270 271 272 | 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | - | ** without overreading if the records are corrupt. */ #define FTS5_DATA_ZERO_PADDING 8 typedef struct Fts5BtreeIter Fts5BtreeIter; typedef struct Fts5BtreeIterLevel Fts5BtreeIterLevel; typedef struct Fts5ChunkIter Fts5ChunkIter; |
︙ | |||
307 308 309 310 311 312 313 | 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | - + | sqlite3_blob *pReader; /* RO incr-blob open on %_data table */ sqlite3_stmt *pWriter; /* "INSERT ... %_data VALUES(?,?)" */ sqlite3_stmt *pDeleter; /* "DELETE FROM %_data ... id>=? AND id<=?" */ int nRead; /* Total number of blocks read */ }; struct Fts5DoclistIter { |
︙ | |||
329 330 331 332 333 334 335 | 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | - - - - - - - - - | Fts5Index *pIndex; Fts5Structure *pStruct; Fts5MultiSegIter *pMulti; Fts5DoclistIter *pDoclist; Fts5Buffer poslist; /* Buffer containing current poslist */ }; |
︙ | |||
1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 | 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 | + + + + + | */ static void fts5DlidxIterFree(Fts5DlidxIter *pIter){ if( pIter ){ fts5DataRelease(pIter->pData); sqlite3_free(pIter); } } static void fts5LeafHeader(Fts5Data *pLeaf, int *piRowid, int *piTerm){ *piRowid = (int)fts5GetU16(&pLeaf->p[0]); *piTerm = (int)fts5GetU16(&pLeaf->p[2]); } /* ** Load the next leaf page into the segment iterator. */ static void fts5SegIterNextPage( Fts5Index *p, /* FTS5 backend object */ Fts5SegIter *pIter /* Iterator to advance to next page */ |
︙ | |||
1499 1500 1501 1502 1503 1504 1505 | 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 | + + + - - + + + + + + | ); }else{ pIter->pLeaf = 0; } } /* ** Fts5SegIter.iLeafOffset currently points to the first byte of the ** "nSuffix" field of a term. Function parameter nKeep contains the value ** of the "nPrefix" field (if there was one - it is passed 0 if this is |
︙ | |||
1565 1566 1567 1568 1569 1570 1571 | 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 | - - - - - | if( p->rc==SQLITE_OK ){ u8 *a = pIter->pLeaf->p; pIter->iLeafOffset = fts5GetU16(&a[2]); fts5SegIterLoadTerm(p, pIter, 0); } } |
︙ | |||
1594 1595 1596 1597 1598 1599 1600 | 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 | - + | int nPos; i += fts5GetVarint32(&a[i], nPos); i += nPos; if( i>=n ) break; i += getVarint(&a[i], (u64*)&iDelta); if( iDelta==0 ) break; |
︙ | |||
1674 1675 1676 1677 1678 1679 1680 | 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 | - + | int bRet = 0; Fts5Data *pLeaf = pIter->pLeaf; if( p->rc==SQLITE_OK && pLeaf ){ if( pIter->iLeafOffset<pLeaf->n ){ bRet = (pLeaf->p[pIter->iLeafOffset]==0x00); }else{ Fts5Data *pNew = fts5DataRead(p, FTS5_SEGMENT_ROWID( |
︙ | |||
1709 1710 1711 1712 1713 1714 1715 | 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 | - + | i64 iDelta; pIter->iRowidOffset--; pIter->iLeafOffset = iOff = pIter->aRowidOffset[pIter->iRowidOffset]; iOff += fts5GetVarint32(&a[iOff], nPos); iOff += nPos; getVarint(&a[iOff], (u64*)&iDelta); |
︙ | |||
1744 1745 1746 1747 1748 1749 1750 | 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 | - + | if( iOff>=n ){ fts5SegIterNextPage(p, pIter); pIter->iLeafOffset = 4; }else if( iOff!=fts5GetU16(&a[2]) ){ pIter->iLeafOffset += fts5GetVarint32(&a[iOff], nKeep); } }else{ |
︙ | |||
1918 1919 1920 1921 1922 1923 1924 | 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 | - + | Fts5SegIter *pIter /* Object to populate */ ){ int iPg = 1; int h; int bGe = ((flags & FTS5INDEX_QUERY_PREFIX) && iIdx==0); int bDlidx = 0; /* True if there is a doclist-index */ |
︙ | |||
1976 1977 1978 1979 1980 1981 1982 | 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 | - + - + | pIter->pLeaf = 0; } } if( p->rc==SQLITE_OK && bGe==0 ){ pIter->flags |= FTS5_SEGITER_ONETERM; if( pIter->pLeaf ){ |
︙ | |||
2038 2039 2040 2041 2042 2043 2044 | 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 | - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | iRes = i1; }else{ int res = fts5BufferCompare(&p1->term, &p2->term); if( res==0 ){ assert( i2>i1 ); assert( i2!=0 ); if( p1->iRowid==p2->iRowid ) return i2; |
︙ | |||
2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 | 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | if( pIter->pLeaf==0 ) break; if( bRev==0 && pIter->iRowid<=iMatch ) break; if( bRev!=0 && pIter->iRowid>=iMatch ) break; bMove = 1; } } /* ** Free the iterator object passed as the second argument. */ static void fts5MultiIterFree(Fts5Index *p, Fts5MultiSegIter *pIter){ if( pIter ){ int i; for(i=0; i<pIter->nSeg; i++){ fts5SegIterClear(&pIter->aSeg[i]); } sqlite3_free(pIter); } } static void fts5MultiIterAdvanced( Fts5Index *p, /* FTS5 backend to iterate within */ Fts5MultiSegIter *pIter, /* Iterator to update aFirst[] array for */ int iChanged, /* Index of sub-iterator just advanced */ int iMinset /* Minimum entry in aFirst[] to set */ ){ int i; for(i=(pIter->nSeg+iChanged)/2; i>=iMinset && p->rc==SQLITE_OK; i=i/2){ int iEq; if( (iEq = fts5MultiIterDoCompare(pIter, i)) ){ fts5SegIterNext(p, &pIter->aSeg[iEq]); i = pIter->nSeg + iEq; } } } /* ** Move the iterator to the next entry. ** ** If an error occurs, an error code is left in Fts5Index.rc. It is not ** considered an error if the iterator reaches EOF, or if it is already at ** EOF when this function is called. */ |
︙ | |||
2244 2245 2246 2247 2248 2249 2250 | 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 | - + | sizeof(Fts5SegIter) * nSlot + /* pNew->aSeg[] */ sizeof(u16) * nSlot /* pNew->aFirst[] */ ); if( pNew==0 ) return; pNew->nSeg = nSlot; pNew->aSeg = (Fts5SegIter*)&pNew[1]; pNew->aFirst = (u16*)&pNew->aSeg[nSlot]; |
︙ | |||
2324 2325 2326 2327 2328 2329 2330 | 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 | - - + + | i64 iMatch ){ while( 1 ){ i64 iRowid; fts5MultiIterNext(p, pIter, 1, iMatch); if( fts5MultiIterEof(p, pIter) ) break; iRowid = fts5MultiIterRowid(pIter); |
︙ | |||
2790 2791 2792 2793 2794 2795 2796 | 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 | - - + + | fts5WriteDlidxAppend(p, pWriter, iRowid); } /* Write the docid. */ if( pWriter->bFirstRowidInDoclist || pWriter->bFirstRowidInPage ){ fts5BufferAppendVarint(&p->rc, &pPage->buf, iRowid); }else{ |
︙ | |||
3707 3708 3709 3710 3711 3712 3713 | 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 | - - + + - + - + - + - + - + - + - - + + - + - + - + - + | } static void fts5DoclistIterNext(Fts5DoclistIter *pIter){ if( pIter->i<pIter->n ){ if( pIter->i ){ i64 iDelta; pIter->i += getVarint(&pIter->a[pIter->i], (u64*)&iDelta); |
︙ | |||
3843 3844 3845 3846 3847 3848 3849 | 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 | - + | Fts5Buffer tmp = *p1; *p1 = *p2; *p2 = tmp; } static void fts5SetupPrefixIter( Fts5Index *p, /* Index to read from */ |
︙ | |||
3874 3875 3876 3877 3878 3879 3880 | 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 | - + - + - + - + - + | i64 iRowid = fts5MultiIterRowid(p1); int nTerm; const u8 *pTerm = fts5MultiIterTerm(p1, &nTerm); assert( memcmp(pToken, pTerm, MIN(nToken, nTerm))<=0 ); if( nTerm<nToken || memcmp(pToken, pTerm, nToken) ) break; if( doclist.n>0 |
︙ | |||
4269 4270 4271 4272 4273 4274 4275 | 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 | - - + + | pRet->pStruct = fts5StructureRead(p, iIdx); if( pRet->pStruct ){ fts5MultiIterNew(p, pRet->pStruct, iIdx, 1, flags, (const u8*)pToken, nToken, -1, 0, &pRet->pMulti ); } }else{ |
︙ | |||
4317 4318 4319 4320 4321 4322 4323 | 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 | - - + + | ** matching rowid that occurs at or after iMatch. The definition of "at ** or after" depends on whether this iterator iterates in ascending or ** descending rowid order. */ static void fts5DoclistIterNextFrom(Fts5DoclistIter *p, i64 iMatch){ do{ i64 iRowid = p->iRowid; |
︙ | |||
4598 4599 4600 4601 4602 4603 4604 | 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 | - + | int nPos; iOff += fts5GetVarint32(&a[iOff], nPos); iOff += fts5DecodePoslist(pRc, pBuf, &a[iOff], MIN(n-iOff, nPos)); if( iOff<n ){ i64 iDelta; iOff += sqlite3GetVarint(&a[iOff], (u64*)&iDelta); if( iDelta==0 ) return iOff; |
︙ | |||
4687 4688 4689 4690 4691 4692 4693 | 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 | - | iOff = iRowidOff; }else if( iTermOff ){ iOff = iTermOff; }else{ iOff = n; } fts5DecodePoslist(&rc, &s, &a[4], iOff-4); |
︙ |
Changes to ext/fts5/test/fts5aa.test.
︙ | |||
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | + + | set y [doc] set z [doc] 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 {$i==2} break } #db eval {SELECT rowid, fts5_decode(rowid, block) aS r FROM t1_data} {puts $r} #------------------------------------------------------------------------- # reset_db do_execsql_test 8.0 { CREATE VIRTUAL TABLE t1 USING fts5(x, prefix="1,2,3"); INSERT INTO t1(t1, rank) VALUES('pgsz', 32); |
︙ | |||
308 309 310 311 312 313 314 | 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | - + | do_execsql_test 13.1 { CREATE VIRTUAL TABLE t1 USING fts5(x); INSERT INTO t1(rowid, x) VALUES(1, 'o n e'), (2, 't w o'); } {} do_execsql_test 13.2 { SELECT rowid FROM t1 WHERE t1 MATCH 'o'; |
︙ |
Changes to ext/fts5/test/fts5ab.test.
︙ | |||
26 27 28 29 30 31 32 | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | - + - + | CREATE VIRTUAL TABLE t1 USING fts5(a, b); INSERT INTO t1 VALUES('hello', 'world'); INSERT INTO t1 VALUES('one two', 'three four'); INSERT INTO t1(rowid, a, b) VALUES(45, 'forty', 'five'); } do_execsql_test 1.1 { |
︙ | |||
86 87 88 89 90 91 92 | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | - + + + + + + | 5 e {5 4} 6 f {4} 7 g {4} 8 x {6} 9 y {6} 10 z {6} } { |
︙ | |||
123 124 125 126 127 128 129 | 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | - + - + - + - + | 3 {abase + abash} {1} 4 {abash + abase} {9} 5 {abaft + abashing} {8 5} 6 {abandon + abandoning} {10} 7 {"abashing abases abasement abaft abashing"} {8} } { do_execsql_test 3.2.$tn { |
︙ | |||
229 230 231 232 233 234 235 236 237 238 | 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | + + + + + + + + + + + + + + + + + | } {0 1} do_test 5.4 { execsql { INSERT INTO s2 VALUES(rnddoc(160)) } fts5_level_segs s2 } {2 0} #------------------------------------------------------------------------- # do_execsql_test 6.0 { CREATE VIRTUAL TABLE s3 USING fts5(x); BEGIN; INSERT INTO s3 VALUES('a b c'); INSERT INTO s3 VALUES('A B C'); } do_execsql_test 6.1 { SELECT rowid FROM s3 WHERE s3 MATCH 'a' } {2 1} do_execsql_test 6.2 { COMMIT; SELECT rowid FROM s3 WHERE s3 MATCH 'a' } {2 1} finish_test |
Changes to ext/fts5/test/fts5ac.test.
︙ | |||
130 131 132 133 134 135 136 137 138 139 140 141 142 143 | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | + | 99 {r c v w i v h a t a c v c r e} {h h u m g o f b a e o} } do_test 1.1 { foreach {id x y} $data { execsql { INSERT INTO xx(rowid, x, y) VALUES($id, $x, $y) } } execsql { INSERT INTO xx(xx) VALUES('integrity-check') } } {} # Usage: # # poslist aCol ?-pc VARNAME? ?-near N? ?-col C? -- phrase1 phrase2... # proc poslist {aCol args} { |
︙ | |||
249 250 251 252 253 254 255 | 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | - + | # formatted as follows: # # <rowid> {<phrase 0 matches> <phrase 1 matches>...} # # where each <phrase X matches> element is a list of phrase matches in the # same form as returned by auxiliary scalar function fts5_test(). # |
︙ | |||
303 304 305 306 307 308 309 310 311 312 313 314 315 316 | 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | + + | sqlite3_fts5_create_function db fts5_test_poslist fts5_test_poslist #------------------------------------------------------------------------- # Test phrase queries. # foreach {tn phrase} { 8 "c" 1 "o" 2 "b q" 3 "e a e" 4 "m d g q q b k b w f q q p p" 5 "l o o l v v k" 6 "a" 7 "b" |
︙ | |||
396 397 398 399 400 401 402 | 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | - - + + | #------------------------------------------------------------------------- # do_execsql_test 6.integrity { INSERT INTO xx(xx) VALUES('integrity-check'); } #db eval {SELECT rowid, fts5_decode(rowid, block) aS r FROM xx_data} {puts $r} foreach {bAsc sql} { |
︙ |
Changes to ext/fts5/test/fts5ad.test.
︙ | |||
32 33 34 35 36 37 38 | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | - + - + | foreach {tn match res} { 1 {c*} {1} 2 {i*} {3 2} 3 {t*} {3 1} 4 {r*} {3 1} } { do_execsql_test 1.$tn { |
︙ | |||
190 191 192 193 194 195 196 | 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | - - + + | } if {$bMatch} { lappend ret $rowid } } return $ret } foreach {bAsc sql} { |
︙ |
Changes to ext/fts5/test/fts5ae.test.
︙ | |||
105 106 107 108 109 110 111 | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | - + | do_execsql_test 3.3 { INSERT INTO t3 VALUES('k x j r m a d o i z j', 'r t t t f e b r x i v j v g o'); SELECT rowid, fts5_test_poslist(t3) FROM t3 WHERE t3 MATCH 'a OR b AND c'; } { |
︙ | |||
186 187 188 189 190 191 192 | 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | - + | INSERT INTO t6 VALUES('There are more', 'things in heaven and earth'); INSERT INTO t6 VALUES(', Horatio, Than are', 'dreamt of in your philosophy.'); } do_execsql_test 6.2 { SELECT rowid, fts5_test_tokenize(t6) FROM t6 WHERE t6 MATCH 't*' } { |
︙ |
Changes to ext/fts5/test/fts5ak.test.
︙ | |||
36 37 38 39 40 41 42 | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | - - + + + - + - - + - + - - + + + - + - - + | INSERT INTO ft1 VALUES('i d i g c d c h b f'); INSERT INTO ft1 VALUES('g d a e h a b c f j'); } do_execsql_test 1.2 { SELECT highlight(ft1, 0, '[', ']') FROM ft1 WHERE ft1 MATCH 'e'; } { |
︙ | |||
129 130 131 132 133 134 135 | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | - + - + | -- The following SELECT statement returns these three rows: -- '[a b c] x [c d e]' -- '[a b c] [c d e]' -- '[a b c d e]' SELECT highlight(ft, 0, '[', ']') FROM ft WHERE ft MATCH 'a+b+c AND c+d+e'; } { |
Changes to ext/fts5/test/fts5al.test.
︙ | |||
100 101 102 103 104 105 106 | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | - + - - + + - + + - + | } {{123 456} {123 456}} proc rowidtest {cmd} { $cmd xRowid } sqlite3_fts5_create_function db rowidtest rowidtest do_execsql_test 3.3.1 { SELECT rowidtest(t1) FROM t1 WHERE t1 MATCH 'q' |
︙ | |||
184 185 186 187 188 189 190 | 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | - + - + - + | } do_execsql_test 4.1.3 { SELECT rowid, rank FROM t2 WHERE t2 MATCH 'a' AND rank MATCH 'firstinst()' ORDER BY rank DESC } { |
︙ | |||
253 254 255 256 257 258 259 | 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | - + - + | breakpoint do_execsql_test 4.3.2 { SELECT * FROM t3 WHERE t3 MATCH 'a' AND rank MATCH 'rowidmod(4)' ORDER BY rank ASC } { |
Changes to ext/fts5/test/fts5content.test.
︙ | |||
22 23 24 25 26 27 28 | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | - + - + - + - + - + - + - + - + | INSERT INTO f1(rowid, a, b) VALUES(1, 'one', 'o n e'); INSERT INTO f1(rowid, a, b) VALUES(2, 'two', 't w o'); INSERT INTO f1(rowid, a, b) VALUES(3, 'three', 't h r e e'); } do_execsql_test 1.2 { SELECT rowid FROM f1 WHERE f1 MATCH 'o'; |
︙ | |||
81 82 83 84 85 86 87 | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | - + - + | do_execsql_test 1.15 { INSERT INTO f1(f1, rowid, a, b) VALUES('delete', 2, 'two', 't w o'); } {} do_execsql_test 1.16 { SELECT rowid FROM f1 WHERE f1 MATCH 'o'; |
︙ |
Changes to ext/fts5/test/fts5corrupt.test.
︙ | |||
49 50 51 52 53 54 55 | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | - + - + + - - - + + - - - - + + - - + + + | catchsql { INSERT INTO t1(t1) VALUES('integrity-check') } } {1 {database disk image is malformed}} db_restore_and_reopen #db eval {SELECT rowid, fts5_decode(rowid, block) aS r FROM t1_data} {puts $r} |
Changes to ext/fts5/test/fts5fault1.test.
︙ | |||
86 87 88 89 90 91 92 | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | - - + + - - + + | INSERT INTO t2 VALUES('k fe fd rd a gi ho kk', 'ng m c r d ml rm r'); } faultsim_save_and_close foreach {tn expr res} { 1 { dk } 7 2 { m f } 1 |
︙ | |||
298 299 300 301 302 303 304 | 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | - + | reset_db db func rnddoc rnddoc do_test 8.0 { execsql { CREATE VIRTUAL TABLE x1 USING fts5(a) } set ::res [list] |
︙ |
Changes to ext/fts5/test/fts5rowid.test.
︙ | |||
168 169 170 171 172 173 174 | 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | - + | } foreach str $strlist { execsql { INSERT INTO x4 VALUES($str) } } execsql COMMIT } {} do_execsql_test 5.1 { SELECT rowid FROM x4 WHERE x4 MATCH 'a' |
︙ |