/ Check-in [7123bb26]
Login

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

Overview
Comment:Fix a problem that was causing the FTS4 integrity-check command to fail if the table had one or more "notindexed" columns.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:7123bb2605216396f65db5d156431b3613f313b5
User & Date: dan 2014-06-05 11:15:56
Context
2014-06-06
17:09
Fix an obsolete comment on the whereRangeScanEst() routine. No changes to code. check-in: b16bf851 user: drh tags: trunk
2014-06-05
13:22
Bring the threads branch up-to-date with the 3.8.5 release. check-in: e4b01676 user: drh tags: threads
12:53
Merge in the 3.8.5 release changes and the FTS integrity-check fix. check-in: 2dbdfa51 user: drh tags: apple-osx
11:15
Fix a problem that was causing the FTS4 integrity-check command to fail if the table had one or more "notindexed" columns. check-in: 7123bb26 user: dan tags: trunk
2014-06-04
14:06
Version 3.8.5 check-in: b1ed4f2a user: drh tags: trunk, release, version-3.8.5
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/fts3/fts3_write.c.

  5170   5170   
  5171   5171       while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
  5172   5172         i64 iDocid = sqlite3_column_int64(pStmt, 0);
  5173   5173         int iLang = langidFromSelect(p, pStmt);
  5174   5174         int iCol;
  5175   5175   
  5176   5176         for(iCol=0; rc==SQLITE_OK && iCol<p->nColumn; iCol++){
  5177         -        const char *zText = (const char *)sqlite3_column_text(pStmt, iCol+1);
  5178         -        int nText = sqlite3_column_bytes(pStmt, iCol+1);
  5179         -        sqlite3_tokenizer_cursor *pT = 0;
  5180         -
  5181         -        rc = sqlite3Fts3OpenTokenizer(p->pTokenizer, iLang, zText, nText, &pT);
  5182         -        while( rc==SQLITE_OK ){
  5183         -          char const *zToken;       /* Buffer containing token */
  5184         -          int nToken = 0;           /* Number of bytes in token */
  5185         -          int iDum1 = 0, iDum2 = 0; /* Dummy variables */
  5186         -          int iPos = 0;             /* Position of token in zText */
  5187         -
  5188         -          rc = pModule->xNext(pT, &zToken, &nToken, &iDum1, &iDum2, &iPos);
  5189         -          if( rc==SQLITE_OK ){
  5190         -            int i;
  5191         -            cksum2 = cksum2 ^ fts3ChecksumEntry(
  5192         -                zToken, nToken, iLang, 0, iDocid, iCol, iPos
  5193         -            );
  5194         -            for(i=1; i<p->nIndex; i++){
  5195         -              if( p->aIndex[i].nPrefix<=nToken ){
  5196         -                cksum2 = cksum2 ^ fts3ChecksumEntry(
  5197         -                  zToken, p->aIndex[i].nPrefix, iLang, i, iDocid, iCol, iPos
  5198         -                );
         5177  +        if( p->abNotindexed[iCol]==0 ){
         5178  +          const char *zText = (const char *)sqlite3_column_text(pStmt, iCol+1);
         5179  +          int nText = sqlite3_column_bytes(pStmt, iCol+1);
         5180  +          sqlite3_tokenizer_cursor *pT = 0;
         5181  +
         5182  +          rc = sqlite3Fts3OpenTokenizer(p->pTokenizer, iLang, zText, nText,&pT);
         5183  +          while( rc==SQLITE_OK ){
         5184  +            char const *zToken;       /* Buffer containing token */
         5185  +            int nToken = 0;           /* Number of bytes in token */
         5186  +            int iDum1 = 0, iDum2 = 0; /* Dummy variables */
         5187  +            int iPos = 0;             /* Position of token in zText */
         5188  +
         5189  +            rc = pModule->xNext(pT, &zToken, &nToken, &iDum1, &iDum2, &iPos);
         5190  +            if( rc==SQLITE_OK ){
         5191  +              int i;
         5192  +              cksum2 = cksum2 ^ fts3ChecksumEntry(
         5193  +                  zToken, nToken, iLang, 0, iDocid, iCol, iPos
         5194  +              );
         5195  +              for(i=1; i<p->nIndex; i++){
         5196  +                if( p->aIndex[i].nPrefix<=nToken ){
         5197  +                  cksum2 = cksum2 ^ fts3ChecksumEntry(
         5198  +                      zToken, p->aIndex[i].nPrefix, iLang, i, iDocid, iCol, iPos
         5199  +                  );
         5200  +                }
  5199   5201                 }
  5200   5202               }
  5201   5203             }
         5204  +          if( pT ) pModule->xClose(pT);
         5205  +          if( rc==SQLITE_DONE ) rc = SQLITE_OK;
  5202   5206           }
  5203         -        if( pT ) pModule->xClose(pT);
  5204         -        if( rc==SQLITE_DONE ) rc = SQLITE_OK;
  5205   5207         }
  5206   5208       }
  5207   5209   
  5208   5210       sqlite3_finalize(pStmt);
  5209   5211     }
  5210   5212   
  5211   5213     *pbOk = (cksum1==cksum2);

Changes to test/fts4check.test.

   147    147   } {
   148    148     do_execsql_test  3.2.1.$tn "BEGIN; $disruption"
   149    149     do_catchsql_test 3.2.2.$tn {
   150    150       INSERT INTO t3 (t3) VALUES('integrity-check')
   151    151     } {1 {database disk image is malformed}}
   152    152     do_execsql_test  3.2.3.$tn "ROLLBACK"
   153    153   }
          154  +
          155  +#--------------------------------------------------------------------------
          156  +# Test case 4.*
          157  +#
          158  +# Test that the integrity-check works if there are "notindexed" columns.
          159  +#
          160  +do_execsql_test 4.0 {
          161  +  CREATE VIRTUAL TABLE t4 USING fts4(a, b, c, notindexed=b);
          162  +  INSERT INTO t4 VALUES('text one', 'text two', 'text three');
          163  +  INSERT INTO t4(t4) VALUES('integrity-check');
          164  +}
          165  +
          166  +do_execsql_test 4.1 {
          167  +  PRAGMA writable_schema = 1;
          168  +  UPDATE sqlite_master 
          169  +    SET sql = 'CREATE VIRTUAL TABLE t4 USING fts4(a, b, c)' 
          170  +    WHERE name = 't4';
          171  +}
          172  +
          173  +do_test 4.2 {
          174  +  db close
          175  +  sqlite3 db test.db
          176  +  catchsql {
          177  +    INSERT INTO t4(t4) VALUES('integrity-check');
          178  +  }
          179  +} {1 {database disk image is malformed}}
          180  +reset_db
   154    181   
   155    182   finish_test
          183  +