mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Fix an auto-vacuum bug for btree entries that span more than one overflow page. (CVS 2039)
FossilOrigin-Name: 40249ed19cd53cb61f9575d8165316faf2627479
This commit is contained in:
16
manifest
16
manifest
@@ -1,5 +1,5 @@
|
||||
C Require\sthat\sthe\spage\ssize\sbe\sa\spower\sof\s2.\s(CVS\s2038)
|
||||
D 2004-11-02T14:24:34
|
||||
C Fix\san\sauto-vacuum\sbug\sfor\sbtree\sentries\sthat\sspan\smore\sthan\sone\soverflow\spage.\s(CVS\s2039)
|
||||
D 2004-11-02T14:40:32
|
||||
F Makefile.in 9e90c685d69f09039015a6b1f3b0a48e9738c9e5
|
||||
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
|
||||
F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1
|
||||
@@ -29,7 +29,7 @@ F sqlite3.def dbaeb20c153e1d366e8f421b55a573f5dfc00863
|
||||
F sqlite3.pc.in 985b9bf34192a549d7d370e0f0b6b34a4f61369a
|
||||
F src/attach.c e49d09dad9f5f9fb10b4b0c1be5a70ae4c45e689
|
||||
F src/auth.c 3b81f2a42f48a62c2c9c9b0eda31a157c681edea
|
||||
F src/btree.c 057e97744f4e9ca02d4815db554fd95fdabd60d5
|
||||
F src/btree.c 5958f65a3795e91fd017e4902b6ee7fe98169eb0
|
||||
F src/btree.h 94dfec0a1722d33359b23e7e310f2b64ffedf029
|
||||
F src/build.c bb896c5f85ab749d17ae5d730235134c12c08033
|
||||
F src/date.c 34bdb0082db7ec2a83ef00063f7b44e61ee19dad
|
||||
@@ -87,7 +87,7 @@ F test/attach.test 6ad560eb3e77751a4faecd77da09deac9e38cc41
|
||||
F test/attach2.test f7795123d3051ace1672b6d23973da6435de3745
|
||||
F test/attach3.test 6d060986ff004ebb89e1876a331d96c6bb62269e
|
||||
F test/auth.test 1cc252d9e7b3bdc1314199cbf3a0d3c5ed026c21
|
||||
F test/autovacuum.test 77eec318b1be7764b8dcb3198c035edc30cd319f
|
||||
F test/autovacuum.test 9ab4fcfb98ac1537548d61ce1e1718794aac4719
|
||||
F test/bigfile.test d3744a8821ce9abb8697f2826a3e3d22b719e89f
|
||||
F test/bigrow.test f0aeb7573dcb8caaafea76454be3ade29b7fc747
|
||||
F test/bind.test a8682ba41433b93bb36a4213a43f282ca9aec5a9
|
||||
@@ -252,7 +252,7 @@ F www/tclsqlite.tcl 560ecd6a916b320e59f2917317398f3d59b7cc25
|
||||
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
|
||||
F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
|
||||
F www/whentouse.tcl fdacb0ba2d39831e8a6240d05a490026ad4c4e4c
|
||||
P d12481f09cbe51c7ea499bc22afec5de3af14ad4
|
||||
R ce7547bdb8b99a29e1e65ec61753f1b6
|
||||
U drh
|
||||
Z ac7564dbdf799e2f506094e004f86e98
|
||||
P c33b34dbe9657b151b9ab00a6b50a255fae623f8
|
||||
R 6249b189aa86705bd047e7b6eada805a
|
||||
U danielk1977
|
||||
Z d61c7336a7d899fa402be79ab44af7cd
|
||||
|
@@ -1 +1 @@
|
||||
c33b34dbe9657b151b9ab00a6b50a255fae623f8
|
||||
40249ed19cd53cb61f9575d8165316faf2627479
|
22
src/btree.c
22
src/btree.c
@@ -9,7 +9,7 @@
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** $Id: btree.c,v 1.197 2004/11/02 14:24:34 drh Exp $
|
||||
** $Id: btree.c,v 1.198 2004/11/02 14:40:32 danielk1977 Exp $
|
||||
**
|
||||
** This file implements a external (disk-based) database using BTrees.
|
||||
** For a detailed discussion of BTrees, refer to
|
||||
@@ -1564,8 +1564,9 @@ set_child_ptrmaps_out:
|
||||
static void modifyPagePointer(MemPage *pPage, Pgno iFrom, Pgno iTo, u8 eType){
|
||||
|
||||
if( eType==PTRMAP_OVERFLOW2 ){
|
||||
/* The pointer is always the first 4 bytes of the page in this case. */
|
||||
assert( get4byte(pPage->aData)==iFrom );
|
||||
put4byte(pPage->aData, iFrom);
|
||||
put4byte(pPage->aData, iTo);
|
||||
}else{
|
||||
int isInitOrig = pPage->isInit;
|
||||
int i;
|
||||
@@ -1574,8 +1575,6 @@ static void modifyPagePointer(MemPage *pPage, Pgno iFrom, Pgno iTo, u8 eType){
|
||||
initPage(pPage, 0);
|
||||
nCell = pPage->nCell;
|
||||
|
||||
/* assert( !pPage->leaf && eType==PTRMAP_BTREE ); */
|
||||
|
||||
for(i=0; i<nCell; i++){
|
||||
u8 *pCell = findCell(pPage, i);
|
||||
if( eType==PTRMAP_OVERFLOW1 ){
|
||||
@@ -1695,8 +1694,8 @@ static int autoVacuumCommit(Btree *pBt){
|
||||
}while( iFreePage>finDbSize );
|
||||
|
||||
/* Move page iDbPage from it's current location to page number iFreePage */
|
||||
TRACE(("AUTOVACUUM: Moving %d to free page %d (ptr page %d)\n",
|
||||
iDbPage, iFreePage, iPtrPage));
|
||||
TRACE(("AUTOVACUUM: Moving %d to free page %d (ptr page %d type %d)\n",
|
||||
iDbPage, iFreePage, iPtrPage, eType));
|
||||
releasePage(pFreeMemPage);
|
||||
pFreeMemPage = 0;
|
||||
rc = sqlite3pager_movepage(pPager, pDbPage, iFreePage);
|
||||
@@ -1706,10 +1705,21 @@ static int autoVacuumCommit(Btree *pBt){
|
||||
/* If pDbPage was a btree-page, then it may have child pages and/or cells
|
||||
** that point to overflow pages. The pointer map entries for all these
|
||||
** pages need to be changed.
|
||||
**
|
||||
** If pDbPage is an overflow page, then the first 4 bytes may store a
|
||||
** pointer to a subsequent overflow page. If this is the case, then
|
||||
** the pointer map needs to be updated for the subsequent overflow page.
|
||||
*/
|
||||
if( eType==PTRMAP_BTREE ){
|
||||
rc = setChildPtrmaps(pDbMemPage);
|
||||
if( rc!=SQLITE_OK ) goto autovacuum_out;
|
||||
}else{
|
||||
Pgno nextOvfl = get4byte(pDbPage);
|
||||
if( nextOvfl!=0 ){
|
||||
assert( nextOvfl<=origDbSize );
|
||||
rc = ptrmapPut(pBt, nextOvfl, PTRMAP_OVERFLOW2, iFreePage);
|
||||
if( rc!=SQLITE_OK ) goto autovacuum_out;
|
||||
}
|
||||
}
|
||||
releasePage(pDbMemPage);
|
||||
pDbMemPage = 0;
|
||||
|
@@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing the SELECT statement.
|
||||
#
|
||||
# $Id: autovacuum.test,v 1.1 2004/11/02 12:56:41 danielk1977 Exp $
|
||||
# $Id: autovacuum.test,v 1.2 2004/11/02 14:40:32 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@@ -28,10 +28,11 @@ proc file_pages {} {
|
||||
do_test autovacuum-1.1 {
|
||||
execsql {
|
||||
CREATE TABLE av1(a);
|
||||
-- CREATE INDEX av1_idx ON av1(a);
|
||||
}
|
||||
} {}
|
||||
|
||||
set ENTRY_LEN 1100
|
||||
set ENTRY_LEN 3000
|
||||
|
||||
set delete_orders [list]
|
||||
lappend delete_orders {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20}
|
||||
|
Reference in New Issue
Block a user