]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Make sure the nOverflow flag in MemPage is reset to zero after every insert. (CVS...
authordrh <drh@noemail.net>
Fri, 5 Dec 2008 20:01:43 +0000 (20:01 +0000)
committerdrh <drh@noemail.net>
Fri, 5 Dec 2008 20:01:43 +0000 (20:01 +0000)
FossilOrigin-Name: bfde3dae0c7b97308344519ca06cd4b290e8cf47

manifest
manifest.uuid
src/btree.c

index 84e5f781ddb07f1f489114372e9dcfd8fffca20d..7a880f22f7e3f37a676c0694e1b1ca29ee77f2ff 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sharmless\scompiler\swarnings.\s\sImproved\scomments\sin\sthe\squery\soptimizer.\s(CVS\s5982)
-D 2008-12-05T17:17:08
+C Make\ssure\sthe\snOverflow\sflag\sin\sMemPage\sis\sreset\sto\szero\safter\severy\sinsert.\s(CVS\s5983)
+D 2008-12-05T20:01:43
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in f7e4c81c347b04f7b0f1c1b081a168645d7b8af7
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -100,7 +100,7 @@ F src/attach.c 85c6a3d0daf11965b47604190d7cf5597dc88382
 F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627
 F src/bitvec.c 4300d311b17fb3c1476623fd895a8feac02a0b08
 F src/btmutex.c 63c5cc4ad5715690767ffcb741e185d7bc35ec1a
-F src/btree.c 372c5b32dc919fed608be57f440d054a46d002fd
+F src/btree.c b3438bc1f262b8048df9949aeb2a14cf7c55e9bd
 F src/btree.h 179c3ea813780df78a289a8f5130db18e6d4616e
 F src/btreeInt.h 8d21590c97b6a2c00cce1f78ed5dc5756e835108
 F src/build.c ce642b06016d94b0dbc34d379bac82b597baf8d5
@@ -663,7 +663,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P 46f2d08959423e130a5b346138311649d92f0fde
-R 96105d8de358fb97d30ada8cbb7880b2
+P adedd697b475dadaa2eeae0d0413603195c955cf
+R 4b745e4c65ef95b4efde274748b84506
 U drh
-Z d6ba8ef05cc5f5653a1e2350d4d75f6c
+Z 4883cace950bdb143cdb09610e9fe51d
index 3978b918715779783c93efc46960198ea1c5fce7..f9e8cbbce80a0df3442ad38008b9efc3ad36db98 100644 (file)
@@ -1 +1 @@
-adedd697b475dadaa2eeae0d0413603195c955cf
\ No newline at end of file
+bfde3dae0c7b97308344519ca06cd4b290e8cf47
\ No newline at end of file
index 1cfb7bcd9cd6aa963181513ee5cbbfa783143af9..01250750bcca2f7df893c23bb597963bff89f98c 100644 (file)
@@ -9,7 +9,7 @@
 **    May you share freely, never taking more than you give.
 **
 *************************************************************************
-** $Id: btree.c,v 1.543 2008/11/27 02:22:11 drh Exp $
+** $Id: btree.c,v 1.544 2008/12/05 20:01:43 drh Exp $
 **
 ** This file implements a external (disk-based) database using BTrees.
 ** See the header comment on "btreeInt.h" for additional information.
@@ -5537,6 +5537,7 @@ balance_cleanup:
   for(i=0; i<nNew; i++){
     releasePage(apNew[i]);
   }
+  pPage->nOverflow = 0;
 
   /* releasePage(pParent); */
   TRACE(("BALANCE: finished with %d: old=%d new=%d cells=%d\n",
@@ -5610,7 +5611,7 @@ static int balance_shallower(BtCursor *pCur){
         assert( sqlite3PagerIswriteable(pPage->pDbPage) );
         put4byte(&pPage->aData[pPage->hdrOffset+8], 
             get4byte(&pChild->aData[pChild->hdrOffset+8]));
-        freePage(pChild);
+        rc = freePage(pChild);
         TRACE(("BALANCE: child %d transfer to page 1\n", pChild->pgno));
       }else{
         /* The child has more information that will fit on the root.
@@ -5628,7 +5629,7 @@ static int balance_shallower(BtCursor *pCur){
     }
     assert( pPage->nOverflow==0 );
 #ifndef SQLITE_OMIT_AUTOVACUUM
-    if( ISAUTOVACUUM ){
+    if( ISAUTOVACUUM && rc==SQLITE_OK ){
       rc = setChildPtrmaps(pPage);
     }
 #endif
@@ -5734,14 +5735,17 @@ static int balance(BtCursor *pCur, int isInsert){
     rc = sqlite3PagerWrite(pPage->pDbPage);
     if( rc==SQLITE_OK && pPage->nOverflow>0 ){
       rc = balance_deeper(pCur);
+      assert( pPage->nOverflow==0 || rc!=SQLITE_OK );
     }
     if( rc==SQLITE_OK && pPage->nCell==0 ){
       rc = balance_shallower(pCur);
+      assert( pPage->nOverflow==0 || rc!=SQLITE_OK );
     }
   }else{
     if( pPage->nOverflow>0 || 
         (!isInsert && pPage->nFree>pPage->pBt->usableSize*2/3) ){
       rc = balance_nonroot(pCur);
+      assert( pPage->nOverflow==0 || rc!=SQLITE_OK );
     }
   }
   return rc;
@@ -5910,8 +5914,15 @@ int sqlite3BtreeInsert(
     assert( pPage->leaf );
   }
   rc = insertCell(pPage, idx, newCell, szNew, 0, 0);
-  if( rc!=SQLITE_OK ) goto end_insert;
-  rc = balance(pCur, 1);
+  if( rc==SQLITE_OK ){
+    rc = balance(pCur, 1);
+  }
+
+  /* Must make sure nOverflow is reset to zero even if the balance()
+  ** fails.  Internal data structure corruption will result otherwise. */
+  assert( pPage->nOverflow==0 || rc!=SQLITE_OK );
+  pPage->nOverflow = 0;
+
   if( rc==SQLITE_OK ){
     moveToRoot(pCur);
   }