-C Additional\scomments\sto\sclarify\sthe\soperation\sof\sthe\sLIKE\soptimizer\sin\nwhere.c.\s(CVS\s6731)
-D 2009-06-08T19:44:37
+C Do\snot\sclear\sthe\sMemPage.nFree\svariable\swhen\sinsertCell()\sadds\san\soverflow\scell\sto\sa\spage.\sNot\sdoing\sthis\smeans\sbalance_quick()\scan\savoid\sa\scall\sto\ssqlite3BtreeInitPage().\s(CVS\s6732)
+D 2009-06-09T09:41:00
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 8b8fb7823264331210cddf103831816c286ba446
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F src/backup.c ff50af53184a5fd7bdee4d620b5dabef74717c79
F src/bitvec.c 0ef0651714728055d43de7a4cdd95e703fac0119
F src/btmutex.c 9b899c0d8df3bd68f527b0afe03088321b696d3c
-F src/btree.c 50716b7a8bd32b9101bd3238ed7bd61fafe5cd67
+F src/btree.c 53c5df7ff0df6b3d089d1f93888c85195e3fd367
F src/btree.h f70b694e8c163227369a66863b01fbff9009f323
F src/btreeInt.h df64030d632f8c8ac217ed52e8b6b3eacacb33a5
F src/build.c 20e02fd72249159ff6829009f3029d16d59cdff5
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746
-P 6b42dc3d04e98f91c203c277926ed6ead62a9270
-R 69d714b02afbfbf66f436fb2d5f497ad
-U drh
-Z 112608f13ef95b6e8bc2968c1b5cb3e1
+P cc9c12170c3f6f0f485977e47e7fbb75c50e82b1
+R d036fc96778854a1f95e2dd9e0b87a34
+U danielk1977
+Z ee3eb7d6cafebd45a9fd708a20a004b3
** May you share freely, never taking more than you give.
**
*************************************************************************
-** $Id: btree.c,v 1.620 2009/06/08 14:49:46 danielk1977 Exp $
+** $Id: btree.c,v 1.621 2009/06/09 09:41:00 danielk1977 Exp $
**
** This file implements a external (disk-based) database using BTrees.
** See the header comment on "btreeInt.h" for additional information.
assert( j<(int)(sizeof(pPage->aOvfl)/sizeof(pPage->aOvfl[0])) );
pPage->aOvfl[j].pCell = pCell;
pPage->aOvfl[j].idx = (u16)i;
- pPage->nFree = 0;
}else{
int rc = sqlite3PagerWrite(pPage->pDbPage);
if( rc!=SQLITE_OK ){
/* Release the reference to the new page. */
releasePage(pNew);
-
- /* At this point the pPage->nFree variable is not set correctly with
- ** respect to the content of the page (because it was set to 0 by
- ** insertCell). So call sqlite3BtreeInitPage() to make sure it is
- ** correct.
- **
- ** This has to be done even if an error will be returned. Normally, if
- ** an error occurs during tree balancing, the contents of MemPage are
- ** not important, as they will be recalculated when the page is rolled
- ** back. But here, in balance_quick(), it is possible that pPage has
- ** not yet been marked dirty or written into the journal file. Therefore
- ** it will not be rolled back and so it is important to make sure that
- ** the page data and contents of MemPage are consistent.
- */
- pPage->isInit = 0;
- sqlite3BtreeInitPage(pPage);
- assert( pPage->nOverflow==0 );
}
return rc;
** is called recursively on the parent.
**
** If this routine fails for any reason, it might leave the database
-** in a corrupted state. So if this routine fails, the database should
+** in a corrupted state. So if this routine fails, the database should
** be rolled back.
*/
-static int balance_nonroot(MemPage *pParent, int iParentIdx, u8 *aSpace2){
+static int balance_nonroot(MemPage *pParent, int iParentIdx, u8 *aOvflSpace){
BtShared *pBt; /* The whole database */
int nCell = 0; /* Number of cells in apCell[] */
int nMaxCells = 0; /* Allocated size of apCell, szCell, aFrom. */
int pageFlags; /* Value of pPage->aData[0] */
int subtotal; /* Subtotal of bytes in cells on one page */
int iSpace1 = 0; /* First unused byte of aSpace1[] */
- int iSpace2 = 0; /* First unused byte of aSpace2[] */
+ int iOvflSpace = 0; /* First unused byte of aOvflSpace[] */
int szScratch; /* Size of scratch memory requested */
MemPage *apOld[NB]; /* pPage and up to two siblings */
Pgno pgnoOld[NB]; /* Page numbers for each page in apOld[] */
+ pBt->pageSize /* aSpace1 */
+ (ISAUTOVACUUM ? nMaxCells : 0); /* aFrom */
apCell = sqlite3ScratchMalloc( szScratch );
- if( apCell==0 ){
+ if( apCell==0 || aOvflSpace==0 ){
rc = SQLITE_NOMEM;
goto balance_cleanup;
}
if( ISAUTOVACUUM ){
aFrom = &aSpace1[pBt->pageSize];
}
- /* aSpace2 = sqlite3PageMalloc(pBt->pageSize); */
- if( aSpace2==0 ){
- rc = SQLITE_NOMEM;
- goto balance_cleanup;
- }
/*
** Make copies of the content of pPage and its siblings into aOld[].
assert( j<nMaxCells );
pCell = apCell[j];
sz = szCell[j] + leafCorrection;
- pTemp = &aSpace2[iSpace2];
+ pTemp = &aOvflSpace[iOvflSpace];
if( !pNew->leaf ){
memcpy(&pNew->aData[8], pCell, 4);
if( ISAUTOVACUUM
sz = cellSizePtr(pParent, pCell);
}
}
- iSpace2 += sz;
+ iOvflSpace += sz;
assert( sz<=pBt->pageSize/4 );
- assert( iSpace2<=pBt->pageSize );
+ assert( iOvflSpace<=pBt->pageSize );
rc = insertCell(pParent, nxDiv, pCell, sz, pTemp, 4);
if( rc!=SQLITE_OK ) goto balance_cleanup;
assert( sqlite3PagerIswriteable(pParent->pDbPage) );
** shallower by one level.
*/
static int balance_shallower(MemPage *pRoot){
-
/* The root page is empty but has one child. Transfer the
** information from that one child into the root page if it
** will fit. This reduces the depth of the tree by one.
if( rc==SQLITE_OK ){
if( pChild->nFree>=hdr ){
if( hdr ){
- rc = defragmentPage(pChild);
+ rc = defragmentPage(pChild);
}
if( rc==SQLITE_OK ){
rc = copyNodeContent(pChild, pRoot);
/* Copy the overflow cells from pRoot to pChild */
memcpy(pChild->aOvfl, pRoot->aOvfl, pRoot->nOverflow*sizeof(pRoot->aOvfl[0]));
pChild->nOverflow = pRoot->nOverflow;
- pChild->nFree = 0;
/* Zero the contents of pRoot. Then install pChild as the right-child. */
zeroPage(pRoot, pChild->aData[0] & ~PTF_LEAF);