]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add a special case to the integrity-check code to check that the final integer in...
authordan <dan@noemail.net>
Fri, 1 Aug 2014 20:13:49 +0000 (20:13 +0000)
committerdan <dan@noemail.net>
Fri, 1 Aug 2014 20:13:49 +0000 (20:13 +0000)
FossilOrigin-Name: c98934155cb48adfda57bd0fd1b950226d45f67a

ext/fts5/fts5_index.c
manifest
manifest.uuid

index 685492d0b743e7ec4a773c81cc3f1bd76dcd0f38..8c4734e26520841f7a5935ce3c9ba8620ed65914 100644 (file)
@@ -3087,6 +3087,35 @@ static void fts5IndexIntegrityCheckSegment(
       }
       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);
   }
 
index ec7f134bbc257652b5080e2caffeecaa5a82d50e..089486568edde45334d62597c1abafe1c5f84a70 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Have\sthe\sfts5\sintegrity-check\sverify\sthat\sdoclist\sindexes\smatch\sthe\scontents\sof\sthe\sleaf\spages\sthat\sthey\sindex.
-D 2014-08-01T19:27:07.492
+C Add\sa\sspecial\scase\sto\sthe\sintegrity-check\scode\sto\scheck\sthat\sthe\sfinal\sinteger\sin\sa\sdoclist\sindex\sis\sas\sexpected.
+D 2014-08-01T20:13:49.462
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in b03432313a3aad96c706f8164fb9f5307eaf19f5
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -110,7 +110,7 @@ F ext/fts5/fts5_aux.c 366057c7186bc3615deb5ecc0ff61de50b6d2dbc
 F ext/fts5/fts5_buffer.c 248c61ac9fec001602efc72a45704f3b8d367c00
 F ext/fts5/fts5_config.c f4ebf143e141b8c77355e3b15aba81b7be51d710
 F ext/fts5/fts5_expr.c e764d75c58a3accda795f1da1b45960ac87dc77a
-F ext/fts5/fts5_index.c 3e33e3b86f026fc5b2cb3c573ba05375c8e4de0b
+F ext/fts5/fts5_index.c 13f9dd9788f90c419ea33db0fcb2214c2f1290ef
 F ext/fts5/fts5_storage.c 2866e7e1de9dc851756c3a9c76b6e1d75e0facb7
 F ext/fts5/fts5parse.y 777da8e5819f75c217982c79c29d014c293acac9
 F ext/icu/README.txt d9fbbad0c2f647c3fdf715fc9fd64af53aedfc43
@@ -1199,7 +1199,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 89377421ff69f2450364987afe781b6d8bcbf087
-R 49a5d37abb265ab7fa662e06ee8ea874
+P 37a7d3035eb4bbad7e32fe550321ac9fae611a57
+R 21856f96ed42128f5622f6977d9547a6
 U dan
-Z 90844fe42071f9a2a3f80f69e16c73d8
+Z 83c769d88a67f25fcdc4af671199630b
index e25707dfd10d9b20ea6bbadf221707dbf6492f1a..312136f10970fab98946892bbe9f8325321d915a 100644 (file)
@@ -1 +1 @@
-37a7d3035eb4bbad7e32fe550321ac9fae611a57
\ No newline at end of file
+c98934155cb48adfda57bd0fd1b950226d45f67a
\ No newline at end of file