]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Correct use of usableSize versus pageSize in btree.c. Ticket #1010. (CVS 2125)
authordrh <drh@noemail.net>
Sat, 20 Nov 2004 20:31:11 +0000 (20:31 +0000)
committerdrh <drh@noemail.net>
Sat, 20 Nov 2004 20:31:11 +0000 (20:31 +0000)
FossilOrigin-Name: 5a4013ec9cabb2c933cbf45495f5d1e8b3b20da5

manifest
manifest.uuid
src/btree.c

index 0048e2e3499132f38828181c51103e1dca22cdf1..281a4ca6c9286ed756eab06f873df1b444477702 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Better\serror\smessage\son\san\sSQLITE_RANGE\serror.\s\sTicket\s#991.\s(CVS\s2124)
-D 2004-11-20T20:18:55
+C Correct\suse\sof\susableSize\sversus\spageSize\sin\sbtree.c.\s\sTicket\s#1010.\s(CVS\s2125)
+D 2004-11-20T20:31:12
 F Makefile.in e747bb5ba34ccbdd81f79dcf1b2b33c02817c21d
 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
 F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1
@@ -29,7 +29,7 @@ F sqlite3.def dbaeb20c153e1d366e8f421b55a573f5dfc00863
 F sqlite3.pc.in 985b9bf34192a549d7d370e0f0b6b34a4f61369a
 F src/attach.c e49d09dad9f5f9fb10b4b0c1be5a70ae4c45e689
 F src/auth.c 3b81f2a42f48a62c2c9c9b0eda31a157c681edea
-F src/btree.c 49b09718cd988d1c7c981b03e94679bc10b5f711
+F src/btree.c c65849bd85dc8188c045bc6b44e70a470e624bbc
 F src/btree.h 861e40b759a195ba63819740e484390012cf81ab
 F src/build.c c7dd57fdbb330d65df241277291cad8e58687a46
 F src/date.c 65536e7ea04fdde6e0551264fca15966966e171f
@@ -260,7 +260,7 @@ F www/tclsqlite.tcl 560ecd6a916b320e59f2917317398f3d59b7cc25
 F www/vdbe.tcl 095f106d93875c94b47367384ebc870517431618
 F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
 F www/whentouse.tcl fdacb0ba2d39831e8a6240d05a490026ad4c4e4c
-P 297559c6d1a8c1172bb0c35cf538f6f2958c7820
-R e1b70aa789cac7356bd9698812787a2b
+P accd432e4d9626353e555e63298fb7a56a41e53d
+R 1ccf4dda121470590ad512e7b345f98d
 U drh
-Z 1b775c53c7601d773da3bf83ca1cbe67
+Z c6333e370a3a5a96836061f6165224d0
index 1f1e22356a2943e61cf84400eabbfd135c51e932..f9cac990af8091220cedf9cef56d3d85dd5298c9 100644 (file)
@@ -1 +1 @@
-accd432e4d9626353e555e63298fb7a56a41e53d
\ No newline at end of file
+5a4013ec9cabb2c933cbf45495f5d1e8b3b20da5
\ No newline at end of file
index 3947b57ed78dfac070869bb0e52f3c542156b9dc..6968b458b3322b7849eee97325b2fa205d054d63 100644 (file)
@@ -9,7 +9,7 @@
 **    May you share freely, never taking more than you give.
 **
 *************************************************************************
-** $Id: btree.c,v 1.220 2004/11/17 10:22:03 danielk1977 Exp $
+** $Id: btree.c,v 1.221 2004/11/20 20:31:12 drh Exp $
 **
 ** This file implements a external (disk-based) database using BTrees.
 ** For a detailed discussion of BTrees, refer to
