More speed improvements to btree. (CVS 1384)
FossilOrigin-Name: aab4b794b4238bad5c4a6aee7d4443732921127d
This commit is contained in:
parent
d7556d209e
commit
3add367f2f
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C Allocates\sVDBE\scursors\sone\sby\sone\sin\sseparate\smemory\sso\sthat\spointers\sto\ncursors\scan\spersist\sthrough\sa\srealloc().\s(CVS\s1383)
|
||||
D 2004-05-14T21:59:40
|
||||
C More\sspeed\simprovements\sto\sbtree.\s(CVS\s1384)
|
||||
D 2004-05-15T00:29:24
|
||||
F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a
|
||||
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
|
||||
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
|
||||
@ -23,7 +23,7 @@ F sqlite.def fc4f5734786fe4743cfe2aa98eb2da4b089edb5f
|
||||
F sqlite.pc.in 30552343140c53304c2a658c080fbe810cd09ca2
|
||||
F src/attach.c c315c58cb16fd6e913b3bfa6412aedecb4567fa5
|
||||
F src/auth.c 5c2f0bea4729c98c2be3b69d6b466fc51448fe79
|
||||
F src/btree.c 731695f701be37c20146b0aaaf415135f01b6deb
|
||||
F src/btree.c 05aefd3eec56690d9731bf090203b57d8ae4bf19
|
||||
F src/btree.h 6f51ad0ffebfba71295fcacdbe86007512200050
|
||||
F src/btree_rb.c 9d7973e266ee6f9c61ce592f68742ce9cd5b10e5
|
||||
F src/build.c e93f443a20eab57ffb77ff6244b1e09a1f7d9390
|
||||
@ -191,7 +191,7 @@ F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604
|
||||
F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
|
||||
F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
|
||||
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
|
||||
P 8d9eab178f285415775060369f372a88c7091f9f
|
||||
R b51b67250edc5f732aa65343a7a205f1
|
||||
P d8bacc16801606176fe8639b2f55b4584ad549df
|
||||
R d43b2b97f5dc394b60a54b98133aa83a
|
||||
U drh
|
||||
Z 23e87bbd07c6c07486d74ecaf3cab33d
|
||||
Z 06eabac28a7b451889010e7a03f02723
|
||||
|
@ -1 +1 @@
|
||||
d8bacc16801606176fe8639b2f55b4584ad549df
|
||||
aab4b794b4238bad5c4a6aee7d4443732921127d
|
37
src/btree.c
37
src/btree.c
@ -9,7 +9,7 @@
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** $Id: btree.c,v 1.139 2004/05/14 21:12:23 drh Exp $
|
||||
** $Id: btree.c,v 1.140 2004/05/15 00:29:24 drh Exp $
|
||||
**
|
||||
** This file implements a external (disk-based) database using BTrees.
|
||||
** For a detailed discussion of BTrees, refer to
|
||||
@ -709,7 +709,8 @@ static int initPage(
|
||||
int c, pc, i, hdr;
|
||||
unsigned char *data;
|
||||
int usableSize;
|
||||
/* int sumCell = 0; // Total size of all cells */
|
||||
int nCell, nFree;
|
||||
u8 *aCell[MX_PAGE_SIZE/2];
|
||||
|
||||
|
||||
assert( pPage->pBt!=0 );
|
||||
@ -739,43 +740,37 @@ static int initPage(
|
||||
usableSize = pPage->pBt->usableSize;
|
||||
|
||||
/* Initialize the cell count and cell pointers */
|
||||
i = 0;
|
||||
pc = get2byte(&data[hdr+3]);
|
||||
nCell = 0;
|
||||
while( pc>0 ){
|
||||
if( pc>=usableSize ) return SQLITE_CORRUPT;
|
||||
if( pPage->nCell>usableSize ) return SQLITE_CORRUPT;
|
||||
pPage->nCell++;
|
||||
if( nCell>sizeof(aCell)/sizeof(aCell[0]) ) return SQLITE_CORRUPT;
|
||||
aCell[nCell++] = &data[pc];
|
||||
pc = get2byte(&data[pc]);
|
||||
}
|
||||
if( resizeCellArray(pPage, pPage->nCell) ){
|
||||
if( resizeCellArray(pPage, nCell) ){
|
||||
return SQLITE_NOMEM;
|
||||
}
|
||||
pc = get2byte(&data[hdr+3]);
|
||||
for(i=0; pc>0; i++){
|
||||
pPage->aCell[i] = &data[pc];
|
||||
/* sumCell += cellSize(pPage, &data[pc]); */
|
||||
pc = get2byte(&data[pc]);
|
||||
}
|
||||
pPage->nCell = nCell;
|
||||
memcpy(pPage->aCell, aCell, nCell*sizeof(aCell[0]));
|
||||
|
||||
/* Compute the total free space on the page */
|
||||
pPage->nFree = data[hdr+5];
|
||||
pc = get2byte(&data[hdr+1]);
|
||||
nFree = data[hdr+5];
|
||||
i = 0;
|
||||
while( pc>0 ){
|
||||
int next, size;
|
||||
if( pc>=usableSize ) return SQLITE_CORRUPT;
|
||||
if( i++>MX_PAGE_SIZE ) return SQLITE_CORRUPT;
|
||||
next = get2byte(&data[pc]);
|
||||
size = get2byte(&data[pc+2]);
|
||||
if( next>0 && next<=pc+size+3 ) return SQLITE_CORRUPT;
|
||||
pPage->nFree += size;
|
||||
nFree += size;
|
||||
pc = next;
|
||||
}
|
||||
if( pPage->nFree>=usableSize ) return SQLITE_CORRUPT;
|
||||
|
||||
/* Sanity check: Cells and freespace and header must sum to the size
|
||||
** a page.
|
||||
if( sumCell+pPage->nFree+hdr+10-pPage->leaf*4 != usableSize ){
|
||||
return SQLITE_CORRUPT;
|
||||
}
|
||||
*/
|
||||
pPage->nFree = nFree;
|
||||
if( nFree>=usableSize ) return SQLITE_CORRUPT;
|
||||
|
||||
pPage->isInit = 1;
|
||||
pageIntegrity(pPage);
|
||||
|
Loading…
Reference in New Issue
Block a user