]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Remove the MemPage.idxShift variable. It is no longer required. (CVS 5750)
authordanielk1977 <danielk1977@noemail.net>
Mon, 29 Sep 2008 15:53:25 +0000 (15:53 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Mon, 29 Sep 2008 15:53:25 +0000 (15:53 +0000)
FossilOrigin-Name: 7354abd03be756b1d7d0a3d5b8958f5c0c985ff5

manifest
manifest.uuid
src/btree.c
src/btreeInt.h

index 84d5710650b5aa0e1e8af4b763901c3f7960be64..df150eff1e7d7e92330e3555dc6dd1259b69c422 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Do\snot\srun\svacuum.test\sas\spart\sof\sthe\s"exclusive"\spermutation\stest.\s(CVS\s5749)
-D 2008-09-29T14:27:41
+C Remove\sthe\sMemPage.idxShift\svariable.\sIt\sis\sno\slonger\srequired.\s(CVS\s5750)
+D 2008-09-29T15:53:26
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in e4ab842f9a64ef61d57093539a8aab76b12810db
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -99,9 +99,9 @@ F src/attach.c db3f4a60538733c1e4dcb9d0217a6e0d6ccd615b
 F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627
 F src/bitvec.c 95c86bd18d8fedf0533f5af196192546e10a7e7d
 F src/btmutex.c 709cad2cdca0afd013f0f612363810e53f59ec53
-F src/btree.c 8fc7c0bd577e0e8850d95b0f8d927c983e53deab
+F src/btree.c 002084e207070d17e29863a7453409fd8717dd73
 F src/btree.h 6371c5e599fab391a150c96afbc10062b276d107
-F src/btreeInt.h a9388a5e5998cec0b79c2024e6740d12d094ad17
+F src/btreeInt.h 3e93c0a6f363bbf68fdd975620f4d3671b6cf7bc
 F src/build.c 160c71acca8f643f436ed6c1ee2f684c88df4dfe
 F src/callback.c 7a40fd44da3eb89e7f6eff30aa6f940c45d73a97
 F src/complete.c cb14e06dbe79dee031031f0d9e686ff306afe07c
@@ -637,7 +637,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P 292acaf7c4e68b532cc8d1763e02aa79d90ea20c
-R 2e374347a03a1d74809c97c540cb28f9
+P 2fb15ae9e9af716a5684a21826814bc4c332a596
+R 45649b03c1be1592a9f04aa95ab9d358
 U danielk1977
-Z c73cbb2539399e32cc6d96320e7fb756
+Z 44ecc5d9fa4059a6de64d456c7327e83
index b92f0039cf3b74298625b4488ca87160009c8823..7f3f055fb273edeae5a8a6cee6cce84360a49427 100644 (file)
@@ -1 +1 @@
-2fb15ae9e9af716a5684a21826814bc4c332a596
\ No newline at end of file
+7354abd03be756b1d7d0a3d5b8958f5c0c985ff5
\ No newline at end of file
index 2b0b386db4d17dcd31cd04035e577a54e3c03faf..f284cd4c3efc7f703bf8e5e7eb26235cf2a1eb33 100644 (file)
@@ -9,7 +9,7 @@
 **    May you share freely, never taking more than you give.
 **
 *************************************************************************
-** $Id: btree.c,v 1.518 2008/09/29 11:49:48 danielk1977 Exp $
+** $Id: btree.c,v 1.519 2008/09/29 15:53:26 danielk1977 Exp $
 **
 ** This file implements a external (disk-based) database using BTrees.
 ** See the header comment on "btreeInt.h" for additional information.
@@ -944,7 +944,6 @@ int sqlite3BtreeInitPage(MemPage *pPage){
     assert( pBt->pageSize>=512 && pBt->pageSize<=32768 );
     pPage->maskPage = pBt->pageSize - 1;
     pPage->nOverflow = 0;
-    pPage->idxShift = 0;
     usableSize = pBt->usableSize;
     pPage->cellOffset = cellOffset = hdr + 12 - 4*pPage->leaf;
     top = get2byte(&data[hdr+5]);
@@ -1031,7 +1030,6 @@ static void zeroPage(MemPage *pPage, int flags){
   pPage->nOverflow = 0;
   assert( pBt->pageSize>=512 && pBt->pageSize<=32768 );
   pPage->maskPage = pBt->pageSize - 1;
-  pPage->idxShift = 0;
   pPage->nCell = 0;
   pPage->isInit = 1;
 }
@@ -3443,7 +3441,6 @@ static int moveToChild(BtCursor *pCur, u32 newPgno){
   }
   rc = getAndInitPage(pBt, newPgno, &pNewPage);
   if( rc ) return rc;
-  pCur->apPage[i]->idxShift = 0;
   pCur->apPage[i+1] = pNewPage;
   pCur->aiIdx[i+1] = 0;
   pCur->iPage++;
@@ -3456,6 +3453,26 @@ static int moveToChild(BtCursor *pCur, u32 newPgno){
   return SQLITE_OK;
 }
 
+#ifndef NDEBUG
+/*
+** Page pParent is an internal (non-leaf) tree page. This function 
+** asserts that page number iChild is the left-child if the iIdx'th
+** cell in page pParent. Or, if iIdx is equal to the total number of
+** cells in pParent, that page number iChild is the right-child of
+** the page.
+*/
+static void assertParentIndex(MemPage *pParent, int iIdx, Pgno iChild){
+  assert( iIdx<=pParent->nCell );
+  if( iIdx==pParent->nCell ){
+    assert( get4byte(&pParent->aData[pParent->hdrOffset+8])==iChild );
+  }else{
+    assert( get4byte(findCell(pParent, iIdx))==iChild );
+  }
+}
+#else
+#  define assertParentIndex(x,y,z) 
+#endif
+
 /*
 ** Move the cursor up to the parent page.
 **
@@ -3469,12 +3486,15 @@ void sqlite3BtreeMoveToParent(BtCursor *pCur){
   assert( pCur->eState==CURSOR_VALID );
   assert( pCur->iPage>0 );
   assert( pCur->apPage[pCur->iPage] );
-
+  assertParentIndex(
+    pCur->apPage[pCur->iPage-1], 
+    pCur->aiIdx[pCur->iPage-1], 
+    pCur->apPage[pCur->iPage]->pgno
+  );
   releasePage(pCur->apPage[pCur->iPage]);
   pCur->iPage--;
   pCur->info.nSize = 0;
   pCur->validNKey = 0;
-  assert( pCur->apPage[pCur->iPage]->idxShift==0 );
 }
 
 /*
@@ -4589,7 +4609,6 @@ static int reparentChildPages(MemPage *pPage, int updatePtrmap){
       if( rc!=SQLITE_OK ) return rc;
     }
     rc = reparentPage(pBt, iRight, pPage, i, updatePtrmap);
-    pPage->idxShift = 0;
   }
   return rc;
 }
@@ -4624,7 +4643,6 @@ static void dropCell(MemPage *pPage, int idx, int sz){
   pPage->nCell--;
   put2byte(&data[pPage->hdrOffset+3], pPage->nCell);
   pPage->nFree += 2;
-  pPage->idxShift = 1;
 }
 
 /*
@@ -4704,7 +4722,6 @@ static int insertCell(
     }
     put2byte(&data[ins], idx);
     put2byte(&data[hdr+3], pPage->nCell);
-    pPage->idxShift = 1;
 #ifndef SQLITE_OMIT_AUTOVACUUM
     if( pPage->pBt->autoVacuum ){
       /* The cell may contain a pointer to an overflow page. If so, write
@@ -4833,12 +4850,6 @@ static int balance_quick(BtCursor *pCur){
     assemblePage(pNew, 1, &pCell, &szCell);
     pPage->nOverflow = 0;
   
-    /* Set the parent of the newly allocated page to pParent. */
-#if 0
-    pNew->pParent = pParent;
-    sqlite3PagerRef(pParent->pDbPage);
-#endif
-  
     /* pPage is currently the right-child of pParent. Change this
     ** so that the right-child is the new page allocated above and
     ** pPage is the next-to-right child. 
@@ -5023,27 +5034,14 @@ static int balance_nonroot(BtCursor *pCur){
   ** to pPage.  The "idx" variable is the index of that cell.  If pPage
   ** is the rightmost child of pParent then set idx to pParent->nCell 
   */
-  if( pParent->idxShift ){
-    Pgno pgno;
-    pgno = pPage->pgno;
-    assert( pgno==sqlite3PagerPagenumber(pPage->pDbPage) );
-    for(idx=0; idx<pParent->nCell; idx++){
-      if( get4byte(findCell(pParent, idx))==pgno ){
-        break;
-      }
-    }
-    assert( idx<pParent->nCell
-             || get4byte(&pParent->aData[pParent->hdrOffset+8])==pgno );
-  }else{
-    idx = pCur->aiIdx[pCur->iPage-1];
-  }
+  idx = pCur->aiIdx[pCur->iPage-1];
+  assertParentIndex(pParent, idx, pPage->pgno);
 
   /*
   ** Initialize variables so that it will be safe to jump
   ** directly to balance_cleanup at any moment.
   */
   nOld = nNew = 0;
-  /* sqlite3PagerRef(pParent->pDbPage); */
 
   /*
   ** Find sibling pages to pPage and the cells in pParent that divide
@@ -5732,6 +5730,7 @@ static int balance_deeper(BtCursor *pCur){
   if( rc==SQLITE_OK ){
     pCur->iPage++;
     pCur->apPage[1] = pChild;
+    pCur->aiIdx[0] = 0;
     rc = balance_nonroot(pCur);
   }else{
     releasePage(pChild);
index a10eb488b3cd56870174bc1391dfe1ed7d68ad82..14b852bc97f1d00a1a68da01da9176ca48e5f730 100644 (file)
@@ -9,7 +9,7 @@
 **    May you share freely, never taking more than you give.
 **
 *************************************************************************
-** $Id: btreeInt.h,v 1.32 2008/09/29 11:49:48 danielk1977 Exp $
+** $Id: btreeInt.h,v 1.33 2008/09/29 15:53:26 danielk1977 Exp $
 **
 ** This file implements a external (disk-based) database using BTrees.
 ** For a detailed discussion of BTrees, refer to
@@ -271,7 +271,6 @@ typedef struct BtLock BtLock;
 */
 struct MemPage {
   u8 isInit;           /* True if previously initialized. MUST BE FIRST! */
-  u8 idxShift;         /* True if Cell indices have changed */
   u8 nOverflow;        /* Number of overflow cell bodies in aCell[] */
   u8 intKey;           /* True if intkey flag is set */
   u8 leaf;             /* True if leaf flag is set */