1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

All tests now pass. But there are still issues. For example, inserts

are way too slow.  And additional tests are needed for new features. (CVS 243)

FossilOrigin-Name: e7b65e37fd88c4d69c89cfe73ab345b8b645ada6
This commit is contained in:
drh
2001-09-14 03:24:23 +00:00
parent 009d3b72ca
commit 3fc190cc3f
19 changed files with 119 additions and 92 deletions

View File

@@ -1,5 +1,5 @@
C Many\sproblems\sfixed.\sMany\sproblems\syet\sto\sgo.\s(CVS\s1722) C All\stests\snow\spass.\s\sBut\sthere\sare\sstill\sissues.\s\sFor\sexample,\sinserts\nare\sway\stoo\sslow.\s\sAnd\sadditional\stests\sare\sneeded\sfor\snew\sfeatures.\s(CVS\s243)
D 2001-09-13T21:53:10 D 2001-09-14T03:24:24
F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4 F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4
F Makefile.in 7ecb2370b5cb34d390af1fcb3118ea6d84a253ca F Makefile.in 7ecb2370b5cb34d390af1fcb3118ea6d84a253ca
F README 51f6a4e7408b34afa5bc1c0485f61b6a4efb6958 F README 51f6a4e7408b34afa5bc1c0485f61b6a4efb6958
@@ -13,9 +13,9 @@ F notes/notes2.txt 7e3fafd5e25906c1fe1e95f13b089aa398ca403e
F notes/notes2b.txt 1c17a5b7f6b44a75cd3eb98ed2c24db1eefb06c3 F notes/notes2b.txt 1c17a5b7f6b44a75cd3eb98ed2c24db1eefb06c3
F notes/notes3.txt 71e47be517e3d2578b3b9343a45b772d43b7ba16 F notes/notes3.txt 71e47be517e3d2578b3b9343a45b772d43b7ba16
F src/TODO f0ea267ab55c4d15127c1ac1667edbf781147438 F src/TODO f0ea267ab55c4d15127c1ac1667edbf781147438
F src/btree.c 823d765a20ef208ba9e8fc841d2c521fa91baefd F src/btree.c 72a9c0b2bac00ed4141488f9f2e3cea5533f1976
F src/btree.h 2427961c702dd0755ec70f529cf3db32707d689b F src/btree.h 2427961c702dd0755ec70f529cf3db32707d689b
F src/build.c ebc3ecd58f2c2792d23dd20c06fbd58393628ad7 F src/build.c d639146a7d88045f1e69d6bb827a51c19c9ec825
F src/delete.c 62500a09606c0f714b651756475cd42979ef08e8 F src/delete.c 62500a09606c0f714b651756475cd42979ef08e8
F src/ex/README b745b00acce2d892f60c40111dacdfc48e0c1c7a F src/ex/README b745b00acce2d892f60c40111dacdfc48e0c1c7a
F src/ex/db.c f1419ae6c93e40b5ac6e39fe7efd95d868e6f9d7 F src/ex/db.c f1419ae6c93e40b5ac6e39fe7efd95d868e6f9d7
@@ -25,16 +25,16 @@ F src/ex/dbbemird.c b00aef85656fa0a101dac2c32e12922ad106715a
F src/ex/pg.c 2bbf6a94f37226d06337868b6bf4d7affc60197f F src/ex/pg.c 2bbf6a94f37226d06337868b6bf4d7affc60197f
F src/ex/pg.h 23a4ac807b0546ec2bb6239ec8bd3e06926572cd F src/ex/pg.h 23a4ac807b0546ec2bb6239ec8bd3e06926572cd
F src/ex/sizes.tcl f54bad4a2ac567624be59131a6ee42d71b41a3d7 F src/ex/sizes.tcl f54bad4a2ac567624be59131a6ee42d71b41a3d7
F src/expr.c 83b6a7ed4cf502249f192b698517e9a9b8f05303 F src/expr.c bcd91d0487c71cfa44413a46efe5e2c2244901b6
F src/insert.c 1072c0dd7782c17af735df37f447630d4d577ba1 F src/insert.c edf098ecbbe00e3ecde6b5f22404a8230590c9fd
F src/main.c b72d2b03a226fdbc241afd3cf66254d504ce74b5 F src/main.c b72d2b03a226fdbc241afd3cf66254d504ce74b5
F src/md5.c 52f677bfc590e09f71d07d7e327bd59da738d07c F src/md5.c 52f677bfc590e09f71d07d7e327bd59da738d07c
F src/pager.c 05a2177c99a835c3efec1e4187556e2e29311d4a F src/pager.c 4f9e2b3955687c84567847337faeadca7d8399fa
F src/pager.h 238aa88bafe33911bf9b0b365f35afd0a261cd46 F src/pager.h 238aa88bafe33911bf9b0b365f35afd0a261cd46
F src/parse.y 8fc096948994a7ffbf61ba13129cc589f794a9cb F src/parse.y 8fc096948994a7ffbf61ba13129cc589f794a9cb
F src/printf.c b1e22a47be8cdf707815647239991e08e8cb69f9 F src/printf.c b1e22a47be8cdf707815647239991e08e8cb69f9
F src/random.c 55775802549c7152086bd19c3342293d31608532 F src/random.c b626726c4f0066610739e52e7431adae7ccd9651
F src/select.c 1e37bea8f9d8e8fdb31ef750bb038ca6a2337447 F src/select.c f1673b4d06c24665097faf28d76c4533bce18b84
F src/shell.c 1fcdf8c4180098bcfdee12501e01b4c8eb21d726 F src/shell.c 1fcdf8c4180098bcfdee12501e01b4c8eb21d726
F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e
F src/sqlite.h.in 8faa2fed0513d188ced16e5f9094e57694594e70 F src/sqlite.h.in 8faa2fed0513d188ced16e5f9094e57694594e70
@@ -44,10 +44,10 @@ F src/tclsqlite.c d328970848c028e13e61e173bef79adcc379568a
F src/test1.c abb3cb427e735ae87e6533f5b3b7164b7da91bc4 F src/test1.c abb3cb427e735ae87e6533f5b3b7164b7da91bc4
F src/test2.c b3177e061fabd20d48e4b1b4bca610a0d2b28670 F src/test2.c b3177e061fabd20d48e4b1b4bca610a0d2b28670
F src/test3.c 1fc103f198cbd0447d1a12c3ce48795755ec1a53 F src/test3.c 1fc103f198cbd0447d1a12c3ce48795755ec1a53
F src/tokenize.c 0118b57702cb6550769316e8443b06760b067acf F src/tokenize.c 00c8ab42ee731ff7466b048b449e1e838e9d638c
F src/update.c ea8f2c0712cd4cd19314a26ef4766866013facda F src/update.c ea8f2c0712cd4cd19314a26ef4766866013facda
F src/util.c c77668fef860cfd2e4e682ef4f3ed8f9e68c551b F src/util.c c77668fef860cfd2e4e682ef4f3ed8f9e68c551b
F src/vdbe.c 826fcc85277ed256d2db725cabfbefbd186b734a F src/vdbe.c 47b256d1229c448e6d9d95fb8bfa22612dd9a9df
F src/vdbe.h 9f32bd12c47bd2b4bdd7e93092bb796f2a3b649f F src/vdbe.h 9f32bd12c47bd2b4bdd7e93092bb796f2a3b649f
F src/where.c fef978a9a2234b01e30e36833ab63e14bbc626d3 F src/where.c fef978a9a2234b01e30e36833ab63e14bbc626d3
F test/all.test 841d176f11fe2fb4419e5b617faedfa617f815fa F test/all.test 841d176f11fe2fb4419e5b617faedfa617f815fa
@@ -60,28 +60,28 @@ F test/func.test ac3def2a673d1042750ae1a4ad1768bb7c7ae90b
F test/in.test ea48016c4fcc479d315932ae2b8568146686ffaf F test/in.test ea48016c4fcc479d315932ae2b8568146686ffaf
F test/index.test 73f34caeab4751e48dc337e504199b934e06b12d F test/index.test 73f34caeab4751e48dc337e504199b934e06b12d
F test/insert.test dbd3bd189edb61fddbe66c236694ef23352429f1 F test/insert.test dbd3bd189edb61fddbe66c236694ef23352429f1
F test/insert2.test 732405e30331635af8d159fccabe835eea5cd0c6 F test/insert2.test 5177c1889ee9fe238f9a021aa927fe2b59aeaf4b
F test/lock.test bca7d53de73138b1f670a2fbdb1f481ff7eaa45a F test/lock.test 9bac462a198943f73fd4b877496dff3e33f76829
F test/main.test da635f9e078cd21ddf074e727381a715064489ff F test/main.test 54527ab3195d68d15655a947d1af1818148dfc95
F test/malloc.test 3daa97f6a9577d8f4c6e468b274333af19ce5861 F test/malloc.test 3daa97f6a9577d8f4c6e468b274333af19ce5861
F test/pager.test 775a86d5b4877f3b49cb0f8ef0a1621cc6683e3b F test/pager.test 5b9d0958c85139087d6e53569c447af64bed252e
F test/printf.test 4c71871e1a75a2dacb673945fc13ddb30168798f F test/printf.test 4c71871e1a75a2dacb673945fc13ddb30168798f
F test/quote.test 40a3164af8456933a81312803fa8cdb21b205c12 F test/quote.test 40a3164af8456933a81312803fa8cdb21b205c12
F test/rowid.test b01e6dec09780c93f55db6cfe7ad097323954f23 F test/rowid.test b01e6dec09780c93f55db6cfe7ad097323954f23
F test/select1.test 223507655cdb4f9901d83fa7f5c5328e022c211f F test/select1.test 223507655cdb4f9901d83fa7f5c5328e022c211f
F test/select2.test 3817db11ee8d547328cfb6775f6399f50e3a4aa6 F test/select2.test d47c78fda07a088985b688dde42c96b46165a87f
F test/select3.test a9234b8424b6c6d71de534f43b91ade9be68e9cc F test/select3.test a9234b8424b6c6d71de534f43b91ade9be68e9cc
F test/select4.test cb5374d7c87680e294ac749307459a5cc547609d F test/select4.test cb5374d7c87680e294ac749307459a5cc547609d
F test/select5.test e2b9d51d88cbd6c307c2c05b0ef55fe7ba811ac2 F test/select5.test e2b9d51d88cbd6c307c2c05b0ef55fe7ba811ac2
F test/sort.test 838cd862642ed9a2c47e1a17b5c33da452b4552e F test/sort.test 838cd862642ed9a2c47e1a17b5c33da452b4552e
F test/subselect.test bf8b251a92fb091973c1c469ce499dc9648a41d5 F test/subselect.test bf8b251a92fb091973c1c469ce499dc9648a41d5
F test/table.test 4d3a978ea7fb0bd88e6eec27ebd69877a529b7dd F test/table.test a882150e82ef01a869cae2d35522145992258502
F test/tableapi.test 4778414470ba150983d03b9858334effe720c2e0 F test/tableapi.test 4778414470ba150983d03b9858334effe720c2e0
F test/tclsqlite.test d2aa55926874783b2401f0146e839f773c6796e1 F test/tclsqlite.test d2aa55926874783b2401f0146e839f773c6796e1
F test/tester.tcl 3147bb13461280dfc0afb7a74d14efcd8c0969a0 F test/tester.tcl 3147bb13461280dfc0afb7a74d14efcd8c0969a0
F test/trans.test 51e50e8273da6845b31a2095e9d3b221fb60d8d0 F test/trans.test 1727a0ebf0f3fb6714fcdc016cb9655b55dddbaa
F test/update.test 72c0c93310483b86dc904a992220c5b84c7ce100 F test/update.test 72c0c93310483b86dc904a992220c5b84c7ce100
F test/vacuum.test 62b01e7972dd513fb9587fbc383e5f6a5ef1a3fb F test/vacuum.test 135b57e0947ed65e92cf7e1eab64bcefd8cf9519
F test/where.test 755957829c493b1b7ad1ecb27d6c782131a6b3d5 F test/where.test 755957829c493b1b7ad1ecb27d6c782131a6b3d5
F tool/gdbmdump.c 529e67c78d920606ba196326ea55b57b75fcc82b F tool/gdbmdump.c 529e67c78d920606ba196326ea55b57b75fcc82b
F tool/gdbmstat.c 56a9033531e5f5a48413f6ec436d5fb0341632c1 F tool/gdbmstat.c 56a9033531e5f5a48413f6ec436d5fb0341632c1
@@ -107,7 +107,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 62c7bd11bcf6438cdcbf66fa67a2bf4ab9d1664d P 3dfe1711e67e08525427497f0edc3d287dc2733e
R 2372c1f59dbe1995efdd6847c777d732 R 7cdc3ce95a1070f684959a39723e9ffa
U drh U drh
Z 9edda9a44c3e972600e05079de600040 Z 5045ad3f3570f9f72b603cda49b0fddc

