Added an interrupt capability (CVS 153)

FossilOrigin-Name: f7ea08b931b9b40831bfe73cd7afea17f92112cf
This commit is contained in:
drh 2000-10-16 22:06:40 +00:00
parent b2b415b97f
commit 4c5043910b
16 changed files with 146 additions and 59 deletions

View File

@ -1 +1 @@
1.0.10 1.0.11

View File

@ -1,38 +1,38 @@
C Removed\sdlmalloc.c\s(CVS\s1705) C Added\san\sinterrupt\scapability\s(CVS\s153)
D 2000-10-12T13:29:49 D 2000-10-16T22:06:41
F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4 F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4
F Makefile.in faecea9b6419cec25030b4818c9b3f7f4163b3c1 F Makefile.in faecea9b6419cec25030b4818c9b3f7f4163b3c1
F README 51f6a4e7408b34afa5bc1c0485f61b6a4efb6958 F README 51f6a4e7408b34afa5bc1c0485f61b6a4efb6958
F VERSION 0302755bd219af2c39c53cc097caccb858798223 F VERSION 680e898474f571402b75096f1fb5d186126c3296
F configure 3dc1edb9dcf60215e31ff72b447935ab62211442 x F configure 3dc1edb9dcf60215e31ff72b447935ab62211442 x
F configure.in d892ca33db7e88a055519ce2f36dcb11020e8fff F configure.in d892ca33db7e88a055519ce2f36dcb11020e8fff
F doc/lemon.html e233a3e97a779c7a87e1bc4528c664a58e49dd47 F doc/lemon.html e233a3e97a779c7a87e1bc4528c664a58e49dd47
F src/build.c 4d90e9e94750ca80249fc7958c617021d8bb7a50 F src/build.c e2ceba852dc45ca899e68a042b29c3daab011575
F src/dbbe.c 226daaf8c095ceb4aff48cad188dad90643f9867 F src/dbbe.c 226daaf8c095ceb4aff48cad188dad90643f9867
F src/dbbe.h 6337132f904e72ecb28b07390021c241397e4cbf F src/dbbe.h 6337132f904e72ecb28b07390021c241397e4cbf
F src/dbbemem.c eb3d79be7105bd80069815ee499c8e8682876378 F src/dbbemem.c eb3d79be7105bd80069815ee499c8e8682876378
F src/delete.c 4d491eaf61b515516749c7ed68fa3b2ee8a09065 F src/delete.c 4d491eaf61b515516749c7ed68fa3b2ee8a09065
F src/expr.c e8e350d7baa33bd9ed8701c159eaba5e912e0adb F src/expr.c e8e350d7baa33bd9ed8701c159eaba5e912e0adb
F src/insert.c f146f149ad2422a1dc3bfa7a1651a25940f98958 F src/insert.c f146f149ad2422a1dc3bfa7a1651a25940f98958
F src/main.c 03ca6d7601b40a3c6de95d7f8c6c817e8cca9fdf F src/main.c 4774731549159ba33c031cfaf6e4c78630c80d96
F src/parse.y 5d199034de5d29ebedb42c1c51f34db4df40cbe5 F src/parse.y 5d199034de5d29ebedb42c1c51f34db4df40cbe5
F src/printf.c 6fc343f0c3537e2530a11ac164ce64ba171aebf8 F src/printf.c 6fc343f0c3537e2530a11ac164ce64ba171aebf8
F src/select.c d382e96c2221d08367cc87976f2b574537c9de97 F src/select.c c1de8ac34131324fa05664b06b0ae1ee9c02905d
F src/shell.c ef5d12129c824cb98238763e9e86ca1847e0c7bd F src/shell.c 146149928c7dca23ceebd6aa53026e9b02d3b4e4
F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e
F src/sqlite.h.in 7a11f9d131e9657d11dee5c23dfe458da91de8e2 F src/sqlite.h.in 43c0e1e321e94c20eb20efe593155296cd57728a
F src/sqliteInt.h b65fdecac7281aafb4c9ff3e79ea1b5546478385 F src/sqliteInt.h 4b49e8c162c2ebf5d7a7ed392953380dbfd3673a
F src/table.c f08189678c806d8a74a70c156d7c27083760e028 F src/table.c f08189678c806d8a74a70c156d7c27083760e028
F src/tclsqlite.c 44b08b47612a668caaf7c4ec32133b69d73ff78e F src/tclsqlite.c 44b08b47612a668caaf7c4ec32133b69d73ff78e
F src/tokenize.c 097bec5843d4a0fb4509e036fee93bac080c5e73 F src/tokenize.c b0f5c12598105ec924c0733a916485f920168720
F src/update.c 51b9ef7434b15e31096155da920302e9db0d27fc F src/update.c 51b9ef7434b15e31096155da920302e9db0d27fc
F src/util.c 811e0ad47f842c16555aaf361b26dab7221c1a6c F src/util.c 811e0ad47f842c16555aaf361b26dab7221c1a6c
F src/vdbe.c b8b0bc26d6543d5d33820809122bf0e7659e4663 F src/vdbe.c 7acc17367da350259107dcb1dac5590e8747b890
F src/vdbe.h 8ca755f77eeaa93886d25188fd66129febfa16cf F src/vdbe.h 140cdec3c56f70483e169f8ae657bd90f9fd6e98
F src/where.c 3dfad2ffd0aa994d5eceac88852f7189c8d1d3c8 F src/where.c 3dfad2ffd0aa994d5eceac88852f7189c8d1d3c8
F test/all.test 0950c135cab7e60c07bd745ccfad1476211e5bd7 F test/all.test 0950c135cab7e60c07bd745ccfad1476211e5bd7
F test/copy.test b77a1214bd7756f2849d5c4fa6e715c0ff0c34eb F test/copy.test b77a1214bd7756f2849d5c4fa6e715c0ff0c34eb
F test/dbbe.test c6079572516aeb2739a35fd272b105c45c30cc76 F test/dbbe.test bd2cd9fe84c6d69b6ae42ac5f55b1e940bdca886
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
@ -40,7 +40,7 @@ F test/in.test 2c560c0f55fb777029fd9bb5378f2997582aa603
F test/index.test 950be6116122c6e2db7c2c345eabcdb854ced1d0 F test/index.test 950be6116122c6e2db7c2c345eabcdb854ced1d0
F test/insert.test 66f4c3bd600fec8eb1e733b928cbe6fa885eff0c F test/insert.test 66f4c3bd600fec8eb1e733b928cbe6fa885eff0c
F test/insert2.test 732405e30331635af8d159fccabe835eea5cd0c6 F test/insert2.test 732405e30331635af8d159fccabe835eea5cd0c6
F test/lock.test 72f3b11be44f29739cb270b14faea2687dedde7d F test/lock.test 4b334f4978cf68321b76f1854b6ee2232e4659e5
F test/main.test b7366cc6f3690915a11834bc1090deeff08acaf9 F test/main.test b7366cc6f3690915a11834bc1090deeff08acaf9
F test/select1.test 68ff778c24fc8982e63dda37acb5b0396913adf7 F test/select1.test 68ff778c24fc8982e63dda37acb5b0396913adf7
F test/select2.test 45c28211702b5c82b06dd624a112ea17417f343c F test/select2.test 45c28211702b5c82b06dd624a112ea17417f343c
@ -64,8 +64,8 @@ F tool/renumberOps.awk 6d067177ad5f8d711b79577b462da9b3634bd0a9
F www/arch.fig 4f246003b7da23bd63b8b0af0618afb4ee3055c8 F www/arch.fig 4f246003b7da23bd63b8b0af0618afb4ee3055c8
F www/arch.png 8dae0766d42ed3de9ed013c1341a5792bcf633e6 F www/arch.png 8dae0766d42ed3de9ed013c1341a5792bcf633e6
F www/arch.tcl a40380c1fe0080c43e6cc5c20ed70731511b06be F www/arch.tcl a40380c1fe0080c43e6cc5c20ed70731511b06be
F www/c_interface.tcl 03f5fe8f2da9713aa1748f7e4ce34a0c35926ac9 F www/c_interface.tcl 1a0b13d056625e4acb59b67edc360cfd9c92ba90
F www/changes.tcl fcd35239062ac03d6169506ae8ef19189979c8f1 F www/changes.tcl 9e9f657e28c7168fc27ef787fd2e2c0ad009564d
F www/crosscompile.tcl bee79c34f6c3f162ec1c6f5294e79f73651d27ee F www/crosscompile.tcl bee79c34f6c3f162ec1c6f5294e79f73651d27ee
F www/fileformat.tcl cfb7fba80b7275555281ba2f256c00734bcdd1c9 F www/fileformat.tcl cfb7fba80b7275555281ba2f256c00734bcdd1c9
F www/index.tcl b19418d506f90968deef972bf1b427d98bdf13e0 F www/index.tcl b19418d506f90968deef972bf1b427d98bdf13e0
@ -75,7 +75,7 @@ F www/opcode.tcl cb3a1abf8b7b9be9f3a228d097d6bf8b742c2b6f
F www/sqlite.tcl cb0d23d8f061a80543928755ec7775da6e4f362f F www/sqlite.tcl cb0d23d8f061a80543928755ec7775da6e4f362f
F www/tclsqlite.tcl ae101d5f7c07dcc59770e2a84aae09025fab2dad F www/tclsqlite.tcl ae101d5f7c07dcc59770e2a84aae09025fab2dad
F www/vdbe.tcl bcbfc33bcdd0ebad95eab31286adb9e1bc289520 F www/vdbe.tcl bcbfc33bcdd0ebad95eab31286adb9e1bc289520
P e0c9e80bdbaf672c72ead7827946bb9ac6b7ec32 P d67884f6278a130c81bc75f472170eb6c799ddfa
R 9c1be87ea23318c1508107b40e37070e R 2f7e4e8c1990ac2e5aa0bbfe9f423798
U drh U drh
Z dfb59234c10578475ae6c45a8d446adf Z 12eb66ddad145a24d9572d4df23b3c52

