diff options
author | drh <drh@noemail.net> | 2014-09-24 19:47:27 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2014-09-24 19:47:27 +0000 |
commit | 3fbb022b98a05d985571a188003f3dd1fb2b94a5 (patch) | |
tree | aa34c5c473b6a532508314d4d0acc7817f73cf69 /src | |
parent | b2325b72df09777cf039ff5036d58047fd0bb2f7 (diff) | |
download | sqlite-3fbb022b98a05d985571a188003f3dd1fb2b94a5.tar.gz sqlite-3fbb022b98a05d985571a188003f3dd1fb2b94a5.zip |
Have each open database allocate its pTmpSpace when the first write cursor
is opened, rather than on each insert or delete, for a small space savings
and performance boost.
FossilOrigin-Name: 99323552c001bc9173eb2a44542234c8ef7a9845
Diffstat (limited to 'src')
-rw-r--r-- | src/btree.c | 11 | ||||
-rw-r--r-- | src/vdbe.c | 4 |
2 files changed, 6 insertions, 9 deletions
diff --git a/src/btree.c b/src/btree.c index d8bf076e8..37aabbef7 100644 --- a/src/btree.c +++ b/src/btree.c @@ -3672,6 +3672,10 @@ static int btreeCursor( if( NEVER(wrFlag && (pBt->btsFlags & BTS_READ_ONLY)!=0) ){ return SQLITE_READONLY; } + if( wrFlag ){ + allocateTempSpace(pBt); + if( pBt->pTmpSpace==0 ) return SQLITE_NOMEM; + } if( iTable==1 && btreePagecount(pBt)==0 ){ assert( wrFlag==0 ); iTable = 0; @@ -7154,9 +7158,8 @@ int sqlite3BtreeInsert( pCur->pgnoRoot, nKey, nData, pPage->pgno, loc==0 ? "overwrite" : "new entry")); assert( pPage->isInit ); - allocateTempSpace(pBt); newCell = pBt->pTmpSpace; - if( newCell==0 ) return SQLITE_NOMEM; + assert( newCell!=0 ); rc = fillInCell(pPage, newCell, pKey, nKey, pData, nData, nZero, &szNew); if( rc ) goto end_insert; assert( szNew==cellSizePtr(pPage, newCell) ); @@ -7302,10 +7305,8 @@ int sqlite3BtreeDelete(BtCursor *pCur){ pCell = findCell(pLeaf, pLeaf->nCell-1); nCell = cellSizePtr(pLeaf, pCell); assert( MX_CELL_SIZE(pBt) >= nCell ); - - allocateTempSpace(pBt); pTmp = pBt->pTmpSpace; - + assert( pTmp!=0 ); rc = sqlite3PagerWrite(pLeaf->pDbPage); insertCell(pPage, iCellIdx, pCell-4, nCell+4, pTmp, n, &rc); dropCell(pLeaf, pLeaf->nCell-1, nCell, &rc); diff --git a/src/vdbe.c b/src/vdbe.c index 26ca72b9f..4c2b75f64 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -3287,10 +3287,6 @@ case OP_OpenWrite: { assert( OPFLAG_BULKCSR==BTREE_BULKLOAD ); sqlite3BtreeCursorHints(pCur->pCursor, (pOp->p5 & OPFLAG_BULKCSR)); - /* Since it performs no memory allocation or IO, the only value that - ** sqlite3BtreeCursor() may return is SQLITE_OK. */ - assert( rc==SQLITE_OK ); - /* Set the VdbeCursor.isTable variable. Previous versions of ** SQLite used to check if the root-page flags were sane at this point ** and report database corruption if they were not, but this check has |