/ Check-in [f7ea08b9]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added an interrupt capability (CVS 153)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f7ea08b931b9b40831bfe73cd7afea17f92112cf
User & Date: drh 2000-10-16 22:06:41
Context
2000-10-16
22:06
Added an interrupt capability (CVS 1706) check-in: fb015479 user: drh tags: trunk
22:06
Added an interrupt capability (CVS 153) check-in: f7ea08b9 user: drh tags: trunk
2000-10-12
13:29
Removed dlmalloc.c (CVS 1705) check-in: d67884f6 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to VERSION.

     1         -1.0.10
            1  +1.0.11

Changes to src/build.c.

    29     29   **     DROP TABLE
    30     30   **     CREATE INDEX
    31     31   **     DROP INDEX
    32     32   **     creating expressions and ID lists
    33     33   **     COPY
    34     34   **     VACUUM
    35     35   **
    36         -** $Id: build.c,v 1.23 2000/08/03 15:09:20 drh Exp $
           36  +** $Id: build.c,v 1.24 2000/10/16 22:06:42 drh Exp $
    37     37   */
    38     38   #include "sqliteInt.h"
    39     39   
    40     40   /*
    41     41   ** This routine is called after a single SQL statement has been
    42     42   ** parsed and we want to execute the VDBE code to implement 
    43     43   ** that statement.  Prior action routines should have already
................................................................................
    44     44   ** constructed VDBE code to do the work of the SQL statement.
    45     45   ** This routine just has to execute the VDBE code.
    46     46   **
    47     47   ** Note that if an error occurred, it might be the case that
    48     48   ** no VDBE code was generated.
    49     49   */
    50     50   void sqliteExec(Parse *pParse){
           51  +  int rc = SQLITE_OK;
    51     52     if( pParse->pVdbe ){
    52     53       if( pParse->explain ){
    53         -      sqliteVdbeList(pParse->pVdbe, pParse->xCallback, pParse->pArg, 
    54         -                     &pParse->zErrMsg);
           54  +      rc = sqliteVdbeList(pParse->pVdbe, pParse->xCallback, pParse->pArg, 
           55  +                          &pParse->zErrMsg);
    55     56       }else{
    56     57         FILE *trace = (pParse->db->flags & SQLITE_VdbeTrace)!=0 ? stderr : 0;
    57     58         sqliteVdbeTrace(pParse->pVdbe, trace);
    58         -      sqliteVdbeExec(pParse->pVdbe, pParse->xCallback, pParse->pArg, 
    59         -                     &pParse->zErrMsg, pParse->db->pBusyArg,
    60         -                     pParse->db->xBusyCallback);
           59  +      rc = sqliteVdbeExec(pParse->pVdbe, pParse->xCallback, pParse->pArg, 
           60  +                          &pParse->zErrMsg, pParse->db->pBusyArg,
           61  +                          pParse->db->xBusyCallback);
    61     62       }
    62     63       sqliteVdbeDelete(pParse->pVdbe);
    63     64       pParse->pVdbe = 0;
    64     65       pParse->colNamesSet = 0;
           66  +    pParse->rc = rc;
    65     67     }
    66     68   }
    67     69   
    68     70   /*
    69     71   ** Construct a new expression node and return a pointer to it.
    70     72   */
    71     73   Expr *sqliteExpr(int op, Expr *pLeft, Expr *pRight, Token *pToken){

Changes to src/main.c.

    22     22   **
    23     23   *************************************************************************
    24     24   ** Main file for the SQLite library.  The routines in this file
    25     25   ** implement the programmer interface to the library.  Routines in
    26     26   ** other files are for internal use by SQLite and should not be
    27     27   ** accessed by users of the library.
    28     28   **
    29         -** $Id: main.c,v 1.19 2000/10/11 19:28:52 drh Exp $
           29  +** $Id: main.c,v 1.20 2000/10/16 22:06:42 drh Exp $
    30     30   */
    31     31   #include "sqliteInt.h"
    32     32   
    33     33   /*
    34     34   ** This is the callback routine for the code that initializes the
    35     35   ** database.  Each callback contains text of a CREATE TABLE or
    36     36   ** CREATE INDEX statement that must be parsed to yield the internal
................................................................................
   150    150       { OP_Goto,     0, 18, 0},
   151    151       { OP_Halt,     0, 0,  0},           /* 25 */
   152    152     };
   153    153   
   154    154     /* Create a virtual machine to run the initialization program.  Run
   155    155     ** the program.  The delete the virtual machine.
   156    156     */
   157         -  vdbe = sqliteVdbeCreate(db->pBe);
          157  +  vdbe = sqliteVdbeCreate(db);
   158    158     if( vdbe==0 ){
   159    159       sqliteSetString(pzErrMsg, "out of memory",0); 
   160    160       return 1;
   161    161     }
   162    162     sqliteVdbeAddOpList(vdbe, sizeof(initProg)/sizeof(initProg[0]), initProg);
   163    163     rc = sqliteVdbeExec(vdbe, sqliteOpenCb, db, pzErrMsg, 
   164    164                         db->pBusyArg, db->xBusyCallback);
