SQLite

Check-in [f1138a38bd]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Ensure that FTS5 queries of the form "WHERE rowid BETWEEN ? AND ? AND tbl MATCH ? ORDER BY rank" do rowid filtering before sorting.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f1138a38bd23f201a35621a71e82c5718abddb42ab82938e9516ab9d43e4df16
User & Date: dan 2018-09-03 17:11:11.873
Context
2018-09-05
16:16
Remove an old testcase() macro that is no longer valid. (check-in: e628713338 user: drh tags: trunk)
2018-09-04
18:23
Merge latest trunk changes into this branch. (check-in: ef9e088290 user: dan tags: alter-table-rename-column)
2018-09-03
17:11
Ensure that FTS5 queries of the form "WHERE rowid BETWEEN ? AND ? AND tbl MATCH ? ORDER BY rank" do rowid filtering before sorting. (check-in: f1138a38bd user: dan tags: trunk)
2018-09-01
06:13
Update test script snapshot_fault.test to account for the new sqlite3_snapshot_open() error code. (check-in: c1aca7673a user: dan tags: trunk)
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to ext/fts5/fts5_main.c.
1201
1202
1203
1204
1205
1206
1207







1208
1209
1210
1211
1212
1213
1214
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221







+
+
+
+
+
+
+







    ** return results to the user for this query. The current cursor 
    ** (pCursor) is used to execute the query issued by function 
    ** fts5CursorFirstSorted() above.  */
    assert( pRowidEq==0 && pRowidLe==0 && pRowidGe==0 && pRank==0 );
    assert( nVal==0 && pMatch==0 && bOrderByRank==0 && bDesc==0 );
    assert( pCsr->iLastRowid==LARGEST_INT64 );
    assert( pCsr->iFirstRowid==SMALLEST_INT64 );
    if( pTab->pSortCsr->bDesc ){
      pCsr->iLastRowid = pTab->pSortCsr->iFirstRowid;
      pCsr->iFirstRowid = pTab->pSortCsr->iLastRowid;
    }else{
      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( pMatch ){
    const char *zExpr = (const char*)sqlite3_value_text(apVal[0]);
    if( zExpr==0 ) zExpr = "";

Changes to ext/fts5/test/fts5rank.test.
144
145
146
147
148
149
150






151
152



153




154

144
145
146
147
148
149
150
151
152
153
154
155
156


157
158
159
160
161
162
163
164
165
166







+
+
+
+
+
+
-
-
+
+
+

+
+
+
+

+
  );
  INSERT INTO VTest (Title, Author) VALUES ('wrinkle in time', 'Bill Smith');

  SELECT * FROM VTest WHERE 
  VTest MATCH 'wrinkle in time OR a wrinkle in time' ORDER BY rank;
} {{wrinkle in time} {Bill Smith}}

#-------------------------------------------------------------------------
reset_db
do_execsql_test 5.0 {
  CREATE VIRTUAL TABLE ttt USING fts5(a);
  WITH s(i) AS (
    SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100


  )
  INSERT INTO ttt SELECT 'word ' || i FROM s;
}

do_execsql_test 5.1 {
  SELECT rowid FROM ttt('word') WHERE rowid BETWEEN 30 AND 40 ORDER BY rank;
} {30 31 32 33 34 35 36 37 38 39 40}

finish_test