-C Remove\san\sassert()\sfrom\svdbeaux.c\sthat\smight\snot\sbe\strue\sif\sthe\sdatabase\nfile\sis\scorrupt.\s(CVS\s6895)
-D 2009-07-15T16:30:50
+C Simplifications\sto\sbtree.c\sin\ssupport\sof\sstructural\stesting.\s\sRenamed\sthe\n"skip"\sfield\sof\sthe\sBtCursor\sobject\sto\s"skipNext"\sto\smake\sit\seasier\sto\nsearch\sfor\splaces\swhere\sit\sis\sused.\s(CVS\s6896)
+D 2009-07-15T17:25:46
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in df9359da7a726ccb67a45db905c5447d5c00c6ef
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F src/backup.c 6f1c2d9862c8a3feb7739dfcca02c1f5352e37f3
F src/bitvec.c 0ef0651714728055d43de7a4cdd95e703fac0119
F src/btmutex.c 9b899c0d8df3bd68f527b0afe03088321b696d3c
-F src/btree.c b5a8d21f6b21ab0068910d881b38a3c54ba7214d
+F src/btree.c a1fda2c54edd21079c60c34ee6973e0522c4ece2
F src/btree.h e53a10fd31d16c60a86f03c9467a6f470aa3683b
-F src/btreeInt.h a568bf057aa249eb06fd31358b4393a5ac88c118
+F src/btreeInt.h 1c86297e69380f6577e7ae67452597dd8d5c2705
F src/build.c 867028ee9f63f7bc8eb8d4a720bb98cf9b9a12b4
F src/callback.c cb68b21b0d4ae7d11ae0e487933bce3323784dcf
F src/complete.c 5ad5c6cd4548211867c204c41a126d73a9fbcea0
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746
-P cfbeda1b3126503e9631471ce4713e25b007859f
-R d6155ec47b65f864575de01cbf0050eb
+P a42dc51e3bd258d5a357e557251fb2642708ceac
+R b79ce4fac444a551c4798dffd50747f8
U drh
-Z 0b9e2d4ca82b865798da8f05eede3fbb
+Z d31e2bba272164e36061fcdc880b0bf2
** May you share freely, never taking more than you give.
**
*************************************************************************
-** $Id: btree.c,v 1.688 2009/07/15 11:26:44 drh Exp $
+** $Id: btree.c,v 1.689 2009/07/15 17:25:46 drh Exp $
**
** This file implements a external (disk-based) database using BTrees.
** See the header comment on "btreeInt.h" for additional information.
static int btreeSetHasContent(BtShared *pBt, Pgno pgno){
int rc = SQLITE_OK;
if( !pBt->pHasContent ){
- int nPage;
- rc = sqlite3PagerPagecount(pBt->pPager, &nPage);
- if( rc==SQLITE_OK ){
- pBt->pHasContent = sqlite3BitvecCreate((u32)nPage);
- if( !pBt->pHasContent ){
- rc = SQLITE_NOMEM;
- }
+ int nPage = 100;
+ sqlite3PagerPagecount(pBt->pPager, &nPage);
+ /* If sqlite3PagerPagecount() fails there is no harm because the
+ ** nPage variable is unchanged from its default value of 100 */
+ pBt->pHasContent = sqlite3BitvecCreate((u32)nPage);
+ if( !pBt->pHasContent ){
+ rc = SQLITE_NOMEM;
}
}
if( rc==SQLITE_OK && pgno<=sqlite3BitvecSize(pBt->pHasContent) ){
assert( cursorHoldsMutex(pCur) );
rc = sqlite3BtreeKeySize(pCur, &pCur->nKey);
+ assert( rc==SQLITE_OK ); /* Cannot fail since pCur->eState==VALID */
/* If this is an intKey table, then the above call to BtreeKeySize()
** stores the integer key in pCur->nKey. In this case this value is
** table, then malloc space for and store the pCur->nKey bytes of key
** data.
*/
- if( rc==SQLITE_OK && 0==pCur->apPage[0]->intKey){
+ if( 0==pCur->apPage[0]->intKey ){
void *pKey = sqlite3Malloc( (int)pCur->nKey );
if( pKey ){
rc = sqlite3BtreeKey(pCur, 0, (int)pCur->nKey, pKey);
assert( cursorHoldsMutex(pCur) );
assert( pCur->eState>=CURSOR_REQUIRESEEK );
if( pCur->eState==CURSOR_FAULT ){
- return pCur->skip;
+ return pCur->skipNext;
}
pCur->eState = CURSOR_INVALID;
- rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &pCur->skip);
+ rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &pCur->skipNext);
if( rc==SQLITE_OK ){
sqlite3_free(pCur->pKey);
pCur->pKey = 0;
*pHasMoved = 1;
return rc;
}
- if( pCur->eState!=CURSOR_VALID || pCur->skip!=0 ){
+ if( pCur->eState!=CURSOR_VALID || pCur->skipNext!=0 ){
*pHasMoved = 1;
}else{
*pHasMoved = 0;
/* Any read-only or read-write transaction implies a read-lock on
** page 1. So if some other shared-cache client already has a write-lock
** on page 1, the transaction cannot be opened. */
- if( SQLITE_OK!=(rc = querySharedCacheTableLock(p, MASTER_ROOT, READ_LOCK)) ){
- goto trans_begun;
- }
+ rc = querySharedCacheTableLock(p, MASTER_ROOT, READ_LOCK);
+ if( SQLITE_OK!=rc ) goto trans_begun;
do {
/* Call lockBtree() until either pBt->pPage1 is populated or
int i;
sqlite3BtreeClearCursor(p);
p->eState = CURSOR_FAULT;
- p->skip = errCode;
+ p->skipNext = errCode;
for(i=0; i<=p->iPage; i++){
releasePage(p->apPage[i]);
p->apPage[i] = 0;
assert( CURSOR_FAULT > CURSOR_REQUIRESEEK );
if( pCur->eState>=CURSOR_REQUIRESEEK ){
if( pCur->eState==CURSOR_FAULT ){
- assert( pCur->skip!=SQLITE_OK );
- return pCur->skip;
+ assert( pCur->skipNext!=SQLITE_OK );
+ return pCur->skipNext;
}
sqlite3BtreeClearCursor(pCur);
}
}
pCur->iPage = 0;
}else{
- if(
- SQLITE_OK!=(rc = getAndInitPage(pBt, pCur->pgnoRoot, &pCur->apPage[0]))
- ){
+ rc = getAndInitPage(pBt, pCur->pgnoRoot, &pCur->apPage[0]);
+ if( rc!=SQLITE_OK ){
pCur->eState = CURSOR_INVALID;
return rc;
}
*pRes = 1;
return SQLITE_OK;
}
- if( pCur->skip>0 ){
- pCur->skip = 0;
+ if( pCur->skipNext>0 ){
+ pCur->skipNext = 0;
*pRes = 0;
return SQLITE_OK;
}
- pCur->skip = 0;
+ pCur->skipNext = 0;
pPage = pCur->apPage[pCur->iPage];
idx = ++pCur->aiIdx[pCur->iPage];
*pRes = 1;
return SQLITE_OK;
}
- if( pCur->skip<0 ){
- pCur->skip = 0;
+ if( pCur->skipNext<0 ){
+ pCur->skipNext = 0;
*pRes = 0;
return SQLITE_OK;
}
- pCur->skip = 0;
+ pCur->skipNext = 0;
pPage = pCur->apPage[pCur->iPage];
assert( pPage->isInit );
}
k = get4byte(&pTrunk->aData[4]);
- testcase( k==(u32)(pBt->usableSize/4 - 2) );
if( k==0 && !searchList ){
/* The trunk has no leaves and the list is not being searched.
** So extract the trunk page itself and use it as the newly
data = pPage->aData;
ptr = &data[pPage->cellOffset + 2*idx];
pc = get2byte(ptr);
- if( NEVER(pc<pPage->hdrOffset+6+pPage->childPtrSize)
+ if( (pc<pPage->hdrOffset+6+pPage->childPtrSize)
|| (pc+sz>pPage->pBt->usableSize) ){
return SQLITE_CORRUPT_BKPT;
}
}
if( pCur->eState==CURSOR_FAULT ){
- assert( pCur->skip!=SQLITE_OK );
- return pCur->skip;
+ assert( pCur->skipNext!=SQLITE_OK );
+ return pCur->skipNext;
}
/* Save the positions of any other cursors open on this table.
** doing any work. To avoid thwarting these optimizations, it is important
** not to clear the cursor here.
*/
- if(
- SQLITE_OK!=(rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur)) || (!loc &&
- SQLITE_OK!=(rc = btreeMoveto(pCur, pKey, nKey, appendBias, &loc))
- )){
- return rc;
+ rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);
+ if( rc ) return rc;
+ if( !loc ){
+ rc = btreeMoveto(pCur, pKey, nKey, appendBias, &loc);
+ if( rc ) return rc;
}
assert( pCur->eState==CURSOR_VALID || (pCur->eState==CURSOR_INVALID && loc) );
** balancing the tree following the delete operation easier. */
if( !pPage->leaf ){
int notUsed;
- if( SQLITE_OK!=(rc = sqlite3BtreePrevious(pCur, ¬Used)) ){
- return rc;
- }
+ rc = sqlite3BtreePrevious(pCur, ¬Used);
+ if( rc ) return rc;
}
/* Save the positions of any other cursors open on this table before
** May you share freely, never taking more than you give.
**
*************************************************************************
-** $Id: btreeInt.h,v 1.51 2009/07/09 05:07:38 danielk1977 Exp $
+** $Id: btreeInt.h,v 1.52 2009/07/15 17:25:46 drh Exp $
**
** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to
u8 eState; /* One of the CURSOR_XXX constants (see below) */
void *pKey; /* Saved key that was cursor's last known position */
i64 nKey; /* Size of pKey, or last integer key */
- int skip; /* (skip<0) -> Prev() is a no-op. (skip>0) -> Next() is */
+ int skipNext; /* Prev() is noop if negative. Next() is noop if positive */
#ifndef SQLITE_OMIT_INCRBLOB
u8 isIncrblobHandle; /* True if this cursor is an incr. io handle */
Pgno *aOverflow; /* Cache of overflow page locations */
#define put2byte(p,v) ((p)[0] = (u8)((v)>>8), (p)[1] = (u8)(v))
#define get4byte sqlite3Get4byte
#define put4byte sqlite3Put4byte
-