From 4c5043910bdfc78797702dec7a4b42a31d1e2049 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 16 Oct 2000 22:06:40 +0000 Subject: [PATCH] Added an interrupt capability (CVS 153) FossilOrigin-Name: f7ea08b931b9b40831bfe73cd7afea17f92112cf --- VERSION | 2 +- manifest | 38 +++++++++++++++++++------------------- manifest.uuid | 2 +- src/build.c | 14 ++++++++------ src/main.c | 18 ++++++++++++------ src/select.c | 6 +++--- src/shell.c | 24 +++++++++++++++++++++--- src/sqlite.h.in | 16 +++++++++++++--- src/sqliteInt.h | 8 +++++--- src/tokenize.c | 17 ++++++++++++++--- src/vdbe.c | 23 ++++++++++++++++++++--- src/vdbe.h | 4 ++-- test/dbbe.test | 4 ++-- test/lock.test | 4 ++-- www/c_interface.tcl | 16 +++++++++++++++- www/changes.tcl | 9 ++++++++- 16 files changed, 146 insertions(+), 59 deletions(-) diff --git a/VERSION b/VERSION index 7ee7020b38..59e9e60491 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.10 +1.0.11 diff --git a/manifest b/manifest index d6588931e1..c57804da86 100644 --- a/manifest +++ b/manifest @@ -1,38 +1,38 @@ -C Removed\sdlmalloc.c\s(CVS\s1705) -D 2000-10-12T13:29:49 +C Added\san\sinterrupt\scapability\s(CVS\s153) +D 2000-10-16T22:06:41 F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4 F Makefile.in faecea9b6419cec25030b4818c9b3f7f4163b3c1 F README 51f6a4e7408b34afa5bc1c0485f61b6a4efb6958 -F VERSION 0302755bd219af2c39c53cc097caccb858798223 +F VERSION 680e898474f571402b75096f1fb5d186126c3296 F configure 3dc1edb9dcf60215e31ff72b447935ab62211442 x F configure.in d892ca33db7e88a055519ce2f36dcb11020e8fff F doc/lemon.html e233a3e97a779c7a87e1bc4528c664a58e49dd47 -F src/build.c 4d90e9e94750ca80249fc7958c617021d8bb7a50 +F src/build.c e2ceba852dc45ca899e68a042b29c3daab011575 F src/dbbe.c 226daaf8c095ceb4aff48cad188dad90643f9867 F src/dbbe.h 6337132f904e72ecb28b07390021c241397e4cbf F src/dbbemem.c eb3d79be7105bd80069815ee499c8e8682876378 F src/delete.c 4d491eaf61b515516749c7ed68fa3b2ee8a09065 F src/expr.c e8e350d7baa33bd9ed8701c159eaba5e912e0adb F src/insert.c f146f149ad2422a1dc3bfa7a1651a25940f98958 -F src/main.c 03ca6d7601b40a3c6de95d7f8c6c817e8cca9fdf +F src/main.c 4774731549159ba33c031cfaf6e4c78630c80d96 F src/parse.y 5d199034de5d29ebedb42c1c51f34db4df40cbe5 F src/printf.c 6fc343f0c3537e2530a11ac164ce64ba171aebf8 -F src/select.c d382e96c2221d08367cc87976f2b574537c9de97 -F src/shell.c ef5d12129c824cb98238763e9e86ca1847e0c7bd +F src/select.c c1de8ac34131324fa05664b06b0ae1ee9c02905d +F src/shell.c 146149928c7dca23ceebd6aa53026e9b02d3b4e4 F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e -F src/sqlite.h.in 7a11f9d131e9657d11dee5c23dfe458da91de8e2 -F src/sqliteInt.h b65fdecac7281aafb4c9ff3e79ea1b5546478385 +F src/sqlite.h.in 43c0e1e321e94c20eb20efe593155296cd57728a +F src/sqliteInt.h 4b49e8c162c2ebf5d7a7ed392953380dbfd3673a F src/table.c f08189678c806d8a74a70c156d7c27083760e028 F src/tclsqlite.c 44b08b47612a668caaf7c4ec32133b69d73ff78e -F src/tokenize.c 097bec5843d4a0fb4509e036fee93bac080c5e73 +F src/tokenize.c b0f5c12598105ec924c0733a916485f920168720 F src/update.c 51b9ef7434b15e31096155da920302e9db0d27fc F src/util.c 811e0ad47f842c16555aaf361b26dab7221c1a6c -F src/vdbe.c b8b0bc26d6543d5d33820809122bf0e7659e4663 -F src/vdbe.h 8ca755f77eeaa93886d25188fd66129febfa16cf +F src/vdbe.c 7acc17367da350259107dcb1dac5590e8747b890 +F src/vdbe.h 140cdec3c56f70483e169f8ae657bd90f9fd6e98 F src/where.c 3dfad2ffd0aa994d5eceac88852f7189c8d1d3c8 F test/all.test 0950c135cab7e60c07bd745ccfad1476211e5bd7 F test/copy.test b77a1214bd7756f2849d5c4fa6e715c0ff0c34eb -F test/dbbe.test c6079572516aeb2739a35fd272b105c45c30cc76 +F test/dbbe.test bd2cd9fe84c6d69b6ae42ac5f55b1e940bdca886 F test/delete.test 402ee3ccb6e544582d24c573ef70b34d09583ae7 F test/expr.test 48273bf48a15d226c35829f702af4254c0ff6795 F test/func.test 02aed8845b98bde1043dda97455de1d37238ebb3 @@ -40,7 +40,7 @@ F test/in.test 2c560c0f55fb777029fd9bb5378f2997582aa603 F test/index.test 950be6116122c6e2db7c2c345eabcdb854ced1d0 F test/insert.test 66f4c3bd600fec8eb1e733b928cbe6fa885eff0c F test/insert2.test 732405e30331635af8d159fccabe835eea5cd0c6 -F test/lock.test 72f3b11be44f29739cb270b14faea2687dedde7d +F test/lock.test 4b334f4978cf68321b76f1854b6ee2232e4659e5 F test/main.test b7366cc6f3690915a11834bc1090deeff08acaf9 F test/select1.test 68ff778c24fc8982e63dda37acb5b0396913adf7 F test/select2.test 45c28211702b5c82b06dd624a112ea17417f343c @@ -64,8 +64,8 @@ F tool/renumberOps.awk 6d067177ad5f8d711b79577b462da9b3634bd0a9 F www/arch.fig 4f246003b7da23bd63b8b0af0618afb4ee3055c8 F www/arch.png 8dae0766d42ed3de9ed013c1341a5792bcf633e6 F www/arch.tcl a40380c1fe0080c43e6cc5c20ed70731511b06be -F www/c_interface.tcl 03f5fe8f2da9713aa1748f7e4ce34a0c35926ac9 -F www/changes.tcl fcd35239062ac03d6169506ae8ef19189979c8f1 +F www/c_interface.tcl 1a0b13d056625e4acb59b67edc360cfd9c92ba90 +F www/changes.tcl 9e9f657e28c7168fc27ef787fd2e2c0ad009564d F www/crosscompile.tcl bee79c34f6c3f162ec1c6f5294e79f73651d27ee F www/fileformat.tcl cfb7fba80b7275555281ba2f256c00734bcdd1c9 F www/index.tcl b19418d506f90968deef972bf1b427d98bdf13e0 @@ -75,7 +75,7 @@ F www/opcode.tcl cb3a1abf8b7b9be9f3a228d097d6bf8b742c2b6f F www/sqlite.tcl cb0d23d8f061a80543928755ec7775da6e4f362f F www/tclsqlite.tcl ae101d5f7c07dcc59770e2a84aae09025fab2dad F www/vdbe.tcl bcbfc33bcdd0ebad95eab31286adb9e1bc289520 -P e0c9e80bdbaf672c72ead7827946bb9ac6b7ec32 -R 9c1be87ea23318c1508107b40e37070e +P d67884f6278a130c81bc75f472170eb6c799ddfa +R 2f7e4e8c1990ac2e5aa0bbfe9f423798 U drh -Z dfb59234c10578475ae6c45a8d446adf +Z 12eb66ddad145a24d9572d4df23b3c52 diff --git a/manifest.uuid b/manifest.uuid index 19d52d3140..13d0833c86 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d67884f6278a130c81bc75f472170eb6c799ddfa \ No newline at end of file +f7ea08b931b9b40831bfe73cd7afea17f92112cf \ No newline at end of file diff --git a/src/build.c b/src/build.c index 180141a5bd..531a9f16e5 100644 --- a/src/build.c +++ b/src/build.c @@ -33,7 +33,7 @@ ** COPY ** VACUUM ** -** $Id: build.c,v 1.23 2000/08/03 15:09:20 drh Exp $ +** $Id: build.c,v 1.24 2000/10/16 22:06:42 drh Exp $ */ #include "sqliteInt.h" @@ -48,20 +48,22 @@ ** no VDBE code was generated. */ void sqliteExec(Parse *pParse){ + int rc = SQLITE_OK; if( pParse->pVdbe ){ if( pParse->explain ){ - sqliteVdbeList(pParse->pVdbe, pParse->xCallback, pParse->pArg, - &pParse->zErrMsg); + rc = sqliteVdbeList(pParse->pVdbe, pParse->xCallback, pParse->pArg, + &pParse->zErrMsg); }else{ FILE *trace = (pParse->db->flags & SQLITE_VdbeTrace)!=0 ? stderr : 0; sqliteVdbeTrace(pParse->pVdbe, trace); - sqliteVdbeExec(pParse->pVdbe, pParse->xCallback, pParse->pArg, - &pParse->zErrMsg, pParse->db->pBusyArg, - pParse->db->xBusyCallback); + rc = sqliteVdbeExec(pParse->pVdbe, pParse->xCallback, pParse->pArg, + &pParse->zErrMsg, pParse->db->pBusyArg, + pParse->db->xBusyCallback); } sqliteVdbeDelete(pParse->pVdbe); pParse->pVdbe = 0; pParse->colNamesSet = 0; + pParse->rc = rc; } } diff --git a/src/main.c b/src/main.c index 24355db728..b953dae0f7 100644 --- a/src/main.c +++ b/src/main.c @@ -26,7 +26,7 @@ ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** -** $Id: main.c,v 1.19 2000/10/11 19:28:52 drh Exp $ +** $Id: main.c,v 1.20 2000/10/16 22:06:42 drh Exp $ */ #include "sqliteInt.h" @@ -154,7 +154,7 @@ static int sqliteInit(sqlite *db, char **pzErrMsg){ /* Create a virtual machine to run the initialization program. Run ** the program. The delete the virtual machine. */ - vdbe = sqliteVdbeCreate(db->pBe); + vdbe = sqliteVdbeCreate(db); if( vdbe==0 ){ sqliteSetString(pzErrMsg, "out of memory",0); return 1; @@ -227,7 +227,7 @@ sqlite *sqlite_open(const char *zFilename, int mode, char **pzErrMsg){ if( rc!=SQLITE_OK && rc!=SQLITE_BUSY ){ sqlite_close(db); return 0; - }else{ + }else /* if( pzErrMsg ) */{ free(*pzErrMsg); *pzErrMsg = 0; } @@ -311,9 +311,8 @@ int sqlite_exec( sParse.db = db; sParse.xCallback = xCallback; sParse.pArg = pArg; - rc = sqliteRunParser(&sParse, zSql, pzErrMsg); - sqliteStrRealloc(pzErrMsg); - return rc; + sqliteRunParser(&sParse, zSql, pzErrMsg); + return sParse.rc; } /* @@ -382,3 +381,10 @@ void sqlite_busy_timeout(sqlite *db, int ms){ sqlite_busy_handler(db, 0, 0); } } + +/* +** Cause any pending operation to stop at its earliest opportunity. +*/ +void sqlite_interrupt(sqlite *db){ + db->flags |= SQLITE_Interrupt; +} diff --git a/src/select.c b/src/select.c index 0eac435cdc..e15f09ea6f 100644 --- a/src/select.c +++ b/src/select.c @@ -24,7 +24,7 @@ ** This file contains C code routines that are called by the parser ** to handle SELECT statements. ** -** $Id: select.c,v 1.26 2000/07/29 13:06:59 drh Exp $ +** $Id: select.c,v 1.27 2000/10/16 22:06:42 drh Exp $ */ #include "sqliteInt.h" @@ -424,7 +424,7 @@ static int matchOrderbyToColumn( Vdbe *sqliteGetVdbe(Parse *pParse){ Vdbe *v = pParse->pVdbe; if( v==0 ){ - v = pParse->pVdbe = sqliteVdbeCreate(pParse->db->pBe); + v = pParse->pVdbe = sqliteVdbeCreate(pParse->db); } if( v==0 ){ sqliteSetString(&pParse->zErrMsg, "out of memory", 0); @@ -818,7 +818,7 @@ int sqliteSelect( */ v = pParse->pVdbe; if( v==0 ){ - v = pParse->pVdbe = sqliteVdbeCreate(pParse->db->pBe); + v = pParse->pVdbe = sqliteVdbeCreate(pParse->db); } if( v==0 ){ sqliteSetString(&pParse->zErrMsg, "out of memory", 0); diff --git a/src/shell.c b/src/shell.c index 0fedfebf60..0bb5ed8087 100644 --- a/src/shell.c +++ b/src/shell.c @@ -24,7 +24,7 @@ ** This file contains code to implement the "sqlite" command line ** utility for accessing SQLite databases. ** -** $Id: shell.c,v 1.26 2000/10/08 22:20:58 drh Exp $ +** $Id: shell.c,v 1.27 2000/10/16 22:06:42 drh Exp $ */ #include #include @@ -32,6 +32,9 @@ #include "sqlite.h" #include #include +#ifdef OS_UNIX +# include +#endif #if defined(HAVE_READLINE) && HAVE_READLINE==1 # include @@ -41,6 +44,13 @@ # define add_history(X) #endif +/* +** The following is the open SQLite database. We make a pointer +** to this database a static variable so that it can be accessed +** by the SIGINT handler to interrupt database processing. +*/ +static sqlite *db = 0; + /* ** This routine reads a line of text from standard input, stores ** the text in memory obtained from malloc() and returns a pointer @@ -229,6 +239,13 @@ static void output_html_string(FILE *out, const char *z){ } } +/* +** This routine runs when the user presses Ctrl-C +*/ +static void interrupt_handler(int NotUsed){ + if( db ) sqlite_interrupt(db); +} + /* ** This is the callback routine that the SQLite library ** invokes for each row of a query result. @@ -447,7 +464,6 @@ static void do_meta_command(char *zLine, sqlite *db, struct callback_data *p){ if( nArg==0 ) return; n = strlen(azArg[0]); c = azArg[0][0]; - if( c=='d' && strncmp(azArg[0], "dump", n)==0 ){ char *zErrMsg = 0; if( nArg==1 ){ @@ -669,7 +685,6 @@ static void do_meta_command(char *zLine, sqlite *db, struct callback_data *p){ } int main(int argc, char **argv){ - sqlite *db; char *zErrMsg = 0; char *argv0 = argv[0]; struct callback_data data; @@ -678,6 +693,9 @@ int main(int argc, char **argv){ data.mode = MODE_List; strcpy(data.separator,"|"); data.showHeader = 0; +#ifdef SIGINT + signal(SIGINT, interrupt_handler); +#endif while( argc>=2 && argv[1][0]=='-' ){ if( strcmp(argv[1],"-html")==0 ){ data.mode = MODE_Html; diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 9b8374d573..8e3945defd 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -24,7 +24,7 @@ ** This header file defines the interface that the sqlite library ** presents to client programs. ** -** @(#) $Id: sqlite.h.in,v 1.5 2000/10/09 12:57:01 drh Exp $ +** @(#) $Id: sqlite.h.in,v 1.6 2000/10/16 22:06:42 drh Exp $ */ #ifndef _SQLITE_H_ #define _SQLITE_H_ @@ -130,13 +130,23 @@ int sqlite_exec( ** Return values for sqlite_exec() */ #define SQLITE_OK 0 /* Successful result */ -#define SQLITE_INTERNAL 1 /* An internal logic error in SQLite */ -#define SQLITE_ERROR 2 /* SQL error or missing database */ +#define SQLITE_ERROR 1 /* SQL error or missing database */ +#define SQLITE_INTERNAL 2 /* An internal logic error in SQLite */ #define SQLITE_PERM 3 /* Access permission denied */ #define SQLITE_ABORT 4 /* Callback routine requested an abort */ #define SQLITE_BUSY 5 /* One or more database files are locked */ #define SQLITE_NOMEM 6 /* A malloc() failed */ #define SQLITE_READONLY 7 /* Attempt to write a readonly database */ +#define SQLITE_INTERRUPT 8 /* Operation terminated by sqlite_interrupt() */ + +/* This function causes any pending database operation to abort and +** return at its earliest opportunity. This routine is typically +** called in response to a user include such as pressing "Cancel" +** or Ctrl-C where the user wants a long query operation to halt +** immediately. +*/ +void sqlite_interrupt(sqlite*); + /* This function returns true if the given input string comprises ** one or more complete SQL statements. diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 092feb5b67..74b6f5373c 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -23,7 +23,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.30 2000/08/28 15:51:44 drh Exp $ +** @(#) $Id: sqliteInt.h,v 1.31 2000/10/16 22:06:42 drh Exp $ */ #include "sqlite.h" #include "dbbe.h" @@ -135,8 +135,9 @@ struct sqlite { /* ** Possible values for the sqlite.flags. */ -#define SQLITE_VdbeTrace 0x00000001 -#define SQLITE_Initialized 0x00000002 +#define SQLITE_VdbeTrace 0x00000001 /* True to trace VDBE execution */ +#define SQLITE_Initialized 0x00000002 /* True after initialization */ +#define SQLITE_Interrupt 0x00000004 /* Cancel current operation */ /* ** Current file format version @@ -325,6 +326,7 @@ struct AggExpr { */ struct Parse { sqlite *db; /* The main database structure */ + int rc; /* Return code from execution */ sqlite_callback xCallback; /* The callback function */ void *pArg; /* First argument to the callback function */ char *zErrMsg; /* An error message */ diff --git a/src/tokenize.c b/src/tokenize.c index a374ec3852..bb9098534e 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -27,7 +27,7 @@ ** individual tokens and sends those tokens one-by-one over to the ** parser for analysis. ** -** $Id: tokenize.c,v 1.13 2000/08/09 17:17:25 drh Exp $ +** $Id: tokenize.c,v 1.14 2000/10/16 22:06:42 drh Exp $ */ #include "sqliteInt.h" #include @@ -298,7 +298,7 @@ int sqliteGetToken(const char *z, int *tokenType){ /* ** Run the parser on the given SQL string. The parser structure is -** passed in. Return the number of errors. +** passed in. An SQLITE_ status code. */ int sqliteRunParser(Parse *pParse, char *zSql, char **pzErrMsg){ int nErr = 0; @@ -311,6 +311,8 @@ int sqliteRunParser(Parse *pParse, char *zSql, char **pzErrMsg){ extern int sqliteParser(void*, int, ...); extern void sqliteParserTrace(FILE*, char *); + pParse->db->flags &= ~SQLITE_Interrupt; + pParse->rc = SQLITE_OK; i = 0; sqliteParseInfoReset(pParse); pEngine = sqliteParserAlloc((void*(*)(int))malloc); @@ -322,6 +324,11 @@ int sqliteRunParser(Parse *pParse, char *zSql, char **pzErrMsg){ while( nErr==0 && i>=0 && zSql[i]!=0 ){ int tokenType; + if( (pParse->db->flags & SQLITE_Interrupt)!=0 ){ + pParse->rc = SQLITE_INTERRUPT; + sqliteSetString(pzErrMsg, "interrupt", 0); + break; + } pParse->sLastToken.z = &zSql[i]; pParse->sLastToken.n = sqliteGetToken(&zSql[i], &tokenType); i += pParse->sLastToken.n; @@ -391,7 +398,7 @@ int sqliteRunParser(Parse *pParse, char *zSql, char **pzErrMsg){ break; } } - if( nErr==0 ){ + if( nErr==0 && (pParse->db->flags & SQLITE_Interrupt)==0 ){ sqliteParser(pEngine, 0, pParse->sLastToken, pParse); if( pParse->zErrMsg && pParse->sErrToken.z ){ sqliteSetNString(pzErrMsg, "near \"", -1, @@ -423,5 +430,9 @@ int sqliteRunParser(Parse *pParse, char *zSql, char **pzErrMsg){ pParse->pNewTable = 0; } sqliteParseInfoReset(pParse); + sqliteStrRealloc(pzErrMsg); + if( nErr>0 && pParse->rc==SQLITE_OK ){ + pParse->rc = SQLITE_ERROR; + } return nErr; } diff --git a/src/vdbe.c b/src/vdbe.c index 1f89782a3d..c7b9cb9d46 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -41,7 +41,7 @@ ** But other routines are also provided to help in building up ** a program instruction by instruction. ** -** $Id: vdbe.c,v 1.42 2000/10/11 19:28:53 drh Exp $ +** $Id: vdbe.c,v 1.43 2000/10/16 22:06:43 drh Exp $ */ #include "sqliteInt.h" #include @@ -169,6 +169,7 @@ struct SetElem { ** An instance of the virtual machine */ struct Vdbe { + sqlite *db; /* The whole database */ Dbbe *pBe; /* Opaque context structure used by DB backend */ FILE *trace; /* Write an execution trace here, if not NULL */ int nOp; /* Number of instructions in the program */ @@ -204,11 +205,12 @@ struct Vdbe { /* ** Create a new virtual database engine. */ -Vdbe *sqliteVdbeCreate(Dbbe *pBe){ +Vdbe *sqliteVdbeCreate(sqlite *db){ Vdbe *p; p = sqliteMalloc( sizeof(Vdbe) ); - p->pBe = pBe; + p->pBe = db->pBe; + p->db = db; return p; } @@ -836,6 +838,12 @@ int sqliteVdbeList( rc = SQLITE_OK; /* if( pzErrMsg ){ *pzErrMsg = 0; } */ for(i=0; rc==SQLITE_OK && inOp; i++){ + if( p->db->flags & SQLITE_Interrupt ){ + p->db->flags &= ~SQLITE_Interrupt; + sqliteSetString(pzErrMsg, "interrupted", 0); + rc = SQLITE_INTERRUPT; + break; + } sprintf(zAddr,"%d",i); sprintf(zP1,"%d", p->aOp[i].p1); sprintf(zP2,"%d", p->aOp[i].p2); @@ -929,6 +937,15 @@ int sqliteVdbeExec( for(pc=0; rc==SQLITE_OK && pcnOp && pc>=0; pc++){ pOp = &p->aOp[pc]; + /* Interrupt processing if requested. + */ + if( p->db->flags & SQLITE_Interrupt ){ + p->db->flags &= ~SQLITE_Interrupt; + rc = SQLITE_INTERRUPT; + sqliteSetString(pzErrMsg, "interrupted", 0); + break; + } + /* Only allow tracing if NDEBUG is not defined. */ #ifndef NDEBUG diff --git a/src/vdbe.h b/src/vdbe.h index 7357e4ddbe..8e94ad365e 100644 --- a/src/vdbe.h +++ b/src/vdbe.h @@ -27,7 +27,7 @@ ** or VDBE. The VDBE implements an abstract machine that runs a ** simple program to access and modify the underlying database. ** -** $Id: vdbe.h,v 1.13 2000/10/11 19:28:53 drh Exp $ +** $Id: vdbe.h,v 1.14 2000/10/16 22:06:43 drh Exp $ */ #ifndef _SQLITE_VDBE_H_ #define _SQLITE_VDBE_H_ @@ -182,7 +182,7 @@ typedef struct VdbeOp VdbeOp; ** Prototypes for the VDBE interface. See comments on the implementation ** for a description of what each of these routines does. */ -Vdbe *sqliteVdbeCreate(Dbbe*); +Vdbe *sqliteVdbeCreate(sqlite*); int sqliteVdbeAddOp(Vdbe*,int,int,int,const char*,int); int sqliteVdbeAddOpList(Vdbe*, int nOp, VdbeOp const *aOp); void sqliteVdbeChangeP3(Vdbe*, int addr, const char *zP1, int N); diff --git a/test/dbbe.test b/test/dbbe.test index 3c9104e63f..95b43c184a 100644 --- a/test/dbbe.test +++ b/test/dbbe.test @@ -23,7 +23,7 @@ # This file implements regression tests for SQLite library. The # focus of this file is exercising the code in dbbe.c. # -# $Id: dbbe.test,v 1.3 2000/08/17 09:50:00 drh Exp $ +# $Id: dbbe.test,v 1.4 2000/10/16 22:06:43 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -130,7 +130,7 @@ do_test dbbe-3.1 { sqlite db testdb 0444 set v [catch {execsql {INSERT INTO t1 VALUES(1)}} msg] lappend v $msg -} {1 {table t1 is readonly}} +} {7 {table t1 is readonly}} finish_test diff --git a/test/lock.test b/test/lock.test index 6e2e048f56..5ca16b0096 100644 --- a/test/lock.test +++ b/test/lock.test @@ -23,7 +23,7 @@ # This file implements regression tests for SQLite library. The # focus of this script is database locks. # -# $Id: lock.test,v 1.2 2000/08/04 13:51:11 drh Exp $ +# $Id: lock.test,v 1.3 2000/10/16 22:06:43 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -59,7 +59,7 @@ do_test lock-1.2 { # set v [catch {execsql {UPDATE big SET f2='xyz' WHERE f1=11}} msg] lappend v $msg -} {1 {table big is locked}} +} {5 {table big is locked}} do_test lock-1.3 { # Try to update the database in a separate process diff --git a/www/c_interface.tcl b/www/c_interface.tcl index f191b5ce05..bfe2f1f017 100644 --- a/www/c_interface.tcl +++ b/www/c_interface.tcl @@ -1,7 +1,7 @@ # # Run this Tcl script to generate the sqlite.html file. # -set rcsid {$Id: c_interface.tcl,v 1.10 2000/10/09 12:57:01 drh Exp $} +set rcsid {$Id: c_interface.tcl,v 1.11 2000/10/16 22:06:43 drh Exp $} puts { @@ -68,6 +68,8 @@ int sqlite_get_table( void sqlite_free_table(char**); +void sqlite_interrupt(sqlite*); + int sqlite_complete(const char *sql); void sqlite_busy_handler(sqlite*, int (*)(void*,const char*,int), void*); @@ -263,6 +265,10 @@ a database file that was originally opened for reading only. This can happen if the callback from a query attempts to update the table being queried.

