Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix a use-after-free error in fts5 that could occur when querying the "rank" column immediately after another connection changes its definition. forum post a2dd636330. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
cb54c2da52d3175844127ead41cfed18 |
User & Date: | dan 2023-09-12 18:36:46 |
Context
2023-09-12
| ||
23:21 | CLI .import to accept EOF in lieu of record terminator on last field of CSV (with multiple field records), per RFC 4180. forum post 5b21c25bdfa (check-in: 6f7842f5 user: larrybr tags: trunk) | |
23:11 | Fix a use-after-free error in fts5 that could occur when querying the "rank" column immediately after another connection changes its definition. (check-in: dfc42411 user: drh tags: branch-3.43) | |
18:36 | Fix a use-after-free error in fts5 that could occur when querying the "rank" column immediately after another connection changes its definition. forum post a2dd636330. (check-in: cb54c2da user: dan tags: trunk) | |
17:49 | Clarify some metrics output in Tester1.java. (check-in: 4ae7199a user: stephan tags: trunk) | |
Changes
Changes to ext/fts5/fts5_main.c.
︙ | ︙ | |||
1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 | pCsr->iFirstRowid = fts5GetRowidLimit(pRowidLe, LARGEST_INT64); pCsr->iLastRowid = fts5GetRowidLimit(pRowidGe, SMALLEST_INT64); }else{ pCsr->iLastRowid = fts5GetRowidLimit(pRowidLe, LARGEST_INT64); pCsr->iFirstRowid = fts5GetRowidLimit(pRowidGe, SMALLEST_INT64); } if( pTab->pSortCsr ){ /* If pSortCsr is non-NULL, then this call is being made as part of ** processing for a "... MATCH <expr> ORDER BY rank" query (ePlan is ** set to FTS5_PLAN_SORTED_MATCH). pSortCsr is the cursor that will ** return results to the user for this query. The current cursor ** (pCursor) is used to execute the query issued by function ** fts5CursorFirstSorted() above. */ | > > > | 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 | pCsr->iFirstRowid = fts5GetRowidLimit(pRowidLe, LARGEST_INT64); pCsr->iLastRowid = fts5GetRowidLimit(pRowidGe, SMALLEST_INT64); }else{ pCsr->iLastRowid = fts5GetRowidLimit(pRowidLe, LARGEST_INT64); pCsr->iFirstRowid = fts5GetRowidLimit(pRowidGe, SMALLEST_INT64); } rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex); if( rc!=SQLITE_OK ) goto filter_out; if( pTab->pSortCsr ){ /* If pSortCsr is non-NULL, then this call is being made as part of ** processing for a "... MATCH <expr> ORDER BY rank" query (ePlan is ** set to FTS5_PLAN_SORTED_MATCH). pSortCsr is the cursor that will ** return results to the user for this query. The current cursor ** (pCursor) is used to execute the query issued by function ** fts5CursorFirstSorted() above. */ |
︙ | ︙ | |||
1347 1348 1349 1350 1351 1352 1353 | pCsr->iLastRowid = pTab->pSortCsr->iLastRowid; pCsr->iFirstRowid = pTab->pSortCsr->iFirstRowid; } pCsr->ePlan = FTS5_PLAN_SOURCE; pCsr->pExpr = pTab->pSortCsr->pExpr; rc = fts5CursorFirst(pTab, pCsr, bDesc); }else if( pCsr->pExpr ){ | > | > | 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 | pCsr->iLastRowid = pTab->pSortCsr->iLastRowid; pCsr->iFirstRowid = pTab->pSortCsr->iFirstRowid; } pCsr->ePlan = FTS5_PLAN_SOURCE; pCsr->pExpr = pTab->pSortCsr->pExpr; rc = fts5CursorFirst(pTab, pCsr, bDesc); }else if( pCsr->pExpr ){ if( rc==SQLITE_OK ){ rc = fts5CursorParseRank(pConfig, pCsr, pRank); } if( rc==SQLITE_OK ){ if( bOrderByRank ){ pCsr->ePlan = FTS5_PLAN_SORTED_MATCH; rc = fts5CursorFirstSorted(pTab, pCsr, bDesc); }else{ pCsr->ePlan = FTS5_PLAN_MATCH; rc = fts5CursorFirst(pTab, pCsr, bDesc); |
︙ | ︙ |
Changes to ext/fts5/test/fts5misc.test.
︙ | ︙ | |||
40 41 42 43 44 45 46 | do_catchsql_test 1.2.2 { SELECT a FROM t1 WHERE rank = (SELECT highlight(t1, 4, '<b>', '</b>') FROM t1('*id')); } {0 {}} do_catchsql_test 1.3.1 { SELECT highlight(t1, 4, '<b>', '</b>') FROM t1('*reads'); | | | | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | do_catchsql_test 1.2.2 { SELECT a FROM t1 WHERE rank = (SELECT highlight(t1, 4, '<b>', '</b>') FROM t1('*id')); } {0 {}} do_catchsql_test 1.3.1 { SELECT highlight(t1, 4, '<b>', '</b>') FROM t1('*reads'); } {1 {no such cursor: 2}} do_catchsql_test 1.3.2 { SELECT a FROM t1 WHERE rank = (SELECT highlight(t1, 4, '<b>', '</b>') FROM t1('*reads')); } {1 {no such cursor: 2}} db close sqlite3 db test.db do_catchsql_test 1.3.3 { SELECT a FROM t1 WHERE rank = (SELECT highlight(t1, 4, '<b>', '</b>') FROM t1('*reads')); |
︙ | ︙ |
Changes to ext/fts5/test/fts5rank.test.
︙ | ︙ | |||
176 177 178 179 180 181 182 183 | } do_execsql_test 6.1 { SELECT * FROM "My.Table" WHERE Text MATCH 'table' ORDER BY rank; } { {table table table} {the table names.} {rank on an fts5 table} } finish_test | > > > > > > > > > > > > > > > > > > > > > > > > | 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | } do_execsql_test 6.1 { SELECT * FROM "My.Table" WHERE Text MATCH 'table' ORDER BY rank; } { {table table table} {the table names.} {rank on an fts5 table} } #------------------------------------------------------------------------- # forum post: https://sqlite.org/forum/forumpost/a2dd636330 # reset_db do_execsql_test 1.0 { CREATE VIRTUAL TABLE t USING fts5 (a, b); INSERT INTO t (a, b) VALUES ('data1', 'sentence1'), ('data2', 'sentence2'); INSERT INTO t(t, rank) VALUES ('rank', 'bm25(10.0,1.0)'); } sqlite3 db2 test.db do_execsql_test -db db2 1.1 { SELECT *, rank<0.0 FROM t('data*') ORDER BY RANK; } {data1 sentence1 1 data2 sentence2 1} do_execsql_test 1.2 { INSERT INTO t(t, rank) VALUES ('rank', 'bm25(10.0,1.0)'); } do_execsql_test -db db2 1.3 { SELECT *, rank<0.0 FROM t('data*') ORDER BY RANK; } {data1 sentence1 1 data2 sentence2 1} db2 close finish_test |