]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
:-) (CVS 215)
authordrh <drh@noemail.net>
Sun, 29 Apr 2001 23:32:55 +0000 (23:32 +0000)
committerdrh <drh@noemail.net>
Sun, 29 Apr 2001 23:32:55 +0000 (23:32 +0000)
FossilOrigin-Name: 624ccbca98be33a26c2af72d2d91c78f8a06ae9c

manifest
manifest.uuid
src/btree.c

index f1036bf40ef01e972f46cfd0fbd51a667a8594e2..b9f7b6165422e6b4f7ccb52a6359e45fc0097583 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C :-)\s(CVS\s214)
-D 2001-04-28T16:52:41
+C :-)\s(CVS\s215)
+D 2001-04-29T23:32:56
 F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4
 F Makefile.in acef0f0275a5ca8e68bda165f7f05d810a207664
 F README 51f6a4e7408b34afa5bc1c0485f61b6a4efb6958
@@ -12,7 +12,7 @@ F notes/notes1.txt b7c0812b704a022e88c621146ae50955c923d464
 F notes/notes2.txt 80a0c3e3a0063b81fa8df6aab01bd014353dde01
 F notes/notes3.txt cd5e7bd2167d7ef89b1077abdfa68f0af6337744
 F src/TODO 38a68a489e56e9fd4a96263e0ff9404a47368ad4
-F src/btree.c 71381fdaec3122f80c53f7f4f38887bcff19d273
+F src/btree.c eb7eec19f54e758c86a231f97fd366cc2d4cffc1
 F src/btree.h f21c240d0c95f93e2a128106d04a6c448ed0eb94
 F src/build.c 4f6a2d551c56342cd4a0420654835be3ad179651
 F src/dbbe.c b18259f99d87240cbe751021cf14dd3aa83a48af
@@ -106,7 +106,7 @@ F www/opcode.tcl cb3a1abf8b7b9be9f3a228d097d6bf8b742c2b6f
 F www/sqlite.tcl cb0d23d8f061a80543928755ec7775da6e4f362f
 F www/tclsqlite.tcl 06f81c401f79a04f2c5ebfb97e7c176225c0aef2
 F www/vdbe.tcl 0c8aaa529dd216ccbf7daaabd80985e413d5f9ad
-P 8e0476f9004a7db8a3426e57f477393645ff5629
-R 3f48b136215cd8bc470d216a44941a5e
+P 73a1ed61265040925f1a41c9c0cfeea50db70b01
+R 6983c25437d4d42e0292396f95237df8
 U drh
-Z f40f8ecab433b0ffb267dc5ca6c7154e
+Z 352332e9d2b2a7ec788ddf63618fa616
index f03409e7175b27201cca98c2446c8a875eeefc5d..8fb1accbfd836fb31827ae8fed49a0e7fab239e6 100644 (file)
@@ -1 +1 @@
-73a1ed61265040925f1a41c9c0cfeea50db70b01
\ No newline at end of file
+624ccbca98be33a26c2af72d2d91c78f8a06ae9c
\ No newline at end of file
index bfca825bd0fa9dc95b281d0c2c88ab1761f275f7..c310dc3a335d3c0ac5f735d618a433c1c0fdf18b 100644 (file)
@@ -21,7 +21,7 @@
 **   http://www.hwaci.com/drh/
 **
 *************************************************************************
-** $Id: btree.c,v 1.2 2001/04/28 16:52:41 drh Exp $
+** $Id: btree.c,v 1.3 2001/04/29 23:32:56 drh Exp $
 */
 #include "sqliteInt.h"
 #include "pager.h"
 
 typedef unsigned int u32;
 
