Fix a bug in the btree balancer. ticket #1346. (CVS 2573)
FossilOrigin-Name: 3af69a49289f52f321ccd365e92d22b820c3139e
This commit is contained in:
parent
3d21423c65
commit
09d0debf3b
13
manifest
13
manifest
@ -1,5 +1,5 @@
|
||||
C Add\sthe\s"transaction"\scoommand\sto\sthe\sTCL\sinterface.\s\sUntested.\s(CVS\s2572)
|
||||
D 2005-08-02T12:21:09
|
||||
C Fix\sa\sbug\sin\sthe\sbtree\sbalancer.\sticket\s#1346.\s(CVS\s2573)
|
||||
D 2005-08-02T17:13:10
|
||||
F Makefile.in 22ea9c0fe748f591712d8fe3c6d972c6c173a165
|
||||
F Makefile.linux-gcc 06be33b2a9ad4f005a5f42b22c4a19dab3cbb5c7
|
||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||
@ -31,7 +31,7 @@ F src/alter.c 03041f2464e22532601254f87cb49997fa21dcdf
|
||||
F src/analyze.c 3ab32927f4d3067ead10e4c4f6fb61b2a93479cc
|
||||
F src/attach.c 3615dbe960cbee4aa5ea300b8a213dad36527b0f
|
||||
F src/auth.c 31e2304bef67f44d635655f44234387ea7d21454
|
||||
F src/btree.c ec55bd70052cdd0958f3a0e79ad58d93561acb20
|
||||
F src/btree.c 667227e4375d8bf6abd748cf6bad7a2004bf5d87
|
||||
F src/btree.h 41a71ce027db9ddee72cb43df2316bbe3a1d92af
|
||||
F src/build.c e50f2f4c7b40e097a045a2b4a849ac0eff1a1c49
|
||||
F src/callback.c 0910b611e0c158f107ee3ff86f8a371654971e2b
|
||||
@ -113,6 +113,7 @@ F test/btree4.test 3797b4305694c7af6828675b0f4b1424b8ca30e4
|
||||
F test/btree5.test 8e5ff32c02e685d36516c6499add9375fe1377f2
|
||||
F test/btree6.test a5ede6bfbbb2ec8b27e62813612c0f28e8f3e027
|
||||
F test/btree7.test a6d3b842db22af97dd14b989e90a2fd96066b72f
|
||||
F test/btree8.test fadc112bcbd6a0c622d34c813fc8a648eacf8804
|
||||
F test/busy.test e355bee7d32aae35ccb3786f7a6470b73559d0f9
|
||||
F test/capi2.test f897209386fb21cfdc9267595e0c667ebaca9164
|
||||
F test/capi3.test 4d848cc55ad6e5f68cf2712716e9fc1fa55d7635
|
||||
@ -289,7 +290,7 @@ F www/tclsqlite.tcl 425be741b8ae664f55cb1ef2371aab0a75109cf9
|
||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
|
||||
F www/whentouse.tcl 528299b8316726dbcc5548e9aa0648c8b1bd055b
|
||||
P 1a4e526d46280970b43505a5c8a4090767c63043
|
||||
R 78b1c899f4b5fe928acfe9e6cfb5036e
|
||||
P a5ce6c58c3bfc0e1c9953fe4ad4991ac56a4fb87
|
||||
R 4a8c7582f7970695b98ddf619a01cae9
|
||||
U drh
|
||||
Z 52f52fd4f5ae893bb4b1cf865ecc97b9
|
||||
Z 991528171fafbc48e93c00ec9f920c3c
|
||||
|
@ -1 +1 @@
|
||||
a5ce6c58c3bfc0e1c9953fe4ad4991ac56a4fb87
|
||||
3af69a49289f52f321ccd365e92d22b820c3139e
|
35
src/btree.c
35
src/btree.c
@ -9,7 +9,7 @@
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** $Id: btree.c,v 1.263 2005/07/09 02:16:03 drh Exp $
|
||||
** $Id: btree.c,v 1.264 2005/08/02 17:13:10 drh Exp $
|
||||
**
|
||||
** This file implements a external (disk-based) database using BTrees.
|
||||
** For a detailed discussion of BTrees, refer to
|
||||
@ -3602,17 +3602,19 @@ static void assemblePage(
|
||||
data = pPage->aData;
|
||||
hdr = pPage->hdrOffset;
|
||||
put2byte(&data[hdr+3], nCell);
|
||||
cellbody = allocateSpace(pPage, totalSize);
|
||||
assert( cellbody>0 );
|
||||
assert( pPage->nFree >= 2*nCell );
|
||||
pPage->nFree -= 2*nCell;
|
||||
for(i=0; i<nCell; i++){
|
||||
put2byte(&data[cellptr], cellbody);
|
||||
memcpy(&data[cellbody], apCell[i], aSize[i]);
|
||||
cellptr += 2;
|
||||
cellbody += aSize[i];
|
||||
if( nCell ){
|
||||
cellbody = allocateSpace(pPage, totalSize);
|
||||
assert( cellbody>0 );
|
||||
assert( pPage->nFree >= 2*nCell );
|
||||
pPage->nFree -= 2*nCell;
|
||||
for(i=0; i<nCell; i++){
|
||||
put2byte(&data[cellptr], cellbody);
|
||||
memcpy(&data[cellbody], apCell[i], aSize[i]);
|
||||
cellptr += 2;
|
||||
cellbody += aSize[i];
|
||||
}
|
||||
assert( cellbody==pPage->pBt->usableSize );
|
||||
}
|
||||
assert( cellbody==pPage->pBt->usableSize );
|
||||
pPage->nCell = nCell;
|
||||
}
|
||||
|
||||
@ -3816,7 +3818,7 @@ static int balance_nonroot(MemPage *pPage){
|
||||
/*
|
||||
** A special case: If a new entry has just been inserted into a
|
||||
** table (that is, a btree with integer keys and all data at the leaves)
|
||||
** an the new entry is the right-most entry in the tree (it has the
|
||||
** and the new entry is the right-most entry in the tree (it has the
|
||||
** largest key) then use the special balance_quick() routine for
|
||||
** balancing. balance_quick() is much faster and results in a tighter
|
||||
** packing of data in the common case.
|
||||
@ -4089,7 +4091,12 @@ static int balance_nonroot(MemPage *pPage){
|
||||
szNew[i] = szRight;
|
||||
szNew[i-1] = szLeft;
|
||||
}
|
||||
assert( cntNew[0]>0 );
|
||||
|
||||
/* Either we found one or more cells (cntnew[0])>0) or we are the
|
||||
** a virtual root page. A virtual root page is when the real root
|
||||
** page is page 1 and we are the only child of that page.
|
||||
*/
|
||||
assert( cntNew[0]>0 || (pParent->pgno==1 && pParent->nCell==0) );
|
||||
|
||||
/*
|
||||
** Allocate k new pages. Reuse old pages where possible.
|
||||
@ -4178,7 +4185,7 @@ static int balance_nonroot(MemPage *pPage){
|
||||
assert( j<nMaxCells );
|
||||
assert( pNew->pgno==pgnoNew[i] );
|
||||
assemblePage(pNew, cntNew[i]-j, &apCell[j], &szCell[j]);
|
||||
assert( pNew->nCell>0 );
|
||||
assert( pNew->nCell>0 || (nNew==1 && cntNew[0]==0) );
|
||||
assert( pNew->nOverflow==0 );
|
||||
|
||||
#ifndef SQLITE_OMIT_AUTOVACUUM
|
||||
|
43
test/btree8.test
Normal file
43
test/btree8.test
Normal file
@ -0,0 +1,43 @@
|
||||
# 2005 August 2
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this script is btree database backend.
|
||||
#
|
||||
# $Id: btree8.test,v 1.6 2005/08/02 17:13:12 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
# Ticket #1346: If the table rooted on page 1 contains a single entry
|
||||
# and that single entries has to flow out into another page because
|
||||
# page 1 is 100-bytes smaller than most other pages, then you delete that
|
||||
# one entry, everything should still work.
|
||||
#
|
||||
do_test btree8-1.1 {
|
||||
execsql {
|
||||
CREATE TABLE t1(x
|
||||
----------------------------------------------------------------------------
|
||||
----------------------------------------------------------------------------
|
||||
----------------------------------------------------------------------------
|
||||
----------------------------------------------------------------------------
|
||||
----------------------------------------------------------------------------
|
||||
----------------------------------------------------------------------------
|
||||
----------------------------------------------------------------------------
|
||||
----------------------------------------------------------------------------
|
||||
----------------------------------------------------------------------------
|
||||
----------------------------------------------------------------------------
|
||||
----------------------------------------------------------------------------
|
||||
----------------------------------------------------------------------------
|
||||
);
|
||||
DROP table t1;
|
||||
}
|
||||
} {}
|
||||
integrity_check btree8-1.2
|
Loading…
x
Reference in New Issue
Block a user