/ Check-in [8ab0aebd]
Login

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

Overview
Comment:Disallow page-sizes smaller than 32 bytes in fts5. Also ensure the fts5 integrity-check works even when "PRAGMA reverse_unordered_selects" is true. Fix for [265e935b26].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 8ab0aebdb3c2d6fb3160b2c58ce6cc0495a6ddd960878a6395958c837f3d1b71
User & Date: dan 2019-10-07 20:36:18
Context
2019-10-08
13:34
Fix problems with using the fts5 'rebuild' command inside a transaction that contains other updates of the same table. Fix for [e258f008]. check-in: 238e0835 user: dan tags: trunk
2019-10-07
20:36
Disallow page-sizes smaller than 32 bytes in fts5. Also ensure the fts5 integrity-check works even when "PRAGMA reverse_unordered_selects" is true. Fix for [265e935b26]. check-in: 8ab0aebd user: dan tags: trunk
20:33
Omit a pointless memory allocation in vdbeSorterSort(). check-in: 5d76dbc5 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/fts5/fts5_config.c.

   824    824     int rc = SQLITE_OK;
   825    825   
   826    826     if( 0==sqlite3_stricmp(zKey, "pgsz") ){
   827    827       int pgsz = 0;
   828    828       if( SQLITE_INTEGER==sqlite3_value_numeric_type(pVal) ){
   829    829         pgsz = sqlite3_value_int(pVal);
   830    830       }
   831         -    if( pgsz<=0 || pgsz>FTS5_MAX_PAGE_SIZE ){
          831  +    if( pgsz<32 || pgsz>FTS5_MAX_PAGE_SIZE ){
   832    832         *pbBadkey = 1;
   833    833       }else{
   834    834         pConfig->pgsz = pgsz;
   835    835       }
   836    836     }
   837    837   
   838    838     else if( 0==sqlite3_stricmp(zKey, "hashsize") ){

Changes to ext/fts5/fts5_index.c.

  5886   5886     int rc2;
  5887   5887     int iIdxPrevLeaf = pSeg->pgnoFirst-1;
  5888   5888     int iDlidxPrevLeaf = pSeg->pgnoLast;
  5889   5889   
  5890   5890     if( pSeg->pgnoFirst==0 ) return;
  5891   5891   
  5892   5892     fts5IndexPrepareStmt(p, &pStmt, sqlite3_mprintf(
  5893         -      "SELECT segid, term, (pgno>>1), (pgno&1) FROM %Q.'%q_idx' WHERE segid=%d",
         5893  +      "SELECT segid, term, (pgno>>1), (pgno&1) FROM %Q.'%q_idx' WHERE segid=%d "
         5894  +      "ORDER BY 1, 2",
  5894   5895         pConfig->zDb, pConfig->zName, pSeg->iSegid
  5895   5896     ));
  5896   5897   
  5897   5898     /* Iterate through the b-tree hierarchy.  */
  5898   5899     while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
  5899   5900       i64 iRow;                     /* Rowid for this leaf */
  5900   5901       Fts5Data *pLeaf;              /* Data for this leaf */

Changes to ext/fts5/test/fts5corrupt3.test.

  4480   4480   |   4080: 00 00 03 03 02 01 03 03 02 02 01 02 02 01 0c e9   ................
  4481   4481   | end crash-a6651222df1bd1.db
  4482   4482   }]} {}
  4483   4483   
  4484   4484   do_catchsql_test 36.1 {
  4485   4485     INSERT INTO t1(b) VALUES(
  4486   4486         x'78de3fa24af3733ca8769291a0fee3669f9fddefc5cba913e4225d4b6ce2b04f26b87fad3ee6f9b7d90a1ea62a169bf41e5d32707a6ca5c3d05e4bde05c9d89eaaa8c50e74333d2e9fcd7dfe95528a3a016aac1102d825c5cd70cf99d8a88e0ea7f798d4334386518b7ad359beb168b93aba059a2a3bd93112d65b44c12b9904ea786b204d80531cdf0504bf9b203dbe927061974caf7b9f30cbc3397b61f802e732012a6663d41c3607d6f1c0dbcfd489adac05ca500c0b04439d894cd93a840159225ef73b627e178b9f84b3ffe66cf22a963a8368813ff7961fc47f573211ccec95e0220dcbb3bf429f4a50ba54d7a53784ac51bfef346e6a');
  4487         -} {1 {database disk image is malformed}}
         4487  +} {0 {}}
  4488   4488   
  4489   4489   #-------------------------------------------------------------------------
  4490   4490   reset_db
  4491   4491   do_test 37.0 {
  4492   4492     sqlite3 db {}
  4493   4493     db deserialize [decode_hexdb {
  4494   4494   | size 40960 pagesize 4096 filename null-memcmp-param-1..db

Changes to ext/fts5/test/fts5misc.test.

   101    101   do_execsql_test 2.2.4 {
   102    102     INSERT INTO vt0(c0) VALUES ('abc');
   103    103     COMMIT;
   104    104   }
   105    105   do_execsql_test 2.2.5 {
   106    106     INSERT INTO vt0(vt0) VALUES('integrity-check');
   107    107   }
          108  +
          109  +#-------------------------------------------------------------------------
          110  +reset_db
          111  +do_execsql_test 3.0 {
          112  +  CREATE VIRTUAL TABLE vt0 USING fts5(a);
          113  +  PRAGMA reverse_unordered_selects = true;
          114  +  INSERT INTO vt0 VALUES('365062398'), (0), (0);
          115  +  INSERT INTO vt0(vt0, rank) VALUES('pgsz', '38');
          116  +}
          117  +do_execsql_test 3.1 {
          118  +  UPDATE vt0 SET a = 399905135; -- unexpected: database disk image is malformed
          119  +}
          120  +do_execsql_test 3.2 {
          121  +  INSERT INTO vt0(vt0) VALUES('integrity-check');
          122  +}
   108    123   
   109    124   
   110    125   finish_test
   111    126