mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Working better with Win95.
Continued work on the new db.c backend. (CVS 1714) FossilOrigin-Name: df0ff304855bd18c7a3517c500e891b6d006be6a
This commit is contained in:
26
manifest
26
manifest
@@ -1,5 +1,5 @@
|
|||||||
C :-)\s(CVS\s1713)
|
C Working\sbetter\swith\sWin95.\nContinued\swork\son\sthe\snew\sdb.c\sbackend.\s(CVS\s1714)
|
||||||
D 2001-01-29T01:27:20
|
D 2001-01-31T13:28:08
|
||||||
F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4
|
F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4
|
||||||
F Makefile.in 7efa81e2985b45ba73db27d55b70cc927f5abfd7
|
F Makefile.in 7efa81e2985b45ba73db27d55b70cc927f5abfd7
|
||||||
F README 51f6a4e7408b34afa5bc1c0485f61b6a4efb6958
|
F README 51f6a4e7408b34afa5bc1c0485f61b6a4efb6958
|
||||||
@@ -10,8 +10,8 @@ F doc/lemon.html e233a3e97a779c7a87e1bc4528c664a58e49dd47
|
|||||||
F doc/report1.txt ad0a41513479f1be0355d1f3f074e66779ff2282
|
F doc/report1.txt ad0a41513479f1be0355d1f3f074e66779ff2282
|
||||||
F src/TODO 38a68a489e56e9fd4a96263e0ff9404a47368ad4
|
F src/TODO 38a68a489e56e9fd4a96263e0ff9404a47368ad4
|
||||||
F src/build.c 7aa5879bf58ea6bbff22c26c59d1130021fa6ca4
|
F src/build.c 7aa5879bf58ea6bbff22c26c59d1130021fa6ca4
|
||||||
F src/db.c c789cd4491afcdeddc2327107dcf3d15d4558e1a
|
F src/db.c fff070e77423bbf98f5b138f23c605006a61066d
|
||||||
F src/db.h 7109f0acd9694c58529fbf98ad6f51a74fb95bc8
|
F src/db.h 6c8b8b6777f7c55b37cb851e9fe4bc3f379920c0
|
||||||
F src/dbbe.c 162d29b09ac379f160892c5795efc14099dcc8eb
|
F src/dbbe.c 162d29b09ac379f160892c5795efc14099dcc8eb
|
||||||
F src/dbbe.h 0435a36906a839cce062608f51bd9d3e79878fec
|
F src/dbbe.h 0435a36906a839cce062608f51bd9d3e79878fec
|
||||||
F src/dbbegdbm.c 5bfcb1b4ee47a98c5eae83041e9716cd3233fd0e
|
F src/dbbegdbm.c 5bfcb1b4ee47a98c5eae83041e9716cd3233fd0e
|
||||||
@@ -23,15 +23,15 @@ F src/main.c 92fcd6d967ceee1f96a5b9543779eef6e9b56913
|
|||||||
F src/parse.y 25ee4d8efccc4b247c32fe4ab194e3dd8fd5a4ee
|
F src/parse.y 25ee4d8efccc4b247c32fe4ab194e3dd8fd5a4ee
|
||||||
F src/pg.c 2981173b2a752ef3578168e7af1a32ff22b70db6
|
F src/pg.c 2981173b2a752ef3578168e7af1a32ff22b70db6
|
||||||
F src/pg.h a95c4803a1aae99449aa2c0a1af0c8d863a3f340
|
F src/pg.h a95c4803a1aae99449aa2c0a1af0c8d863a3f340
|
||||||
F src/printf.c 1efb6b3e7f28a93be57132de3f8f400d2ac1460e
|
F src/printf.c af0dc65c293427272e1949c7807b1d88f10004fd
|
||||||
F src/random.c 3dc42fb35d834901577aa547308ff3c8941fea25
|
F src/random.c b36c3f57dc80c8f354e6bfbf39cf1e1de021d54a
|
||||||
F src/select.c 0cadab95c8011ddbffe804de94f12f3c0e317863
|
F src/select.c 0cadab95c8011ddbffe804de94f12f3c0e317863
|
||||||
F src/shell.c 441e20913cde0bb71281f4027623c623530241cd
|
F src/shell.c 441e20913cde0bb71281f4027623c623530241cd
|
||||||
F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e
|
F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e
|
||||||
F src/sqlite.h.in 7c1a53f020418d89d13ed2fe9c477ff54540755d
|
F src/sqlite.h.in 7c1a53f020418d89d13ed2fe9c477ff54540755d
|
||||||
F src/sqliteInt.h fd513fa6b7ac94919f85ebfa183aaa194284ce16
|
F src/sqliteInt.h fd513fa6b7ac94919f85ebfa183aaa194284ce16
|
||||||
F src/table.c 5be76051a8ed6f6bfa641f4adc52529efa34fbf9
|
F src/table.c 5be76051a8ed6f6bfa641f4adc52529efa34fbf9
|
||||||
F src/tclsqlite.c 178adf318eab2ff480c288a87541d4ab1c37d985
|
F src/tclsqlite.c 2a925e1835c348f07dd17c87d95ae9a577833407
|
||||||
F src/tokenize.c 6843f1d7a5d2ee08ceb10bdecfcc8684131ffcf7
|
F src/tokenize.c 6843f1d7a5d2ee08ceb10bdecfcc8684131ffcf7
|
||||||
F src/update.c 9692fbac8e95fdbc5318d39db576aa6c57b9c8ab
|
F src/update.c 9692fbac8e95fdbc5318d39db576aa6c57b9c8ab
|
||||||
F src/util.c 0298100e6427a4b644f767ede12276fa7170fbb6
|
F src/util.c 0298100e6427a4b644f767ede12276fa7170fbb6
|
||||||
@@ -40,7 +40,7 @@ F src/vdbe.h d94224ad39c8e9de83dda8d8f960059eb71c0780
|
|||||||
F src/where.c fcc2c2c84fe81a008485a32c680db3eb0aee5d22
|
F src/where.c fcc2c2c84fe81a008485a32c680db3eb0aee5d22
|
||||||
F test/all.test 15cac2f6b2d4c55bf896212aff3cc9d6597b0490
|
F test/all.test 15cac2f6b2d4c55bf896212aff3cc9d6597b0490
|
||||||
F test/copy.test b77a1214bd7756f2849d5c4fa6e715c0ff0c34eb
|
F test/copy.test b77a1214bd7756f2849d5c4fa6e715c0ff0c34eb
|
||||||
F test/dbbe.test bd2cd9fe84c6d69b6ae42ac5f55b1e940bdca886
|
F test/dbbe.test 27deeebf2a01da97cabaab8dc7f34ca3b51a0123
|
||||||
F test/delete.test 402ee3ccb6e544582d24c573ef70b34d09583ae7
|
F test/delete.test 402ee3ccb6e544582d24c573ef70b34d09583ae7
|
||||||
F test/expr.test 48273bf48a15d226c35829f702af4254c0ff6795
|
F test/expr.test 48273bf48a15d226c35829f702af4254c0ff6795
|
||||||
F test/func.test 02aed8845b98bde1043dda97455de1d37238ebb3
|
F test/func.test 02aed8845b98bde1043dda97455de1d37238ebb3
|
||||||
@@ -58,7 +58,7 @@ F test/select5.test e2b9d51d88cbd6c307c2c05b0ef55fe7ba811ac2
|
|||||||
F test/sort.test d582086c4bb7df3fbf50aa72e69d7e235e9f8e31
|
F test/sort.test d582086c4bb7df3fbf50aa72e69d7e235e9f8e31
|
||||||
F test/subselect.test bf8b251a92fb091973c1c469ce499dc9648a41d5
|
F test/subselect.test bf8b251a92fb091973c1c469ce499dc9648a41d5
|
||||||
F test/table.test eaa25951c0f18615763cd3dc248ea4bc38739c05
|
F test/table.test eaa25951c0f18615763cd3dc248ea4bc38739c05
|
||||||
F test/tester.tcl e053e14aa986c05a87de0b5635e76566f1e022ae
|
F test/tester.tcl e24caef6d07c58c16b24e7afc967464b288a4065
|
||||||
F test/update.test 62f6ce99ff31756aab0ca832ff6d34c5a87b6250
|
F test/update.test 62f6ce99ff31756aab0ca832ff6d34c5a87b6250
|
||||||
F test/vacuum.test 2127748ff4ddb409212efbb6d9fb9c469ea1b49c
|
F test/vacuum.test 2127748ff4ddb409212efbb6d9fb9c469ea1b49c
|
||||||
F test/where.test bbab5a308055fb6087dc23d600b4ad2b72797397
|
F test/where.test bbab5a308055fb6087dc23d600b4ad2b72797397
|
||||||
@@ -75,7 +75,7 @@ F www/arch.png 8dae0766d42ed3de9ed013c1341a5792bcf633e6
|
|||||||
F www/arch.tcl a40380c1fe0080c43e6cc5c20ed70731511b06be
|
F www/arch.tcl a40380c1fe0080c43e6cc5c20ed70731511b06be
|
||||||
F www/c_interface.tcl 11be2d5826eb7d6efd629751d3b483c1ed78ba14
|
F www/c_interface.tcl 11be2d5826eb7d6efd629751d3b483c1ed78ba14
|
||||||
F www/changes.tcl cb276a239c98524731e2780c70deb01b2e7e4bcc
|
F www/changes.tcl cb276a239c98524731e2780c70deb01b2e7e4bcc
|
||||||
F www/crosscompile.tcl bee79c34f6c3f162ec1c6f5294e79f73651d27ee
|
F www/crosscompile.tcl c99efacb3aefaa550c6e80d91b240f55eb9fd33e
|
||||||
F www/fileformat.tcl cfb7fba80b7275555281ba2f256c00734bcdd1c9
|
F www/fileformat.tcl cfb7fba80b7275555281ba2f256c00734bcdd1c9
|
||||||
F www/index.tcl b19418d506f90968deef972bf1b427d98bdf13e0
|
F www/index.tcl b19418d506f90968deef972bf1b427d98bdf13e0
|
||||||
F www/lang.tcl 9192e114b19987e630a41e879585b87006eb84a1
|
F www/lang.tcl 9192e114b19987e630a41e879585b87006eb84a1
|
||||||
@@ -84,7 +84,7 @@ F www/opcode.tcl cb3a1abf8b7b9be9f3a228d097d6bf8b742c2b6f
|
|||||||
F www/sqlite.tcl cb0d23d8f061a80543928755ec7775da6e4f362f
|
F www/sqlite.tcl cb0d23d8f061a80543928755ec7775da6e4f362f
|
||||||
F www/tclsqlite.tcl 06f81c401f79a04f2c5ebfb97e7c176225c0aef2
|
F www/tclsqlite.tcl 06f81c401f79a04f2c5ebfb97e7c176225c0aef2
|
||||||
F www/vdbe.tcl 0c8aaa529dd216ccbf7daaabd80985e413d5f9ad
|
F www/vdbe.tcl 0c8aaa529dd216ccbf7daaabd80985e413d5f9ad
|
||||||
P edb01b1275c3de7c398522b5826c898917811247
|
P 3259a53111bd19417e78160174bd67c69098494a
|
||||||
R fad18d8d52121b49568c3b69513e9996
|
R 75bfcecb552e742e2d0e7291a0cc0ff8
|
||||||
U drh
|
U drh
|
||||||
Z f548d6e222a005fc922c38f88384f46b
|
Z 45825268c6b006d5b2dd82f20b34d079
|
||||||
|
@@ -1 +1 @@
|
|||||||
3259a53111bd19417e78160174bd67c69098494a
|
df0ff304855bd18c7a3517c500e891b6d006be6a
|
269
src/db.c
269
src/db.c
@@ -21,7 +21,7 @@
|
|||||||
** http://www.hwaci.com/drh/
|
** http://www.hwaci.com/drh/
|
||||||
**
|
**
|
||||||
*************************************************************************
|
*************************************************************************
|
||||||
** $Id: db.c,v 1.5 2001/01/29 01:27:20 drh Exp $
|
** $Id: db.c,v 1.6 2001/01/31 13:28:08 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "pg.h"
|
#include "pg.h"
|
||||||
@@ -33,9 +33,9 @@ struct Db {
|
|||||||
Pgr *pPgr; /* The pager for the database */
|
Pgr *pPgr; /* The pager for the database */
|
||||||
DbCursor *pCursor; /* All open cursors */
|
DbCursor *pCursor; /* All open cursors */
|
||||||
int inTransaction; /* True if a transaction is in progress */
|
int inTransaction; /* True if a transaction is in progress */
|
||||||
int nContents; /* Number of slots in aContents[] */
|
u32 freeList; /* List of free blocks */
|
||||||
int nAlloc; /* Space allocated for aContents[] */
|
int nTable; /* Number of slots in aContent[] */
|
||||||
u32 *aContents; /* Contents table for the database */
|
u32 *aTable; /* Root page numbers for all tables */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -52,8 +52,6 @@ struct DbIdxpt {
|
|||||||
int pgno; /* The page number */
|
int pgno; /* The page number */
|
||||||
u32 *aPage; /* The page data */
|
u32 *aPage; /* The page data */
|
||||||
int idx; /* Index into pPage[] */
|
int idx; /* Index into pPage[] */
|
||||||
int hashLB; /* Lower bound on hash at this level */
|
|
||||||
int hashUB; /* Upper bound on hash at this level */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -69,79 +67,45 @@ struct DbCursor {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Used for rebalancing
|
** Data layouts
|
||||||
*/
|
**
|
||||||
typedef struct DbEntry DbEntry;
|
** LEAF:
|
||||||
struct DbEntry {
|
** x[0] Magic number: BLOCK_LEAF
|
||||||
int nByte; /* Space needed on leaf to record this entry */
|
** x[1] If root page, total number of entries in this table
|
||||||
int pgno; /* Page on which this entry is currently found */
|
** ... One or more entries follow the leaf.
|
||||||
int idx; /* Index slot in part that points to leaf "pgno" */
|
**
|
||||||
u32 *aPage; /* Pointer to the leaf for this entry */
|
** Entry:
|
||||||
u32 *aEntry; /* Pointer to the actual text of this entry */
|
** x[N+0] Number of u32-sized words in this entry
|
||||||
DbEntry *pNext; /* Next entry in a list of them all */
|
** x[N+1] Hash value for this entry
|
||||||
};
|
** x[N+2] Number of bytes of key in the payload
|
||||||
typedef struct DbEntrySet DbEntrySet;
|
** x[N+3] Number of bytes of data in the payload
|
||||||
struct DbEntrySet {
|
** x{N+4]... The payload area.
|
||||||
u32 *pIndex; /* The index node above the leaf pages being balanced */
|
**
|
||||||
int nAlloc; /* Number of slots allocated in aEntry[] */
|
** INDEX:
|
||||||
int nEntry; /* Number of slots in aEntry[] actually used */
|
** x[0] Magic number: BLOCK_INDEX
|
||||||
DbEntry *pFirst; /* First entry in hash order */
|
** x[1] If root page: total number of entries in this table
|
||||||
DbEntry aEntry[100]; /* Descriptions of actual database entries */
|
** x[2] Number of slots in this index (Max value of N)
|
||||||
};
|
** x[2*N+3] Page number containing entries with hash <= x[2*N+4]
|
||||||
|
** x[2*N+4] The maximum hash value for entries on page x[2*N+3].
|
||||||
|
**
|
||||||
|
** FREE:
|
||||||
|
** x[0] Magic number: BLOCK_FREE
|
||||||
|
** x[1] Page number of the next free block on the free list
|
||||||
|
**
|
||||||
|
** PAGE1:
|
||||||
|
** x[0] Magic number: BLOCK_PAGE1
|
||||||
|
** x[1] First page of the freelist
|
||||||
|
** x[2] Number of tables in this database
|
||||||
|
** x[N+3] Root page for table N
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** The first word of every page is some combination of these values
|
** The first word of every page is some combination of these values
|
||||||
** used to indicate its function.
|
** used to indicate its function.
|
||||||
*/
|
*/
|
||||||
#define BLOCK_MAGIC 0x24e47190
|
#define BLOCK_PAGE1 0x24e47191
|
||||||
#define BLOCK_INDEX 0x00000001
|
#define BLOCK_INDEX 0x7ac53b46
|
||||||
#define BLOCK_LEAF 0x00000002
|
#define BLOCK_LEAF 0x60c45eef
|
||||||
#define BLOCK_FREE 0x00000003
|
#define BLOCK_FREE 0x5b2dda47
|
||||||
#define BLOCK_OVERFLOW 0x00000004
|
|
||||||
#define BLOCK_CONTENTS 0x00000005
|
|
||||||
#define BLOCK_MAGIC_MASK 0xfffffff8
|
|
||||||
#define BLOCK_TYPE_MASK 0x00000007
|
|
||||||
|
|
||||||
/*
|
|
||||||
** Free blocks:
|
|
||||||
**
|
|
||||||
** 0. BLOCK_MAGIC | BLOCK_FREE
|
|
||||||
** 1. address of next block on freelist
|
|
||||||
**
|
|
||||||
** Leaf blocks:
|
|
||||||
**
|
|
||||||
** 0. BLOCK_MAGIC | BLOCK_LEAF
|
|
||||||
** 1. number of table entries (only used if a table root block)
|
|
||||||
** entries....
|
|
||||||
** 0. size of this entry (measured in u32's)
|
|
||||||
** 1. hash
|
|
||||||
** 2. keysize (in bytes)
|
|
||||||
** 3. datasize (in bytes)
|
|
||||||
** 4. payload
|
|
||||||
**
|
|
||||||
** Payload area:
|
|
||||||
**
|
|
||||||
** * up to LOCAL_PAYLOAD bytes of data
|
|
||||||
** * 10 page number of direct blocks
|
|
||||||
** * 1 indirect block
|
|
||||||
** * 1 double-indirect block
|
|
||||||
**
|
|
||||||
** Index block:
|
|
||||||
**
|
|
||||||
** 0. BLOCK_MAGIC | BLOCK_INDEX
|
|
||||||
** 1. number of table entries (only used if a table root block)
|
|
||||||
** 2. entries in this index block
|
|
||||||
** entries...
|
|
||||||
** 0. largest hash value for pgno
|
|
||||||
** 1. pgno of subblock
|
|
||||||
**
|
|
||||||
** Contents block: (The first page in the file)
|
|
||||||
** 0. BLOCK_MAGIC | BLOCK_CONTENTS
|
|
||||||
** 1. zero
|
|
||||||
** 2. number of bytes of payload
|
|
||||||
** 3. freelist
|
|
||||||
** 4... root pages numbers of tables
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** The number of u32-sized objects that will fit on one page.
|
** The number of u32-sized objects that will fit on one page.
|
||||||
@@ -154,34 +118,47 @@ struct DbEntrySet {
|
|||||||
#define N_DIRECT 10
|
#define N_DIRECT 10
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** The maximum amount of payload that will fit on on the same
|
** The maximum amount of payload (in bytes) that will fit on on the same
|
||||||
** page as a leaf, assuming the leaf contains only a single
|
** page as a leaf. In other words, the maximum amount of payload
|
||||||
** database entry and the entry uses no overflow pages.
|
** that does not require any overflow pages.
|
||||||
|
**
|
||||||
|
** This size is chosen so that a least 3 entry will fit on every
|
||||||
|
** leaf. That guarantees it will always be possible to add a new
|
||||||
|
** entry after a page split.
|
||||||
*/
|
*/
|
||||||
#define LOCAL_PAYLOAD (SQLITE_PAGE_SIZE - (8+N_DIRECT)*sizeof(u32))
|
#define LOCAL_PAYLOAD (((U32_PER_PAGE-2)/3 - (6+N_DIRECT))*sizeof(u32))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Allocate a new page. Return both the page number and a pointer
|
** Allocate a new page. Return both the page number and a pointer
|
||||||
** to the page data. The calling function is responsible for unref-ing
|
** to the page data. The calling function is responsible for unref-ing
|
||||||
** the page when it is no longer needed.
|
** the page when it is no longer needed.
|
||||||
|
**
|
||||||
|
** The page is obtained from the freelist if there is anything there.
|
||||||
|
** If the freelist is empty, the new page comes from the end of the
|
||||||
|
** database file.
|
||||||
*/
|
*/
|
||||||
int allocPage(Db *pDb, u32 *pPgno, u32 **ppPage){
|
int allocPage(Db *pDb, u32 *pPgno, u32 **ppPage){
|
||||||
u32 pgno;
|
u32 pgno;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if( pDb->aContent==0 ) return SQLITE_NOMEM;
|
if( pDb->aTable==0 ) return SQLITE_NOMEM;
|
||||||
|
|
||||||
/* Try to reuse a page from the freelist
|
/* Try to reuse a page from the freelist
|
||||||
*/
|
*/
|
||||||
pgno = pDb->aContent[0];
|
if( pDb->freeList==0 ){
|
||||||
if( pgno!=0 ){
|
u32 *pPage;
|
||||||
rc = sqlitePgGet(pDb->pPgr, pgno, (void**)ppPage);
|
rc = sqlitePgGet(pDb->pPgr, pDb->freeList, &pPage);
|
||||||
if( rc==SQLITE_OK ){
|
if( rc==SQLITE_OK ){
|
||||||
pDb->aContent[0] = pFree[1];
|
if( pPage[0]==BLOCK_FREE ){
|
||||||
*pPgno = pgno;
|
*pPgno = pDb->freeList;
|
||||||
|
*ppPage = aPage;
|
||||||
|
pDb->freeList = aPage[1];
|
||||||
memset(*ppPage, 0, SQLITE_PAGE_SIZE);
|
memset(*ppPage, 0, SQLITE_PAGE_SIZE);
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
|
/* This only happens if we have database corruption */
|
||||||
|
sqlitePgUnref(pPage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the freelist is empty, or we cannot access it,
|
/* If the freelist is empty, or we cannot access it,
|
||||||
@@ -200,17 +177,17 @@ int allocPage(Db *pDb, u32 *pPgno, u32 **ppPage){
|
|||||||
** Return a page to the freelist and dereference the page.
|
** Return a page to the freelist and dereference the page.
|
||||||
*/
|
*/
|
||||||
static void freePage(DB *pDb, u32 pgno, u32 *aPage){
|
static void freePage(DB *pDb, u32 pgno, u32 *aPage){
|
||||||
if( pDb->aContent==0 ) return;
|
|
||||||
if( pgno==0 ) return
|
if( pgno==0 ) return
|
||||||
if( aPage==0 ){
|
if( aPage==0 ){
|
||||||
int rc;
|
int rc;
|
||||||
rc = sqlitePgGet(pDb->pPgr, pgno, &aPage);
|
rc = sqlitePgGet(pDb->pPgr, pgno, &aPage);
|
||||||
if( rc!=SQLITE_OK ) return;
|
if( rc!=SQLITE_OK ) return;
|
||||||
}
|
}
|
||||||
aPage[0] = BLOCK_MAGIC | BLOCK_FREE;
|
assert( sqlitePgNum(aPage)==pgno );
|
||||||
aPage[1] = pDb->aContent[0];
|
aPage[0] = BLOCK_FREE;
|
||||||
|
aPage[1] = pDb->freeList;
|
||||||
|
pDb->freeList = pgno;
|
||||||
memset(&aPage[2], 0, SQLITE_PAGE_SIZE - 2*sizeof(u32));
|
memset(&aPage[2], 0, SQLITE_PAGE_SIZE - 2*sizeof(u32));
|
||||||
pDb->aContent[0] = pgno;
|
|
||||||
sqlitePgTouch(aPage);
|
sqlitePgTouch(aPage);
|
||||||
sqlitePgUnref(aPage);
|
sqlitePgUnref(aPage);
|
||||||
}
|
}
|
||||||
@@ -535,11 +512,11 @@ static int payloadWrite(Db *pDb, u32 *aPage, int offset, int amt, void *pBuf){
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Release any and all overflow pages associated with data starting
|
** Resize the payload area. If the payload area descreases in size,
|
||||||
** with byte "newSize". oldSize is the amount of payload before doing
|
** this routine deallocates unused overflow pages. If the payload
|
||||||
** the free operation.
|
** area increases in size, this routine is a no-op.
|
||||||
*/
|
*/
|
||||||
static int payloadFree(Db *pDb, u32 *aPage, int newSize, int oldSize){
|
static int payloadResize(Db *pDb, u32 *aPage, int oldSize, int newSize){
|
||||||
int i, j; /* Loop counters */
|
int i, j; /* Loop counters */
|
||||||
int first, last; /* Indices of first and last pages to be freed */
|
int first, last; /* Indices of first and last pages to be freed */
|
||||||
int rc; /* Return code from sqlitePgGet() */
|
int rc; /* Return code from sqlitePgGet() */
|
||||||
@@ -638,13 +615,9 @@ static int payloadFree(Db *pDb, u32 *aPage, int newSize, int oldSize){
|
|||||||
** Allocate space for the content table in the given Db structure.
|
** Allocate space for the content table in the given Db structure.
|
||||||
** return SQLITE_OK on success and SQLITE_NOMEM if it fails.
|
** return SQLITE_OK on success and SQLITE_NOMEM if it fails.
|
||||||
*/
|
*/
|
||||||
static int sqliteDbExpandContent(Db *pDb, int newSize){
|
static int sqliteDbExpandTableArray(Db *pDb){
|
||||||
if( pDb->nAlloc>=newSize ) return SQLITE_OK;
|
pDb->aTable = sqliteRealloc( pDb->aTable, pDb->nTable*sizeof(u32));
|
||||||
pDb->nAlloc = newSize;
|
if( pDb->aTable==0 ){
|
||||||
pDb->aContent = sqliteRealloc( pDb->aContent, pDb->nAlloc*sizeof(u32));
|
|
||||||
if( pDb->aContent==0 ){
|
|
||||||
pDb->nContent = 0;
|
|
||||||
pDb->nAlloc = 0;
|
|
||||||
pDb->inTranaction = 0;
|
pDb->inTranaction = 0;
|
||||||
return SQLITE_NOMEM;
|
return SQLITE_NOMEM;
|
||||||
}
|
}
|
||||||
@@ -676,16 +649,15 @@ int sqliteDbOpen(const char *filename, Db **ppDb){
|
|||||||
if( rc!=0 ) goto open_err;
|
if( rc!=0 ) goto open_err;
|
||||||
if( nPage==0 ){
|
if( nPage==0 ){
|
||||||
sqlitePgBeginTransaction(pDb->pPgr);
|
sqlitePgBeginTransaction(pDb->pPgr);
|
||||||
aPage1[0] = BLOCK_MAGIC|BLOCK_CONTENT;
|
aPage1[0] = BLOCK_PAGE1;
|
||||||
aPage1[2] = sizeof(u32)*10;
|
|
||||||
sqlitePgTouch(aPage1);
|
sqlitePgTouch(aPage1);
|
||||||
sqlitePgCommit(pDb->pPgr);
|
sqlitePgCommit(pDb->pPgr);
|
||||||
}
|
}
|
||||||
pDb->nContent = aPage1[2]/sizeof(u32);
|
pDb->freeList = aPage[1];
|
||||||
pDb->nAlloc = 0;
|
pDb->nTable = aPage[2];
|
||||||
rc = sqliteDbExpandContent(pDb, pDb->nContent);
|
rc = sqliteDbExpandTableArray(pDb);
|
||||||
if( rc!=SQLITE_OK ) goto open_err;
|
if( rc!=SQLITE_OK ) goto open_err;
|
||||||
rc = payloadRead(pDb, &aPage1[3], 0, aPage1[2], pDb->aContent);
|
rc = payloadRead(pDb, &aPage1[3], 0, pDb->nTable*sizeof(u32), pDb->aTable);
|
||||||
sqlitePgUnref(aPage1);
|
sqlitePgUnref(aPage1);
|
||||||
if( rc!=SQLITE_OK ) goto open_err;
|
if( rc!=SQLITE_OK ) goto open_err;
|
||||||
*ppDb = pDb;
|
*ppDb = pDb;
|
||||||
@@ -744,8 +716,9 @@ int sqliteDbCommit(Db *pDb){
|
|||||||
}
|
}
|
||||||
rc = sqlitePgGet(pDb->pPgr, 1, &aPage1);
|
rc = sqlitePgGet(pDb->pPgr, 1, &aPage1);
|
||||||
if( rc!=SQLITE_OK ) return rc;
|
if( rc!=SQLITE_OK ) return rc;
|
||||||
aPage1[2] = pDb->nContent*sizeof(u32);
|
aPage1[1] = pDb->freeList;
|
||||||
payloadWrite(pDb, 0, aPage1[2], pDb->aContent);
|
aPage1[2] = pDb->nTable;
|
||||||
|
payloadWrite(pDb, &aPage1[3], 0, pDb->nTable*sizeof(u32), pDb->aTable);
|
||||||
sqlitePgUnref(aPage1);
|
sqlitePgUnref(aPage1);
|
||||||
rc = sqlitePgCommit(pDb->pPgr);
|
rc = sqlitePgCommit(pDb->pPgr);
|
||||||
if( rc!=SQLITE_OK ) return rc;
|
if( rc!=SQLITE_OK ) return rc;
|
||||||
@@ -764,11 +737,13 @@ int sqliteDbRollback(Db *pDb){
|
|||||||
if( rc!=SQLITE_OK ) return rc;
|
if( rc!=SQLITE_OK ) return rc;
|
||||||
rc = sqlitePgGet(pDb->pPgr, 1, &aPage1);
|
rc = sqlitePgGet(pDb->pPgr, 1, &aPage1);
|
||||||
if( rc!=SQLITE_OK ) return rc;
|
if( rc!=SQLITE_OK ) return rc;
|
||||||
pDb->nContent = SWB(aPage1[3]) + 2;
|
pDb->freeList = aPage1[1];
|
||||||
if( sqliteDbExpandContent(pDb, pDb->nContent)!=SQLITE_OK ){
|
pDb->nTable = aPage1[2];
|
||||||
|
if( sqliteDbExpandTableArray(pDb)!=SQLITE_OK ){
|
||||||
return SQLITE_NOMEM;
|
return SQLITE_NOMEM;
|
||||||
}
|
}
|
||||||
payloadRead(pDb, &aPage1[3], 0, pDb->nContent*sizeof(u32), pDb->aContent);
|
payloadRead(pDb, &aPage1[3], 0, pDb->nTable*sizeof(u32), pDb->aTable);
|
||||||
|
sqlitePgUnref(aPage1);
|
||||||
pDb->inTransaction = 0;
|
pDb->inTransaction = 0;
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
@@ -778,38 +753,35 @@ int sqliteDbRollback(Db *pDb){
|
|||||||
** that is used to open a cursor into that table into *pTblno.
|
** that is used to open a cursor into that table into *pTblno.
|
||||||
*/
|
*/
|
||||||
int sqliteDbCreateTable(Db *pDb, int *pTblno){
|
int sqliteDbCreateTable(Db *pDb, int *pTblno){
|
||||||
u32 *pPage;
|
u32 *aPage;
|
||||||
u32 pgno;
|
u32 pgno;
|
||||||
int rc;
|
int rc;
|
||||||
int swTblno;
|
int swTblno;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
rc = allocPage(pDb, &pgno, &pPage);
|
rc = allocPage(pDb, &pgno, &aPage);
|
||||||
if( rc!=SQLITE_OK ){
|
if( rc!=SQLITE_OK ){
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
tblno = -1;
|
tblno = -1;
|
||||||
for(i=2; i<pDb->nContent; i++){
|
for(i=0; i<pDb->nTable; i++){
|
||||||
if( pDb->aContent[i]==0 ){
|
if( pDb->aTable[i]==0 ){
|
||||||
tblno = i - 2;
|
tblno = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( tblno<0 ){
|
if( tblno<0 ){
|
||||||
tblno = pDb->aContent[1];
|
pDb->nTable++;
|
||||||
|
rc = sqliteExpandTableArray(pDb);
|
||||||
|
if( rc!=SQLITE_OK ){
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
if( tblno+2 >= pDb->nContent ){
|
|
||||||
sqliteDbExpandContent(pDb, tblno+2);
|
|
||||||
}
|
}
|
||||||
if( pDb->aContent==0 ){
|
pDb->aTable[tblno] = pgno;
|
||||||
rc = SQLITE_NOMEM;
|
aPage[0] = BLOCK_LEAF;
|
||||||
}else{
|
memset(&aPage[1], 0, SQLITE_PAGE_SIZE - sizeof(u32));
|
||||||
pDb->aContent[tblno+2] = pgno;
|
sqlitePgTouch(aPage);
|
||||||
pPage[0] = SWB(BLOCK_MAGIC | BLOCK_LEAF);
|
sqlitePgUnref(aPage);
|
||||||
memset(&pPage[1], 0, SQLITE_PAGE_SIZE - sizeof(u32));
|
|
||||||
sqlitePgTouch(pPage);
|
|
||||||
}
|
|
||||||
sqlitePgUnref(pPage);
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -823,22 +795,22 @@ static int sqliteDbDropPage(Db *pDb, u32 pgno){
|
|||||||
rc = sqlitePgGet(pDb->pPgr, pgno, (void**)&aPage);
|
rc = sqlitePgGet(pDb->pPgr, pgno, (void**)&aPage);
|
||||||
if( rc!=SQLITE_OK ) return rc;
|
if( rc!=SQLITE_OK ) return rc;
|
||||||
switch( aPage[0] ){
|
switch( aPage[0] ){
|
||||||
case BLOCK_MAGIC | BLOCK_INDEX: {
|
case BLOCK_INDEX: {
|
||||||
int n, i;
|
int n, i;
|
||||||
n = aPage[2];
|
n = aPage[2];
|
||||||
for(i=0; i<n; i++){
|
for(i=0; i<n; i++){
|
||||||
u32 subpgno = aPage[4+i*2];
|
u32 subpgno = aPage[3 + i*2];
|
||||||
if( subpgno>0 ) sqliteDbDropPage(pDb, subpgno);
|
if( subpgno>0 ) sqliteDbDropPage(pDb, subpgno);
|
||||||
}
|
}
|
||||||
freePage(pDb, pgno, aPage);
|
freePage(pDb, pgno, aPage);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BLOCK_MAGIC | BLOCK_LEAF: {
|
case BLOCK_LEAF: {
|
||||||
int i = 2;
|
int i = 2;
|
||||||
while( i<U32_PER_PAGE ){
|
while( i<U32_PER_PAGE ){
|
||||||
int entrySize = aPage[i];
|
int entrySize = aPage[i];
|
||||||
if( entrySize==0 ) break;
|
if( entrySize==0 ) break;
|
||||||
payloadFree(pDb, &aPage[i+4], 0, aPage[i+2]+aPage[i+3]);
|
payloadResize(pDb, &aPage[i+4], aPage[i+2]+aPage[i+3], 0);
|
||||||
i += entrySize;
|
i += entrySize;
|
||||||
}
|
}
|
||||||
freePage(pDb, pgno, aPage);
|
freePage(pDb, pgno, aPage);
|
||||||
@@ -874,14 +846,17 @@ static int sqliteDbDropTable(Db *pDb, int tblno){
|
|||||||
|
|
||||||
/* Find the root page for the table to be dropped.
|
/* Find the root page for the table to be dropped.
|
||||||
*/
|
*/
|
||||||
if( pDb->aContent==0 ){
|
if( pDb->aTable==0 ){
|
||||||
return SQLITE_NOMEM;
|
return SQLITE_NOMEM;
|
||||||
}
|
}
|
||||||
if( tblno<0 || tblno+2>=pDb->nContent || pDb->aContent[tblno+2]==0 ){
|
if( tblno<0 || tblno>=pDb->nTable || pDb->aTable[tblno]==0 ){
|
||||||
return SQLITE_NOTFOUND;
|
return SQLITE_NOTFOUND;
|
||||||
}
|
}
|
||||||
pgno = pDb->aContent[tblno+2];
|
pgno = pDb->aTable[tblno];
|
||||||
pDb->aContent[tblno+2] = 0;
|
pDb->aTable[tblno] = 0;
|
||||||
|
if( tblno==pDb->nTable-1 ){
|
||||||
|
pDb->nTable--;
|
||||||
|
}
|
||||||
|
|
||||||
/* Reset any cursors pointing to the table that is about to
|
/* Reset any cursors pointing to the table that is about to
|
||||||
** be dropped */
|
** be dropped */
|
||||||
@@ -906,15 +881,15 @@ int sqliteDbCursorOpen(Db *pDb, int tblno, DbCursor **ppCur){
|
|||||||
|
|
||||||
/* Translate the table number into a page number
|
/* Translate the table number into a page number
|
||||||
*/
|
*/
|
||||||
if( pDb->aContent==0 ){
|
if( pDb->aTable==0 ){
|
||||||
*ppCur = 0;
|
*ppCur = 0;
|
||||||
return SQLITE_NOMEM;
|
return SQLITE_NOMEM;
|
||||||
}
|
}
|
||||||
if( tblno<0 || tblno+2>=pDb->nContent || pDb->aContent[tblno+2]==0 ){
|
if( tblno<0 || tblno>=pDb->nContent || pDb->aTable[tblno]==0 ){
|
||||||
*ppCur = 0;
|
*ppCur = 0;
|
||||||
return SQLITE_NOTFOUND;
|
return SQLITE_NOTFOUND;
|
||||||
}
|
}
|
||||||
pgno = SWB(pDb->aContent[tblno+2]);
|
pgno = pDb->aTable[tblno];
|
||||||
|
|
||||||
/* Allocate the cursor
|
/* Allocate the cursor
|
||||||
*/
|
*/
|
||||||
@@ -965,10 +940,10 @@ static int sqliteDbGotoFirst(DbCursor *pCur, int i){
|
|||||||
while( rc < 0 ){
|
while( rc < 0 ){
|
||||||
u32 *aPage = pCur->aLevel[i].aPage;
|
u32 *aPage = pCur->aLevel[i].aPage;
|
||||||
assert( aPage!=0 );
|
assert( aPage!=0 );
|
||||||
switch( SWB(aPage[0]) ){
|
switch( aPage[0] ){
|
||||||
case BLOCK_LEAF | BLOCK_MAGIC: {
|
case BLOCK_LEAF: {
|
||||||
if( aPage[1]!=0 ){
|
if( aPage[2]!=0 ){
|
||||||
pCur->aLevel[i].idx = 1;
|
pCur->aLevel[i].idx = 2;
|
||||||
pCur->onEntry = 1;
|
pCur->onEntry = 1;
|
||||||
}else{
|
}else{
|
||||||
sqliteDbResetCursor(pCur, 1);
|
sqliteDbResetCursor(pCur, 1);
|
||||||
@@ -976,16 +951,16 @@ static int sqliteDbGotoFirst(DbCursor *pCur, int i){
|
|||||||
rc = SQLITE_OK;
|
rc = SQLITE_OK;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BLOCK_INDEX | BLOCK_MAGIC: {
|
case BLOCK_INDEX: {
|
||||||
int n = SWB(aPage[2]);
|
int n = aPage[2];
|
||||||
if( n<2 || n>=((SQLITE_PAGE_SIZE/sizeof(u32))-3)/2 ){
|
if( n<2 || n>=((U32_PER_PAGE - 3)/2) ){
|
||||||
sqliteDbResetCur(pCur, 1);
|
sqliteDbResetCur(pCur, 1);
|
||||||
rc = SQLITE_CORRUPT;
|
rc = SQLITE_CORRUPT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pCur->nLevel++;
|
pCur->nLevel++;
|
||||||
i++;
|
i++;
|
||||||
pCur->aLevel[i].pgno = SWB(aPage[4]);
|
pCur->aLevel[i].pgno = aPage[3];
|
||||||
rc = sqlitePgGet(pCur->pDb->pPgr, pCur->aLevel[i].pgno,
|
rc = sqlitePgGet(pCur->pDb->pPgr, pCur->aLevel[i].pgno,
|
||||||
&pCur->aLevel[i].aPage);
|
&pCur->aLevel[i].aPage);
|
||||||
if( rc != SQLITE_OK ){
|
if( rc != SQLITE_OK ){
|
||||||
@@ -1004,6 +979,8 @@ static int sqliteDbGotoFirst(DbCursor *pCur, int i){
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Move the cursor to the first entry in the table.
|
** Move the cursor to the first entry in the table.
|
||||||
*/
|
*/
|
||||||
|
4
src/db.h
4
src/db.h
@@ -21,7 +21,7 @@
|
|||||||
** http://www.hwaci.com/drh/
|
** http://www.hwaci.com/drh/
|
||||||
**
|
**
|
||||||
*************************************************************************
|
*************************************************************************
|
||||||
** $Id: db.h,v 1.4 2001/01/29 01:27:20 drh Exp $
|
** $Id: db.h,v 1.5 2001/01/31 13:28:09 drh Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct Db Db;
|
typedef struct Db Db;
|
||||||
@@ -47,5 +47,5 @@ int sqliteDbCursorRead(DbCursor*, int amt, int offset, void *buf);
|
|||||||
int sqliteDbCursorReadKey(DbCursor*, int amt, int offset, void *buf);
|
int sqliteDbCursorReadKey(DbCursor*, int amt, int offset, void *buf);
|
||||||
int sqliteDbCursorWrite(DbCursor*, int amt, int offset, const void *buf);
|
int sqliteDbCursorWrite(DbCursor*, int amt, int offset, const void *buf);
|
||||||
|
|
||||||
int sqliteDbCursorFind(DbCursor*, int nKey, const void *pKey, int createSize);
|
int sqliteDbCursorFind(DbCursor*, int nKey, const void *pKey, int createFlag);
|
||||||
int sqliteDbCursorResize(DbCursor*, int nData);
|
int sqliteDbCursorResize(DbCursor*, int nData);
|
||||||
|
@@ -46,7 +46,6 @@
|
|||||||
** + All functions are fully reentrant.
|
** + All functions are fully reentrant.
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
#include <ctype.h>
|
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -262,7 +261,7 @@ static int vxprintf(
|
|||||||
}
|
}
|
||||||
c = *++fmt;
|
c = *++fmt;
|
||||||
}else{
|
}else{
|
||||||
while( isdigit(c) ){
|
while( c>='0' && c<='9' ){
|
||||||
width = width*10 + c - '0';
|
width = width*10 + c - '0';
|
||||||
c = *++fmt;
|
c = *++fmt;
|
||||||
}
|
}
|
||||||
@@ -282,7 +281,7 @@ static int vxprintf(
|
|||||||
#endif
|
#endif
|
||||||
c = *++fmt;
|
c = *++fmt;
|
||||||
}else{
|
}else{
|
||||||
while( isdigit(c) ){
|
while( c>='0' && c<='9' ){
|
||||||
precision = precision*10 + c - '0';
|
precision = precision*10 + c - '0';
|
||||||
c = *++fmt;
|
c = *++fmt;
|
||||||
}
|
}
|
||||||
|
@@ -27,10 +27,10 @@
|
|||||||
** Random numbers are used by some of the database backends in order
|
** Random numbers are used by some of the database backends in order
|
||||||
** to generate random integer keys for tables or random filenames.
|
** to generate random integer keys for tables or random filenames.
|
||||||
**
|
**
|
||||||
** $Id: random.c,v 1.1 2001/01/13 14:34:07 drh Exp $
|
** $Id: random.c,v 1.2 2001/01/31 13:28:09 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Get a single 8-bit random value from the RC4 PRNG.
|
** Get a single 8-bit random value from the RC4 PRNG.
|
||||||
|
@@ -23,12 +23,12 @@
|
|||||||
*************************************************************************
|
*************************************************************************
|
||||||
** A TCL Interface to SQLite
|
** A TCL Interface to SQLite
|
||||||
**
|
**
|
||||||
** $Id: tclsqlite.c,v 1.12 2000/10/19 14:59:27 drh Exp $
|
** $Id: tclsqlite.c,v 1.13 2001/01/31 13:28:09 drh Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef NO_TCL /* Omit this whole file if TCL is unavailable */
|
#ifndef NO_TCL /* Omit this whole file if TCL is unavailable */
|
||||||
|
|
||||||
#include "sqlite.h"
|
#include "sqlite.h"
|
||||||
#include <tcl.h>
|
#include "tcl.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
# This file implements regression tests for SQLite library. The
|
# This file implements regression tests for SQLite library. The
|
||||||
# focus of this file is exercising the code in dbbe.c.
|
# focus of this file is exercising the code in dbbe.c.
|
||||||
#
|
#
|
||||||
# $Id: dbbe.test,v 1.4 2000/10/16 22:06:43 drh Exp $
|
# $Id: dbbe.test,v 1.5 2001/01/31 13:28:09 drh Exp $
|
||||||
|
|
||||||
set testdir [file dirname $argv0]
|
set testdir [file dirname $argv0]
|
||||||
source $testdir/tester.tcl
|
source $testdir/tester.tcl
|
||||||
@@ -32,13 +32,13 @@ source $testdir/tester.tcl
|
|||||||
#
|
#
|
||||||
do_test dbbe-1.1 {
|
do_test dbbe-1.1 {
|
||||||
catch {db close}
|
catch {db close}
|
||||||
file delete -force testdb
|
forcedelete testdb
|
||||||
set v [catch {sqlite db testdb 0444} msg]
|
set v [catch {sqlite db testdb 0444} msg]
|
||||||
lappend v $msg
|
lappend v $msg
|
||||||
} {1 {can't find directory "testdb"}}
|
} {1 {can't find directory "testdb"}}
|
||||||
do_test dbbe-1.2 {
|
do_test dbbe-1.2 {
|
||||||
catch {db close}
|
catch {db close}
|
||||||
file delete -force testdb
|
forcedelete testdb
|
||||||
set v [catch {sqlite db testdb/dummy 0666} msg]
|
set v [catch {sqlite db testdb/dummy 0666} msg]
|
||||||
lappend v $msg
|
lappend v $msg
|
||||||
} {1 {can't find or create directory "testdb/dummy"}}
|
} {1 {can't find or create directory "testdb/dummy"}}
|
||||||
@@ -49,7 +49,7 @@ do_test dbbe-1.2 {
|
|||||||
#
|
#
|
||||||
do_test dbbe-1.3 {
|
do_test dbbe-1.3 {
|
||||||
catch {db close}
|
catch {db close}
|
||||||
file delete -force testdb
|
forcedelete testdb
|
||||||
set v [catch {sqlite db testdb 0666} msg]
|
set v [catch {sqlite db testdb 0666} msg]
|
||||||
lappend v $msg
|
lappend v $msg
|
||||||
} {0 {}}
|
} {0 {}}
|
||||||
@@ -58,7 +58,7 @@ do_test dbbe-1.3 {
|
|||||||
#
|
#
|
||||||
do_test dbbe-1.4 {
|
do_test dbbe-1.4 {
|
||||||
catch {db close}
|
catch {db close}
|
||||||
file delete -force testdb
|
forcedelete testdb
|
||||||
set fd [open testdb w]
|
set fd [open testdb w]
|
||||||
puts $fd hi!
|
puts $fd hi!
|
||||||
close $fd
|
close $fd
|
||||||
@@ -70,7 +70,7 @@ do_test dbbe-1.4 {
|
|||||||
#
|
#
|
||||||
do_test dbbe-1.5 {
|
do_test dbbe-1.5 {
|
||||||
catch {db close}
|
catch {db close}
|
||||||
file delete -force testdb
|
forcedelete testdb
|
||||||
file mkdir testdb
|
file mkdir testdb
|
||||||
file attributes testdb -permissions 0
|
file attributes testdb -permissions 0
|
||||||
set v [catch {sqlite db testdb 0666} msg]
|
set v [catch {sqlite db testdb 0666} msg]
|
||||||
@@ -81,7 +81,7 @@ do_test dbbe-1.5 {
|
|||||||
#
|
#
|
||||||
do_test dbbe-1.6 {
|
do_test dbbe-1.6 {
|
||||||
catch {db close}
|
catch {db close}
|
||||||
file delete -force testdb
|
forcedelete testdb
|
||||||
sqlite db testdb 0666
|
sqlite db testdb 0666
|
||||||
execsql {CREATE TABLE t1(x int)}
|
execsql {CREATE TABLE t1(x int)}
|
||||||
db close
|
db close
|
||||||
@@ -91,7 +91,7 @@ do_test dbbe-1.6 {
|
|||||||
} {1 {access permission denied for testdb/sqlite_master.tbl}}
|
} {1 {access permission denied for testdb/sqlite_master.tbl}}
|
||||||
do_test dbbe-1.6b {
|
do_test dbbe-1.6b {
|
||||||
catch {db close}
|
catch {db close}
|
||||||
file delete -force testdb
|
forcedelete testdb
|
||||||
sqlite db testdb 0666
|
sqlite db testdb 0666
|
||||||
execsql {CREATE TABLE t1(x int)}
|
execsql {CREATE TABLE t1(x int)}
|
||||||
db close
|
db close
|
||||||
@@ -105,7 +105,7 @@ do_test dbbe-1.6b {
|
|||||||
#
|
#
|
||||||
do_test dbbe-2.1 {
|
do_test dbbe-2.1 {
|
||||||
catch {db close}
|
catch {db close}
|
||||||
file delete -force testdb
|
forcedelete testdb
|
||||||
sqlite db testdb 0666
|
sqlite db testdb 0666
|
||||||
execsql {
|
execsql {
|
||||||
CREATE TABLE t1(x int);
|
CREATE TABLE t1(x int);
|
||||||
@@ -123,7 +123,7 @@ do_test dbbe-2.1 {
|
|||||||
#
|
#
|
||||||
do_test dbbe-3.1 {
|
do_test dbbe-3.1 {
|
||||||
catch {db close}
|
catch {db close}
|
||||||
file delete -force testdb
|
forcedelete testdb
|
||||||
sqlite db testdb 0666
|
sqlite db testdb 0666
|
||||||
execsql {CREATE TABLE t1(x int)}
|
execsql {CREATE TABLE t1(x int)}
|
||||||
db close
|
db close
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
# This file implements some common TCL routines used for regression
|
# This file implements some common TCL routines used for regression
|
||||||
# testing the SQLite library
|
# testing the SQLite library
|
||||||
#
|
#
|
||||||
# $Id: tester.tcl,v 1.9 2001/01/22 00:31:53 drh Exp $
|
# $Id: tester.tcl,v 1.10 2001/01/31 13:28:09 drh Exp $
|
||||||
|
|
||||||
# Create a test database
|
# Create a test database
|
||||||
#
|
#
|
||||||
@@ -36,7 +36,9 @@ if {![info exists dbprefix]} {
|
|||||||
}
|
}
|
||||||
switch $dbprefix {
|
switch $dbprefix {
|
||||||
gdbm: {
|
gdbm: {
|
||||||
file delete -force testdb
|
if {[catch {file delete -force testdb}]} {
|
||||||
|
exec rm -rf testdb
|
||||||
|
}
|
||||||
file mkdir testdb
|
file mkdir testdb
|
||||||
}
|
}
|
||||||
memory: {
|
memory: {
|
||||||
@@ -155,3 +157,11 @@ proc execsql2 {sql} {
|
|||||||
}
|
}
|
||||||
return $result
|
return $result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Delete a file or directory
|
||||||
|
#
|
||||||
|
proc forcedelete {filename} {
|
||||||
|
if {[catch {file delete -force $filename}]} {
|
||||||
|
exec rm -rf $filename
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# Run this Tcl script to generate the crosscompile.html file.
|
# Run this Tcl script to generate the crosscompile.html file.
|
||||||
#
|
#
|
||||||
set rcsid {$Id: crosscompile.tcl,v 1.3 2000/10/11 19:28:53 drh Exp $}
|
set rcsid {$Id: crosscompile.tcl,v 1.4 2001/01/31 13:28:09 drh Exp $}
|
||||||
|
|
||||||
puts {<html>
|
puts {<html>
|
||||||
<head>
|
<head>
|
||||||
@@ -148,9 +148,9 @@ cat >>systems.h <<\END
|
|||||||
#undef UNLOCK_FILE
|
#undef UNLOCK_FILE
|
||||||
#define UNLOCK_FILE(x)
|
#define UNLOCK_FILE(x)
|
||||||
#undef READLOCK_FILE
|
#undef READLOCK_FILE
|
||||||
#define READLOCK_FILE(x)
|
#define READLOCK_FILE(x) lock_val=0;
|
||||||
#undef WRITELOCK_FILE
|
#undef WRITELOCK_FILE
|
||||||
#define WRITELOCK_FILE(x)
|
#define WRITELOCK_FILE(x) lock_val=0;
|
||||||
#endif
|
#endif
|
||||||
END
|
END
|
||||||
</pre></blockquote>
|
</pre></blockquote>
|
||||||
|
Reference in New Issue
Block a user