@@ -413,10 +413,10 @@ static void put4byte(unsigned char *p, u32 v){
 
 #ifndef SQLITE_OMIT_AUTOVACUUM
 /*
-** These two macros define the location of the pointer-map entry for a 
-** database page. The first argument to each is the page size used 
-** by the database (often 1024). The second is the page number to look
-** up in the pointer map.
+** These macros define the location of the pointer-map entry for a 
+** database page. The first argument to each is the number of usable
+** bytes on each page of the database (often 1024). The second is the
+** page number to look up in the pointer map.
 **
 ** PTRMAP_PAGENO returns the database page number of the pointer-map
 ** page that stores the required pointer. PTRMAP_PTROFFSET returns
@@ -476,12 +476,12 @@ static int ptrmapPut(Btree *pBt, Pgno key, u8 eType, Pgno pgno){
   int rc;
 
   assert( key!=0 );
-  iPtrmap = PTRMAP_PAGENO(pBt->pageSize, key);
+  iPtrmap = PTRMAP_PAGENO(pBt->usableSize, key);
   rc = sqlite3pager_get(pBt->pPager, iPtrmap, (void **)&pPtrmap);
   if( rc!=SQLITE_OK ){
     return rc;
   }
-  offset = PTRMAP_PTROFFSET(pBt->pageSize, key);
+  offset = PTRMAP_PTROFFSET(pBt->usableSize, key);
 
   if( eType!=pPtrmap[offset] || get4byte(&pPtrmap[offset+1])!=pgno ){
     rc = sqlite3pager_write(pPtrmap);
@@ -509,13 +509,13 @@ static int ptrmapGet(Btree *pBt, Pgno key, u8 *pEType, Pgno *pPgno){
   int offset;        /* Offset of entry in pointer map */
   int rc;
 
-  iPtrmap = PTRMAP_PAGENO(pBt->pageSize, key);
+  iPtrmap = PTRMAP_PAGENO(pBt->usableSize, key);
   rc = sqlite3pager_get(pBt->pPager, iPtrmap, (void **)&pPtrmap);
   if( rc!=0 ){
     return rc;
   }
 
-  offset = PTRMAP_PTROFFSET(pBt->pageSize, key);
+  offset = PTRMAP_PTROFFSET(pBt->usableSize, key);
   if( pEType ) *pEType = pPtrmap[offset];
   if( pPgno ) *pPgno = get4byte(&pPtrmap[offset+1]);
 
@@ -1774,7 +1774,7 @@ static int autoVacuumCommit(Btree *pBt, Pgno *nTrunc){
   finSize = origSize - nFreeList - nPtrMap;
   if( origSize>PENDING_BYTE_PAGE(pBt) && finSize<=PENDING_BYTE_PAGE(pBt) ){
     finSize--;
-    if( PTRMAP_ISPAGE(pBt->pageSize, finSize) ){
+    if( PTRMAP_ISPAGE(pBt->usableSize, finSize) ){
       finSize--;
     }
   }
@@ -3091,7 +3091,7 @@ static int allocatePage(
     *pPgno = sqlite3pager_pagecount(pBt->pPager) + 1;
 
 #ifndef SQLITE_OMIT_AUTOVACUUM
-    if( pBt->autoVacuum && PTRMAP_ISPAGE(pBt->pageSize, *pPgno) ){
+    if( pBt->autoVacuum && PTRMAP_ISPAGE(pBt->usableSize, *pPgno) ){
       /* If *pPgno refers to a pointer-map page, allocate two new pages
       ** at the end of the file instead of one. The first allocated page
       ** becomes a new pointer-map page, the second is used by the caller.
@@ -4685,7 +4685,7 @@ int sqlite3BtreeCreateTable(Btree *pBt, int *piTable, int flags){
     /* The new root-page may not be allocated on a pointer-map page, or the
     ** PENDING_BYTE page.
     */
-    if( pgnoRoot==PTRMAP_PAGENO(pBt->pageSize, pgnoRoot) ||
+    if( pgnoRoot==PTRMAP_PAGENO(pBt->usableSize, pgnoRoot) ||
         pgnoRoot==PENDING_BYTE_PAGE(pBt) ){
       pgnoRoot++;
     }
@@ -4929,7 +4929,7 @@ int sqlite3BtreeDropTable(Btree *pBt, int iTable, int *piMoved){
       if( maxRootPgno==PENDING_BYTE_PAGE(pBt) ){
         maxRootPgno--;
       }
-      if( maxRootPgno==PTRMAP_PAGENO(pBt->pageSize, maxRootPgno) ){
+      if( maxRootPgno==PTRMAP_PAGENO(pBt->usableSize, maxRootPgno) ){
         maxRootPgno--;
       }
       assert( maxRootPgno!=PENDING_BYTE_PAGE(pBt) );
@@ -5536,7 +5536,7 @@ char *sqlite3BtreeIntegrityCheck(Btree *pBt, int *aRoot, int nRoot){
   }
   sCheck.anRef = sqliteMallocRaw( (sCheck.nPage+1)*sizeof(sCheck.anRef[0]) );
   for(i=0; i<=sCheck.nPage; i++){ sCheck.anRef[i] = 0; }
-  i = PENDING_BYTE/pBt->pageSize + 1;
+  i = PENDING_BYTE_PAGE(pBt);
   if( i<=sCheck.nPage ){
     sCheck.anRef[i] = 1;
   }
@@ -5571,11 +5571,11 @@ char *sqlite3BtreeIntegrityCheck(Btree *pBt, int *aRoot, int nRoot){
     ** references to pointer-map pages.
     */
     if( sCheck.anRef[i]==0 && 
-       (PTRMAP_PAGENO(pBt->pageSize, i)!=i || !pBt->autoVacuum) ){
+       (PTRMAP_PAGENO(pBt->usableSize, i)!=i || !pBt->autoVacuum) ){
       checkAppendMsg(&sCheck, 0, "Page %d is never used", i);
     }
     if( sCheck.anRef[i]!=0 && 
-       (PTRMAP_PAGENO(pBt->pageSize, i)==i && pBt->autoVacuum) ){
+       (PTRMAP_PAGENO(pBt->usableSize, i)==i && pBt->autoVacuum) ){
       checkAppendMsg(&sCheck, 0, "Pointer map page %d is referenced", i);
     }
 #endif