]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Reactivate an older assert() (adding an "|| CORRUPT_DB" term) and add a
authordrh <drh@noemail.net>
Wed, 25 Mar 2015 13:06:54 +0000 (13:06 +0000)
committerdrh <drh@noemail.net>
Wed, 25 Mar 2015 13:06:54 +0000 (13:06 +0000)
new assert() in btree.c.

FossilOrigin-Name: 1e96520ac1d12ca83f019a60482efa0a074f2f94

manifest
manifest.uuid
src/btree.c

index e78289f5945ac2b1a43d472c980de8f42427db2e..a0f706c6357eda1bdc97b17d88c0f2ce2dc0f18f 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\stwo\snew\sassert()s\sto\sthe\ssqlite3BtreeDataSize()\smethod.
-D 2015-03-25T12:05:49.756
+C Reactivate\san\solder\sassert()\s(adding\san\s"||\sCORRUPT_DB"\sterm)\sand\sadd\sa\nnew\sassert()\sin\sbtree.c.
+D 2015-03-25T13:06:54.837
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 88a3e6261286db378fdffa1124cad11b3c05f5bb
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -173,7 +173,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240
 F src/backup.c ff743689c4d6c5cb55ad42ed9d174b2b3e71f1e3
 F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb
 F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79
-F src/btree.c 8d92800add6e237c883b286845d8159911acdf54
+F src/btree.c 3634c2ee748bbbb2488cdca9dc8fc8c7bdc2f66f
 F src/btree.h 969adc948e89e449220ff0ff724c94bb2a52e9f1
 F src/btreeInt.h 2bfefc01875d8da066504c233ec259fcb3b2ef72
 F src/build.c 0419bba592c22f6d00e6d57a2ca7136720d02c1a
@@ -1246,7 +1246,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 cae3239aa58b4f7016fc9dcac3966fe6ef833879
-R 9d1846f3cd769389c238477907eb38ab
+P 42d1793d6516e285a8925bbfd96b3d3375603d15
+R 90535e28cf02760b75aa0324ce2f944c
 U drh
-Z 681e7b9df0d47c3c796413431bb9a3b2
+Z 7ee968129b9c07925188972da6333faa
index 484d3c2181cd50ba9376bfe6f93d06856f47ec08..d4bfb47acf64557d8523a5e963313de6187ac159 100644 (file)
@@ -1 +1 @@
-42d1793d6516e285a8925bbfd96b3d3375603d15
\ No newline at end of file
+1e96520ac1d12ca83f019a60482efa0a074f2f94
\ No newline at end of file
index 1e0e57fe2eca160607758bb8413447053f2897f7..ac350ac92fe934caf194194ea3706c29acf8b450 100644 (file)
@@ -4511,7 +4511,7 @@ static int moveToChild(BtCursor *pCur, u32 newPgno){
   return SQLITE_OK;
 }
 
-#if 0
+#if SQLITE_DEBUG
 /*
 ** Page pParent is an internal (non-leaf) tree page. This function 
 ** asserts that page number iChild is the left-child if the iIdx'th
@@ -4520,6 +4520,8 @@ static int moveToChild(BtCursor *pCur, u32 newPgno){
 ** the page.
 */
 static void assertParentIndex(MemPage *pParent, int iIdx, Pgno iChild){
+  if( CORRUPT_DB ) return;  /* The conditions tested below might not be true
+                            ** in a corrupt database */
   assert( iIdx<=pParent->nCell );
   if( iIdx==pParent->nCell ){
     assert( get4byte(&pParent->aData[pParent->hdrOffset+8])==iChild );
@@ -4544,19 +4546,11 @@ static void moveToParent(BtCursor *pCur){
   assert( pCur->eState==CURSOR_VALID );
   assert( pCur->iPage>0 );
   assert( pCur->apPage[pCur->iPage] );
-
-  /* UPDATE: It is actually possible for the condition tested by the assert
-  ** below to be untrue if the database file is corrupt. This can occur if
-  ** one cursor has modified page pParent while a reference to it is held 
-  ** by a second cursor. Which can only happen if a single page is linked
-  ** into more than one b-tree structure in a corrupt database.  */
-#if 0
   assertParentIndex(
     pCur->apPage[pCur->iPage-1], 
     pCur->aiIdx[pCur->iPage-1], 
     pCur->apPage[pCur->iPage]->pgno
   );
-#endif
   testcase( pCur->aiIdx[pCur->iPage-1] > pCur->apPage[pCur->iPage-1]->nCell );
 
   releasePage(pCur->apPage[pCur->iPage]);
@@ -7504,6 +7498,7 @@ static int balance(BtCursor *pCur){
       /* The next iteration of the do-loop balances the parent page. */
       releasePage(pPage);
       pCur->iPage--;
+      assert( pCur->iPage>=0 );
     }
   }while( rc==SQLITE_OK );