-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
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
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
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
-a5ce6c58c3bfc0e1c9953fe4ad4991ac56a4fb87
\ No newline at end of file
+3af69a49289f52f321ccd365e92d22b820c3139e
\ No newline at end of file
** 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
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;
}
/*
** 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.
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.
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
--- /dev/null
+# 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