/ Check-in [c9893415]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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 Unified Diffs Show Whitespace Changes Patch

Changes to ext/fts5/fts5_index.c.

3083
3084
3085
3086
3087
3088
3089





























3090
3091
3092
3093
3094
3095
3096
            getVarint(&pLeaf->p[iRowidOff], (u64*)&iRowid);
            if( iRowid!=dliter.iRowid ) p->rc = FTS5_CORRUPT;
          }
        }
      }
      fts5DataRelease(pLeaf);
    }





























    fts5DataRelease(dliter.pDlidx);
  }

  if( p->rc==SQLITE_OK && iter.iLeaf!=pSeg->pgnoLast ){
    p->rc = FTS5_CORRUPT;
  }








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
            getVarint(&pLeaf->p[iRowidOff], (u64*)&iRowid);
            if( iRowid!=dliter.iRowid ) p->rc = FTS5_CORRUPT;
          }
        }
      }
      fts5DataRelease(pLeaf);
    }

    /* There may (or may not be) a final entry in the doclist. The entry
    ** is only present if the page following the nEmpty termless pages
    ** (a) exists and (b) contains at least one rowid that is part of
    ** the doclist.  */
    if( dliter.pDlidx ){
      if( (iter.iLeaf + iter.nEmpty)==pSeg->pgnoLast ){
        /* The next page does not exist. So the iterator should be at EOF. */
        if( fts5IndexDoclistIterNext(&dliter)==0 ) p->rc = FTS5_CORRUPT;
      }else{
        Fts5Data *pLeaf = fts5DataRead(p, iRow+i);
        if( pLeaf ){
          int iRowidOff = fts5GetU16(&pLeaf->p[0]);
          if( iRowidOff==0 ){
            if( fts5IndexDoclistIterNext(&dliter)==0 ) p->rc = FTS5_CORRUPT;
          }else{
            if( fts5IndexDoclistIterNext(&dliter) ){
              p->rc = FTS5_CORRUPT;
            }else{
              i64 iRowid;
              getVarint(&pLeaf->p[iRowidOff], (u64*)&iRowid);
              if( iRowid!=dliter.iRowid ) p->rc = FTS5_CORRUPT;
            }
          }
          fts5DataRelease(pLeaf);
        }
      }
    }

    fts5DataRelease(dliter.pDlidx);
  }

  if( p->rc==SQLITE_OK && iter.iLeaf!=pSeg->pgnoLast ){
    p->rc = FTS5_CORRUPT;
  }