1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Make sure the nOverflow flag in MemPage is reset to zero after every insert. (CVS 5983)

FossilOrigin-Name: bfde3dae0c7b97308344519ca06cd4b290e8cf47
This commit is contained in:
drh
2008-12-05 20:01:43 +00:00
parent 902b9ee436
commit 9bf9e9c86d
3 changed files with 23 additions and 12 deletions

View File

@@ -1,5 +1,5 @@
C Fix\sharmless\scompiler\swarnings.\s\sImproved\scomments\sin\sthe\squery\soptimizer.\s(CVS\s5982)
D 2008-12-05T17:17:08
C Make\ssure\sthe\snOverflow\sflag\sin\sMemPage\sis\sreset\sto\szero\safter\severy\sinsert.\s(CVS\s5983)
D 2008-12-05T20:01:43
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in f7e4c81c347b04f7b0f1c1b081a168645d7b8af7
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -100,7 +100,7 @@ F src/attach.c 85c6a3d0daf11965b47604190d7cf5597dc88382
F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627
F src/bitvec.c 4300d311b17fb3c1476623fd895a8feac02a0b08
F src/btmutex.c 63c5cc4ad5715690767ffcb741e185d7bc35ec1a
F src/btree.c 372c5b32dc919fed608be57f440d054a46d002fd
F src/btree.c b3438bc1f262b8048df9949aeb2a14cf7c55e9bd
F src/btree.h 179c3ea813780df78a289a8f5130db18e6d4616e
F src/btreeInt.h 8d21590c97b6a2c00cce1f78ed5dc5756e835108
F src/build.c ce642b06016d94b0dbc34d379bac82b597baf8d5
@@ -663,7 +663,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
P 46f2d08959423e130a5b346138311649d92f0fde
R 96105d8de358fb97d30ada8cbb7880b2
P adedd697b475dadaa2eeae0d0413603195c955cf
R 4b745e4c65ef95b4efde274748b84506
U drh
Z d6ba8ef05cc5f5653a1e2350d4d75f6c
Z 4883cace950bdb143cdb09610e9fe51d

View File

@@ -1 +1 @@
adedd697b475dadaa2eeae0d0413603195c955cf
bfde3dae0c7b97308344519ca06cd4b290e8cf47

View File

@@ -9,7 +9,7 @@
** May you share freely, never taking more than you give.
**
*************************************************************************
** $Id: btree.c,v 1.543 2008/11/27 02:22:11 drh Exp $
** $Id: btree.c,v 1.544 2008/12/05 20:01:43 drh Exp $
**
** This file implements a external (disk-based) database using BTrees.
** See the header comment on "btreeInt.h" for additional information.
@@ -5537,6 +5537,7 @@ balance_cleanup:
for(i=0; i<nNew; i++){
releasePage(apNew[i]);
}
pPage->nOverflow = 0;
/* releasePage(pParent); */
TRACE(("BALANCE: finished with %d: old=%d new=%d cells=%d\n",
@@ -5610,7 +5611,7 @@ static int balance_shallower(BtCursor *pCur){
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
put4byte(&pPage->aData[pPage->hdrOffset+8],
get4byte(&pChild->aData[pChild->hdrOffset+8]));
freePage(pChild);
rc = freePage(pChild);
TRACE(("BALANCE: child %d transfer to page 1\n", pChild->pgno));
}else{
/* The child has more information that will fit on the root.
@@ -5628,7 +5629,7 @@ static int balance_shallower(BtCursor *pCur){
}
assert( pPage->nOverflow==0 );
#ifndef SQLITE_OMIT_AUTOVACUUM
if( ISAUTOVACUUM ){
if( ISAUTOVACUUM && rc==SQLITE_OK ){
rc = setChildPtrmaps(pPage);
}
#endif
@@ -5734,14 +5735,17 @@ static int balance(BtCursor *pCur, int isInsert){
rc = sqlite3PagerWrite(pPage->pDbPage);
if( rc==SQLITE_OK && pPage->nOverflow>0 ){
rc = balance_deeper(pCur);
assert( pPage->nOverflow==0 || rc!=SQLITE_OK );
}
if( rc==SQLITE_OK && pPage->nCell==0 ){
rc = balance_shallower(pCur);
assert( pPage->nOverflow==0 || rc!=SQLITE_OK );
}
}else{
if( pPage->nOverflow>0 ||
(!isInsert && pPage->nFree>pPage->pBt->usableSize*2/3) ){
rc = balance_nonroot(pCur);
assert( pPage->nOverflow==0 || rc!=SQLITE_OK );
}
}
return rc;
@@ -5910,8 +5914,15 @@ int sqlite3BtreeInsert(
assert( pPage->leaf );
}
rc = insertCell(pPage, idx, newCell, szNew, 0, 0);
if( rc!=SQLITE_OK ) goto end_insert;
if( rc==SQLITE_OK ){
rc = balance(pCur, 1);
}
/* Must make sure nOverflow is reset to zero even if the balance()
** fails. Internal data structure corruption will result otherwise. */
assert( pPage->nOverflow==0 || rc!=SQLITE_OK );
pPage->nOverflow = 0;
if( rc==SQLITE_OK ){
moveToRoot(pCur);
}