-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
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
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
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
-d67884f6278a130c81bc75f472170eb6c799ddfa
\ No newline at end of file
+f7ea08b931b9b40831bfe73cd7afea17f92112cf
\ No newline at end of file
** 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"
** 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;
}
}
** 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"
/* 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;
if( rc!=SQLITE_OK && rc!=SQLITE_BUSY ){
sqlite_close(db);
return 0;
- }else{
+ }else /* if( pzErrMsg ) */{
free(*pzErrMsg);
*pzErrMsg = 0;
}
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;
}
/*
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;
+}
** 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"
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);
*/
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);
** 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 <stdlib.h>
#include <string.h>
#include "sqlite.h"
#include <unistd.h>
#include <ctype.h>
+#ifdef OS_UNIX
+# include <signal.h>
+#endif
#if defined(HAVE_READLINE) && HAVE_READLINE==1
# include <readline/readline.h>
# 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
}
}
+/*
+** 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.
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 ){
}
int main(int argc, char **argv){
- sqlite *db;
char *zErrMsg = 0;
char *argv0 = argv[0];
struct callback_data data;
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;
** 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_
** 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.
*************************************************************************
** 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"
/*
** 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
*/
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 */
** 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 <ctype.h>
/*
** 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;
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);
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;
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,
pParse->pNewTable = 0;
}
sqliteParseInfoReset(pParse);
+ sqliteStrRealloc(pzErrMsg);
+ if( nErr>0 && pParse->rc==SQLITE_OK ){
+ pParse->rc = SQLITE_ERROR;
+ }
return nErr;
}
** 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 <unistd.h>
** 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 */
/*
** 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;
}
rc = SQLITE_OK;
/* if( pzErrMsg ){ *pzErrMsg = 0; } */
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(zP1,"%d", p->aOp[i].p1);
sprintf(zP2,"%d", p->aOp[i].p2);
for(pc=0; rc==SQLITE_OK && pc<p->nOp && 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
** 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_
** 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);
# 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
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
# 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
#
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
#
# 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>
<head>
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*);
happen if the callback from a query attempts to update the table
being queried.
</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>
</blockquote>
<p>The <b>sqlite_get_table()</b> routine returns the same integer
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>
<p>The next interface routine to SQLite is a convenience function used
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>Add Doug Lea's memory allocator to the distribution, for completeness.</li>
<li>Removed a few variables that were not being used. Etc.</li>