diff --git a/manifest b/manifest index 8f0b79035d..5d4c5c5824 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sfor\sexplicitly\sinserting\sa\sNULL\svalue\sinto\sthe\srowid\scolumn\sof\sa\svirtual\stable.\s(CVS\s5343) -D 2008-07-04T10:56:08 +C Fix\sa\sbug\sin\sbtree.c\sthat\scaused\sit\sto\sreport\sa\sdatabase\sas\sbeing\ncorrupt\sif\sit\sused\sone\sof\sthe\slast\s6\sslots\sin\sa\sfreelist\strunk\spage.\nContinue\sto\snever\suse\sthose\slast\s6\sslots\sso\sthat\sdatabases\sfrom\snewer\nversions\sare\sstill\sreadable\swith\solder\sversions.\s(CVS\s5344) +D 2008-07-04T17:52:43 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 325dfac0a0dd1cb4d975f1ace6453157892e6042 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -95,7 +95,7 @@ F src/attach.c b18ba42c77f7d3941f5d23d2ca20fa1d841a4e91 F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627 F src/bitvec.c 95c86bd18d8fedf0533f5af196192546e10a7e7d F src/btmutex.c 483ced3c52205b04b97df69161fadbf87f4f1ea2 -F src/btree.c dd7b7a92fe9a0e950279e86a771bb522adb6a86b +F src/btree.c e00268557794be741e26cbca1cd77aa37e53b1cc F src/btree.h b1bd7e0b8c2e33658aaf447cb0d1d94f74664b6b F src/btreeInt.h 02325f04758dba0fcd0c08ac55cd9b189dad61a5 F src/build.c 88cc5501a87f72d0538b040001d88d31f994edea @@ -598,7 +598,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -P 212d05d38c8126f99c028c5ab021b219487fa01e -R 05b4445ad462e1bc7a4f23619c79cabb -U danielk1977 -Z ef13a447ae3cb8c8f3ec0022bfd3fe35 +P a7f3b431669f7392a6acba8cd8f3fa5297a916b5 +R 4ce10b31fd2cef40edfbb643bb66a36c +U drh +Z b35f68dfaeeab8333199ab46961442d2 diff --git a/manifest.uuid b/manifest.uuid index 94909c48ac..503e204aa2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a7f3b431669f7392a6acba8cd8f3fa5297a916b5 \ No newline at end of file +b8ff6b0a3dc2ccc51519c764a092822968a09b10 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index f704baebcc..da4666c081 100644 --- a/src/btree.c +++ b/src/btree.c @@ -9,7 +9,7 @@ ** May you share freely, never taking more than you give. ** ************************************************************************* -** $Id: btree.c,v 1.470 2008/06/28 15:33:25 danielk1977 Exp $ +** $Id: btree.c,v 1.471 2008/07/04 17:52:43 drh Exp $ ** ** This file implements a external (disk-based) database using BTrees. ** See the header comment on "btreeInt.h" for additional information. @@ -4051,7 +4051,7 @@ static int allocateBtreePage( *ppPage = pTrunk; pTrunk = 0; TRACE(("ALLOCATE: %d trunk - %d free pages left\n", *pPgno, n-1)); - }else if( k>pBt->usableSize/4 - 8 ){ + }else if( k>pBt->usableSize/4 - 2 ){ /* Value of k is out of range. Database corruption */ rc = SQLITE_CORRUPT_BKPT; goto end_allocate_page; @@ -4271,7 +4271,19 @@ static int freePage(MemPage *pPage){ k = get4byte(&pTrunk->aData[4]); if( k>=pBt->usableSize/4 - 8 ){ /* The trunk is full. Turn the page being freed into a new - ** trunk page with no leaves. */ + ** trunk page with no leaves. + ** + ** Note that the trunk page is not really full until it contains + ** usableSize/4 - 2 entries, not usableSize/4 - 8 entries as we have + ** coded. But due to a coding error in versions of SQLite prior to + ** 3.6.0, databases with freelist trunk pages holding more than + ** usableSize/4 - 8 entries will be reported as corrupt. In order + ** to maintain backwards compatibility with older versions of SQLite, + ** we will contain to restrict the number of entries to usableSize/4 - 8 + ** for now. At some point in the future (once everyone has upgraded + ** to 3.6.0 or later) we should consider fixing the conditional above + ** to read "usableSize/4-2" instead of "usableSize/4-8". + */ rc = sqlite3PagerWrite(pPage->pDbPage); if( rc==SQLITE_OK ){ put4byte(pPage->aData, pTrunk->pgno); @@ -6498,7 +6510,7 @@ static void checkList( checkPtrmap(pCheck, iPage, PTRMAP_FREEPAGE, 0, zContext); } #endif - if( n>pCheck->pBt->usableSize/4-8 ){ + if( n>pCheck->pBt->usableSize/4-2 ){ checkAppendMsg(pCheck, zContext, "freelist leaf count too big on page %d", iPage); N--;