................................................................................
   223    223     db->file_format = 1;
   224    224   
   225    225     /* Attempt to read the schema */
   226    226     rc = sqliteInit(db, pzErrMsg);
   227    227     if( rc!=SQLITE_OK && rc!=SQLITE_BUSY ){
   228    228       sqlite_close(db);
   229    229       return 0;
   230         -  }else{
          230  +  }else /* if( pzErrMsg ) */{
   231    231       free(*pzErrMsg);
   232    232       *pzErrMsg = 0;
   233    233     }
   234    234     return db;
   235    235   }
   236    236   
   237    237   /*
................................................................................
   307    307       int rc = sqliteInit(db, pzErrMsg);
   308    308       if( rc!=SQLITE_OK ) return rc;
   309    309     }
   310    310     memset(&sParse, 0, sizeof(sParse));
   311    311     sParse.db = db;
   312    312     sParse.xCallback = xCallback;
   313    313     sParse.pArg = pArg;
   314         -  rc = sqliteRunParser(&sParse, zSql, pzErrMsg);
   315         -  sqliteStrRealloc(pzErrMsg);
   316         -  return rc;
          314  +  sqliteRunParser(&sParse, zSql, pzErrMsg);
          315  +  return sParse.rc;
   317    316   }
   318    317   
   319    318   /*
   320    319   ** This routine implements a busy callback that sleeps and tries
   321    320   ** again until a timeout value is reached.  The timeout value is
   322    321   ** an integer number of milliseconds passed in as the first
   323    322   ** argument.
................................................................................
   378    377   void sqlite_busy_timeout(sqlite *db, int ms){
   379    378     if( ms>0 ){
   380    379       sqlite_busy_handler(db, sqlite_default_busy_callback, (void*)ms);
   381    380     }else{
   382    381       sqlite_busy_handler(db, 0, 0);
   383    382     }
   384    383   }
          384  +
          385  +/*
          386  +** Cause any pending operation to stop at its earliest opportunity.
          387  +*/
          388  +void sqlite_interrupt(sqlite *db){
          389  +  db->flags |= SQLITE_Interrupt;
          390  +}

Changes to src/select.c.

    20     20   **   drh@hwaci.com
    21     21   **   http://www.hwaci.com/drh/
    22     22   **
    23     23   *************************************************************************
    24     24   ** This file contains C code routines that are called by the parser
    25     25   ** to handle SELECT statements.
    26     26   **
    27         -** $Id: select.c,v 1.26 2000/07/29 13:06:59 drh Exp $
           27  +** $Id: select.c,v 1.27 2000/10/16 22:06:42 drh Exp $
    28     28   */
    29     29   #include "sqliteInt.h"
    30     30   
    31     31   /*
    32     32   ** Allocate a new Select structure and return a pointer to that
    33     33   ** structure.
    34     34   */
................................................................................
   420    420   /*
   421    421   ** Get a VDBE for the given parser context.  Create a new one if necessary.
   422    422   ** If an error occurs, return NULL and leave a message in pParse.
   423    423   */
   424    424   Vdbe *sqliteGetVdbe(Parse *pParse){
   425    425     Vdbe *v = pParse->pVdbe;
   426    426     if( v==0 ){
   427         -    v = pParse->pVdbe = sqliteVdbeCreate(pParse->db->pBe);
          427  +    v = pParse->pVdbe = sqliteVdbeCreate(pParse->db);
   428    428     }
   429    429     if( v==0 ){
   430    430       sqliteSetString(&pParse->zErrMsg, "out of memory", 0);
   431    431       pParse->nErr++;
   432    432     }
   433    433     return v;
   434    434   }