View File

@ -1 +1 @@
d67884f6278a130c81bc75f472170eb6c799ddfa f7ea08b931b9b40831bfe73cd7afea17f92112cf

View File

@ -33,7 +33,7 @@
** COPY ** COPY
** VACUUM ** 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" #include "sqliteInt.h"
@ -48,20 +48,22 @@
** no VDBE code was generated. ** no VDBE code was generated.
*/ */
void sqliteExec(Parse *pParse){ void sqliteExec(Parse *pParse){
int rc = SQLITE_OK;
if( pParse->pVdbe ){ if( pParse->pVdbe ){
if( pParse->explain ){ if( pParse->explain ){
sqliteVdbeList(pParse->pVdbe, pParse->xCallback, pParse->pArg, rc = sqliteVdbeList(pParse->pVdbe, pParse->xCallback, pParse->pArg,
&pParse->zErrMsg); &pParse->zErrMsg);
}else{ }else{
FILE *trace = (pParse->db->flags & SQLITE_VdbeTrace)!=0 ? stderr : 0; FILE *trace = (pParse->db->flags & SQLITE_VdbeTrace)!=0 ? stderr : 0;
sqliteVdbeTrace(pParse->pVdbe, trace); sqliteVdbeTrace(pParse->pVdbe, trace);
sqliteVdbeExec(pParse->pVdbe, pParse->xCallback, pParse->pArg, rc = sqliteVdbeExec(pParse->pVdbe, pParse->xCallback, pParse->pArg,
&pParse->zErrMsg, pParse->db->pBusyArg, &pParse->zErrMsg, pParse->db->pBusyArg,
pParse->db->xBusyCallback); pParse->db->xBusyCallback);
} }
sqliteVdbeDelete(pParse->pVdbe); sqliteVdbeDelete(pParse->pVdbe);
pParse->pVdbe = 0; pParse->pVdbe = 0;
pParse->colNamesSet = 0; pParse->colNamesSet = 0;
pParse->rc = rc;
} }
} }