View File

@@ -1 +1 @@
3dfe1711e67e08525427497f0edc3d287dc2733e e7b65e37fd88c4d69c89cfe73ab345b8b645ada6

View File

@@ -21,7 +21,7 @@
** http://www.hwaci.com/drh/ ** http://www.hwaci.com/drh/
** **
************************************************************************* *************************************************************************
** $Id: btree.c,v 1.24 2001/09/13 21:53:09 drh Exp $ ** $Id: btree.c,v 1.25 2001/09/14 03:24:24 drh Exp $
** **
** This file implements a external (disk-based) database using BTrees. ** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to ** For a detailed discussion of BTrees, refer to
@@ -1702,7 +1702,7 @@ static int balance(Btree *pBt, MemPage *pPage, BtCursor *pCur){
** underfull. ** underfull.
*/ */
assert( sqlitepager_iswriteable(pPage) ); assert( sqlitepager_iswriteable(pPage) );
if( !pPage->isOverfull && pPage->nFree<SQLITE_PAGE_SIZE/3 ){ if( !pPage->isOverfull && pPage->nFree<SQLITE_PAGE_SIZE/2 && pPage->nCell>=2){
relinkCellList(pPage); relinkCellList(pPage);
return SQLITE_OK; return SQLITE_OK;
} }
@@ -1981,10 +1981,15 @@ static int balance(Btree *pBt, MemPage *pPage, BtCursor *pCur){
pParent->apCell[nxDiv]->h.leftChild = pgnoNew[nNew-1]; pParent->apCell[nxDiv]->h.leftChild = pgnoNew[nNew-1];
} }
if( pCur ){ if( pCur ){
if( j<=iCur && pCur->pPage==pParent && pCur->idx>idxDiv[nOld-1] ){
assert( pCur->pPage==pOldCurPage );
pCur->idx += nNew - nOld;
}else{
assert( pOldCurPage!=0 ); assert( pOldCurPage!=0 );
sqlitepager_ref(pCur->pPage); sqlitepager_ref(pCur->pPage);
sqlitepager_unref(pOldCurPage); sqlitepager_unref(pOldCurPage);
} }
}
/* /*
** Reparent children of all cells. ** Reparent children of all cells.
@@ -2063,6 +2068,8 @@ int sqliteBtreeInsert(
} }
insertCell(pPage, pCur->idx, &newCell, szNew); insertCell(pPage, pCur->idx, &newCell, szNew);
rc = balance(pCur->pBt, pPage, pCur); rc = balance(pCur->pBt, pPage, pCur);
/* sqliteBtreePageDump(pCur->pBt, pCur->pgnoRoot, 1); */
/* fflush(stdout); */
return rc; return rc;
} }

