/ Check-in [9cd64ce4]
Login

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

Overview
Comment:Fix a problem causing a crash if an fts5vocab table was created to query an fts3/4 FTS index.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:9cd64ce453e4435d80117b8610c22a0a4b53cd6e84b39815e70e684f6b0295c8
User & Date: dan 2019-01-14 15:35:15
Context
2019-01-14
16:16
Add the "prefixes" table-valued function in the ext/misc folder. check-in: f0fd2163 user: drh tags: trunk
15:35
Fix a problem causing a crash if an fts5vocab table was created to query an fts3/4 FTS index. check-in: 9cd64ce4 user: dan tags: trunk
15:09
Fix a problem with querying a corrupt fts3 database. check-in: 65e50706 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/fts5/fts5_main.c.

  2240   2240   */
  2241   2241   Fts5Index *sqlite3Fts5IndexFromCsrid(
  2242   2242     Fts5Global *pGlobal,            /* FTS5 global context for db handle */
  2243   2243     i64 iCsrId,                     /* Id of cursor to find */
  2244   2244     Fts5Config **ppConfig           /* OUT: Configuration object */
  2245   2245   ){
  2246   2246     Fts5Cursor *pCsr;
  2247         -  Fts5Table *pTab;
  2248         -
  2249   2247     pCsr = fts5CursorFromCsrid(pGlobal, iCsrId);
  2250         -  pTab = (Fts5Table*)pCsr->base.pVtab;
  2251         -  *ppConfig = pTab->pConfig;
  2252         -
  2253         -  return pTab->pIndex;
         2248  +  if( pCsr ){
         2249  +    Fts5Table *pTab = (Fts5Table*)pCsr->base.pVtab;
         2250  +    *ppConfig = pTab->pConfig;
         2251  +    return pTab->pIndex;
         2252  +  }
         2253  +  return 0;
  2254   2254   }
  2255   2255   
  2256   2256   /*
  2257   2257   ** Return a "position-list blob" corresponding to the current position of
  2258   2258   ** cursor pCsr via sqlite3_result_blob(). A position-list blob contains
  2259   2259   ** the current position-list for each phrase in the query associated with
  2260   2260   ** cursor pCsr.

Changes to ext/fts5/test/fts5vocab2.test.

   197    197     three 2 {} {}
   198    198   }
   199    199   
   200    200   do_execsql_test 3.5 {
   201    201     DELETE FROM t1;
   202    202     SELECT * FROM v1;
   203    203   } {}
          204  +
          205  +#-------------------------------------------------------------------------
          206  +#
          207  +reset_db
          208  +do_execsql_test 4.0 {
          209  +  CREATE VIRTUAL TABLE v1 USING fts5vocab(nosuchtable, col);
          210  +}
          211  +
          212  +do_catchsql_test 4.1 {
          213  +  SELECT * FROM v1 WHERE term=='nosuchterm';
          214  +} {1 {no such fts5 table: main.nosuchtable}}
          215  +
          216  +do_execsql_test 4.2.1 {
          217  +  CREATE TABLE nosuchtable(nosuchtable, y, z);
          218  +}
          219  +do_catchsql_test 4.2.2 {
          220  +  SELECT * FROM v1 WHERE term=='nosuchterm';
          221  +} {1 {no such fts5 table: main.nosuchtable}}
          222  +
          223  +ifcapable fts3 {
          224  +  do_execsql_test 4.3.1 {
          225  +    DROP TABLE nosuchtable;
          226  +    CREATE VIRTUAL TABLE nosuchtable USING fts3(a, b);
          227  +  } {}
          228  +  do_catchsql_test 4.3.2 {
          229  +    SELECT * FROM v1 WHERE term=='nosuchterm';
          230  +  } {1 {no such fts5 table: main.nosuchtable}}
          231  +  do_catchsql_test 4.3.3 {
          232  +    INSERT INTO nosuchtable VALUES('id', '*id');
          233  +    SELECT * FROM v1 WHERE term=='nosuchterm';
          234  +  } {1 {no such fts5 table: main.nosuchtable}}
          235  +}
   204    236   
   205    237   finish_test