Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix some problems with calling fts5 api functions from within non-full-text queries. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
56d265f956fe6433b625c6d732e55f38 |
User & Date: | dan 2024-06-24 16:08:01.650 |
Context
2024-06-24
| ||
18:06 | Fix an incorrect tcl comment that appeared in many fts5 test files. (check-in: d07085e203 user: dan tags: trunk) | |
16:08 | Fix some problems with calling fts5 api functions from within non-full-text queries. (check-in: 56d265f956 user: dan tags: trunk) | |
14:53 | Enhance the output of ".scanstats vm" to include the absolute number of ticks for each VM instruction, instead of just the percentage of the total. (check-in: 1535828335 user: dan tags: trunk) | |
Changes
Changes to ext/fts5/fts5_expr.c.
︙ | ︙ | |||
1890 1891 1892 1893 1894 1895 1896 | int iPhrase, Fts5Expr **ppNew ){ int rc = SQLITE_OK; /* Return code */ Fts5ExprPhrase *pOrig = 0; /* The phrase extracted from pExpr */ Fts5Expr *pNew = 0; /* Expression to return via *ppNew */ TokenCtx sCtx = {0,0,0}; /* Context object for fts5ParseTokenize */ | | | 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 | int iPhrase, Fts5Expr **ppNew ){ int rc = SQLITE_OK; /* Return code */ Fts5ExprPhrase *pOrig = 0; /* The phrase extracted from pExpr */ Fts5Expr *pNew = 0; /* Expression to return via *ppNew */ TokenCtx sCtx = {0,0,0}; /* Context object for fts5ParseTokenize */ if( !pExpr || iPhrase<0 || iPhrase>=pExpr->nPhrase ){ rc = SQLITE_RANGE; }else{ pOrig = pExpr->apExprPhrase[iPhrase]; pNew = (Fts5Expr*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5Expr)); } if( rc==SQLITE_OK ){ pNew->apExprPhrase = (Fts5ExprPhrase**)sqlite3Fts5MallocZero(&rc, |
︙ | ︙ |
Changes to ext/fts5/fts5_main.c.
︙ | ︙ | |||
959 960 961 962 963 964 965 966 967 968 969 970 971 972 | if( rc!=SQLITE_OK ){ pCursor->pVtab->zErrMsg = sqlite3_mprintf( "%s", sqlite3_errmsg(pConfig->db) ); } }else{ rc = SQLITE_OK; } break; } } } return rc; | > | 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 | if( rc!=SQLITE_OK ){ pCursor->pVtab->zErrMsg = sqlite3_mprintf( "%s", sqlite3_errmsg(pConfig->db) ); } }else{ rc = SQLITE_OK; CsrFlagSet(pCsr, FTS5CSR_REQUIRE_DOCSIZE); } break; } } } return rc; |
︙ | ︙ | |||
1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 | /* ** Return the rowid that the cursor currently points to. */ static i64 fts5CursorRowid(Fts5Cursor *pCsr){ assert( pCsr->ePlan==FTS5_PLAN_MATCH || pCsr->ePlan==FTS5_PLAN_SORTED_MATCH || pCsr->ePlan==FTS5_PLAN_SOURCE ); if( pCsr->pSorter ){ return pCsr->pSorter->iRowid; }else{ return sqlite3Fts5ExprRowid(pCsr->pExpr); } } /* ** This is the xRowid method. The SQLite core calls this routine to ** retrieve the rowid for the current row of the result set. fts5 ** exposes %_content.rowid as the rowid for the virtual table. The ** rowid should be written to *pRowid. */ static int fts5RowidMethod(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){ Fts5Cursor *pCsr = (Fts5Cursor*)pCursor; int ePlan = pCsr->ePlan; assert( CsrFlagTest(pCsr, FTS5CSR_EOF)==0 ); | > > > > < | | < | < < < | < < < < < | 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 | /* ** Return the rowid that the cursor currently points to. */ static i64 fts5CursorRowid(Fts5Cursor *pCsr){ assert( pCsr->ePlan==FTS5_PLAN_MATCH || pCsr->ePlan==FTS5_PLAN_SORTED_MATCH || pCsr->ePlan==FTS5_PLAN_SOURCE || pCsr->ePlan==FTS5_PLAN_SCAN || pCsr->ePlan==FTS5_PLAN_ROWID ); if( pCsr->pSorter ){ return pCsr->pSorter->iRowid; }else if( pCsr->ePlan>=FTS5_PLAN_SCAN ){ return sqlite3_column_int64(pCsr->pStmt, 0); }else{ return sqlite3Fts5ExprRowid(pCsr->pExpr); } } /* ** This is the xRowid method. The SQLite core calls this routine to ** retrieve the rowid for the current row of the result set. fts5 ** exposes %_content.rowid as the rowid for the virtual table. The ** rowid should be written to *pRowid. */ static int fts5RowidMethod(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){ Fts5Cursor *pCsr = (Fts5Cursor*)pCursor; int ePlan = pCsr->ePlan; assert( CsrFlagTest(pCsr, FTS5CSR_EOF)==0 ); if( ePlan==FTS5_PLAN_SPECIAL ){ *pRowid = 0; }else{ *pRowid = fts5CursorRowid(pCsr); } return SQLITE_OK; } /* ** If the cursor requires seeking (bSeekRequired flag is set), seek it. |
︙ | ︙ |
Changes to ext/fts5/test/fts5_common.tcl.
︙ | ︙ | |||
109 110 111 112 113 114 115 116 117 118 119 120 121 122 | } set res } proc fts5_test_rowcount {cmd} { $cmd xRowCount } proc test_queryphrase_cb {cnt cmd} { upvar $cnt L for {set i 0} {$i < [$cmd xInstCount]} {incr i} { foreach {ip ic io} [$cmd xInst $i] break set A($ic) 1 } | > > > > | 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | } set res } proc fts5_test_rowcount {cmd} { $cmd xRowCount } proc fts5_test_rowid {cmd} { $cmd xRowid } proc test_queryphrase_cb {cnt cmd} { upvar $cnt L for {set i 0} {$i < [$cmd xInstCount]} {incr i} { foreach {ip ic io} [$cmd xInst $i] break set A($ic) 1 } |
︙ | ︙ | |||
163 164 165 166 167 168 169 170 171 172 173 174 175 176 | fts5_test_columntext fts5_test_columntotalsize fts5_test_poslist fts5_test_poslist2 fts5_test_collist fts5_test_tokenize fts5_test_rowcount fts5_test_all fts5_test_queryphrase fts5_test_phrasecount fts5_columntext fts5_queryphrase fts5_collist | > | 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | fts5_test_columntext fts5_test_columntotalsize fts5_test_poslist fts5_test_poslist2 fts5_test_collist fts5_test_tokenize fts5_test_rowcount fts5_test_rowid fts5_test_all fts5_test_queryphrase fts5_test_phrasecount fts5_columntext fts5_queryphrase fts5_collist |
︙ | ︙ |
Added ext/fts5/test/fts5aux2.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 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 68 69 70 71 | # 2024 June 24 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # # Tests focusing on the auxiliary function APIs. # source [file join [file dirname [info script]] fts5_common.tcl] set testprefix fts5aux # If SQLITE_ENABLE_FTS5 is defined, omit this file. ifcapable !fts5 { finish_test return } do_execsql_test 1.0 { CREATE VIRTUAL TABLE x1 USING fts5(a, b); INSERT INTO x1 VALUES('a b', 'c d'); INSERT INTO x1 VALUES('d e', 'a b'); INSERT INTO x1 VALUES('a b', 'e f'); INSERT INTO x1 VALUES('d e', 'c d'); } fts5_aux_test_functions db do_execsql_test 1.1 { SELECT fts5_test_all(x1) FROM x1 WHERE rowid=2 } [list [list {*}{ columnsize {2 2} columntext {{d e} {a b}} columntotalsize {8 8} poslist {} tokenize {{d e} {a b}} rowcount 4 }]] do_execsql_test 1.2 { SELECT fts5_test_columntext(x1) FROM x1 } { {{a b} {c d}} {{d e} {a b}} {{a b} {e f}} {{d e} {c d}} } do_execsql_test 1.3 { SELECT fts5_test_rowid(x1) FROM x1 } { 1 2 3 4 } do_execsql_test 1.4 { SELECT fts5_test_phrasecount(x1) FROM x1 } { 0 0 0 0 } do_catchsql_test 1.5 { SELECT fts5_queryphrase(x1, 0) FROM x1 } {1 SQLITE_RANGE} do_execsql_test 1.6 { SELECT fts5_test_rowcount(x1) FROM x1 } {4 4 4 4} finish_test |
Changes to ext/fts5/test/fts5matchinfo.test.
︙ | ︙ | |||
513 514 515 516 517 518 519 | SELECT quote(matchinfo(t1, 'n')) FROM t1 LIMIT 1; } $res fts5_aux_test_functions db do_execsql_test 15.3 { SELECT fts5_test_all(t1) FROM t1 LIMIT 1; } { | | | 513 514 515 516 517 518 519 520 521 522 523 | SELECT quote(matchinfo(t1, 'n')) FROM t1 LIMIT 1; } $res fts5_aux_test_functions db do_execsql_test 15.3 { SELECT fts5_test_all(t1) FROM t1 LIMIT 1; } { {columnsize {1 1} columntext {c d} columntotalsize {2 2} poslist {} tokenize {c d} rowcount 2} } finish_test |