-C A\sminor\ssimplification\sto\sthe\stokenizer.\s(CVS\s6771)
-D 2009-06-17T01:17:13
+C Fix\sfor\s#3918.\sAlso,\sfix\sthe\sTRACE\smacros\sin\sbalance_nonroot().\s(CVS\s6772)
+D 2009-06-17T11:13:28
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 8b8fb7823264331210cddf103831816c286ba446
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F src/backup.c ff50af53184a5fd7bdee4d620b5dabef74717c79
F src/bitvec.c 0ef0651714728055d43de7a4cdd95e703fac0119
F src/btmutex.c 9b899c0d8df3bd68f527b0afe03088321b696d3c
-F src/btree.c 1edede2a80d466679754453794df2d9070bd14a8
+F src/btree.c 371458438e6436e02b50796edb124a8d0e51299f
F src/btree.h f70b694e8c163227369a66863b01fbff9009f323
F src/btreeInt.h df64030d632f8c8ac217ed52e8b6b3eacacb33a5
F src/build.c 75b57e3f4de1b34d4e1e49d350dc87febff48ba0
F test/tkt3871.test 43ecbc8d90dc83908e2a454aef345acc9d160c6f
F test/tkt3879.test 2ad5bef2c87e9991ce941e054c31abe26ef7fb90
F test/tkt3911.test 74cd324f3ba653040cc6d94cc4857b290d12d633
+F test/tkt3918.test e6cdf6bfcfe9ba939d86a4238a9dc55d6eec5d42
F test/tokenize.test ce430a7aed48fc98301611429595883fdfcab5d7
F test/trace.test 19ffbc09885c3321d56358a5738feae8587fb377
F test/trans.test d887cb07630dc39879a322d958ad8b006137485c
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746
-P 08cca219f16efab93cb00f04d2e2f8033893e5f1
-R 7849aa14ee9aea370d50947a30a5b469
-U drh
-Z 7a86c39b397e7cb764e22053087fdcff
+P 18f2076ac21dd0ab343a79461837f5591f9d4d87
+R e09f9b7c30f5fb6a040ae5f6d3595072
+U danielk1977
+Z fa0237a4a1ebff673136562f4d6dd1cb
-18f2076ac21dd0ab343a79461837f5591f9d4d87
\ No newline at end of file
+368e44ec2e648b04f3b817f82586ccd864e60c89
\ No newline at end of file
** May you share freely, never taking more than you give.
**
*************************************************************************
-** $Id: btree.c,v 1.630 2009/06/16 16:50:22 danielk1977 Exp $
+** $Id: btree.c,v 1.631 2009/06/17 11:13:28 danielk1977 Exp $
**
** This file implements a external (disk-based) database using BTrees.
** See the header comment on "btreeInt.h" for additional information.
pTrunk = 0;
TRACE(("ALLOCATE: %d trunk - %d free pages left\n", *pPgno, n-1));
#endif
- }else{
+ }else if( k>0 ){
/* Extract a leaf from the trunk */
int closest;
Pgno iPage;
assert( sqlite3_mutex_held(pBt->mutex) );
assert( sqlite3PagerIswriteable(pParent->pDbPage) );
+#if 0
TRACE(("BALANCE: begin page %d child of %d\n", pPage->pgno, pParent->pgno));
+#endif
/* At this point pParent may have at most one overflow cell. And if
** this overflow cell is present, it must be the cell with
*/
assert( cntNew[0]>0 || (pParent->pgno==1 && pParent->nCell==0) );
+ TRACE(("BALANCE: old: %d %d %d ",
+ apOld[0]->pgno,
+ nOld>=2 ? apOld[1]->pgno : 0,
+ nOld>=3 ? apOld[2]->pgno : 0
+ ));
+
/*
** Allocate k new pages. Reuse old pages where possible.
*/
apNew[minI] = pT;
}
}
- TRACE(("BALANCE: old: %d %d %d new: %d(%d) %d(%d) %d(%d) %d(%d) %d(%d)\n",
- apOld[0]->pgno,
- nOld>=2 ? apOld[1]->pgno : 0,
- nOld>=3 ? apOld[2]->pgno : 0,
+ TRACE(("new: %d(%d) %d(%d) %d(%d) %d(%d) %d(%d)\n",
apNew[0]->pgno, szNew[0],
nNew>=2 ? apNew[1]->pgno : 0, nNew>=2 ? szNew[1] : 0,
nNew>=3 ? apNew[2]->pgno : 0, nNew>=3 ? szNew[2] : 0,
}
assert( pParent->isInit );
- TRACE(("BALANCE: finished with %d: old=%d new=%d cells=%d\n",
- pPage->pgno, nOld, nNew, nCell));
+ TRACE(("BALANCE: finished: old=%d new=%d cells=%d\n",
+ nOld, nNew, nCell));
/*
** Cleanup before returning.
--- /dev/null
+# 2009 June 17
+#
+# 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.
+#
+#***********************************************************************
+#
+# $Id: tkt3918.test,v 1.1 2009/06/17 11:13:28 danielk1977 Exp $
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt3918.1 {
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA auto_vacuum = incremental;
+ CREATE TABLE t1(i, x);
+ }
+} {}
+do_test tkt3918.2 {
+ execsql {
+ INSERT INTO t1 VALUES(1, randstr(1000,1000));
+ INSERT INTO t1 VALUES(2, zeroblob(248*1020 + 100));
+ INSERT INTO t1 VALUES(3, zeroblob(2*1020 + 100));
+ }
+} {}
+
+# This set of statements sets up the free list so that the
+# first free-list trunk page contains only a single leaf.
+# The leaf page is also the last page in the database. The
+# second free-list trunk page contains, amongst other things,
+# page number 4.
+do_test tkt3918.3 {
+ execsql {
+ DELETE FROM t1 WHERE i = 2;
+ DELETE FROM t1 WHERE i = 1;
+ DELETE FROM t1 WHERE i = 3;
+ }
+} {}
+
+# Incrementally vacuum the database to reduce its size by a single
+# page. This will remove the single leaf from the first page in
+# the linked list of free-list trunk pages.
+do_test tkt3918.4 {
+ execsql { PRAGMA incremental_vacuum = 1 }
+} {}
+
+# Create another table. This operation will attempt to extract
+# page 4 from the database free-list. Bug 3918 caused sqlite to
+# incorrectly report corruption here.
+do_test tkt3918.5 {
+ execsql { CREATE TABLE t2(a, b) }
+} {}
+
+finish_test
+