/ Check-in [c9893415]
Login

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

Overview
Comment:Add a special case to the integrity-check code to check that the final integer in a doclist index is as expected.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fts5
Files: files | file ages | folders
SHA1: c98934155cb48adfda57bd0fd1b950226d45f67a
User & Date: dan 2014-08-01 20:13:49
Context
2014-08-02
20:49
Start changing things to use doclist indexes as required. code is not activated yet. check-in: b8864da9 user: dan tags: fts5
2014-08-01
20:13
Add a special case to the integrity-check code to check that the final integer in a doclist index is as expected. check-in: c9893415 user: dan tags: fts5
19:27
Have the fts5 integrity-check verify that doclist indexes match the contents of the leaf pages that they index. check-in: 37a7d303 user: dan tags: fts5
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/fts5/fts5_index.c.

  3083   3083               getVarint(&pLeaf->p[iRowidOff], (u64*)&iRowid);
  3084   3084               if( iRowid!=dliter.iRowid ) p->rc = FTS5_CORRUPT;
  3085   3085             }
  3086   3086           }
  3087   3087         }
  3088   3088         fts5DataRelease(pLeaf);
  3089   3089       }
         3090  +
         3091  +    /* There may (or may not be) a final entry in the doclist. The entry
         3092  +    ** is only present if the page following the nEmpty termless pages
         3093  +    ** (a) exists and (b) contains at least one rowid that is part of
         3094  +    ** the doclist.  */
         3095  +    if( dliter.pDlidx ){
         3096  +      if( (iter.iLeaf + iter.nEmpty)==pSeg->pgnoLast ){
         3097  +        /* The next page does not exist. So the iterator should be at EOF. */
         3098  +        if( fts5IndexDoclistIterNext(&dliter)==0 ) p->rc = FTS5_CORRUPT;
         3099  +      }else{
         3100  +        Fts5Data *pLeaf = fts5DataRead(p, iRow+i);
         3101  +        if( pLeaf ){
         3102  +          int iRowidOff = fts5GetU16(&pLeaf->p[0]);
         3103  +          if( iRowidOff==0 ){
         3104  +            if( fts5IndexDoclistIterNext(&dliter)==0 ) p->rc = FTS5_CORRUPT;
         3105  +          }else{
         3106  +            if( fts5IndexDoclistIterNext(&dliter) ){
         3107  +              p->rc = FTS5_CORRUPT;
         3108  +            }else{
         3109  +              i64 iRowid;
         3110  +              getVarint(&pLeaf->p[iRowidOff], (u64*)&iRowid);
         3111  +              if( iRowid!=dliter.iRowid ) p->rc = FTS5_CORRUPT;
         3112  +            }
         3113  +          }
         3114  +          fts5DataRelease(pLeaf);
         3115  +        }
         3116  +      }
         3117  +    }
         3118  +
  3090   3119       fts5DataRelease(dliter.pDlidx);
  3091   3120     }
  3092   3121   
  3093   3122     if( p->rc==SQLITE_OK && iter.iLeaf!=pSeg->pgnoLast ){
  3094   3123       p->rc = FTS5_CORRUPT;
  3095   3124     }
  3096   3125