mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Correct use of usableSize versus pageSize in btree.c. Ticket #1010. (CVS 2125)
FossilOrigin-Name: 5a4013ec9cabb2c933cbf45495f5d1e8b3b20da5
This commit is contained in:
12
manifest
12
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Better\serror\smessage\son\san\sSQLITE_RANGE\serror.\s\sTicket\s#991.\s(CVS\s2124)
|
C Correct\suse\sof\susableSize\sversus\spageSize\sin\sbtree.c.\s\sTicket\s#1010.\s(CVS\s2125)
|
||||||
D 2004-11-20T20:18:55
|
D 2004-11-20T20:31:12
|
||||||
F Makefile.in e747bb5ba34ccbdd81f79dcf1b2b33c02817c21d
|
F Makefile.in e747bb5ba34ccbdd81f79dcf1b2b33c02817c21d
|
||||||
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
|
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
|
||||||
F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1
|
F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1
|
||||||
@@ -29,7 +29,7 @@ F sqlite3.def dbaeb20c153e1d366e8f421b55a573f5dfc00863
|
|||||||
F sqlite3.pc.in 985b9bf34192a549d7d370e0f0b6b34a4f61369a
|
F sqlite3.pc.in 985b9bf34192a549d7d370e0f0b6b34a4f61369a
|
||||||
F src/attach.c e49d09dad9f5f9fb10b4b0c1be5a70ae4c45e689
|
F src/attach.c e49d09dad9f5f9fb10b4b0c1be5a70ae4c45e689
|
||||||
F src/auth.c 3b81f2a42f48a62c2c9c9b0eda31a157c681edea
|
F src/auth.c 3b81f2a42f48a62c2c9c9b0eda31a157c681edea
|
||||||
F src/btree.c 49b09718cd988d1c7c981b03e94679bc10b5f711
|
F src/btree.c c65849bd85dc8188c045bc6b44e70a470e624bbc
|
||||||
F src/btree.h 861e40b759a195ba63819740e484390012cf81ab
|
F src/btree.h 861e40b759a195ba63819740e484390012cf81ab
|
||||||
F src/build.c c7dd57fdbb330d65df241277291cad8e58687a46
|
F src/build.c c7dd57fdbb330d65df241277291cad8e58687a46
|
||||||
F src/date.c 65536e7ea04fdde6e0551264fca15966966e171f
|
F src/date.c 65536e7ea04fdde6e0551264fca15966966e171f
|
||||||
@@ -260,7 +260,7 @@ F www/tclsqlite.tcl 560ecd6a916b320e59f2917317398f3d59b7cc25
|
|||||||
F www/vdbe.tcl 095f106d93875c94b47367384ebc870517431618
|
F www/vdbe.tcl 095f106d93875c94b47367384ebc870517431618
|
||||||
F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
|
F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
|
||||||
F www/whentouse.tcl fdacb0ba2d39831e8a6240d05a490026ad4c4e4c
|
F www/whentouse.tcl fdacb0ba2d39831e8a6240d05a490026ad4c4e4c
|
||||||
P 297559c6d1a8c1172bb0c35cf538f6f2958c7820
|
P accd432e4d9626353e555e63298fb7a56a41e53d
|
||||||
R e1b70aa789cac7356bd9698812787a2b
|
R 1ccf4dda121470590ad512e7b345f98d
|
||||||
U drh
|
U drh
|
||||||
Z 1b775c53c7601d773da3bf83ca1cbe67
|
Z c6333e370a3a5a96836061f6165224d0
|
||||||
|
@@ -1 +1 @@
|
|||||||
accd432e4d9626353e555e63298fb7a56a41e53d
|
5a4013ec9cabb2c933cbf45495f5d1e8b3b20da5
|
32
src/btree.c
32
src/btree.c
@@ -9,7 +9,7 @@
|
|||||||
** May you share freely, never taking more than you give.
|
** 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.
|
** This file implements a external (disk-based) database using BTrees.
|
||||||
** For a detailed discussion of BTrees, refer to
|
** For a detailed discussion of BTrees, refer to
|
||||||
@@ -413,10 +413,10 @@ static void put4byte(unsigned char *p, u32 v){
|
|||||||
|
|
||||||
#ifndef SQLITE_OMIT_AUTOVACUUM
|
#ifndef SQLITE_OMIT_AUTOVACUUM
|
||||||
/*
|
/*
|
||||||
** These two macros define the location of the pointer-map entry for a
|
** These macros define the location of the pointer-map entry for a
|
||||||
** database page. The first argument to each is the page size used
|
** database page. The first argument to each is the number of usable
|
||||||
** by the database (often 1024). The second is the page number to look
|
** bytes on each page of the database (often 1024). The second is the
|
||||||
** up in the pointer map.
|
** page number to look up in the pointer map.
|
||||||
**
|
**
|
||||||
** PTRMAP_PAGENO returns the database page number of the pointer-map
|
** PTRMAP_PAGENO returns the database page number of the pointer-map
|
||||||
** page that stores the required pointer. PTRMAP_PTROFFSET returns
|
** 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;
|
int rc;
|
||||||
|
|
||||||
assert( key!=0 );
|
assert( key!=0 );
|
||||||
iPtrmap = PTRMAP_PAGENO(pBt->pageSize, key);
|
iPtrmap = PTRMAP_PAGENO(pBt->usableSize, key);
|
||||||
rc = sqlite3pager_get(pBt->pPager, iPtrmap, (void **)&pPtrmap);
|
rc = sqlite3pager_get(pBt->pPager, iPtrmap, (void **)&pPtrmap);
|
||||||
if( rc!=SQLITE_OK ){
|
if( rc!=SQLITE_OK ){
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
offset = PTRMAP_PTROFFSET(pBt->pageSize, key);
|
offset = PTRMAP_PTROFFSET(pBt->usableSize, key);
|
||||||
|
|
||||||
if( eType!=pPtrmap[offset] || get4byte(&pPtrmap[offset+1])!=pgno ){
|
if( eType!=pPtrmap[offset] || get4byte(&pPtrmap[offset+1])!=pgno ){
|
||||||
rc = sqlite3pager_write(pPtrmap);
|
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 offset; /* Offset of entry in pointer map */
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
iPtrmap = PTRMAP_PAGENO(pBt->pageSize, key);
|
iPtrmap = PTRMAP_PAGENO(pBt->usableSize, key);
|
||||||
rc = sqlite3pager_get(pBt->pPager, iPtrmap, (void **)&pPtrmap);
|
rc = sqlite3pager_get(pBt->pPager, iPtrmap, (void **)&pPtrmap);
|
||||||
if( rc!=0 ){
|
if( rc!=0 ){
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset = PTRMAP_PTROFFSET(pBt->pageSize, key);
|
offset = PTRMAP_PTROFFSET(pBt->usableSize, key);
|
||||||
if( pEType ) *pEType = pPtrmap[offset];
|
if( pEType ) *pEType = pPtrmap[offset];
|
||||||
if( pPgno ) *pPgno = get4byte(&pPtrmap[offset+1]);
|
if( pPgno ) *pPgno = get4byte(&pPtrmap[offset+1]);
|
||||||
|
|
||||||
@@ -1774,7 +1774,7 @@ static int autoVacuumCommit(Btree *pBt, Pgno *nTrunc){
|
|||||||
finSize = origSize - nFreeList - nPtrMap;
|
finSize = origSize - nFreeList - nPtrMap;
|
||||||
if( origSize>PENDING_BYTE_PAGE(pBt) && finSize<=PENDING_BYTE_PAGE(pBt) ){
|
if( origSize>PENDING_BYTE_PAGE(pBt) && finSize<=PENDING_BYTE_PAGE(pBt) ){
|
||||||
finSize--;
|
finSize--;
|
||||||
if( PTRMAP_ISPAGE(pBt->pageSize, finSize) ){
|
if( PTRMAP_ISPAGE(pBt->usableSize, finSize) ){
|
||||||
finSize--;
|
finSize--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3091,7 +3091,7 @@ static int allocatePage(
|
|||||||
*pPgno = sqlite3pager_pagecount(pBt->pPager) + 1;
|
*pPgno = sqlite3pager_pagecount(pBt->pPager) + 1;
|
||||||
|
|
||||||
#ifndef SQLITE_OMIT_AUTOVACUUM
|
#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
|
/* 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
|
** 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.
|
** 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
|
/* The new root-page may not be allocated on a pointer-map page, or the
|
||||||
** PENDING_BYTE page.
|
** PENDING_BYTE page.
|
||||||
*/
|
*/
|
||||||
if( pgnoRoot==PTRMAP_PAGENO(pBt->pageSize, pgnoRoot) ||
|
if( pgnoRoot==PTRMAP_PAGENO(pBt->usableSize, pgnoRoot) ||
|
||||||
pgnoRoot==PENDING_BYTE_PAGE(pBt) ){
|
pgnoRoot==PENDING_BYTE_PAGE(pBt) ){
|
||||||
pgnoRoot++;
|
pgnoRoot++;
|
||||||
}
|
}
|
||||||
@@ -4929,7 +4929,7 @@ int sqlite3BtreeDropTable(Btree *pBt, int iTable, int *piMoved){
|
|||||||
if( maxRootPgno==PENDING_BYTE_PAGE(pBt) ){
|
if( maxRootPgno==PENDING_BYTE_PAGE(pBt) ){
|
||||||
maxRootPgno--;
|
maxRootPgno--;
|
||||||
}
|
}
|
||||||
if( maxRootPgno==PTRMAP_PAGENO(pBt->pageSize, maxRootPgno) ){
|
if( maxRootPgno==PTRMAP_PAGENO(pBt->usableSize, maxRootPgno) ){
|
||||||
maxRootPgno--;
|
maxRootPgno--;
|
||||||
}
|
}
|
||||||
assert( maxRootPgno!=PENDING_BYTE_PAGE(pBt) );
|
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]) );
|
sCheck.anRef = sqliteMallocRaw( (sCheck.nPage+1)*sizeof(sCheck.anRef[0]) );
|
||||||
for(i=0; i<=sCheck.nPage; i++){ sCheck.anRef[i] = 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 ){
|
if( i<=sCheck.nPage ){
|
||||||
sCheck.anRef[i] = 1;
|
sCheck.anRef[i] = 1;
|
||||||
}
|
}
|
||||||
@@ -5571,11 +5571,11 @@ char *sqlite3BtreeIntegrityCheck(Btree *pBt, int *aRoot, int nRoot){
|
|||||||
** references to pointer-map pages.
|
** references to pointer-map pages.
|
||||||
*/
|
*/
|
||||||
if( sCheck.anRef[i]==0 &&
|
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);
|
checkAppendMsg(&sCheck, 0, "Page %d is never used", i);
|
||||||
}
|
}
|
||||||
if( sCheck.anRef[i]!=0 &&
|
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);
|
checkAppendMsg(&sCheck, 0, "Pointer map page %d is referenced", i);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user