+
SQLITE_INTERRUPT
+

This value is returned if a call to sqlite_interrupt() +interrupts a database operation in progress. +

@@ -317,6 +323,14 @@ to sqlite_free_table() when the table is no longer needed.

The sqlite_get_table() routine returns the same integer result code as sqlite_exec().

+

Interrupting an SQLite operation

+ +

The sqlite_interrupt() function can be called from a +different thread or from a signal handler to the current database +operation to exit at its first opportunity. When this happens, +the sqlite_exec() routine (or the equivalent) that started +the database operation will return SQLITE_INTERRUPT.

+

Testing for a complete SQL statement

The next interface routine to SQLite is a convenience function used diff --git a/www/changes.tcl b/www/changes.tcl index f0343552e9..9744123933 100644 --- a/www/changes.tcl +++ b/www/changes.tcl @@ -17,7 +17,14 @@ proc chng {date desc} { puts "

    $desc

" } -chng {2000 Oct 11 (Not Released)} { +chng {2000 Oct 16 (1.0.11) +
  • Added the sqlite_interrupt() interface.
  • +
  • In the shell, sqlite_interrupt() is invoked when the + user presses Control-C
  • +
  • Fixed bugs in the return value of sqlite_exec().
  • +} + +chng {2000 Oct 11 (1.0.10)
  • Added notes on how to compile for Windows95/98.
  • Add Doug Lea's memory allocator to the distribution, for completeness.
  • Removed a few variables that were not being used. Etc.