View File

@@ -33,7 +33,7 @@
** COPY ** COPY
** VACUUM ** VACUUM
** **
** $Id: build.c,v 1.32 2001/09/13 21:53:10 drh Exp $ ** $Id: build.c,v 1.33 2001/09/14 03:24:24 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
@@ -51,12 +51,12 @@ void sqliteExec(Parse *pParse){
int rc = SQLITE_OK; int rc = SQLITE_OK;
sqlite *db = pParse->db; sqlite *db = pParse->db;
if( sqlite_malloc_failed ) return; if( sqlite_malloc_failed ) return;
if( pParse->pVdbe ){ if( pParse->pVdbe && pParse->nErr==0 ){
if( pParse->explain ){ if( pParse->explain ){
rc = sqliteVdbeList(pParse->pVdbe, pParse->xCallback, pParse->pArg, rc = sqliteVdbeList(pParse->pVdbe, pParse->xCallback, pParse->pArg,
&pParse->zErrMsg); &pParse->zErrMsg);
}else{ }else{
FILE *trace = (db->flags & SQLITE_VdbeTrace)!=0 ? stderr : 0; FILE *trace = (db->flags & SQLITE_VdbeTrace)!=0 ? stdout : 0;
sqliteVdbeTrace(pParse->pVdbe, trace); sqliteVdbeTrace(pParse->pVdbe, trace);
rc = sqliteVdbeExec(pParse->pVdbe, pParse->xCallback, pParse->pArg, rc = sqliteVdbeExec(pParse->pVdbe, pParse->xCallback, pParse->pArg,
&pParse->zErrMsg, db->pBusyArg, &pParse->zErrMsg, db->pBusyArg,
@@ -868,6 +868,7 @@ void sqliteDropIndex(Parse *pParse, Token *pName){
sqliteVdbeAddOp(v, OP_Transaction, 0, 0, 0, 0); sqliteVdbeAddOp(v, OP_Transaction, 0, 0, 0, 0);
} }
base = sqliteVdbeAddOpList(v, ArraySize(dropIndex), dropIndex); base = sqliteVdbeAddOpList(v, ArraySize(dropIndex), dropIndex);
sqliteVdbeChangeP3(v, base+2, pIndex->zName, 0);
sqliteVdbeChangeP1(v, base+8, pIndex->tnum); sqliteVdbeChangeP1(v, base+8, pIndex->tnum);
if( (db->flags & SQLITE_InTrans)==0 ){ if( (db->flags & SQLITE_InTrans)==0 ){
sqliteVdbeAddOp(v, OP_Commit, 0, 0, 0, 0); sqliteVdbeAddOp(v, OP_Commit, 0, 0, 0, 0);

View File

@@ -24,7 +24,7 @@
** This file contains routines used for analyzing expressions and ** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions. ** for generating VDBE code that evaluates expressions.
** **
** $Id: expr.c,v 1.26 2001/09/13 14:46:10 drh Exp $ ** $Id: expr.c,v 1.27 2001/09/14 03:24:25 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
@@ -517,7 +517,7 @@ void sqliteExprCode(Parse *pParse, Expr *pExpr){
}else if( pExpr->iColumn>=0 ){ }else if( pExpr->iColumn>=0 ){
sqliteVdbeAddOp(v, OP_Column, pExpr->iTable, pExpr->iColumn, 0, 0); sqliteVdbeAddOp(v, OP_Column, pExpr->iTable, pExpr->iColumn, 0, 0);
}else{ }else{
sqliteVdbeAddOp(v, OP_FullKey, pExpr->iTable, 0, 0, 0); sqliteVdbeAddOp(v, OP_Recno, pExpr->iTable, 0, 0, 0);
} }
break; break;
} }

View File

@@ -24,7 +24,7 @@
** This file contains C code routines that are called by the parser ** This file contains C code routines that are called by the parser
** to handle INSERT statements. ** to handle INSERT statements.
** **
** $Id: insert.c,v 1.15 2001/09/13 14:46:10 drh Exp $ ** $Id: insert.c,v 1.16 2001/09/14 03:24:25 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
@@ -181,7 +181,7 @@ void sqliteInsert(
/* Create a new entry in the table and fill it with data. /* Create a new entry in the table and fill it with data.
*/ */
sqliteVdbeAddOp(v, OP_NewRecno, 0, 0, 0, 0); sqliteVdbeAddOp(v, OP_NewRecno, base, 0, 0, 0);
if( pTab->pIndex ){ if( pTab->pIndex ){
sqliteVdbeAddOp(v, OP_Dup, 0, 0, 0, 0); sqliteVdbeAddOp(v, OP_Dup, 0, 0, 0, 0);
} }

View File

@@ -27,7 +27,7 @@
** all writes in order to support rollback. Locking is used to limit ** all writes in order to support rollback. Locking is used to limit
** access to one or more reader or to one writer. ** access to one or more reader or to one writer.
** **
** @(#) $Id: pager.c,v 1.15 2001/09/13 14:46:10 drh Exp $ ** @(#) $Id: pager.c,v 1.16 2001/09/14 03:24:25 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include "pager.h" #include "pager.h"
@@ -475,11 +475,11 @@ static const char *findTempDir(void){
int i; int i;
struct stat buf; struct stat buf;
for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){ for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){
if( stat(azDirs[i], &buf)==0 && S_ISDIR(buf.st_mode) if( stat(azDirs[i], &buf) ) continue;
&& access(azDirs[i], W_OK) ){ if( !S_ISDIR(buf.st_mode) ) continue;
if( access(azDirs[i], 07) ) continue;
return azDirs[i]; return azDirs[i];
} }
}
return 0; return 0;
} }

View File

@@ -27,7 +27,7 @@
** 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.3 2001/09/13 21:53:10 drh Exp $ ** $Id: random.c,v 1.4 2001/09/14 03:24:25 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <time.h> #include <time.h>
@@ -104,6 +104,16 @@ int sqliteRandomInteger(void){
return r; return r;
} }
/*
** Return a random 16-bit unsigned integer. The integer is generated by
** making 2 calls to sqliteRandomByte().
*/
int sqliteRandomShort(void){
int r;
r = sqliteRandomByte();
r = (r<<8) + sqliteRandomByte();
return r;
}
/* /*
** Generate a random filename with the given prefix. The new filename ** Generate a random filename with the given prefix. The new filename

View File

@@ -24,7 +24,7 @@
** This file contains C code routines that are called by the parser ** This file contains C code routines that are called by the parser
** to handle SELECT statements. ** to handle SELECT statements.
** **
** $Id: select.c,v 1.35 2001/09/13 21:53:10 drh Exp $ ** $Id: select.c,v 1.36 2001/09/14 03:24:25 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
@@ -181,8 +181,8 @@ static int selectInnerLoop(
** the temporary table iParm. ** the temporary table iParm.
*/ */
if( eDest==SRT_Except ){ if( eDest==SRT_Except ){
sqliteVdbeAddOp(v, OP_MakeRecord, nColumn, 0, 0, 0); int addr = sqliteVdbeAddOp(v, OP_MakeRecord, nColumn, 0, 0, 0);
sqliteVdbeAddOp(v, OP_MoveTo, iParm, 0, 0, 0); sqliteVdbeAddOp(v, OP_NotFound, iParm, addr+3, 0, 0);
sqliteVdbeAddOp(v, OP_Delete, iParm, 0, 0, 0); sqliteVdbeAddOp(v, OP_Delete, iParm, 0, 0, 0);
}else }else

View File

@@ -27,7 +27,7 @@
** individual tokens and sends those tokens one-by-one over to the ** individual tokens and sends those tokens one-by-one over to the
** parser for analysis. ** parser for analysis.
** **
** $Id: tokenize.c,v 1.19 2001/04/11 14:28:43 drh Exp $ ** $Id: tokenize.c,v 1.20 2001/09/14 03:24:25 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <ctype.h> #include <ctype.h>
@@ -354,7 +354,7 @@ int sqliteRunParser(Parse *pParse, char *zSql, char **pzErrMsg){
#ifndef NDEBUG #ifndef NDEBUG
char *z = pParse->sLastToken.z; char *z = pParse->sLastToken.z;
if( sqliteStrNICmp(z,"--parser-trace-on--",19)==0 ){ if( sqliteStrNICmp(z,"--parser-trace-on--",19)==0 ){
trace = stderr; trace = stdout;
sqliteParserTrace(trace, "parser: "); sqliteParserTrace(trace, "parser: ");
}else if( sqliteStrNICmp(z,"--parser-trace-off--", 20)==0 ){ }else if( sqliteStrNICmp(z,"--parser-trace-off--", 20)==0 ){
trace = 0; trace = 0;

View File

@@ -41,7 +41,7 @@
** But other routines are also provided to help in building up ** But other routines are also provided to help in building up
** a program instruction by instruction. ** a program instruction by instruction.
** **
** $Id: vdbe.c,v 1.64 2001/09/13 21:53:10 drh Exp $ ** $Id: vdbe.c,v 1.65 2001/09/14 03:24:25 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <ctype.h> #include <ctype.h>
@@ -1061,7 +1061,7 @@ int sqliteVdbeExec(
rc = SQLITE_OK; rc = SQLITE_OK;
#ifdef MEMORY_DEBUG #ifdef MEMORY_DEBUG
if( access("vdbe_trace",0)==0 ){ if( access("vdbe_trace",0)==0 ){
p->trace = stderr; p->trace = stdout;
} }
#endif #endif
/* if( pzErrMsg ){ *pzErrMsg = 0; } */ /* if( pzErrMsg ){ *pzErrMsg = 0; } */
@@ -1085,6 +1085,7 @@ int sqliteVdbeExec(
fprintf(p->trace,"%4d %-12s %4d %4d %s\n", fprintf(p->trace,"%4d %-12s %4d %4d %s\n",
pc, zOpName[pOp->opcode], pOp->p1, pOp->p2, pc, zOpName[pOp->opcode], pOp->p1, pOp->p2,
pOp->p3 ? pOp->p3 : ""); pOp->p3 ? pOp->p3 : "");
fflush(p->trace);
} }
#endif #endif
@@ -2141,8 +2142,8 @@ case OP_Fcnt: {
** **
** Use the top of the stack as a key. If a record with that key ** Use the top of the stack as a key. If a record with that key
** does not exist in file P1, then jump to P2. If the record ** does not exist in file P1, then jump to P2. If the record
** does already exist, then fall thru. The record is not retrieved. ** does already exist, then fall thru. The cursor is left pointing
** The key is not popped from the stack. ** at the record if it exists. The key is not popped from the stack.
** **
** This operation is similar to NotFound except that this operation ** This operation is similar to NotFound except that this operation
** does not pop the key from the stack. ** does not pop the key from the stack.
@@ -2151,15 +2152,15 @@ case OP_Fcnt: {
** **
** Use the top of the stack as a key. If a record with that key ** Use the top of the stack as a key. If a record with that key
** does exist in file P1, then jump to P2. If the record ** does exist in file P1, then jump to P2. If the record
** does not exist, then fall thru. The record is not retrieved. ** does not exist, then fall thru. The cursor is left pointing
** The key is popped from the stack. ** to the record if it exists. The key is popped from the stack.
*/ */
/* Opcode: NotFound P1 P2 * /* Opcode: NotFound P1 P2 *
** **
** Use the top of the stack as a key. If a record with that key ** Use the top of the stack as a key. If a record with that key
** does not exist in file P1, then jump to P2. If the record ** does not exist in file P1, then jump to P2. If the record
** does exist, then fall thru. The record is not retrieved. ** does exist, then fall thru. The cursor is left pointing to the
** The key is popped from the stack. ** record if it exists. The key is popped from the stack.
** **
** The difference between this operation and Distinct is that ** The difference between this operation and Distinct is that
** Distinct does not pop the key from the stack. ** Distinct does not pop the key from the stack.
@@ -2203,14 +2204,18 @@ case OP_Found: {
*/ */
case OP_NewRecno: { case OP_NewRecno: {
int i = pOp->p1; int i = pOp->p1;
int v; static int v = 0;
if( VERIFY( i<0 || i>=p->nCursor || ) p->aCsr[i].pCursor==0 ){ if( VERIFY( i<0 || i>=p->nCursor || ) p->aCsr[i].pCursor==0 ){
v = 0; v = 0;
}else{ }else{
int res, rx, cnt; int res, rx, cnt;
cnt = 0; cnt = 0;
do{ do{
if( v==0 || cnt>5 ){
v = sqliteRandomInteger(); v = sqliteRandomInteger();
}else{
v += sqliteRandomByte() + 1;
}
rx = sqliteBtreeMoveto(p->aCsr[i].pCursor, &v, sizeof(v), &res); rx = sqliteBtreeMoveto(p->aCsr[i].pCursor, &v, sizeof(v), &res);
cnt++; cnt++;
}while( cnt<10 && rx==SQLITE_OK && res==0 ); }while( cnt<10 && rx==SQLITE_OK && res==0 );

View File

@@ -24,7 +24,7 @@
# focus of this file is testing the INSERT statement that takes is # focus of this file is testing the INSERT statement that takes is
# result from a SELECT. # result from a SELECT.
# #
# $Id: insert2.test,v 1.2 2000/06/07 15:11:27 drh Exp $ # $Id: insert2.test,v 1.3 2001/09/14 03:24:25 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@@ -45,10 +45,12 @@ do_test insert2-1.0 {
do_test insert2-1.1 { do_test insert2-1.1 {
execsql { execsql {
CREATE TABLE t1(log int, cnt int); CREATE TABLE t1(log int, cnt int);
---vdbe-trace-on--
INSERT INTO t1 SELECT log, count(*) FROM d1 GROUP BY log; INSERT INTO t1 SELECT log, count(*) FROM d1 GROUP BY log;
} }
execsql {SELECT * FROM t1 ORDER BY log} execsql {SELECT * FROM t1 ORDER BY log}
} {0 1 1 1 2 2 3 4 4 8 5 4} } {0 1 1 1 2 2 3 4 4 8 5 4}
do_test insert2-1.2 { do_test insert2-1.2 {
catch {execsql {DROP TABLE t1}} catch {execsql {DROP TABLE t1}}
execsql { execsql {

View File

@@ -23,9 +23,9 @@
# This file implements regression tests for SQLite library. The # This file implements regression tests for SQLite library. The
# focus of this script is database locks. # focus of this script is database locks.
# #
# $Id: lock.test,v 1.8 2001/04/03 16:53:22 drh Exp $ # $Id: lock.test,v 1.9 2001/09/14 03:24:25 drh Exp $
if {$dbprefix=="gdbm:" && $::tcl_platform(platform)!="windows"} { if {0} {
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl

View File

@@ -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 main.c. # focus of this file is exercising the code in main.c.
# #
# $Id: main.test,v 1.6 2001/04/04 11:48:58 drh Exp $ # $Id: main.test,v 1.7 2001/09/14 03:24:25 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@@ -83,17 +83,15 @@ do_test main-1.15 {
db complete {SELECT a-b FROM t1 } db complete {SELECT a-b FROM t1 }
} {0} } {0}
# Try to open a database with a corrupt master file. # Try to open a database with a corrupt database file.
# #
do_test main-2.0 { do_test main-2.0 {
catch {db close} catch {db close}
foreach f [glob -nocomplain testdb/*] {file delete -force $f} file delete -force test.db
file delete -force testdb set fd [open test.db w]
file mkdir testdb
set fd [open testdb/sqlite_master.tbl w]
puts $fd hi! puts $fd hi!
close $fd close $fd
set v [catch {sqlite db testdb} msg] set v [catch {sqlite db test.db} msg]
lappend v $msg lappend v $msg
} {0 {}} } {0 {}}

View File

@@ -23,13 +23,13 @@
# This file implements regression tests for SQLite library. The # This file implements regression tests for SQLite library. The
# focus of this script is page cache subsystem. # focus of this script is page cache subsystem.
# #
# $Id: pager.test,v 1.8 2001/08/20 00:33:58 drh Exp $ # $Id: pager.test,v 1.9 2001/09/14 03:24:25 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
if {$dbprefix!="memory:" && [info commands pager_open]!=""} { if {[info commands pager_open]!=""} {
# Basic sanity check. Open and close a pager. # Basic sanity check. Open and close a pager.
# #

View File

@@ -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 testing the SELECT statement. # focus of this file is testing the SELECT statement.
# #
# $Id: select2.test,v 1.12 2001/09/13 21:53:10 drh Exp $ # $Id: select2.test,v 1.13 2001/09/14 03:24:25 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@@ -78,6 +78,7 @@ do_test select2-2.0 {
puts $f "$i\t[expr {$i*2}]\t[expr {$i*3}]" puts $f "$i\t[expr {$i*2}]\t[expr {$i*3}]"
} }
close $f close $f
# execsql {--vdbe-trace-on--}
execsql {COPY tbl2 FROM './testdata1.txt'} execsql {COPY tbl2 FROM './testdata1.txt'}
file delete -force ./testdata1.txt file delete -force ./testdata1.txt
} {} } {}

View File

@@ -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 testing the CREATE TABLE statement. # focus of this file is testing the CREATE TABLE statement.
# #
# $Id: table.test,v 1.10 2001/09/13 21:53:10 drh Exp $ # $Id: table.test,v 1.11 2001/09/14 03:24:25 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@@ -57,7 +57,7 @@ do_test table-1.3 {
# #
do_test table-1.4 { do_test table-1.4 {
db close db close
sqlite db testdb sqlite db test.db
execsql {SELECT name, tbl_name, type from sqlite_master WHERE type!='meta'} execsql {SELECT name, tbl_name, type from sqlite_master WHERE type!='meta'}
} {test1 test1 table} } {test1 test1 table}
@@ -68,18 +68,12 @@ do_test table-1.5 {
execsql {SELECT * FROM sqlite_master WHERE type!='meta'} execsql {SELECT * FROM sqlite_master WHERE type!='meta'}
} {} } {}
# Verify that the file associated with the database is gone.
#
do_test table-1.5 {
lsort [glob -nocomplain testdb/*.tbl]
} {testdb/sqlite_master.tbl}
# Close and reopen the database. Verify that the table is # Close and reopen the database. Verify that the table is
# still gone. # still gone.
# #
do_test table-1.6 { do_test table-1.6 {
db close db close
sqlite db testdb sqlite db test.db
execsql {SELECT name FROM sqlite_master WHERE type!='meta'} execsql {SELECT name FROM sqlite_master WHERE type!='meta'}
} {} } {}
@@ -117,7 +111,7 @@ do_test table-2.1b {
} {1 {table sqlite_master already exists}} } {1 {table sqlite_master already exists}}
do_test table-2.1c { do_test table-2.1c {
db close db close
sqlite db testdb sqlite db test.db
set v [catch {execsql {CREATE TABLE sqlite_master(two text)}} msg] set v [catch {execsql {CREATE TABLE sqlite_master(two text)}} msg]
lappend v $msg lappend v $msg
} {1 {table sqlite_master already exists}} } {1 {table sqlite_master already exists}}
@@ -134,19 +128,22 @@ do_test table-2.2a {
} {1 {there is already an index named test3}} } {1 {there is already an index named test3}}
do_test table-2.2b { do_test table-2.2b {
db close db close
sqlite db testdb sqlite db test.db
set v [catch {execsql {CREATE TABLE test3(two text)}} msg] set v [catch {execsql {CREATE TABLE test3(two text)}} msg]
lappend v $msg lappend v $msg
} {1 {there is already an index named test3}} } {1 {there is already an index named test3}}
do_test table-2.2c { do_test table-2.2c {
execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
} {test2 test3}
do_test table-2.2d {
execsql {DROP INDEX test3} execsql {DROP INDEX test3}
set v [catch {execsql {CREATE TABLE test3(two text)}} msg] set v [catch {execsql {CREATE TABLE test3(two text)}} msg]
lappend v $msg lappend v $msg
} {0 {}} } {0 {}}
do_test table-2.2d { do_test table-2.2e {
execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name} execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
} {test2 test3} } {test2 test3}
do_test table-2.2e { do_test table-2.2f {
execsql {DROP TABLE test2; DROP TABLE test3} execsql {DROP TABLE test2; DROP TABLE test3}
execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name} execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
} {} } {}
@@ -194,7 +191,7 @@ do_test table-3.4 {
} {1 {table bIg already exists}} } {1 {table bIg already exists}}
do_test table-3.5 { do_test table-3.5 {
db close db close
sqlite db testdb sqlite db test.db
set v [catch {execsql {CREATE TABLE Big(xyz foo)}} msg] set v [catch {execsql {CREATE TABLE Big(xyz foo)}} msg]
lappend v $msg lappend v $msg
} {1 {table Big already exists}} } {1 {table Big already exists}}
@@ -222,7 +219,7 @@ do_test table-4.1 {
} $r } $r
do_test table-4.1b { do_test table-4.1b {
db close db close
sqlite db testdb sqlite db test.db
execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name} execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
} $r } $r
@@ -232,6 +229,7 @@ set r {}
for {set i 1} {$i<=100} {incr i 2} { for {set i 1} {$i<=100} {incr i 2} {
lappend r test$i lappend r test$i
} }
#execsql {--vdbe-trace-on--}
do_test table-4.2 { do_test table-4.2 {
for {set i 2} {$i<=100} {incr i 2} { for {set i 2} {$i<=100} {incr i 2} {
set sql "DROP TABLE TEST$i" set sql "DROP TABLE TEST$i"
@@ -239,6 +237,7 @@ do_test table-4.2 {
} }
execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name} execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
} $r } $r
#exit
# Drop the odd number tables # Drop the odd number tables
# #
@@ -281,11 +280,11 @@ do_test table-5.4 {
# Create a table with a goofy name # Create a table with a goofy name
# #
do_test table-6.1 { #do_test table-6.1 {
execsql {CREATE TABLE 'Spaces In This Name!'(x int)} # execsql {CREATE TABLE 'Spaces In This Name!'(x int)}
execsql {INSERT INTO 'spaces in this name!' VALUES(1)} # execsql {INSERT INTO 'spaces in this name!' VALUES(1)}
set list [glob -nocomplain testdb/spaces*.tbl] # set list [glob -nocomplain testdb/spaces*.tbl]
} {testdb/spaces+in+this+name+.tbl} #} {testdb/spaces+in+this+name+.tbl}
# Try using keywords as table names or column names. # Try using keywords as table names or column names.
# #

View File

@@ -23,13 +23,13 @@
# This file implements regression tests for SQLite library. The # This file implements regression tests for SQLite library. The
# focus of this script is database locks. # focus of this script is database locks.
# #
# $Id: trans.test,v 1.2 2001/04/12 23:21:59 drh Exp $ # $Id: trans.test,v 1.3 2001/09/14 03:24:25 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
if {$dbprefix=="gdbm:" && $::tcl_platform(platform)!="windows"} { if {0} {
# Create several tables to work with. # Create several tables to work with.
# #

View File

@@ -23,11 +23,13 @@
# This file implements regression tests for SQLite library. The # This file implements regression tests for SQLite library. The
# focus of this file is testing the VACUUM statement. # focus of this file is testing the VACUUM statement.
# #
# $Id: vacuum.test,v 1.4 2001/09/13 21:53:10 drh Exp $ # $Id: vacuum.test,v 1.5 2001/09/14 03:24:25 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
if {0} {
# Try to vacuum a non-existant table. # Try to vacuum a non-existant table.
# #
do_test vacuum-1.1 { do_test vacuum-1.1 {
@@ -79,3 +81,5 @@ do_test vacuum-1.4 {
} ;# End if( platform!=windows ) } ;# End if( platform!=windows )
finish_test finish_test
}