View File

@ -26,7 +26,7 @@
** other files are for internal use by SQLite and should not be ** other files are for internal use by SQLite and should not be
** accessed by users of the library. ** 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" #include "sqliteInt.h"
@ -154,7 +154,7 @@ static int sqliteInit(sqlite *db, char **pzErrMsg){
/* Create a virtual machine to run the initialization program. Run /* Create a virtual machine to run the initialization program. Run
** the program. The delete the virtual machine. ** the program. The delete the virtual machine.
*/ */
vdbe = sqliteVdbeCreate(db->pBe); vdbe = sqliteVdbeCreate(db);
if( vdbe==0 ){ if( vdbe==0 ){
sqliteSetString(pzErrMsg, "out of memory",0); sqliteSetString(pzErrMsg, "out of memory",0);
return 1; return 1;
@ -227,7 +227,7 @@ sqlite *sqlite_open(const char *zFilename, int mode, char **pzErrMsg){
if( rc!=SQLITE_OK && rc!=SQLITE_BUSY ){ if( rc!=SQLITE_OK && rc!=SQLITE_BUSY ){
sqlite_close(db); sqlite_close(db);
return 0; return 0;
}else{ }else /* if( pzErrMsg ) */{
free(*pzErrMsg); free(*pzErrMsg);
*pzErrMsg = 0; *pzErrMsg = 0;
} }
@ -311,9 +311,8 @@ int sqlite_exec(
sParse.db = db; sParse.db = db;
sParse.xCallback = xCallback; sParse.xCallback = xCallback;
sParse.pArg = pArg; sParse.pArg = pArg;
rc = sqliteRunParser(&sParse, zSql, pzErrMsg); sqliteRunParser(&sParse, zSql, pzErrMsg);
sqliteStrRealloc(pzErrMsg); return sParse.rc;
return rc;
} }
/* /*
@ -382,3 +381,10 @@ void sqlite_busy_timeout(sqlite *db, int ms){
sqlite_busy_handler(db, 0, 0); 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;
}

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.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" #include "sqliteInt.h"
@ -424,7 +424,7 @@ static int matchOrderbyToColumn(
Vdbe *sqliteGetVdbe(Parse *pParse){ Vdbe *sqliteGetVdbe(Parse *pParse){
Vdbe *v = pParse->pVdbe; Vdbe *v = pParse->pVdbe;
if( v==0 ){ if( v==0 ){
v = pParse->pVdbe = sqliteVdbeCreate(pParse->db->pBe); v = pParse->pVdbe = sqliteVdbeCreate(pParse->db);
} }
if( v==0 ){ if( v==0 ){
sqliteSetString(&pParse->zErrMsg, "out of memory", 0); sqliteSetString(&pParse->zErrMsg, "out of memory", 0);
@ -818,7 +818,7 @@ int sqliteSelect(
*/ */
v = pParse->pVdbe; v = pParse->pVdbe;
if( v==0 ){ if( v==0 ){
v = pParse->pVdbe = sqliteVdbeCreate(pParse->db->pBe); v = pParse->pVdbe = sqliteVdbeCreate(pParse->db);
} }
if( v==0 ){ if( v==0 ){
sqliteSetString(&pParse->zErrMsg, "out of memory", 0); sqliteSetString(&pParse->zErrMsg, "out of memory", 0);

View File

@ -24,7 +24,7 @@
** This file contains code to implement the "sqlite" command line ** This file contains code to implement the "sqlite" command line
** utility for accessing SQLite databases. ** 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 <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -32,6 +32,9 @@
#include "sqlite.h" #include "sqlite.h"
#include <unistd.h> #include <unistd.h>
#include <ctype.h> #include <ctype.h>
#ifdef OS_UNIX
# include <signal.h>
#endif
#if defined(HAVE_READLINE) && HAVE_READLINE==1 #if defined(HAVE_READLINE) && HAVE_READLINE==1
# include <readline/readline.h> # include <readline/readline.h>
@ -41,6 +44,13 @@
# define add_history(X) # define add_history(X)
#endif #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 ** This routine reads a line of text from standard input, stores
** the text in memory obtained from malloc() and returns a pointer ** 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 ** This is the callback routine that the SQLite library
** invokes for each row of a query result. ** 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; if( nArg==0 ) return;
n = strlen(azArg[0]); n = strlen(azArg[0]);
c = azArg[0][0]; c = azArg[0][0];
if( c=='d' && strncmp(azArg[0], "dump", n)==0 ){ if( c=='d' && strncmp(azArg[0], "dump", n)==0 ){
char *zErrMsg = 0; char *zErrMsg = 0;
if( nArg==1 ){ 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){ int main(int argc, char **argv){
sqlite *db;
char *zErrMsg = 0; char *zErrMsg = 0;
char *argv0 = argv[0]; char *argv0 = argv[0];
struct callback_data data; struct callback_data data;
@ -678,6 +693,9 @@ int main(int argc, char **argv){
data.mode = MODE_List; data.mode = MODE_List;
strcpy(data.separator,"|"); strcpy(data.separator,"|");
data.showHeader = 0; data.showHeader = 0;
#ifdef SIGINT
signal(SIGINT, interrupt_handler);
#endif
while( argc>=2 && argv[1][0]=='-' ){ while( argc>=2 && argv[1][0]=='-' ){
if( strcmp(argv[1],"-html")==0 ){ if( strcmp(argv[1],"-html")==0 ){
data.mode = MODE_Html; data.mode = MODE_Html;

View File

@ -24,7 +24,7 @@
** This header file defines the interface that the sqlite library ** This header file defines the interface that the sqlite library
** presents to client programs. ** 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_ #ifndef _SQLITE_H_
#define _SQLITE_H_ #define _SQLITE_H_
@ -130,13 +130,23 @@ int sqlite_exec(
** Return values for sqlite_exec() ** Return values for sqlite_exec()
*/ */
#define SQLITE_OK 0 /* Successful result */ #define SQLITE_OK 0 /* Successful result */
#define SQLITE_INTERNAL 1 /* An internal logic error in SQLite */ #define SQLITE_ERROR 1 /* SQL error or missing database */
#define SQLITE_ERROR 2 /* SQL error or missing database */ #define SQLITE_INTERNAL 2 /* An internal logic error in SQLite */
#define SQLITE_PERM 3 /* Access permission denied */ #define SQLITE_PERM 3 /* Access permission denied */
#define SQLITE_ABORT 4 /* Callback routine requested an abort */ #define SQLITE_ABORT 4 /* Callback routine requested an abort */
#define SQLITE_BUSY 5 /* One or more database files are locked */ #define SQLITE_BUSY 5 /* One or more database files are locked */
#define SQLITE_NOMEM 6 /* A malloc() failed */ #define SQLITE_NOMEM 6 /* A malloc() failed */
#define SQLITE_READONLY 7 /* Attempt to write a readonly database */ #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 /* This function returns true if the given input string comprises
** one or more complete SQL statements. ** one or more complete SQL statements.

View File

@ -23,7 +23,7 @@
************************************************************************* *************************************************************************
** Internal interface definitions for SQLite. ** 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 "sqlite.h"
#include "dbbe.h" #include "dbbe.h"
@ -135,8 +135,9 @@ struct sqlite {
/* /*
** Possible values for the sqlite.flags. ** Possible values for the sqlite.flags.
*/ */
#define SQLITE_VdbeTrace 0x00000001 #define SQLITE_VdbeTrace 0x00000001 /* True to trace VDBE execution */
#define SQLITE_Initialized 0x00000002 #define SQLITE_Initialized 0x00000002 /* True after initialization */
#define SQLITE_Interrupt 0x00000004 /* Cancel current operation */
/* /*
** Current file format version ** Current file format version
@ -325,6 +326,7 @@ struct AggExpr {
*/ */
struct Parse { struct Parse {
sqlite *db; /* The main database structure */ sqlite *db; /* The main database structure */
int rc; /* Return code from execution */
sqlite_callback xCallback; /* The callback function */ sqlite_callback xCallback; /* The callback function */
void *pArg; /* First argument to the callback function */ void *pArg; /* First argument to the callback function */
char *zErrMsg; /* An error message */ char *zErrMsg; /* An error message */

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.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 "sqliteInt.h"
#include <ctype.h> #include <ctype.h>
@ -298,7 +298,7 @@ int sqliteGetToken(const char *z, int *tokenType){
/* /*
** Run the parser on the given SQL string. The parser structure is ** 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 sqliteRunParser(Parse *pParse, char *zSql, char **pzErrMsg){
int nErr = 0; int nErr = 0;
@ -311,6 +311,8 @@ int sqliteRunParser(Parse *pParse, char *zSql, char **pzErrMsg){
extern int sqliteParser(void*, int, ...); extern int sqliteParser(void*, int, ...);
extern void sqliteParserTrace(FILE*, char *); extern void sqliteParserTrace(FILE*, char *);
pParse->db->flags &= ~SQLITE_Interrupt;
pParse->rc = SQLITE_OK;
i = 0; i = 0;
sqliteParseInfoReset(pParse); sqliteParseInfoReset(pParse);
pEngine = sqliteParserAlloc((void*(*)(int))malloc); 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 ){ while( nErr==0 && i>=0 && zSql[i]!=0 ){
int tokenType; 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.z = &zSql[i];
pParse->sLastToken.n = sqliteGetToken(&zSql[i], &tokenType); pParse->sLastToken.n = sqliteGetToken(&zSql[i], &tokenType);
i += pParse->sLastToken.n; i += pParse->sLastToken.n;
@ -391,7 +398,7 @@ int sqliteRunParser(Parse *pParse, char *zSql, char **pzErrMsg){
break; break;
} }
} }
if( nErr==0 ){ if( nErr==0 && (pParse->db->flags & SQLITE_Interrupt)==0 ){
sqliteParser(pEngine, 0, pParse->sLastToken, pParse); sqliteParser(pEngine, 0, pParse->sLastToken, pParse);
if( pParse->zErrMsg && pParse->sErrToken.z ){ if( pParse->zErrMsg && pParse->sErrToken.z ){
sqliteSetNString(pzErrMsg, "near \"", -1, sqliteSetNString(pzErrMsg, "near \"", -1,
@ -423,5 +430,9 @@ int sqliteRunParser(Parse *pParse, char *zSql, char **pzErrMsg){
pParse->pNewTable = 0; pParse->pNewTable = 0;
} }
sqliteParseInfoReset(pParse); sqliteParseInfoReset(pParse);
sqliteStrRealloc(pzErrMsg);
if( nErr>0 && pParse->rc==SQLITE_OK ){
pParse->rc = SQLITE_ERROR;
}
return nErr; return nErr;
} }

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.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 "sqliteInt.h"
#include <unistd.h> #include <unistd.h>
@ -169,6 +169,7 @@ struct SetElem {
** An instance of the virtual machine ** An instance of the virtual machine
*/ */
struct Vdbe { struct Vdbe {
sqlite *db; /* The whole database */
Dbbe *pBe; /* Opaque context structure used by DB backend */ Dbbe *pBe; /* Opaque context structure used by DB backend */
FILE *trace; /* Write an execution trace here, if not NULL */ FILE *trace; /* Write an execution trace here, if not NULL */
int nOp; /* Number of instructions in the program */ int nOp; /* Number of instructions in the program */
@ -204,11 +205,12 @@ struct Vdbe {
/* /*
** Create a new virtual database engine. ** Create a new virtual database engine.
*/ */
Vdbe *sqliteVdbeCreate(Dbbe *pBe){ Vdbe *sqliteVdbeCreate(sqlite *db){
Vdbe *p; Vdbe *p;
p = sqliteMalloc( sizeof(Vdbe) ); p = sqliteMalloc( sizeof(Vdbe) );
p->pBe = pBe; p->pBe = db->pBe;
p->db = db;
return p; return p;
} }
@ -836,6 +838,12 @@ int sqliteVdbeList(
rc = SQLITE_OK; rc = SQLITE_OK;
/* if( pzErrMsg ){ *pzErrMsg = 0; } */ /* if( pzErrMsg ){ *pzErrMsg = 0; } */
for(i=0; rc==SQLITE_OK && i<p->nOp; i++){ for(i=0; rc==SQLITE_OK && i<p->nOp; 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(zAddr,"%d",i);
sprintf(zP1,"%d", p->aOp[i].p1); sprintf(zP1,"%d", p->aOp[i].p1);
sprintf(zP2,"%d", p->aOp[i].p2); sprintf(zP2,"%d", p->aOp[i].p2);
@ -929,6 +937,15 @@ int sqliteVdbeExec(
for(pc=0; rc==SQLITE_OK && pc<p->nOp && pc>=0; pc++){ for(pc=0; rc==SQLITE_OK && pc<p->nOp && pc>=0; pc++){
pOp = &p->aOp[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. /* Only allow tracing if NDEBUG is not defined.
*/ */
#ifndef NDEBUG #ifndef NDEBUG

View File

@ -27,7 +27,7 @@
** or VDBE. The VDBE implements an abstract machine that runs a ** or VDBE. The VDBE implements an abstract machine that runs a
** simple program to access and modify the underlying database. ** 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_ #ifndef _SQLITE_VDBE_H_
#define _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 ** Prototypes for the VDBE interface. See comments on the implementation
** for a description of what each of these routines does. ** 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 sqliteVdbeAddOp(Vdbe*,int,int,int,const char*,int);
int sqliteVdbeAddOpList(Vdbe*, int nOp, VdbeOp const *aOp); int sqliteVdbeAddOpList(Vdbe*, int nOp, VdbeOp const *aOp);
void sqliteVdbeChangeP3(Vdbe*, int addr, const char *zP1, int N); void sqliteVdbeChangeP3(Vdbe*, int addr, const char *zP1, int N);

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 dbbe.c. # 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] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@ -130,7 +130,7 @@ do_test dbbe-3.1 {
sqlite db testdb 0444 sqlite db testdb 0444
set v [catch {execsql {INSERT INTO t1 VALUES(1)}} msg] set v [catch {execsql {INSERT INTO t1 VALUES(1)}} msg]
lappend v $msg lappend v $msg
} {1 {table t1 is readonly}} } {7 {table t1 is readonly}}
finish_test finish_test

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 script is database locks. # 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] set testdir [file dirname $argv0]
source $testdir/tester.tcl 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] set v [catch {execsql {UPDATE big SET f2='xyz' WHERE f1=11}} msg]
lappend v $msg lappend v $msg
} {1 {table big is locked}} } {5 {table big is locked}}
do_test lock-1.3 { do_test lock-1.3 {
# Try to update the database in a separate process # Try to update the database in a separate process

View File

@ -1,7 +1,7 @@
# #
# Run this Tcl script to generate the sqlite.html file. # 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 {<html> puts {<html>
<head> <head>
@ -68,6 +68,8 @@ int sqlite_get_table(
void sqlite_free_table(char**); void sqlite_free_table(char**);
void sqlite_interrupt(sqlite*);
int sqlite_complete(const char *sql); int sqlite_complete(const char *sql);
void sqlite_busy_handler(sqlite*, int (*)(void*,const char*,int), void*); 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 happen if the callback from a query attempts to update the table
being queried. being queried.
</p></dd> </p></dd>
<dt>SQLITE_INTERRUPT</dt>
<dd><p>This value is returned if a call to <b>sqlite_interrupt()</b>
interrupts a database operation in progress.
</p></dd>
</dl> </dl>
</blockquote> </blockquote>
@ -317,6 +323,14 @@ to <b>sqlite_free_table()</b> when the table is no longer needed.</p>
<p>The <b>sqlite_get_table()</b> routine returns the same integer <p>The <b>sqlite_get_table()</b> routine returns the same integer
result code as <b>sqlite_exec()</b>.</p> result code as <b>sqlite_exec()</b>.</p>
<h2>Interrupting an SQLite operation</h2>
<p>The <b>sqlite_interrupt()</b> 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 <b>sqlite_exec()</b> routine (or the equivalent) that started
the database operation will return SQLITE_INTERRUPT.</p>
<h2>Testing for a complete SQL statement</h2> <h2>Testing for a complete SQL statement</h2>
<p>The next interface routine to SQLite is a convenience function used <p>The next interface routine to SQLite is a convenience function used

View File

@ -17,7 +17,14 @@ proc chng {date desc} {
puts "<DD><P><UL>$desc</UL></P></DD>" puts "<DD><P><UL>$desc</UL></P></DD>"
} }
chng {2000 Oct 11 (Not Released)} { chng {2000 Oct 16 (1.0.11)
<li>Added the <b>sqlite_interrupt()</b> interface.</li>
<li>In the shell, <b>sqlite_interrupt()</b> is invoked when the
user presses Control-C</li>
<li>Fixed bugs in the return value of <b>sqlite_exec()</b>.</li>
}
chng {2000 Oct 11 (1.0.10)
<li>Added notes on how to compile for Windows95/98.</li> <li>Added notes on how to compile for Windows95/98.</li>
<li>Add Doug Lea's memory allocator to the distribution, for completeness.</li> <li>Add Doug Lea's memory allocator to the distribution, for completeness.</li>
<li>Removed a few variables that were not being used. Etc.</li> <li>Removed a few variables that were not being used. Etc.</li>