diff --git a/manifest b/manifest index c286507243..2aba33a84f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Defer\sthe\sexclusive\sdb\slock\suntil\sthe\spager\scache\sis\sflushed\sto\sdisk.\s41\ntests\snow\sfail.\s(CVS\s1528) -D 2004-06-04T10:38:30 +C Critical\sbugs\sfixed\sin\sbtree.c.\s\sIncompatible\sfile\sformat\schange.\s\sUnrelated\ncomment\sfix\sin\sselect.c\s(CVS\s1530) +D 2004-06-05T00:01:45 F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd @@ -25,7 +25,7 @@ F sqlite.def fc4f5734786fe4743cfe2aa98eb2da4b089edb5f F sqlite.pc.in 30552343140c53304c2a658c080fbe810cd09ca2 F src/attach.c c315c58cb16fd6e913b3bfa6412aedecb4567fa5 F src/auth.c 5c2f0bea4729c98c2be3b69d6b466fc51448fe79 -F src/btree.c 39dfc3954a7af77be42ef7fb19ab22c1fa644a83 +F src/btree.c b8a253fbbcca4da758d1d21232e873d8d5c46eb5 F src/btree.h 589427ac13bb544d298cd99726e2572a6fe4bdaa F src/build.c e12e602f06e37a0fbcb49af17cba68ad85e101b6 F src/date.c 8e6fa3173386fb29fdef012ee08a853c1e9908b2 @@ -53,7 +53,7 @@ F src/parse.y 27c1ce09f9d309be91f9e537df2fb00892990af4 F src/pragma.c 1b58d852b84b36a8b84e2245dd29b63c377414ec F src/printf.c ef750e8e2398ca7e8b58be991075f08c6a7f0e53 F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3 -F src/select.c 0297717eb7331604687c2e29c147d3a311359df1 +F src/select.c 02d711160100ef3a730060f7cfb5bc85fde06d72 F src/shell.c a9e2ad8f6c1d39b04bad61a0ec655e9a3a360b50 F src/sqlite.h.in 8236db65bc6d8f5f47dc5a5e86c4a9bce42f2adf F src/sqliteInt.h 99f2b4ff4ed28123890a0c71359fec3d2c5901c9 @@ -91,6 +91,7 @@ F test/btree2.test aa4a6d05b1ea90b1acaf83ba89039dd302a88635 F test/btree4.test 3797b4305694c7af6828675b0f4b1424b8ca30e4 F test/btree5.test 8e5ff32c02e685d36516c6499add9375fe1377f2 F test/btree6.test a5ede6bfbbb2ec8b27e62813612c0f28e8f3e027 +F test/btree7.test 429b96cfef5b51a7d512cfb4b5b3e453384af293 F test/capi2.test 8fb64e8ab7f78b8254cd4d04bb96822167f731b2 F test/capi3.test b6fe8a66d2ffe28d4faaaec154a143131e8ff631 F test/conflict.test 45ce1e44ea748944aed233df8c278a9e1c4c87cc @@ -214,7 +215,7 @@ F www/support.tcl 1801397edd271cc39a2aadd54e701184b5181248 F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 -P ff70b6d2b60c143e3ada0606ceff97571998c7e3 -R 0c89db702f37cfc005476b7d72917d3b -U danielk1977 -Z 2dc315e5203a158a5157a45199e1dfe1 +P d2f69e5ef2f261a00bb8427a4e2a1638ecfd17a9 +R eb52d3018295ee3de4004fb563723044 +U drh +Z ceec225131100608a50f7e5d2660779f diff --git a/manifest.uuid b/manifest.uuid index ab70ce9809..339a01ecd9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d2f69e5ef2f261a00bb8427a4e2a1638ecfd17a9 \ No newline at end of file +cb1ffabf86996ab20dfffcb5f133fa9a9b56bbe2 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index c112b55921..80167cb675 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.157 2004/06/04 06:22:01 danielk1977 Exp $ +** $Id: btree.c,v 1.158 2004/06/05 00:01:45 drh Exp $ ** ** This file implements a external (disk-based) database using BTrees. ** For a detailed discussion of BTrees, refer to @@ -271,8 +271,8 @@ struct MemPage { u8 hasData; /* True if this page stores data */ u8 hdrOffset; /* 100 for page 1. 0 otherwise */ u8 childPtrSize; /* 0 if leaf==1. 4 if leaf==0 */ - u8 maxLocal; /* Copy of Btree.maxLocal or Btree.maxLeaf */ - u8 minLocal; /* Copy of Btree.minLocal or Btree.minLeaf */ + u16 maxLocal; /* Copy of Btree.maxLocal or Btree.maxLeaf */ + u16 minLocal; /* Copy of Btree.minLocal or Btree.minLeaf */ u16 cellOffset; /* Index in aData of first cell pointer */ u16 idxParent; /* Index in parent of this node */ u16 nFree; /* Number of free bytes on the page */ @@ -280,7 +280,7 @@ struct MemPage { struct _OvflCell { /* Cells that will not fit on aData[] */ u8 *pCell; /* Pointers to the body of the overflow cell */ u16 idx; /* Insert this cell before idx-th non-overflow cell */ - } aOvfl[3]; + } aOvfl[5]; struct Btree *pBt; /* Pointer back to BTree structure */ u8 *aData; /* Pointer back to the start of the page */ Pgno pgno; /* Page number for this page */ @@ -307,8 +307,8 @@ struct Btree { u8 maxEmbedFrac; /* Maximum payload as % of total page size */ u8 minEmbedFrac; /* Minimum payload as % of total page size */ u8 minLeafFrac; /* Minimum leaf payload as % of total page size */ - int pageSize; /* Total number of bytes on a page */ - int usableSize; /* Number of usable bytes on each page */ + u16 pageSize; /* Total number of bytes on a page */ + u16 usableSize; /* Number of usable bytes on each page */ int maxLocal; /* Maximum local payload in non-LEAFDATA tables */ int minLocal; /* Minimum local payload in non-LEAFDATA tables */ int maxLeaf; /* Maximum local payload in a LEAFDATA table */ @@ -2807,16 +2807,16 @@ static int balance_nonroot(MemPage *pPage){ MemPage *apOld[NB]; /* pPage and up to two siblings */ Pgno pgnoOld[NB]; /* Page numbers for each page in apOld[] */ MemPage *apCopy[NB]; /* Private copies of apOld[] pages */ - MemPage *apNew[NB+1]; /* pPage and up to NB siblings after balancing */ - Pgno pgnoNew[NB+1]; /* Page numbers for each page in apNew[] */ + MemPage *apNew[NB+2]; /* pPage and up to NB siblings after balancing */ + Pgno pgnoNew[NB+2]; /* Page numbers for each page in apNew[] */ int idxDiv[NB]; /* Indices of divider cells in pParent */ u8 *apDiv[NB]; /* Divider cells in pParent */ - int cntNew[NB+1]; /* Index in aCell[] of cell after i-th page */ - int szNew[NB+1]; /* Combined size of cells place on i-th page */ + int cntNew[NB+2]; /* Index in aCell[] of cell after i-th page */ + int szNew[NB+2]; /* Combined size of cells place on i-th page */ u8 *apCell[(MX_CELL+2)*NB]; /* All cells from pages being balanced */ int szCell[(MX_CELL+2)*NB]; /* Local size of all cells */ u8 aCopy[NB][MX_PAGE_SIZE+sizeof(MemPage)]; /* Space for apCopy[] */ - u8 aSpace[MX_PAGE_SIZE*4]; /* Space to copies of divider cells */ + u8 aSpace[MX_PAGE_SIZE*5]; /* Space to copies of divider cells */ /* ** Find the parent page. @@ -3090,14 +3090,15 @@ static int balance_nonroot(MemPage *pPage){ apNew[minI] = pT; } } - TRACE(("BALANCE: old: %d %d %d new: %d(%d) %d(%d) %d(%d) %d(%d)\n", + TRACE(("BALANCE: old: %d %d %d new: %d(%d) %d(%d) %d(%d) %d(%d) %d(%d)\n", pgnoOld[0], nOld>=2 ? pgnoOld[1] : 0, nOld>=3 ? pgnoOld[2] : 0, pgnoNew[0], szNew[0], nNew>=2 ? pgnoNew[1] : 0, nNew>=2 ? szNew[1] : 0, nNew>=3 ? pgnoNew[2] : 0, nNew>=3 ? szNew[2] : 0, - nNew>=4 ? pgnoNew[3] : 0, nNew>=4 ? szNew[3] : 0)); + nNew>=4 ? pgnoNew[3] : 0, nNew>=4 ? szNew[3] : 0, + nNew>=5 ? pgnoNew[4] : 0, nNew>=5 ? szNew[4] : 0)); /* @@ -3723,11 +3724,16 @@ int sqlite3BtreePageDump(Btree *pBt, int pgno, int recursive){ u16 idx; int hdr; int nCell; + int isInit; unsigned char *data; char range[20]; unsigned char payload[20]; rc = getPage(pBt, (Pgno)pgno, &pPage); + isInit = pPage->isInit; + if( pPage->isInit==0 ){ + initPage(pPage, 0); + } if( rc ){ return rc; } @@ -3801,6 +3807,7 @@ int sqlite3BtreePageDump(Btree *pBt, int pgno, int recursive){ } sqlite3BtreePageDump(pBt, get4byte(&data[hdr+8]), 1); } + pPage->isInit = isInit; sqlite3pager_unref(data); fflush(stdout); return SQLITE_OK; @@ -4247,5 +4254,3 @@ int sqlite3BtreeSync(Btree *pBt, const char *zMaster){ } return SQLITE_OK; } - - diff --git a/src/select.c b/src/select.c index 9bb23b32bc..d6d60bb30f 100644 --- a/src/select.c +++ b/src/select.c @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle SELECT statements in SQLite. ** -** $Id: select.c,v 1.182 2004/05/29 11:24:50 danielk1977 Exp $ +** $Id: select.c,v 1.183 2004/06/05 00:01:46 drh Exp $ */ #include "sqliteInt.h" @@ -310,12 +310,6 @@ static void sqliteAggregateInfoReset(Parse *pParse){ /* ** Insert code into "v" that will push the record on the top of the ** stack into the sorter. -** -** FIX ME: Change this so that it uses the OP_MakeKey opcode -** instead of OP_SortMakeKey. Delete the OP_SortMakeKey opcode. -** All columns should have affinity NONE. Handle ASC versus -** DESC sort order by defining a list of comparison functions to -** be used by the OP_Sort opcode. */ static void pushOntoSorter(Parse *pParse, Vdbe *v, ExprList *pOrderBy){ int i; diff --git a/test/btree7.test b/test/btree7.test new file mode 100644 index 0000000000..7809f3e48d --- /dev/null +++ b/test/btree7.test @@ -0,0 +1,58 @@ +# 2004 Jun 4 +# +# 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: btree7.test,v 1.1 2004/06/05 00:01:46 drh Exp $ + + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +# Stress the balance routine by trying to create situations where +# 3 neighboring nodes split into 5. +# +set bigdata _123456789 ;# 10 +append bigdata $bigdata ;# 20 +append bigdata $bigdata ;# 40 +append bigdata $bigdata ;# 80 +append bigdata $bigdata ;# 160 +append bigdata $bigdata ;# 320 +append bigdata $bigdata ;# 640 +set data450 [string range $bigdata 0 449] +do_test btree7-1.1 { + execsql " + CREATE TABLE t1(x INTEGER PRIMARY KEY, y TEXT); + INSERT INTO t1 VALUES(1, '$bigdata'); + INSERT INTO t1 VALUES(2, '$bigdata'); + INSERT INTO t1 VALUES(3, '$data450'); + INSERT INTO t1 VALUES(5, '$data450'); + INSERT INTO t1 VALUES(8, '$bigdata'); + INSERT INTO t1 VALUES(9, '$bigdata'); + " +} {} +#puts [execsql {select * from sqlite_master}] +#set bt [btree_open test.db 2000 0] +#btree_tree_dump $bt 2 +do_test btree7-1.2 { + execsql {PRAGMA integrity_check} +} {ok} +do_test btree7-1.3 { + execsql " + INSERT INTO t1 VALUES(4, '$bigdata'); + " +} {} +#btree_tree_dump $bt 2 +do_test btree7-1.4 { + execsql {PRAGMA integrity_check} +} {ok} + +finish_test