diff --git a/manifest b/manifest
index 389b4b6d91..836e62df5b 100644
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C :-)\s(CVS\s217)
-D 2001-05-15T00:39:25
+C :-)\s(CVS\s218)
+D 2001-05-21T13:45:10
F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4
F Makefile.in acef0f0275a5ca8e68bda165f7f05d810a207664
F README 51f6a4e7408b34afa5bc1c0485f61b6a4efb6958
@@ -12,7 +12,7 @@ F notes/notes1.txt b7c0812b704a022e88c621146ae50955c923d464
F notes/notes2.txt 49b4d7ba35f183feb1fb098a27272b82f5c76eca
F notes/notes3.txt cd5e7bd2167d7ef89b1077abdfa68f0af6337744
F src/TODO 38a68a489e56e9fd4a96263e0ff9404a47368ad4
-F src/btree.c f6d724fccaf108c4452dba6589e6027ba8f3e88a
+F src/btree.c bc1525234a8b169cae6f903f9cfacbcf971be942
F src/btree.h f21c240d0c95f93e2a128106d04a6c448ed0eb94
F src/build.c 4f6a2d551c56342cd4a0420654835be3ad179651
F src/dbbe.c b18259f99d87240cbe751021cf14dd3aa83a48af
@@ -31,7 +31,7 @@ F src/ex/sizes.tcl f54bad4a2ac567624be59131a6ee42d71b41a3d7
F src/expr.c c4c24c3af1eba094a816522eb0e085bed518ee16
F src/insert.c aa528e20a787af85432a61daaea6df394bd251d7
F src/main.c 0a13c7a2beb8ce36aee43daf8c95989b200727a7
-F src/pager.c 4081e3e9765c272554e22d1dcec0647ac71ea706
+F src/pager.c e45946aaf080aed251653f21667d62c89e539a97
F src/pager.h ed12ac3ddebd3afe61a0ed4bf530e7846d578e46
F src/parse.y 8fc096948994a7ffbf61ba13129cc589f794a9cb
F src/printf.c b1e22a47be8cdf707815647239991e08e8cb69f9
@@ -64,7 +64,7 @@ F test/insert2.test 732405e30331635af8d159fccabe835eea5cd0c6
F test/lock.test bca7d53de73138b1f670a2fbdb1f481ff7eaa45a
F test/main.test da635f9e078cd21ddf074e727381a715064489ff
F test/malloc.test 3daa97f6a9577d8f4c6e468b274333af19ce5861
-F test/pager.test 3416a155c2dc3b1b3c07d4bb0192cbb15b76a90c
+F test/pager.test c1eb25faa0938f803d1e6eb5201e5e976ea88256
F test/printf.test 4c71871e1a75a2dacb673945fc13ddb30168798f
F test/rowid.test 128453599def7435e988216f7fe89c7450b8a9a3
F test/select1.test 223507655cdb4f9901d83fa7f5c5328e022c211f
@@ -99,14 +99,14 @@ F www/changes.tcl 822b425cc50cb8e21563dd1aa0e4b79cf780f3dc
F www/crosscompile.tcl c99efacb3aefaa550c6e80d91b240f55eb9fd33e
F www/dynload.tcl 02eb8273aa78cfa9070dd4501dca937fb22b466c
F www/fileformat.tcl cfb7fba80b7275555281ba2f256c00734bcdd1c9
-F www/index.tcl 553a41c4157fe411465aefe391bec5687027e73f
-F www/lang.tcl 7fec414487ebee2cbb17c90addf5a026cd10396a
+F www/index.tcl 199abaf346d5fed6cf5b462a327faae39fb117b9
+F www/lang.tcl 0969ba9f13b3555e54ccdb8ec462dee2de0bf223
F www/mingw.tcl fc5f4ba9d336b6e8c97347cc6496d6162461ef60
F www/opcode.tcl cb3a1abf8b7b9be9f3a228d097d6bf8b742c2b6f
F www/sqlite.tcl cb0d23d8f061a80543928755ec7775da6e4f362f
F www/tclsqlite.tcl 06f81c401f79a04f2c5ebfb97e7c176225c0aef2
F www/vdbe.tcl 0c8aaa529dd216ccbf7daaabd80985e413d5f9ad
-P c3e521190f02120a34f1e9244fe1ea3a975a6caa
-R d3ffc66c90d6f5774a5954932275df58
+P ee6760fb62e81af95796c0fcf1e65e5dc0701194
+R 6bf7ed657f22039e86c99aa04cca003e
U drh
-Z 0f43bc31472b172caca9953860c2e8b6
+Z 4c32ca5182d7191fa6afdab861fed35d
diff --git a/manifest.uuid b/manifest.uuid
index 9a322bf7e7..847d746e24 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-ee6760fb62e81af95796c0fcf1e65e5dc0701194
\ No newline at end of file
+523d52dfa6ae3028cbcc88d406501f3ebb6cbd2d
\ No newline at end of file
diff --git a/src/btree.c b/src/btree.c
index 89d9f0c24c..767a2218e4 100644
--- a/src/btree.c
+++ b/src/btree.c
@@ -21,7 +21,7 @@
** http://www.hwaci.com/drh/
**
*************************************************************************
-** $Id: btree.c,v 1.5 2001/05/15 00:39:25 drh Exp $
+** $Id: btree.c,v 1.6 2001/05/21 13:45:10 drh Exp $
*/
#include "sqliteInt.h"
#include "pager.h"
@@ -39,8 +39,8 @@
** database entry. If the entry contains more data than this, the
** extra goes onto overflow pages.
*/
-#define MX_LOCAL_PAYLOAD ((SQLITE_PAGE_SIZE-sizeof(PageHdr)-4*sizeof(Cell))/4)
-
+#define MX_LOCAL_PAYLOAD \
+ ((SQLITE_PAGE_SIZE-sizeof(PageHdr)-4*(sizeof(Cell)+sizeof(Pgno)))/4)
/*
** The in-memory image of a disk page has the auxiliary information appended
@@ -54,9 +54,9 @@
*/
#define OVERFLOW_SIZE (SQLITE_PAGE_SIZE-sizeof(Pgno))
-
/*
** Primitive data types. u32 must be 4 bytes and u16 must be 2 bytes.
+** Change these typedefs when porting to new architectures.
*/
typedef unsigned int u32;
typedef unsigned short int u16;
@@ -74,10 +74,12 @@ typedef struct OverflowPage OverflowPage;
/*
** All structures on a database page are aligned to 4-byte boundries.
** This routine rounds up a number of bytes to the next multiple of 4.
+**
+** This might need to change for computer architectures that require
+** and 8-byte alignment boundry for structures.
*/
#define ROUNDUP(X) ((X+3) & ~3)
-
/*
** The first pages of the database file contains some additional
** information used for housekeeping and sanity checking. Otherwise,
@@ -92,7 +94,6 @@ struct Page1Header {
#define MAGIC_1 0x7264dc61
#define MAGIC_2 0x54e55d9e
-
/*
** Each database page has a header as follows:
**
@@ -102,17 +103,30 @@ struct Page1Header {
** first_free Index of first free block
**
** MemPage.pStart always points to the rightmost_pgno. First_free is
-** 0 if there is no free space on this page. Otherwise it points to
-** an area like this:
+** 0 if there is no free space on this page. Otherwise, first_free is
+** the index in MemPage.aPage[] of a FreeBlk structure that describes
+** the first block of free space. All free space is defined by a linked
+** list of FreeBlk structures.
**
-** nByte Number of free bytes in this block
-** next_free Next free block or 0 if this is the end
+** Data is stored in a linked list of Cell structures. First_cell is
+** the index into MemPage.aPage[] of the first cell on the page. The
+** Cells are kept in sorted order.
*/
struct PageHdr {
Pgno pgno; /* Child page that comes after all cells on this page */
u16 firstCell; /* Index in MemPage.aPage[] of the first cell */
u16 firstFree; /* Index in MemPage.aPage[] of the first free block */
};
+
+/*
+** Data on a database page is stored as a linked list of Cell structures.
+** Both the key and the data are stored in aData[]. The key always comes
+** first. The aData[] field grows as necessary to hold the key and data,
+** up to a maximum of MX_LOCAL_PAYLOAD bytes. If the size of the key and
+** data combined exceeds MX_LOCAL_PAYLOAD bytes, then the 4 bytes beginning
+** at Cell.aData[MX_LOCAL_PAYLOAD] are the page number of the first overflow
+** page.
+*/
struct Cell {
Pgno pgno; /* Child page that comes before this cell */
u16 nKey; /* Number of bytes in the key */
@@ -120,10 +134,28 @@ struct Cell {
u32 nData; /* Number of bytes of data */
char aData[4]; /* Key and data */
};
+
+/*
+** Free space on a page is remembered using a linked list of the FreeBlk
+** structures. Space on a database page is allocated in increments of
+** at least 4 bytes and is always aligned to a 4-byte boundry.
+*/
struct FreeBlk {
u16 iSize; /* Number of u32-sized slots in the block of free space */
u16 iNext; /* Index in MemPage.aPage[] of the next free block */
};
+
+/*
+** When the key and data for a single entry in the BTree will not fit in
+** the MX_LOACAL_PAYLOAD bytes of space available on the database page,
+** then all extra data is written to a linked list of overflow pages.
+** Each overflow page is an instance of the following structure.
+**
+** Unused pages in the database are also represented by instances of
+** the OverflowPage structure. The Page1Header.freeList field is the
+** page number of the first page in a linked list of unused database
+** pages.
+*/
struct OverflowPage {
Pgno next;
char aData[SQLITE_PAGE_SIZE-sizeof(Pgno)];
@@ -132,22 +164,29 @@ struct OverflowPage {
/*
** For every page in the database file, an instance of the following structure
** is stored in memory. The aPage[] array contains the data obtained from
-** the disk. The rest is auxiliary data that held in memory only.
+** the disk. The rest is auxiliary data that held in memory only. The
+** auxiliary data is only valid for regular database pages - the auxiliary
+** data is meaningless for overflow pages and pages on the freelist.
+**
+** Of particular interest in the auxiliary data is the aCell[] entry. Each
+** aCell[] entry is a pointer to a Cell structure in aPage[]. The cells
+** put in this array so that they can be accessed in constant time, rather
+** than in linear time which would be needed if we walked the linked list.
*/
struct MemPage {
char aPage[SQLITE_PAGE_SIZE]; /* Page data stored on disk */
- unsigned char isInit; /* True if sequel is initialized */
+ unsigned char isInit; /* True if auxiliary data is initialized */
unsigned char validUp; /* True if MemPage.up is valid */
unsigned char validLeft; /* True if MemPage.left is valid */
unsigned char validRight; /* True if MemPage.right is valid */
- Pgno up; /* The parent page. 0 means this is the root */
- Pgno left; /* Left sibling page. 0==none */
- Pgno right; /* Right sibling page. 0==none */
- int idxStart; /* Index in aPage[] of real data */
- PageHdr *pStart; /* Points to aPage[idxStart] */
- int nFree; /* Number of free bytes in aPage[] */
- int nCell; /* Number of entries on this page */
- u32 *aCell[MX_CELL]; /* All entires in sorted order */
+ Pgno up; /* The parent page. 0 means this is the root */
+ Pgno left; /* Left sibling page. 0==none */
+ Pgno right; /* Right sibling page. 0==none */
+ int idxStart; /* Index in aPage[] of real data */
+ PageHdr *pStart; /* Points to aPage[idxStart] */
+ int nFree; /* Number of free bytes in aPage[] */
+ int nCell; /* Number of entries on this page */
+ Cell *aCell[MX_CELL]; /* All data entires in sorted order */
}
/*
@@ -155,9 +194,9 @@ struct MemPage {
*/
struct Btree {
Pager *pPager; /* The page cache */
- BtCursor *pCursor; /* All open cursors */
+ BtCursor *pCursor; /* A list of all open cursors */
MemPage *page1; /* First page of the database */
- int inTrans; /* True if a transaction is current */
+ int inTrans; /* True if a transaction is in progress */
};
typedef Btree Bt;
@@ -213,7 +252,8 @@ static void defragmentPage(MemPage *pPage){
** nByte bytes in size. (Actually, all allocations are rounded
** up to the next even multiple of 4.) Return the index into
** pPage->aPage[] of the first byte of the new allocation.
-** Or return 0 if there is not enough space.
+** Or return 0 if there is not enough free space on the page to
+** satisfy the allocation request.
**
** This routine will call defragmentPage if necessary to consolidate
** free space.
@@ -249,7 +289,10 @@ static int allocSpace(MemPage *pPage, int nByte){
/*
** Return a section of the MemPage.aPage[] to the freelist.
** The first byte of the new free block is pPage->aPage[start]
-** and there are a told of size bytes to be freed.
+** and the size of the block is "size".
+**
+** Most of the effort here is involved in coalesing adjacent
+** free blocks into a single big free block.
*/
static void freeSpace(MemPage *pPage, int start, int size){
int end = start + size;
@@ -307,6 +350,7 @@ static int initPage(MemPage *pPage, Pgno pgnoThis, Pgno pgnoParent){
idx = pPage->pStart->firstCell;
while( idx!=0 ){
if( idx>SQLITE_PAGE_SIZE-sizeof(Cell) ) goto page_format_error;
+ if( idx
Download the source archive and compile the sqlite -program as described above. The type:
+program as described above. Then type:bash$ sqlite ~/newdb Directory ~/newdb created automatically diff --git a/www/lang.tcl b/www/lang.tcl index 56ae8d7661..de3e9d7790 100644 --- a/www/lang.tcl +++ b/www/lang.tcl @@ -1,7 +1,7 @@ # # Run this Tcl script to generate the sqlite.html file. # -set rcsid {$Id: lang.tcl,v 1.7 2001/04/04 11:48:58 drh Exp $} +set rcsid {$Id: lang.tcl,v 1.8 2001/05/21 13:45:10 drh Exp $} puts { @@ -384,10 +384,16 @@ to the right contains the wildcards.} puts "A percent symbol [Operator %] in the right operand matches any sequence of zero or more characters on the left. An underscore [Operator _] on the right -matches any single character on the left. The LIKE operator is +matches any single character on the left." +puts {The LIKE operator is not case sensitive and will match upper case characters on one -side against lower case characters on the other." -puts { +side against lower case characters on the other. +(A bug: SQLite only understands upper/lower case for 7-bit Latin +characters. Hence the LIKE operator is case sensitive for +8-bit iso8859 characters or UTF-8 characters. For example, +the expression 'a' LIKE 'A' is TRUE but +'æ' LIKE 'Æ' is FALSE.) +The GLOB operator is similar to LIKE but uses the Unix file globbing syntax for its wildcards. Also, GLOB is case @@ -398,7 +404,7 @@ the NOT keyword to invert the sense of the test.
statement or one of the following special identifiers: "ROWID", "OID", or "_ROWID_". These special identifiers all describe the -unique random integer key (the "row key") associated every every +unique random integer key (the "row key") associated with every row of every table. The special identifiers only refer to the row key if the CREATE TABLE statement does not define a real column with the same name. Row keys