Avoid journalling an extra page when a btree insert operation uses the 'quick-balance' trick. (CVS 4257)
FossilOrigin-Name: 0da48209140b6c1ba47df799ce6065054b994f02
This commit is contained in:
parent
f1da17a388
commit
6e465eb0fc
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\ssome\sproblems\sin\sthe\scrash-test\sbackend.\s(CVS\s4256)
|
||||
D 2007-08-21T13:07:47
|
||||
C Avoid\sjournalling\san\sextra\spage\swhen\sa\sbtree\sinsert\soperation\suses\sthe\s'quick-balance'\strick.\s(CVS\s4257)
|
||||
D 2007-08-21T13:11:01
|
||||
F Makefile.in 0c0e53720f658c7a551046442dd7afba0b72bfbe
|
||||
F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
|
||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||
@ -80,7 +80,7 @@ F src/alter.c f0aac0060ae8102e58f210b44d35b53438d53173
|
||||
F src/analyze.c a14237d869c6bea0846493b59317e4097e81a0b6
|
||||
F src/attach.c a52225c75b107be8c5bc144a2b6d20201be3f8f8
|
||||
F src/auth.c 5ea90bc93dfea46e9fe4bf531e14c7cd98219ecb
|
||||
F src/btree.c 9460e9ad37b39f4d397b6207f25814e8dd4db6e9
|
||||
F src/btree.c 8e529f390d8d1d83acbaf13cb1c09da8361cf5b1
|
||||
F src/btree.h 525105564c87111922412368f2e4301c36e74ac1
|
||||
F src/btreeInt.h e93edf57832278138b98cf60cbc54241103c6988
|
||||
F src/build.c add67be992307b4b11849a6611bfd3352aacde92
|
||||
@ -557,7 +557,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
|
||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
||||
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
|
||||
P fbbd5bda544ffec4e1b43407b12e546235dc7873
|
||||
R 0ca0858c81f7f856c15261fd84ff79c4
|
||||
P 5bced2392ad77aff0aa1ddea83f2ff9e3ffe28a8
|
||||
R 62bf9d7ba713afd09c97220ab74284f7
|
||||
U danielk1977
|
||||
Z d922b4212f9baf5077c8cc76317915f9
|
||||
Z b65c4a9665c9f568889e6d02dbdc7083
|
||||
|
@ -1 +1 @@
|
||||
5bced2392ad77aff0aa1ddea83f2ff9e3ffe28a8
|
||||
0da48209140b6c1ba47df799ce6065054b994f02
|
30
src/btree.c
30
src/btree.c
@ -9,7 +9,7 @@
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** $Id: btree.c,v 1.404 2007/08/20 23:50:25 drh Exp $
|
||||
** $Id: btree.c,v 1.405 2007/08/21 13:11:01 danielk1977 Exp $
|
||||
**
|
||||
** This file implements a external (disk-based) database using BTrees.
|
||||
** See the header comment on "btreeInt.h" for additional information.
|
||||
@ -4499,7 +4499,6 @@ static int insertCell(
|
||||
|
||||
assert( i>=0 && i<=pPage->nCell+pPage->nOverflow );
|
||||
assert( sz==cellSizePtr(pPage, pCell) );
|
||||
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
|
||||
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
|
||||
if( pPage->nOverflow || sz+2>pPage->nFree ){
|
||||
if( pTemp ){
|
||||
@ -4512,6 +4511,11 @@ static int insertCell(
|
||||
pPage->aOvfl[j].idx = i;
|
||||
pPage->nFree = 0;
|
||||
}else{
|
||||
int rc = sqlite3PagerWrite(pPage->pDbPage);
|
||||
if( rc!=SQLITE_OK ){
|
||||
return rc;
|
||||
}
|
||||
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
|
||||
data = pPage->aData;
|
||||
hdr = pPage->hdrOffset;
|
||||
top = get2byte(&data[hdr+5]);
|
||||
@ -4519,7 +4523,7 @@ static int insertCell(
|
||||
end = cellOffset + 2*pPage->nCell + 2;
|
||||
ins = cellOffset + 2*i;
|
||||
if( end > top - sz ){
|
||||
int rc = defragmentPage(pPage);
|
||||
rc = defragmentPage(pPage);
|
||||
if( rc!=SQLITE_OK ) return rc;
|
||||
top = get2byte(&data[hdr+5]);
|
||||
assert( end + sz <= top );
|
||||
@ -4547,7 +4551,7 @@ static int insertCell(
|
||||
assert( (info.nData+(pPage->intKey?0:info.nKey))==info.nPayload );
|
||||
if( (info.nData+(pPage->intKey?0:info.nKey))>info.nLocal ){
|
||||
Pgno pgnoOvfl = get4byte(&pCell[info.iOverflow]);
|
||||
int rc = ptrmapPut(pPage->pBt, pgnoOvfl, PTRMAP_OVERFLOW1, pPage->pgno);
|
||||
rc = ptrmapPut(pPage->pBt, pgnoOvfl, PTRMAP_OVERFLOW1, pPage->pgno);
|
||||
if( rc!=SQLITE_OK ) return rc;
|
||||
}
|
||||
}
|
||||
@ -4782,7 +4786,7 @@ static int balance_nonroot(MemPage *pPage){
|
||||
** Find the parent page.
|
||||
*/
|
||||
assert( pPage->isInit );
|
||||
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
|
||||
assert( sqlite3PagerIswriteable(pPage->pDbPage) || pPage->nOverflow==1 );
|
||||
pBt = pPage->pBt;
|
||||
pParent = pPage->pParent;
|
||||
assert( pParent );
|
||||
@ -4816,6 +4820,10 @@ static int balance_nonroot(MemPage *pPage){
|
||||
}
|
||||
#endif
|
||||
|
||||
if( SQLITE_OK!=(rc = sqlite3PagerWrite(pPage->pDbPage)) ){
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
** Find the cell in the parent page whose left child points back
|
||||
** to pPage. The "idx" variable is the index of that cell. If pPage
|
||||
@ -5481,7 +5489,8 @@ static int balance(MemPage *pPage, int insert){
|
||||
int rc = SQLITE_OK;
|
||||
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
|
||||
if( pPage->pParent==0 ){
|
||||
if( pPage->nOverflow>0 ){
|
||||
rc = sqlite3PagerWrite(pPage->pDbPage);
|
||||
if( rc==SQLITE_OK && pPage->nOverflow>0 ){
|
||||
rc = balance_deeper(pPage);
|
||||
}
|
||||
if( rc==SQLITE_OK && pPage->nCell==0 ){
|
||||
@ -5594,11 +5603,6 @@ int sqlite3BtreeInsert(
|
||||
pCur->pgnoRoot, nKey, nData, pPage->pgno,
|
||||
loc==0 ? "overwrite" : "new entry"));
|
||||
assert( pPage->isInit );
|
||||
rc = sqlite3PagerWrite(pPage->pDbPage);
|
||||
if( rc ){
|
||||
sqlite3BtreeLeave(p);
|
||||
return rc;
|
||||
}
|
||||
newCell = sqlite3_malloc( MX_CELL_SIZE(pBt) );
|
||||
if( newCell==0 ) return SQLITE_NOMEM;
|
||||
rc = fillInCell(pPage, newCell, pKey, nKey, pData, nData, nZero, &szNew);
|
||||
@ -5608,6 +5612,10 @@ int sqlite3BtreeInsert(
|
||||
if( loc==0 && CURSOR_VALID==pCur->eState ){
|
||||
int szOld;
|
||||
assert( pCur->idx>=0 && pCur->idx<pPage->nCell );
|
||||
rc = sqlite3PagerWrite(pPage->pDbPage);
|
||||
if( rc ){
|
||||
goto end_insert;
|
||||
}
|
||||
oldCell = findCell(pPage, pCur->idx);
|
||||
if( !pPage->leaf ){
|
||||
memcpy(newCell, oldCell, 4);
|
||||
|
Loading…
Reference in New Issue
Block a user