+
+/*
+** The first page contains the following additional information:
+**
+**      MAGIC-1
+**      MAGIC-2
+**      First free block
+*/
+#define EXTRA_PAGE_1_CELLS  3
+#define MAGIC_1  0x7264dc61
+#define MAGIC_2  0x54e55d9e
+
+/*
+** Each database page has a header as follows:
+**
+**      page1_header          Extra numbers found on page 1 only.
+**      leftmost_pgno         Page number of the leftmost child
+**      first_cell            Index into MemPage.aPage of first cell
+**      first_free            Index of first free block
+**
+** MemPage.pStart always points to the leftmost_pgno.  First_free is
+** 0 if there is no free space on this page.  Otherwise it points to
+** an area like this:
+**
+**      nByte                 Number of free bytes in this block
+**      next_free             Next free block or 0 if this is the end
+*/
+
 /*
 ** The maximum number of database entries that can be held in a single
 ** page of the database.  Each entry has a 16-byte header consisting of
@@ -45,13 +73,7 @@ typedef unsigned int u32;
 ** be at least 4 bytes in the key/data packet, so each entry consumes at
 ** least 20 bytes of space on the page.
 */
-#define MX_CELL (SQLITE_PAGE_SIZE/20)
-
-/*
-** Freeblocks are divided by cells, so there can be at most one more
-** free block than there are cells.
-*/
-#define MX_FREE (MX_CELL+1)
+#define MX_CELL ((SQLITE_PAGE_SIZE-12)/20)
 
 /*
 ** The maximum amount of data (in bytes) that can be stored locally for a
@@ -87,11 +109,9 @@ struct MemPage {
   Pgno left;                   /* Left sibling page.  0==none */
   Pgno right;                  /* Right sibling page.  0==none */
   int idxStart;                /* Index in aPage[] of real data */
+  int nFree;                   /* Number of free elements of aPage[] */
   int nCell;                   /* Number of entries on this page */
   u32 *aCell[MX_CELL];         /* All entires in sorted order */
-  int nFree;                   /* Number of free blocks on this page */
-  int nFreeSlot;               /* Number of free elements of aPage[] */
-  FreeBlk aFree[MX_FREE];      /* Free blocks in no particular order */
 }
 typedef struct MemPage;
 
@@ -143,27 +163,6 @@ struct BtCursor {
   BtIdxpt aLevel[MX_LEVEL];     /* The index levels */
 };
 
-/*
-** The first page contains the following additional information:
-**
-**      MAGIC-1
-**      MAGIC-2
-**      First free block
-*/
-#define EXTRA_PAGE_1_CELLS  3
-#define MAGIC_1  0x7264dc61
-#define MAGIC_2  0x54e55d9e
-
-/*
-** Each database page has a header as follows:
-**
-**      page1_header          Extra numbers found on page 1 only.
-**      leftmost_pgno         Page number of the leftmost child
-**      first_cell            Index into MemPage.aPage of first cell
-**
-** MemPage.pStart always points to the leftmost_pgno.
-*/
-
 /*
 ** Mark a section of the memory block as in-use.
 */
@@ -201,9 +200,12 @@ static void useSpace(MemPage *pPage, int start, int size){
     /* Space at the end of the block */
     p->size -= size;
   }else{
-    /* Space in the middle of the freeblock.  We have to split the
-    ** freeblock in two */
-    /******* TBD *********/
+    /* Space in the middle of the freeblock. */
+    FreeBlk *pNew;
+    assert( p->nFreeSlot < MX_FREE );
+    pNew->idx = start+size;
+    pNew->size = p->idx+p->size - pNew->idx;
+    p->size = start - p->idx;
   }
   pPage->nFreeSlot -= size;
 }
@@ -212,6 +214,26 @@ static void useSpace(MemPage *pPage, int start, int size){
 ** Return a section of the MemPage.aPage[] to the freelist.
 */
 static void freeSpace(MemPage *pPage, int start, int size){
+  int end = start+size;
+  int i;
+  FreeBlk *pMatch = 0;
+  FreeBlk *
+  for(i=0; i<pPage->nFreeSlot; i++){
+    FreeBlk *p = &pPage->aFree[i];
+    if( p->idx==end+1 ){
+      if( pMatch ){
+        
+      }else{
+        p->idx = start;
+        p->size += size;
+        pMatch = p;
+      }
+    }
+    if( p->idx+p->size+1==start ){
+      p->size += size;
+      break;
+    }
+  }
 }
 
 /*