/ Check-in [4ed905b1]
Login

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

Overview
Comment:Ensure fts3/4 prefix indexes are flushed to disk before an 'optimize' command. Fix for [745f1abc].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 4ed905b18847d4dbf5a2570052abced338065f824137b90300f62d77b3159d80
User & Date: dan 2019-10-11 15:33:13
Context
2019-10-11
16:01
Improvements to the LEFT JOIN strength reduction optimization. check-in: 548082df user: drh tags: trunk
15:33
Ensure fts3/4 prefix indexes are flushed to disk before an 'optimize' command. Fix for [745f1abc]. check-in: 4ed905b1 user: dan tags: trunk
14:27
Fix the fts3/4 integrity-check command so that it works with "ORDER=DESC" tables. Fix for [8a6fa2bb]. check-in: 5863546d user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/fts3/fts3_write.c.

  3478   3478   ** iIndex/iLangid combination.
  3479   3479   */
  3480   3480   static int fts3DoOptimize(Fts3Table *p, int bReturnDone){
  3481   3481     int bSeenDone = 0;
  3482   3482     int rc;
  3483   3483     sqlite3_stmt *pAllLangid = 0;
  3484   3484   
  3485         -  rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);
         3485  +  rc = sqlite3Fts3PendingTermsFlush(p);
         3486  +  if( rc==SQLITE_OK ){
         3487  +    rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);
         3488  +  }
  3486   3489     if( rc==SQLITE_OK ){
  3487   3490       int rc2;
  3488   3491       sqlite3_bind_int(pAllLangid, 1, p->iPrevLangid);
  3489   3492       sqlite3_bind_int(pAllLangid, 2, p->nIndex);
  3490   3493       while( sqlite3_step(pAllLangid)==SQLITE_ROW ){
  3491   3494         int i;
  3492   3495         int iLangid = sqlite3_column_int(pAllLangid, 0);
................................................................................
  3499   3502         }
  3500   3503       }
  3501   3504       rc2 = sqlite3_reset(pAllLangid);
  3502   3505       if( rc==SQLITE_OK ) rc = rc2;
  3503   3506     }
  3504   3507   
  3505   3508     sqlite3Fts3SegmentsClose(p);
  3506         -  sqlite3Fts3PendingTermsClear(p);
  3507   3509   
  3508   3510     return (rc==SQLITE_OK && bReturnDone && bSeenDone) ? SQLITE_DONE : rc;
  3509   3511   }
  3510   3512   
  3511   3513   /*
  3512   3514   ** This function is called when the user executes the following statement:
  3513   3515   **

Changes to test/fts3misc.test.

   234    234     INSERT INTO vt0 VALUES (x'00');
   235    235   }
   236    236   do_execsql_test 7.1 {
   237    237     INSERT INTO vt0(vt0) VALUES('integrity-check');
   238    238   }
   239    239   
   240    240   #-------------------------------------------------------------------------
          241  +# Ticket [8a6fa2bb].
   241    242   #
   242    243   reset_db
   243    244   do_execsql_test 7.0.1 {
   244    245     CREATE VIRTUAL TABLE vt0 USING fts4(c0, order=DESC);
   245    246     INSERT INTO vt0(c0) VALUES (0), (0);
   246    247   }
   247    248   do_execsql_test 7.0.2 {
................................................................................
   251    252   do_execsql_test 7.1.1 {
   252    253     CREATE VIRTUAL TABLE vt0 USING fts4(c0, order=ASC);
   253    254     INSERT INTO vt0(c0) VALUES (0), (0);
   254    255   }
   255    256   do_execsql_test 7.1.2 {
   256    257     INSERT INTO vt0(vt0) VALUES('integrity-check');
   257    258   }
   258         -
   259    259   do_execsql_test 7.2.1 {
   260    260     CREATE VIRTUAL TABLE ft USING fts4(c0, c1, order=DESC, prefix=1);
   261    261     INSERT INTO ft VALUES('a b c d', 'hello world');
   262    262     INSERT INTO ft VALUES('negative', 'positive');
   263    263     INSERT INTO ft VALUES('hello world', 'a b c d');
   264    264   }
   265    265   do_execsql_test 7.2.2 {
   266    266     INSERT INTO vt0(vt0) VALUES('integrity-check');
   267    267   }
   268    268   
   269         -
          269  +#-------------------------------------------------------------------------
          270  +# Ticket [745f1abc].
          271  +#
          272  +reset_db
          273  +do_execsql_test 8.1 {
          274  +  CREATE VIRTUAL TABLE vt0 USING fts4(c0, prefix=1);
          275  +}
          276  +do_execsql_test 8.2 {
          277  +  BEGIN;
          278  +    INSERT INTO vt0 VALUES (0);
          279  +    INSERT INTO vt0(vt0) VALUES('optimize');
          280  +  COMMIT;
          281  +}
          282  +do_execsql_test 8.3 {
          283  +  INSERT INTO vt0(vt0) VALUES('integrity-check');
          284  +}
   270    285   
   271    286   finish_test