]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Simplifications and additional testcase() macros for btree.c. (CVS 6866)
authordrh <drh@noemail.net>
Thu, 9 Jul 2009 02:24:35 +0000 (02:24 +0000)
committerdrh <drh@noemail.net>
Thu, 9 Jul 2009 02:24:35 +0000 (02:24 +0000)
FossilOrigin-Name: 1b8c3a8246a5d8b8f5607014f68483735a403249

manifest
manifest.uuid
src/btree.c

index 2c8a8b9e7624583a5662c2120e87faaa4e953b19..49fab3e4163a3276e491078873dfbce9973519d0 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\stypo\sin\s(6861):\s"ifndef\sSQLITE_TEST"\s->\s"ifdef\sSQLITE_TEST".\s(CVS\s6865)
-D 2009-07-08T18:50:55
+C Simplifications\sand\sadditional\stestcase()\smacros\sfor\sbtree.c.\s(CVS\s6866)
+D 2009-07-09T02:24:35
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in df9359da7a726ccb67a45db905c5447d5c00c6ef
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -106,7 +106,7 @@ F src/auth.c 802a9439dfa0b8c208b10055cba400e82ef18025
 F src/backup.c 6f1c2d9862c8a3feb7739dfcca02c1f5352e37f3
 F src/bitvec.c 0ef0651714728055d43de7a4cdd95e703fac0119
 F src/btmutex.c 9b899c0d8df3bd68f527b0afe03088321b696d3c
-F src/btree.c 92c2f9f56945f99689c192835b6b9798c288a8d0
+F src/btree.c 3a97e228379449fcba6a18e88e425bcf433b1fe5
 F src/btree.h e761619e76a1125d2d82bd3613b5a7ac7d1ee6f7
 F src/btreeInt.h b31e5ac04181c7e2892c33ab06228c551df6233c
 F src/build.c 867028ee9f63f7bc8eb8d4a720bb98cf9b9a12b4
@@ -740,7 +740,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746
-P 11e295ccd28fe669ee74c846db507040895a5e5b
-R 803ee0767a7dc1fdc299bc39b74c00c2
-U danielk1977
-Z a4c2be0dc958ea0cc1e9ee2a49c75ee8
+P 890dbab28c3a1af4a1e01221318c9200574139e7
+R ecc6dc57b5c33bedd235ae3d99ecd320
+U drh
+Z 320c447326253cde8031c4d1800cda60
index 1686504a3359c9c6171f559a0d21636e6aa011b4..0e293ef54fa2d1b2f7865762bb6885a1d3a3ef13 100644 (file)
@@ -1 +1 @@
-890dbab28c3a1af4a1e01221318c9200574139e7
\ No newline at end of file
+1b8c3a8246a5d8b8f5607014f68483735a403249
\ No newline at end of file
index ba32a918b0d09c2b470646d8c3bd6a8ae6264e0c..3439c195bd29ab95ac2a7eb5e6c6047e224f8312 100644 (file)
@@ -9,7 +9,7 @@
 **    May you share freely, never taking more than you give.
 **
 *************************************************************************
-** $Id: btree.c,v 1.665 2009/07/08 18:50:55 danielk1977 Exp $
+** $Id: btree.c,v 1.666 2009/07/09 02:24:35 drh Exp $
 **
 ** This file implements a external (disk-based) database using BTrees.
 ** See the header comment on "btreeInt.h" for additional information.
@@ -4561,7 +4561,8 @@ static int allocateBtreePage(
   pPage1 = pBt->pPage1;
   mxPage = pagerPagecount(pBt);
   n = get4byte(&pPage1->aData[36]);
-  if( n>mxPage ){
+  testcase( n==mxPage-1 );
+  if( n>=mxPage ){
     return SQLITE_CORRUPT_BKPT;
   }
   if( n>0 ){
@@ -4605,6 +4606,7 @@ static int allocateBtreePage(
       }else{
         iTrunk = get4byte(&pPage1->aData[32]);
       }
+      testcase( iTrunk==mxPage );
       if( iTrunk>mxPage ){
         rc = SQLITE_CORRUPT_BKPT;
       }else{
@@ -4616,6 +4618,7 @@ static int allocateBtreePage(
       }
 
       k = get4byte(&pTrunk->aData[4]);
+      testcase( k==(u32)(pBt->usableSize/4 - 2) );
       if( k==0 && !searchList ){
         /* The trunk has no leaves and the list is not being searched. 
         ** So extract the trunk page itself and use it as the newly 
@@ -4663,6 +4666,7 @@ static int allocateBtreePage(
             rc = SQLITE_CORRUPT_BKPT;
             goto end_allocate_page;
           }
+          testcase( iNewTrunk==mxPage );
           rc = sqlite3BtreeGetPage(pBt, iNewTrunk, &pNewTrunk, 0);
           if( rc!=SQLITE_OK ){
             goto end_allocate_page;
@@ -4718,20 +4722,15 @@ static int allocateBtreePage(
         }
 
         iPage = get4byte(&aData[8+closest*4]);
+        testcase( iPage==mxPage );
         if( iPage>mxPage ){
           rc = SQLITE_CORRUPT_BKPT;
           goto end_allocate_page;
         }
+        testcase( iPage==mxPage );
         if( !searchList || iPage==nearby ){
           int noContent;
-          Pgno nPage;
           *pPgno = iPage;
-          nPage = pagerPagecount(pBt);
-          if( iPage>nPage ){
-            /* Free page off the end of the file */
-            rc = SQLITE_CORRUPT_BKPT;
-            goto end_allocate_page;
-          }
           TRACE(("ALLOCATE: %d was leaf %d of %d on trunk %d"
                  ": %d more free pages\n",
                  *pPgno, closest+1, k, pTrunk->pgno, n-1));