................................................................................
   814    814       }
   815    815     }
   816    816   
   817    817     /* Begin generating code.
   818    818     */
   819    819     v = pParse->pVdbe;
   820    820     if( v==0 ){
   821         -    v = pParse->pVdbe = sqliteVdbeCreate(pParse->db->pBe);
          821  +    v = pParse->pVdbe = sqliteVdbeCreate(pParse->db);
   822    822     }
   823    823     if( v==0 ){
   824    824       sqliteSetString(&pParse->zErrMsg, "out of memory", 0);
   825    825       pParse->nErr++;
   826    826       return 1;
   827    827     }
   828    828     if( pOrderBy ){

Changes to src/shell.c.

    20     20   **   drh@hwaci.com
    21     21   **   http://www.hwaci.com/drh/
    22     22   **
    23     23   *************************************************************************
    24     24   ** This file contains code to implement the "sqlite" command line
    25     25   ** utility for accessing SQLite databases.
    26     26   **
    27         -** $Id: shell.c,v 1.26 2000/10/08 22:20:58 drh Exp $
           27  +** $Id: shell.c,v 1.27 2000/10/16 22:06:42 drh Exp $
    28     28   */
    29     29   #include <stdlib.h>
    30     30   #include <string.h>
    31     31   #include <stdio.h>
    32     32   #include "sqlite.h"
    33     33   #include <unistd.h>
    34     34   #include <ctype.h>
           35  +#ifdef OS_UNIX
           36  +# include <signal.h>
           37  +#endif
    35     38   
    36     39   #if defined(HAVE_READLINE) && HAVE_READLINE==1
    37     40   # include <readline/readline.h>
    38     41   # include <readline/history.h>
    39     42   #else
    40     43   # define readline getline
    41     44   # define add_history(X) 
    42     45   #endif
    43     46   
           47  +/*
           48  +** The following is the open SQLite database.  We make a pointer
           49  +** to this database a static variable so that it can be accessed
           50  +** by the SIGINT handler to interrupt database processing.
           51  +*/
           52  +static sqlite *db = 0;
           53  +
    44     54   /*
    45     55   ** This routine reads a line of text from standard input, stores
    46     56   ** the text in memory obtained from malloc() and returns a pointer
    47     57   ** to the text.  NULL is returned at end of file, or if malloc()
    48     58   ** fails.
    49     59   **
    50     60   ** The interface is like "readline" but no command-line editing
................................................................................
   224    234         fprintf(out,"&amp;");
   225    235       }else{
   226    236         break;
   227    237       }
   228    238       z += i + 1;
   229    239     }
   230    240   }
          241  +
          242  +/*
          243  +** This routine runs when the user presses Ctrl-C
          244  +*/
          245  +static void interrupt_handler(int NotUsed){
          246  +  if( db ) sqlite_interrupt(db);
          247  +}
   231    248   
   232    249   /*
   233    250   ** This is the callback routine that the SQLite library
   234    251   ** invokes for each row of a query result.
   235    252   */
   236    253   static int callback(void *pArg, int nArg, char **azArg, char **azCol){
   237    254     int i;
................................................................................
   443    460     }
   444    461   
   445    462     /* Process the input line.
   446    463     */
   447    464     if( nArg==0 ) return;
   448    465     n = strlen(azArg[0]);
   449    466     c = azArg[0][0];
   450         - 
   451    467     if( c=='d' && strncmp(azArg[0], "dump", n)==0 ){
   452    468       char *zErrMsg = 0;
   453    469       if( nArg==1 ){
   454    470         sqlite_exec(db,
   455    471           "SELECT name, type, sql FROM sqlite_master "
   456    472           "WHERE type!='meta' "
   457    473           "ORDER BY tbl_name, type DESC, name",
................................................................................
   665    681     {
   666    682       fprintf(stderr, "unknown command: \"%s\". Enter \".help\" for help\n",
   667    683         azArg[0]);
   668    684     }
   669    685   }
   670    686   
   671    687   int main(int argc, char **argv){
   672         -  sqlite *db;
   673    688     char *zErrMsg = 0;
   674    689     char *argv0 = argv[0];
   675    690     struct callback_data data;
   676    691   
   677    692     memset(&data, 0, sizeof(data));
   678    693     data.mode = MODE_List;
   679    694     strcpy(data.separator,"|");
   680    695     data.showHeader = 0;
          696  +#ifdef SIGINT
          697  +  signal(SIGINT, interrupt_handler);
          698  +#endif
   681    699     while( argc>=2 && argv[1][0]=='-' ){
   682    700       if( strcmp(argv[1],"-html")==0 ){
   683    701         data.mode = MODE_Html;
   684    702         argc--;
   685    703         argv++;
   686    704       }else if( strcmp(argv[1],"-list")==0 ){
   687    705         data.mode = MODE_List;

Changes to src/sqlite.h.in.

    20     20   **   drh@hwaci.com
    21     21   **   http://www.hwaci.com/drh/
    22     22   **
    23     23   *************************************************************************
    24     24   ** This header file defines the interface that the sqlite library
    25     25   ** presents to client programs.
    26     26   **
    27         -** @(#) $Id: sqlite.h.in,v 1.5 2000/10/09 12:57:01 drh Exp $
           27  +** @(#) $Id: sqlite.h.in,v 1.6 2000/10/16 22:06:42 drh Exp $
    28     28   */
    29     29   #ifndef _SQLITE_H_
    30     30   #define _SQLITE_H_
    31     31   #include <stdarg.h>     /* Needed for the definition of va_list */
    32     32   
    33     33   /*
    34     34   ** The version of the SQLite library.
................................................................................
   126    126     char **errmsg                 /* Error msg written here */
   127    127   );
   128    128   
   129    129   /*
   130    130   ** Return values for sqlite_exec()
   131    131   */
   132    132   #define SQLITE_OK        0    /* Successful result */
   133         -#define SQLITE_INTERNAL  1    /* An internal logic error in SQLite */
   134         -#define SQLITE_ERROR     2    /* SQL error or missing database */
          133  +#define SQLITE_ERROR     1    /* SQL error or missing database */
          134  +#define SQLITE_INTERNAL  2    /* An internal logic error in SQLite */
   135    135   #define SQLITE_PERM      3    /* Access permission denied */
   136    136   #define SQLITE_ABORT     4    /* Callback routine requested an abort */
   137    137   #define SQLITE_BUSY      5    /* One or more database files are locked */
   138    138   #define SQLITE_NOMEM     6    /* A malloc() failed */
   139    139   #define SQLITE_READONLY  7    /* Attempt to write a readonly database */
          140  +#define SQLITE_INTERRUPT 8    /* Operation terminated by sqlite_interrupt() */
          141  +
          142  +/* This function causes any pending database operation to abort and
          143  +** return at its earliest opportunity.  This routine is typically
          144  +** called in response to a user include such as pressing "Cancel"
          145  +** or Ctrl-C where the user wants a long query operation to halt
          146  +** immediately.
          147  +*/
          148  +void sqlite_interrupt(sqlite*);
          149  +
   140    150   
   141    151   /* This function returns true if the given input string comprises
   142    152   ** one or more complete SQL statements.
   143    153   **
   144    154   ** The algorithm is simple.  If the last token other than spaces
   145    155   ** and comments is a semicolon, then return true.  otherwise return
   146    156   ** false.

Changes to src/sqliteInt.h.

    19     19   ** Author contact information:
    20     20   **   drh@hwaci.com
    21     21   **   http://www.hwaci.com/drh/
    22     22   **
    23     23   *************************************************************************
    24     24   ** Internal interface definitions for SQLite.
    25     25   **
    26         -** @(#) $Id: sqliteInt.h,v 1.30 2000/08/28 15:51:44 drh Exp $
           26  +** @(#) $Id: sqliteInt.h,v 1.31 2000/10/16 22:06:42 drh Exp $
    27     27   */
    28     28   #include "sqlite.h"
    29     29   #include "dbbe.h"
    30     30   #include "vdbe.h"
    31     31   #include "parse.h"
    32     32   #include <gdbm.h>
    33     33   #include <stdio.h>
................................................................................
   131    131     Table *apTblHash[N_HASH];  /* All tables of the database */
   132    132     Index *apIdxHash[N_HASH];  /* All indices of the database */
   133    133   };
   134    134   
   135    135   /*
   136    136   ** Possible values for the sqlite.flags.
   137    137   */
   138         -#define SQLITE_VdbeTrace    0x00000001
   139         -#define SQLITE_Initialized  0x00000002
          138  +#define SQLITE_VdbeTrace    0x00000001  /* True to trace VDBE execution */
          139  +#define SQLITE_Initialized  0x00000002  /* True after initialization */
          140  +#define SQLITE_Interrupt    0x00000004  /* Cancel current operation */
   140    141   
   141    142   /*
   142    143   ** Current file format version
   143    144   */
   144    145   #define SQLITE_FileFormat 2
   145    146   
   146    147   /*
................................................................................
   321    322   };
   322    323   
   323    324   /*
   324    325   ** An SQL parser context
   325    326   */
   326    327   struct Parse {
   327    328     sqlite *db;          /* The main database structure */
          329  +  int rc;              /* Return code from execution */
   328    330     sqlite_callback xCallback;  /* The callback function */
   329    331     void *pArg;          /* First argument to the callback function */
   330    332     char *zErrMsg;       /* An error message */
   331    333     Token sErrToken;     /* The token at which the error occurred */
   332    334     Token sFirstToken;   /* The first token parsed */
   333    335     Token sLastToken;    /* The last token parsed */
   334    336     Table *pNewTable;    /* A table being constructed by CREATE TABLE */

Changes to src/tokenize.c.

    23     23   *************************************************************************
    24     24   ** An tokenizer for SQL
    25     25   **
    26     26   ** This file contains C code that splits an SQL input string up into
    27     27   ** individual tokens and sends those tokens one-by-one over to the
    28     28   ** parser for analysis.
    29     29   **
    30         -** $Id: tokenize.c,v 1.13 2000/08/09 17:17:25 drh Exp $
           30  +** $Id: tokenize.c,v 1.14 2000/10/16 22:06:42 drh Exp $
    31     31   */
    32     32   #include "sqliteInt.h"
    33     33   #include <ctype.h>
    34     34   #include <stdlib.h>
    35     35   
    36     36   /*
    37     37   ** All the keywords of the SQL language are stored as in a hash
................................................................................
   294    294     }
   295    295     *tokenType = TK_ILLEGAL;
   296    296     return 1;
   297    297   }
   298    298   
   299    299   /*
   300    300   ** Run the parser on the given SQL string.  The parser structure is
   301         -** passed in.  Return the number of errors.
          301  +** passed in.  An SQLITE_ status code.
   302    302   */
   303    303   int sqliteRunParser(Parse *pParse, char *zSql, char **pzErrMsg){
   304    304     int nErr = 0;
   305    305     int i;
   306    306     void *pEngine;
   307    307     int once = 1;
   308    308     static FILE *trace = 0;
   309    309     extern void *sqliteParserAlloc(void*(*)(int));
   310    310     extern void sqliteParserFree(void*, void(*)(void*));
   311    311     extern int sqliteParser(void*, int, ...);
   312    312     extern void sqliteParserTrace(FILE*, char *);
   313    313   
          314  +  pParse->db->flags &= ~SQLITE_Interrupt;
          315  +  pParse->rc = SQLITE_OK;
   314    316     i = 0;
   315    317     sqliteParseInfoReset(pParse);
   316    318     pEngine = sqliteParserAlloc((void*(*)(int))malloc);
   317    319     if( pEngine==0 ){
   318    320       sqliteSetString(pzErrMsg, "out of memory", 0);
   319    321       return 1;
   320    322     }
   321    323     sqliteParserTrace(trace, "parser: ");
   322    324     while( nErr==0 && i>=0 && zSql[i]!=0 ){
   323    325       int tokenType;
   324    326       
          327  +    if( (pParse->db->flags & SQLITE_Interrupt)!=0 ){
          328  +      pParse->rc = SQLITE_INTERRUPT;
          329  +      sqliteSetString(pzErrMsg, "interrupt", 0);
          330  +      break;
          331  +    }
   325    332       pParse->sLastToken.z = &zSql[i];
   326    333       pParse->sLastToken.n = sqliteGetToken(&zSql[i], &tokenType);
   327    334       i += pParse->sLastToken.n;
   328    335       if( once ){
   329    336         pParse->sFirstToken = pParse->sLastToken;
   330    337         once = 0;
   331    338       }
................................................................................
   387    394             nErr++;
   388    395             sqliteFree(pParse->zErrMsg);
   389    396             pParse->zErrMsg = 0;
   390    397           }
   391    398           break;
   392    399       }
   393    400     }
   394         -  if( nErr==0 ){
          401  +  if( nErr==0 && (pParse->db->flags & SQLITE_Interrupt)==0 ){
   395    402       sqliteParser(pEngine, 0, pParse->sLastToken, pParse);
   396    403       if( pParse->zErrMsg && pParse->sErrToken.z ){
   397    404          sqliteSetNString(pzErrMsg, "near \"", -1, 
   398    405             pParse->sErrToken.z, pParse->sErrToken.n,
   399    406             "\": ", -1,
   400    407             pParse->zErrMsg, -1,
   401    408             0);
................................................................................
   419    426       pParse->pVdbe = 0;
   420    427     }
   421    428     if( pParse->pNewTable ){
   422    429       sqliteDeleteTable(pParse->db, pParse->pNewTable);
   423    430       pParse->pNewTable = 0;
   424    431     }
   425    432     sqliteParseInfoReset(pParse);
          433  +  sqliteStrRealloc(pzErrMsg);
          434  +  if( nErr>0 && pParse->rc==SQLITE_OK ){
          435  +    pParse->rc = SQLITE_ERROR;
          436  +  }
   426    437     return nErr;
   427    438   }

Changes to src/vdbe.c.

    37     37   ** inplicit conversion from one type to the other occurs as necessary.
    38     38   ** 
    39     39   ** Most of the code in this file is taken up by the sqliteVdbeExec()
    40     40   ** function which does the work of interpreting a VDBE program.
    41     41   ** But other routines are also provided to help in building up
    42     42   ** a program instruction by instruction.
    43     43   **
    44         -** $Id: vdbe.c,v 1.42 2000/10/11 19:28:53 drh Exp $
           44  +** $Id: vdbe.c,v 1.43 2000/10/16 22:06:43 drh Exp $
    45     45   */
    46     46   #include "sqliteInt.h"
    47     47   #include <unistd.h>
    48     48   #include <ctype.h>
    49     49   
    50     50   /*
    51     51   ** SQL is translated into a sequence of instructions to be
................................................................................
   165    165     char zKey[1];          /* Value of this key */
   166    166   };
   167    167   
   168    168   /*
   169    169   ** An instance of the virtual machine
   170    170   */
   171    171   struct Vdbe {
          172  +  sqlite *db;         /* The whole database */
   172    173     Dbbe *pBe;          /* Opaque context structure used by DB backend */
   173    174     FILE *trace;        /* Write an execution trace here, if not NULL */
   174    175     int nOp;            /* Number of instructions in the program */
   175    176     int nOpAlloc;       /* Number of slots allocated for aOp[] */
   176    177     Op *aOp;            /* Space to hold the virtual machine's program */
   177    178     int nLabel;         /* Number of labels used */
   178    179     int nLabelAlloc;    /* Number of slots allocated in aLabel[] */
................................................................................
   200    201     Set *aSet;          /* An array of sets */
   201    202     int nFetch;         /* Number of OP_Fetch instructions executed */
   202    203   };
   203    204   
   204    205   /*
   205    206   ** Create a new virtual database engine.
   206    207   */
   207         -Vdbe *sqliteVdbeCreate(Dbbe *pBe){
          208  +Vdbe *sqliteVdbeCreate(sqlite *db){
   208    209     Vdbe *p;
   209    210   
   210    211     p = sqliteMalloc( sizeof(Vdbe) );
   211         -  p->pBe = pBe;
          212  +  p->pBe = db->pBe;
          213  +  p->db = db;
   212    214     return p;
   213    215   }
   214    216   
   215    217   /*
   216    218   ** Turn tracing on or off
   217    219   */
   218    220   void sqliteVdbeTrace(Vdbe *p, FILE *trace){
................................................................................
   832    834     azValue[0] = zAddr;
   833    835     azValue[2] = zP1;
   834    836     azValue[3] = zP2;
   835    837     azValue[5] = 0;
   836    838     rc = SQLITE_OK;
   837    839     /* if( pzErrMsg ){ *pzErrMsg = 0; } */
   838    840     for(i=0; rc==SQLITE_OK && i<p->nOp; i++){
          841  +    if( p->db->flags & SQLITE_Interrupt ){
          842  +      p->db->flags &= ~SQLITE_Interrupt;
          843  +      sqliteSetString(pzErrMsg, "interrupted", 0);
          844  +      rc = SQLITE_INTERRUPT;
          845  +      break;
          846  +    }
   839    847       sprintf(zAddr,"%d",i);
   840    848       sprintf(zP1,"%d", p->aOp[i].p1);
   841    849       sprintf(zP2,"%d", p->aOp[i].p2);
   842    850       azValue[4] = p->aOp[i].p3;
   843    851       azValue[1] = zOpName[p->aOp[i].opcode];
   844    852       if( xCallback(pArg, 5, azValue, azColumnNames) ){
   845    853         rc = SQLITE_ABORT;
................................................................................
   924    932     if( access("vdbe_trace",0)==0 ){
   925    933       p->trace = stderr;
   926    934     }
   927    935   #endif
   928    936     /* if( pzErrMsg ){ *pzErrMsg = 0; } */
   929    937     for(pc=0; rc==SQLITE_OK && pc<p->nOp && pc>=0; pc++){
   930    938       pOp = &p->aOp[pc];
          939  +
          940  +    /* Interrupt processing if requested.
          941  +    */
          942  +    if( p->db->flags & SQLITE_Interrupt ){
          943  +      p->db->flags &= ~SQLITE_Interrupt;
          944  +      rc = SQLITE_INTERRUPT;
          945  +      sqliteSetString(pzErrMsg, "interrupted", 0);
          946  +      break;
          947  +    }
   931    948   
   932    949       /* Only allow tracing if NDEBUG is not defined.
   933    950       */
   934    951   #ifndef NDEBUG
   935    952       if( p->trace ){
   936    953         fprintf(p->trace,"%4d %-12s %4d %4d %s\n",
   937    954           pc, zOpName[pOp->opcode], pOp->p1, pOp->p2,

Changes to src/vdbe.h.

    23     23   *************************************************************************
    24     24   ** Header file for the Virtual DataBase Engine (VDBE)
    25     25   **
    26     26   ** This header defines the interface to the virtual database engine
    27     27   ** or VDBE.  The VDBE implements an abstract machine that runs a
    28     28   ** simple program to access and modify the underlying database.
    29     29   **
    30         -** $Id: vdbe.h,v 1.13 2000/10/11 19:28:53 drh Exp $
           30  +** $Id: vdbe.h,v 1.14 2000/10/16 22:06:43 drh Exp $
    31     31   */
    32     32   #ifndef _SQLITE_VDBE_H_
    33     33   #define _SQLITE_VDBE_H_
    34     34   #include <stdio.h>
    35     35   
    36     36   /*
    37     37   ** A single VDBE is an opaque structure named "Vdbe".  Only routines
................................................................................
   178    178   
   179    179   #define OP_MAX                90
   180    180   
   181    181   /*
   182    182   ** Prototypes for the VDBE interface.  See comments on the implementation
   183    183   ** for a description of what each of these routines does.
   184    184   */
   185         -Vdbe *sqliteVdbeCreate(Dbbe*);
          185  +Vdbe *sqliteVdbeCreate(sqlite*);
   186    186   int sqliteVdbeAddOp(Vdbe*,int,int,int,const char*,int);
   187    187   int sqliteVdbeAddOpList(Vdbe*, int nOp, VdbeOp const *aOp);
   188    188   void sqliteVdbeChangeP3(Vdbe*, int addr, const char *zP1, int N);
   189    189   void sqliteVdbeDequoteP3(Vdbe*, int addr);
   190    190   int sqliteVdbeMakeLabel(Vdbe*);
   191    191   void sqliteVdbeDelete(Vdbe*);
   192    192   int sqliteVdbeOpcode(const char *zName);

Changes to test/dbbe.test.

    19     19   #   drh@hwaci.com
    20     20   #   http://www.hwaci.com/drh/
    21     21   #
    22     22   #***********************************************************************
    23     23   # This file implements regression tests for SQLite library.  The
    24     24   # focus of this file is exercising the code in dbbe.c.
    25     25   #
    26         -# $Id: dbbe.test,v 1.3 2000/08/17 09:50:00 drh Exp $
           26  +# $Id: dbbe.test,v 1.4 2000/10/16 22:06:43 drh Exp $
    27     27   
    28     28   set testdir [file dirname $argv0]
    29     29   source $testdir/tester.tcl
    30     30   
    31     31   # Try to open a database that does not exist.
    32     32   #
    33     33   do_test dbbe-1.1 {
................................................................................
   126    126     file delete -force testdb
   127    127     sqlite db testdb 0666
   128    128     execsql {CREATE TABLE t1(x int)}
   129    129     db close
   130    130     sqlite db testdb 0444
   131    131     set v [catch {execsql {INSERT INTO t1 VALUES(1)}} msg]
   132    132     lappend v $msg
   133         -} {1 {table t1 is readonly}}
          133  +} {7 {table t1 is readonly}}
   134    134   
   135    135   
   136    136   finish_test

Changes to test/lock.test.

    19     19   #   drh@hwaci.com
    20     20   #   http://www.hwaci.com/drh/
    21     21   #
    22     22   #***********************************************************************
    23     23   # This file implements regression tests for SQLite library.  The
    24     24   # focus of this script is database locks.
    25     25   #
    26         -# $Id: lock.test,v 1.2 2000/08/04 13:51:11 drh Exp $
           26  +# $Id: lock.test,v 1.3 2000/10/16 22:06:43 drh Exp $
    27     27   
    28     28   set testdir [file dirname $argv0]
    29     29   source $testdir/tester.tcl
    30     30   
    31     31   
    32     32   # Create a largish table
    33     33   #
................................................................................
    55     55   } {}
    56     56   
    57     57   do_test lock-1.2 {
    58     58     # Now try to update the database
    59     59     #
    60     60     set v [catch {execsql {UPDATE big SET f2='xyz' WHERE f1=11}} msg]
    61     61     lappend v $msg
    62         -} {1 {table big is locked}}
           62  +} {5 {table big is locked}}
    63     63   
    64     64   do_test lock-1.3 {
    65     65     # Try to update the database in a separate process
    66     66     #
    67     67     set f [open update.sql w]
    68     68     puts $f ".timeout 0"
    69     69     puts $f "UPDATE big SET f2='xyz' WHERE f1=11;"

Changes to www/c_interface.tcl.

     1      1   #
     2      2   # Run this Tcl script to generate the sqlite.html file.
     3      3   #
     4         -set rcsid {$Id: c_interface.tcl,v 1.10 2000/10/09 12:57:01 drh Exp $}
            4  +set rcsid {$Id: c_interface.tcl,v 1.11 2000/10/16 22:06:43 drh Exp $}
     5      5   
     6      6   puts {<html>
     7      7   <head>
     8      8     <title>The C language interface to the SQLite library</title>
     9      9   </head>
    10     10   <body bgcolor=white>
    11     11   <h1 align=center>
................................................................................
    63     63     char ***result,
    64     64     int *nrow,
    65     65     int *ncolumn,
    66     66     char **errmsg
    67     67   );
    68     68   
    69     69   void sqlite_free_table(char**);
           70  +
           71  +void sqlite_interrupt(sqlite*);
    70     72   
    71     73   int sqlite_complete(const char *sql);
    72     74   
    73     75   void sqlite_busy_handler(sqlite*, int (*)(void*,const char*,int), void*);
    74     76   
    75     77   void sqlite_busy_timeout(sqlite*, int ms);
    76     78   
................................................................................
   259    261   </p></dd>
   260    262   <dt>SQLITE_READONLY</dt>
   261    263   <dd><p>This return code indicates that an attempt was made to write to
   262    264   a database file that was originally opened for reading only.  This can
   263    265   happen if the callback from a query attempts to update the table
   264    266   being queried.
   265    267   </p></dd>
          268  +<dt>SQLITE_INTERRUPT</dt>
          269  +<dd><p>This value is returned if a call to <b>sqlite_interrupt()</b>
          270  +interrupts a database operation in progress.
          271  +</p></dd>
   266    272   </dl>
   267    273   </blockquote>
   268    274   
   269    275   <h2>Querying without using a callback function</h2>
   270    276   
   271    277   <p>The <b>sqlite_get_table()</b> function is a wrapper around
   272    278   <b>sqlite_exec()</b> that collects all the information from successive
................................................................................
   313    319   is obtained from malloc().  But the calling function should not try
   314    320   to free this information directly.  Instead, pass the complete table
   315    321   to <b>sqlite_free_table()</b> when the table is no longer needed.</p>
   316    322   
   317    323   <p>The <b>sqlite_get_table()</b> routine returns the same integer
   318    324   result code as <b>sqlite_exec()</b>.</p>
   319    325   
          326  +<h2>Interrupting an SQLite operation</h2>
          327  +
          328  +<p>The <b>sqlite_interrupt()</b> function can be called from a
          329  +different thread or from a signal handler to the current database
          330  +operation to exit at its first opportunity.  When this happens,
          331  +the <b>sqlite_exec()</b> routine (or the equivalent) that started
          332  +the database operation will return SQLITE_INTERRUPT.</p>
          333  +
   320    334   <h2>Testing for a complete SQL statement</h2>
   321    335   
   322    336   <p>The next interface routine to SQLite is a convenience function used
   323    337   to test whether or not a string forms a complete SQL statement.
   324    338   If the <b>sqlite_complete()</b> function returns true when its input
   325    339   is a string, then the argument forms a complete SQL statement.
   326    340   There are no guarantees that the syntax of that statement is correct,

Changes to www/changes.tcl.

    13     13   
    14     14   
    15     15   proc chng {date desc} {
    16     16     puts "<DT><B>$date</B></DT>"
    17     17     puts "<DD><P><UL>$desc</UL></P></DD>"
    18     18   }
    19     19   
    20         -chng {2000 Oct 11 (Not Released)} {
           20  +chng {2000 Oct 16 (1.0.11)
           21  +<li>Added the <b>sqlite_interrupt()</b> interface.</li>
           22  +<li>In the shell, <b>sqlite_interrupt()</b> is invoked when the
           23  +    user presses Control-C</li>
           24  +<li>Fixed bugs in the return value of <b>sqlite_exec()</b>.</li>
           25  +}
           26  +
           27  +chng {2000 Oct 11 (1.0.10)
    21     28   <li>Added notes on how to compile for Windows95/98.</li>
    22     29   <li>Add Doug Lea's memory allocator to the distribution, for completeness.</li>
    23     30   <li>Removed a few variables that were not being used.  Etc.</li>
    24     31   }
    25     32   
    26     33   chng {2000 Oct 8 (1.0.9)} {
    27     34   <li>Added the <b>sqlite_..._printf()</b> interface routines.</li>