]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Reduce the number of "#ifndef SQLITE_OMIT_AUTOVACUUM" conditions in btree.c by using...
authordanielk1977 <danielk1977@noemail.net>
Sat, 19 Jul 2008 14:25:15 +0000 (14:25 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Sat, 19 Jul 2008 14:25:15 +0000 (14:25 +0000)
FossilOrigin-Name: a560c61849cb669ab03ba4a63b23369db234f329

manifest
manifest.uuid
src/btree.c

index e5923064fd0a19184ca7fe75a34f81523dfde148..f0ea8f59ff2f8448a1a14b4b74815f81b480a8ab 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C To\sensure\sSQLITE_THREADSAFE\sis\salways\sdefined,\shave\stest_mutex.c\sinclude\ssqliteInt.h.\s(CVS\s5443)
-D 2008-07-19T13:43:24
+C Reduce\sthe\snumber\sof\s"#ifndef\sSQLITE_OMIT_AUTOVACUUM"\sconditions\sin\sbtree.c\sby\susing\sthe\sISAUTOVACUUM\smacro\sinstead.\s(CVS\s5444)
+D 2008-07-19T14:25:16
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in a03f7cb4f7ad50bc53a788c6c544430e81f95de4
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -96,7 +96,7 @@ F src/attach.c b18ba42c77f7d3941f5d23d2ca20fa1d841a4e91
 F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627
 F src/bitvec.c 95c86bd18d8fedf0533f5af196192546e10a7e7d
 F src/btmutex.c 709cad2cdca0afd013f0f612363810e53f59ec53
-F src/btree.c 7303414d1afc4c56c8e16eb530fbd902c1243fbc
+F src/btree.c 1318ab0eaad158aad791d73611c1c63c9b5e981f
 F src/btree.h 03256ed7ee42b5ecacbe887070b0f8249e7d069d
 F src/btreeInt.h 6e4cb69a9192a8d609c27034ae5f921cf0ecdde1
 F src/build.c bac7233d984be3805aaa41cf500f7ee12dc97249
@@ -608,7 +608,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P 9992b1aecdbbc7a260f00cb6ef78b500aeab22df
-R 615c9acc5406836f8f320d7701ad2533
+P d8be91e2d2737dcb0e82e6c8a6a3f4827bc98d63
+R 62e45d7b8ed334b4b86371bb551b8bcf
 U danielk1977
-Z 549920f4a7d84d25c74c12bb9c25624e
+Z 4b754cdd81d101220a03014dfb941ae8
index 34401185afa5f90d9b23134bd70fdbbf8398ab79..69ca1bb5b2c9b123520a662496df4fb890799507 100644 (file)
@@ -1 +1 @@
-d8be91e2d2737dcb0e82e6c8a6a3f4827bc98d63
\ No newline at end of file
+a560c61849cb669ab03ba4a63b23369db234f329
\ No newline at end of file
index 1594156fcd5e06bbe9f3259a305646ee42e21d51..a51ed1b7826eed62afa21092ace0ba166cc4bbbe 100644 (file)
@@ -9,7 +9,7 @@
 **    May you share freely, never taking more than you give.
 **
 *************************************************************************
-** $Id: btree.c,v 1.490 2008/07/19 11:49:07 danielk1977 Exp $
+** $Id: btree.c,v 1.491 2008/07/19 14:25:16 danielk1977 Exp $
 **
 ** This file implements a external (disk-based) database using BTrees.
 ** See the header comment on "btreeInt.h" for additional information.
@@ -507,7 +507,11 @@ static int ptrmapGet(BtShared *pBt, Pgno key, u8 *pEType, Pgno *pPgno){
   return SQLITE_OK;
 }
 
-#endif /* SQLITE_OMIT_AUTOVACUUM */
+#else /* if defined SQLITE_OMIT_AUTOVACUUM */
+  #define ptrmapPut(w,x,y,z) SQLITE_OK
+  #define ptrmapGet(w,x,y,z) SQLITE_OK
+  #define ptrmapPutOvfl(y,z) SQLITE_OK
+#endif
 
 /*
 ** Given a btree page and a cell index (0 means the first cell on
@@ -4283,15 +4287,13 @@ static int freePage(MemPage *pPage){
   memset(pPage->aData, 0, pPage->pBt->pageSize);
 #endif
 
-#ifndef SQLITE_OMIT_AUTOVACUUM
   /* If the database supports auto-vacuum, write an entry in the pointer-map
   ** to indicate that the page is free.
   */
-  if( pBt->autoVacuum ){
+  if( ISAUTOVACUUM ){
     rc = ptrmapPut(pBt, pPage->pgno, PTRMAP_FREEPAGE, 0);
     if( rc ) return rc;
   }
-#endif
 
   if( n==0 ){
     /* This is the first free page */
@@ -4560,8 +4562,7 @@ static int reparentPage(
     sqlite3PagerUnref(pDbPage);
   }
 
-#ifndef SQLITE_OMIT_AUTOVACUUM
-  if( pBt->autoVacuum && updatePtrmap ){
+  if( ISAUTOVACUUM && updatePtrmap ){
     return ptrmapPut(pBt, pgno, PTRMAP_BTREE, pNewParent->pgno);
   }
 
@@ -4569,7 +4570,7 @@ static int reparentPage(
   /* If the updatePtrmap flag was clear, assert that the entry in the
   ** pointer-map is already correct.
   */
-  if( pBt->autoVacuum ){
+  if( ISAUTOVACUUM ){
     u8 eType;
     Pgno ii;
     ptrmapGet(pBt, pgno, &eType, &ii);
@@ -4577,7 +4578,6 @@ static int reparentPage(
   }
 #endif
 
-#endif
   return SQLITE_OK;
 }
 
@@ -4882,12 +4882,11 @@ static int balance_quick(MemPage *pPage, MemPage *pParent){
   put4byte(findOverflowCell(pParent,parentIdx), pPage->pgno);
   put4byte(&pParent->aData[pParent->hdrOffset+8], pgnoNew);
 
-#ifndef SQLITE_OMIT_AUTOVACUUM
   /* If this is an auto-vacuum database, update the pointer map
   ** with entries for the new page, and any pointer from the 
   ** cell on the page to an overflow page.
   */
-  if( pBt->autoVacuum ){
+  if( ISAUTOVACUUM ){
     rc = ptrmapPut(pBt, pgnoNew, PTRMAP_BTREE, pParent->pgno);
     if( rc==SQLITE_OK ){
       rc = ptrmapPutOvfl(pNew, 0);
@@ -4897,7 +4896,6 @@ static int balance_quick(MemPage *pPage, MemPage *pParent){
       return rc;
     }
   }
-#endif
 
   /* Release the reference to the new page and balance the parent page,
   ** in case the divider cell inserted caused it to become overfull.
@@ -4969,9 +4967,7 @@ static int balance_nonroot(MemPage *pPage){
   u8 *aCopy[NB];         /* Space for holding data of apCopy[] */
   u8 *aSpace1;           /* Space for copies of dividers cells before balance */
   u8 *aSpace2 = 0;       /* Space for overflow dividers cells after balance */
-#ifndef SQLITE_OMIT_AUTOVACUUM
   u8 *aFrom = 0;
-#endif
 
   assert( sqlite3_mutex_held(pPage->pBt->mutex) );
 
@@ -5107,11 +5103,9 @@ static int balance_nonroot(MemPage *pPage){
   }
   aSpace1 = &aCopy[NB-1][pBt->pageSize+ROUND8(sizeof(MemPage))];
   assert( ((aSpace1 - (u8*)apCell) & 7)==0 ); /* 8-byte alignment required */
-#ifndef SQLITE_OMIT_AUTOVACUUM
-  if( pBt->autoVacuum ){
+  if( ISAUTOVACUUM ){
     aFrom = &aSpace1[pBt->pageSize];
   }
-#endif
   aSpace2 = sqlite3PageMalloc(pBt->pageSize);
   if( aSpace2==0 ){
     rc = SQLITE_NOMEM;
@@ -5157,8 +5151,7 @@ static int balance_nonroot(MemPage *pPage){
       assert( nCell<nMaxCells );
       apCell[nCell] = findOverflowCell(pOld, j);
       szCell[nCell] = cellSizePtr(pOld, apCell[nCell]);
-#ifndef SQLITE_OMIT_AUTOVACUUM
-      if( pBt->autoVacuum ){
+      if( ISAUTOVACUUM ){
         int a;
         aFrom[nCell] = i;
         for(a=0; a<pOld->nOverflow; a++){
@@ -5168,7 +5161,6 @@ static int balance_nonroot(MemPage *pPage){
           }
         }
       }
-#endif
       nCell++;
     }
     if( i<nOld-1 ){
@@ -5190,11 +5182,9 @@ static int balance_nonroot(MemPage *pPage){
         assert( iSpace1<=pBt->pageSize );
         memcpy(pTemp, apDiv[i], sz);
         apCell[nCell] = pTemp+leafCorrection;
-#ifndef SQLITE_OMIT_AUTOVACUUM
-        if( pBt->autoVacuum ){
+        if( ISAUTOVACUUM ){
           aFrom[nCell] = 0xFF;
         }
-#endif
         dropCell(pParent, nxDiv, sz);
         szCell[nCell] -= leafCorrection;
         assert( get4byte(pTemp)==pgnoOld[i] );
@@ -5381,8 +5371,7 @@ static int balance_nonroot(MemPage *pPage){
     ** children of cells, the right-child of the page, or overflow pages
     ** pointed to by cells.
     */
-#ifndef SQLITE_OMIT_AUTOVACUUM
-    if( pBt->autoVacuum ){
+    if( ISAUTOVACUUM ){
       for(k=j; k<cntNew[i]; k++){
         assert( k<nMaxCells );
         if( aFrom[k]==0xFF || apCopy[aFrom[k]]->pgno!=pNew->pgno ){
@@ -5396,7 +5385,6 @@ static int balance_nonroot(MemPage *pPage){
         }
       }
     }
-#endif
 
     j = cntNew[i];
 
@@ -5414,8 +5402,7 @@ static int balance_nonroot(MemPage *pPage){
       pTemp = &aSpace2[iSpace2];
       if( !pNew->leaf ){
         memcpy(&pNew->aData[8], pCell, 4);
-#ifndef SQLITE_OMIT_AUTOVACUUM
-        if( pBt->autoVacuum 
+        if( ISAUTOVACUUM 
          && (aFrom[j]==0xFF || apCopy[aFrom[j]]->pgno!=pNew->pgno)
         ){
           rc = ptrmapPut(pBt, get4byte(pCell), PTRMAP_BTREE, pNew->pgno);
@@ -5423,7 +5410,6 @@ static int balance_nonroot(MemPage *pPage){
             goto balance_cleanup;
           }
         }
-#endif
       }else if( leafData ){
         /* If the tree is a leaf-data tree, and the siblings are leaves, 
         ** then there is no divider cell in apCell[]. Instead, the divider 
@@ -5460,31 +5446,28 @@ static int balance_nonroot(MemPage *pPage){
       rc = insertCell(pParent, nxDiv, pCell, sz, pTemp, 4);
       if( rc!=SQLITE_OK ) goto balance_cleanup;
       put4byte(findOverflowCell(pParent,nxDiv), pNew->pgno);
-#ifndef SQLITE_OMIT_AUTOVACUUM
+
       /* If this is an auto-vacuum database, and not a leaf-data tree,
       ** then update the pointer map with an entry for the overflow page
       ** that the cell just inserted points to (if any).
       */
-      if( pBt->autoVacuum && !leafData ){
+      if( ISAUTOVACUUM && !leafData ){
         rc = ptrmapPutOvfl(pParent, nxDiv);
         if( rc!=SQLITE_OK ){
           goto balance_cleanup;
         }
       }
-#endif
       j++;
       nxDiv++;
     }
 
-#ifndef SQLITE_OMIT_AUTOVACUUM
     /* Set the pointer-map entry for the new sibling page. */
-    if( pBt->autoVacuum ){
+    if( ISAUTOVACUUM ){
       rc = ptrmapPut(pBt, pNew->pgno, PTRMAP_BTREE, pParent->pgno);
       if( rc!=SQLITE_OK ){
         goto balance_cleanup;
       }
     }
-#endif
   }
   assert( j==nCell );
   assert( nOld>0 );
@@ -5492,14 +5475,12 @@ static int balance_nonroot(MemPage *pPage){
   if( (pageFlags & PTF_LEAF)==0 ){
     u8 *zChild = &apCopy[nOld-1]->aData[8];
     memcpy(&apNew[nNew-1]->aData[8], zChild, 4);
-#ifndef SQLITE_OMIT_AUTOVACUUM
-    if( pBt->autoVacuum ){
+    if( ISAUTOVACUUM ){
       rc = ptrmapPut(pBt, get4byte(zChild), PTRMAP_BTREE, apNew[nNew-1]->pgno);
       if( rc!=SQLITE_OK ){
         goto balance_cleanup;
       }
     }
-#endif
   }
   if( nxDiv==pParent->nCell+pParent->nOverflow ){
     /* Right-most sibling is the right-most child of pParent */
@@ -5627,8 +5608,7 @@ static int balance_shallower(MemPage *pPage){
     }
     rc = reparentChildPages(pPage, 1);
     assert( pPage->nOverflow==0 );
-#ifndef SQLITE_OMIT_AUTOVACUUM
-    if( pBt->autoVacuum ){
+    if( ISAUTOVACUUM ){
       int i;
       for(i=0; i<pPage->nCell; i++){ 
         rc = ptrmapPutOvfl(pPage, i);
@@ -5637,7 +5617,6 @@ static int balance_shallower(MemPage *pPage){
         }
       }
     }
-#endif
     releasePage(pChild);
   }
 end_shallow_balance:
@@ -5692,8 +5671,7 @@ static int balance_deeper(MemPage *pPage){
   zeroPage(pPage, pChild->aData[0] & ~PTF_LEAF);
   put4byte(&pPage->aData[pPage->hdrOffset+8], pgnoChild);
   TRACE(("BALANCE: copy root %d into %d\n", pPage->pgno, pChild->pgno));
-#ifndef SQLITE_OMIT_AUTOVACUUM
-  if( pBt->autoVacuum ){
+  if( ISAUTOVACUUM ){
     int i;
     rc = ptrmapPut(pBt, pChild->pgno, PTRMAP_BTREE, pPage->pgno);
     if( rc ) goto balancedeeper_out;
@@ -5705,7 +5683,6 @@ static int balance_deeper(MemPage *pPage){
     }
     rc = reparentChildPages(pChild, 1);
   }
-#endif
   if( rc==SQLITE_OK ){
     rc = balance_nonroot(pChild);
   }