/ Check-in [2eb90870]
Login

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

Overview
Comment:Remove code for SQL cursors. (CVS 2312)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2eb90870556c90b8d85da3d5eb7554f74ec922c2
User & Date: danielk1977 2005-02-04 04:07:17
Context
2005-02-04
21:13
Detect and report a subtle case of database file corruption. (CVS 2313) check-in: 9fc0a5cb user: drh tags: trunk
04:07
Remove code for SQL cursors. (CVS 2312) check-in: 2eb90870 user: danielk1977 tags: trunk
2005-02-03
01:08
Get AUTOINCREMENT and VACUUM working together. Ticket #1095. (CVS 2311) check-in: 332a531d user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Makefile.in.

   107    107   ###############################################################################
   108    108   
   109    109   OPTS += -DSQLITE_OMIT_CURSOR          # Cursors do not work at this time
   110    110   TCC += -DSQLITE_OMIT_CURSOR
   111    111   
   112    112   # Object files for the SQLite library.
   113    113   #
   114         -LIBOBJ = attach.lo auth.lo btree.lo build.lo cursor.lo date.lo \
          114  +LIBOBJ = attach.lo auth.lo btree.lo build.lo date.lo \
   115    115            delete.lo expr.lo func.lo hash.lo insert.lo \
   116    116            main.lo opcodes.lo os_unix.lo os_win.lo \
   117    117            pager.lo parse.lo pragma.lo printf.lo random.lo \
   118    118            select.lo table.lo tokenize.lo trigger.lo update.lo \
   119    119            util.lo vacuum.lo vdbe.lo vdbeapi.lo vdbeaux.lo vdbemem.lo \
   120    120            where.lo utf.lo legacy.lo
   121    121   
................................................................................
   123    123   #
   124    124   SRC = \
   125    125     $(TOP)/src/attach.c \
   126    126     $(TOP)/src/auth.c \
   127    127     $(TOP)/src/btree.c \
   128    128     $(TOP)/src/btree.h \
   129    129     $(TOP)/src/build.c \
   130         -  $(TOP)/src/cursor.c \
   131    130     $(TOP)/src/date.c \
   132    131     $(TOP)/src/delete.c \
   133    132     $(TOP)/src/expr.c \
   134    133     $(TOP)/src/func.c \
   135    134     $(TOP)/src/hash.c \
   136    135     $(TOP)/src/hash.h \
   137    136     $(TOP)/src/insert.c \
................................................................................
   284    283   	echo '"#define SQLITE_PTR_SZ %d",sizeof(char*));' >>temp.c
   285    284   	echo 'exit(0);}' >>temp.c
   286    285   	$(BCC) -o temp temp.c
   287    286   	./temp >config.h
   288    287   	echo >>config.h
   289    288   	rm -f temp.c temp
   290    289   
   291         -cursor.lo:	$(TOP)/src/cursor.c $(HDR)
   292         -	$(LTCOMPILE) -c $(TOP)/src/cursor.c
   293         -
   294    290   date.lo:	$(TOP)/src/date.c $(HDR)
   295    291   	$(LTCOMPILE) -c $(TOP)/src/date.c
   296    292   
   297    293   delete.lo:	$(TOP)/src/delete.c $(HDR)
   298    294   	$(LTCOMPILE) -c $(TOP)/src/delete.c
   299    295   
   300    296   expr.lo:	$(TOP)/src/expr.c $(HDR)

Changes to main.mk.

    50     50   
    51     51   # This is how we compile
    52     52   #
    53     53   TCCX = $(TCC) $(OPTS) $(THREADSAFE) $(USLEEP) -I. -I$(TOP)/src
    54     54   
    55     55   # Object files for the SQLite library.
    56     56   #
    57         -LIBOBJ+= attach.o auth.o btree.o build.o cursor.o date.o delete.o \
           57  +LIBOBJ+= attach.o auth.o btree.o build.o date.o delete.o \
    58     58            expr.o func.o hash.o insert.o \
    59     59            main.o opcodes.o os_unix.o os_win.o \
    60     60            pager.o parse.o pragma.o printf.o random.o \
    61     61            select.o table.o tclsqlite.o tokenize.o trigger.o \
    62     62            update.o util.o vacuum.o \
    63     63            vdbe.o vdbeapi.o vdbeaux.o vdbemem.o \
    64     64            where.o utf.o legacy.o
................................................................................
    67     67   #
    68     68   SRC = \
    69     69     $(TOP)/src/attach.c \
    70     70     $(TOP)/src/auth.c \
    71     71     $(TOP)/src/btree.c \
    72     72     $(TOP)/src/btree.h \
    73     73     $(TOP)/src/build.c \
    74         -  $(TOP)/src/cursor.c \
    75     74     $(TOP)/src/date.c \
    76     75     $(TOP)/src/delete.c \
    77     76     $(TOP)/src/expr.c \
    78     77     $(TOP)/src/func.c \
    79     78     $(TOP)/src/hash.c \
    80     79     $(TOP)/src/hash.h \
    81     80     $(TOP)/src/insert.c \
................................................................................
   220    219   	echo '"#define SQLITE_PTR_SZ %d",sizeof(char*));' >>temp.c
   221    220   	echo 'exit(0);}' >>temp.c
   222    221   	$(BCC) -o temp temp.c
   223    222   	./temp >config.h
   224    223   	echo >>config.h
   225    224   	rm -f temp.c temp
   226    225   
   227         -cursor.o:	$(TOP)/src/cursor.c $(HDR)
   228         -	$(TCCX) -c $(TOP)/src/cursor.c
   229         -
   230    226   date.o:	$(TOP)/src/date.c $(HDR)
   231    227   	$(TCCX) -c $(TOP)/src/date.c
   232    228   
   233    229   delete.o:	$(TOP)/src/delete.c $(HDR)
   234    230   	$(TCCX) -c $(TOP)/src/delete.c
   235    231   
   236    232   expr.o:	$(TOP)/src/expr.c $(HDR)

Changes to src/btree.c.

     5      5   ** a legal notice, here is a blessing:
     6      6   **
     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12         -** $Id: btree.c,v 1.244 2005/01/21 11:55:26 danielk1977 Exp $
           12  +** $Id: btree.c,v 1.245 2005/02/04 04:07:17 danielk1977 Exp $
    13     13   **
    14     14   ** This file implements a external (disk-based) database using BTrees.
    15     15   ** For a detailed discussion of BTrees, refer to
    16     16   **
    17     17   **     Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3:
    18     18   **     "Sorting And Searching", pages 473-480. Addison-Wesley
    19     19   **     Publishing Company, Reading, Massachusetts.
................................................................................
  1947   1947   #endif
  1948   1948   
  1949   1949   #ifdef SQLITE_TEST
  1950   1950   /*
  1951   1951   ** Print debugging information about all cursors to standard output.
  1952   1952   */
  1953   1953   void sqlite3BtreeCursorList(Btree *pBt){
  1954         -#ifndef SQLITE_OMIT_CURSOR
  1955   1954     BtCursor *pCur;
  1956   1955     for(pCur=pBt->pCursor; pCur; pCur=pCur->pNext){
  1957   1956       MemPage *pPage = pCur->pPage;
  1958   1957       char *zMode = pCur->wrFlag ? "rw" : "ro";
  1959   1958       sqlite3DebugPrintf("CURSOR %p rooted at %4d(%s) currently at %d.%d%s\n",
  1960   1959          pCur, pCur->pgnoRoot, zMode,
  1961   1960          pPage ? pPage->pgno : 0, pCur->idx,
  1962   1961          pCur->isValid ? "" : " eof"
  1963   1962       );
  1964   1963     }
  1965         -#endif
  1966   1964   }
  1967   1965   #endif
  1968   1966   
  1969   1967   /*
  1970   1968   ** Rollback the transaction in progress.  All cursors will be
  1971   1969   ** invalided by this operation.  Any attempt to use a cursor
  1972   1970   ** that was open at the beginning of this operation will result

Deleted src/cursor.c.

     1         -/*
     2         -** 2004 November 21
     3         -**
     4         -** The author disclaims copyright to this source code.  In place of
     5         -** a legal notice, here is a blessing:
     6         -**
     7         -**    May you do good and not evil.
     8         -**    May you find forgiveness for yourself and forgive others.
     9         -**    May you share freely, never taking more than you give.
    10         -**
    11         -*************************************************************************
    12         -** This file contains code used to implement the DECLARE...CURSOR syntax
    13         -** of SQL and related processing.
    14         -**
    15         -** Do not confuse SQL cursors and B-tree cursors.  An SQL cursor (as
    16         -** implemented by this file) is a user-visible cursor that is created
    17         -** using the DECLARE...CURSOR command and deleted using CLOSE.  A
    18         -** B-tree cursor is an abstraction of the b-tree layer.  See the btree.c
    19         -** module for additional information.  There is also a VDBE-cursor that
    20         -** is used by the VDBE module.  Even though all these objects are called
    21         -** cursors, they are really very different things.  It is worth your while
    22         -** to fully understand the difference.
    23         -**
    24         -** @(#) $Id: cursor.c,v 1.3 2005/01/20 02:14:31 drh Exp $
    25         -*/
    26         -#include "sqliteInt.h"
    27         -#ifndef SQLITE_OMIT_CURSOR
    28         -#include "vdbeInt.h"
    29         -
    30         -/*
    31         -** Delete a cursor object.
    32         -*/
    33         -void sqlite3CursorDelete(SqlCursor *p){
    34         -  if( p ){
    35         -    int i;
    36         -    sqlite3SelectDelete(p->pSelect);
    37         -    for(i=0; i<p->nPtr; i++){
    38         -      sqlite3VdbeMemRelease(&p->aPtr[i]);
    39         -    }
    40         -    sqliteFree(p->aPtr);
    41         -    sqliteFree(p);
    42         -  }
    43         -}
    44         -
    45         -/*
    46         -** Look up a cursor by name.  Return NULL if not found.
    47         -*/
    48         -static SqlCursor *findCursor(sqlite3 *db, Token *pName){
    49         -  int i;
    50         -  SqlCursor *p;
    51         -  for(i=0; i<db->nSqlCursor; i++){
    52         -    p = db->apSqlCursor[i];
    53         -    if( p && sqlite3StrNICmp(p->zName, pName->z, pName->n)==0 ){
    54         -      return p;
    55         -    }
    56         -  }
    57         -  return 0;
    58         -}  
    59         -
    60         -/*
    61         -** The parser calls this routine in order to create a new cursor.
    62         -** The arguments are the name of the new cursor and the SELECT statement
    63         -** that the new cursor will access.
    64         -*/
    65         -void sqlite3CursorCreate(Parse *pParse, Token *pName, Select *pSelect){
    66         -  SqlCursor *pNew;
    67         -  sqlite3 *db = pParse->db;
    68         -  int i;
    69         -  
    70         -
    71         -  pNew = findCursor(db, pName);
    72         -  if( pNew ){
    73         -    sqlite3ErrorMsg(pParse, "another cursor named %T already exists", pName);
    74         -    goto end_create_cursor;
    75         -  }
    76         -  if( pSelect==0 ){
    77         -    /* This can only happen due to a prior malloc failure */
    78         -    goto end_create_cursor;
    79         -  }
    80         -  for(i=0; i<db->nSqlCursor; i++){
    81         -    if( db->apSqlCursor[i]==0 ) break;
    82         -  }
    83         -  if( i>=db->nSqlCursor ){
    84         -    db->apSqlCursor = sqliteRealloc(db->apSqlCursor, (i+1)*sizeof(pNew));
    85         -    db->nSqlCursor = i+1;
    86         -  }
    87         -  db->apSqlCursor[i] = pNew = sqliteMallocRaw( sizeof(*pNew) + pName->n + 1 );
    88         -  if( pNew==0 ) goto end_create_cursor;
    89         -  pNew->idx = i;
    90         -  pNew->zName = (char*)&pNew[1];
    91         -  memcpy(pNew->zName, pName->z, pName->n);
    92         -  pNew->zName[pName->n] = 0;
    93         -  pNew->pSelect = sqlite3SelectDup(pSelect);
    94         -  pNew->nPtr = 2;
    95         -  pNew->aPtr = sqliteMalloc( sizeof(Mem)*2 );
    96         -  for(i=0; i<2; i++){
    97         -    pNew->aPtr[i].flags = MEM_Null;
    98         -  }
    99         -
   100         -end_create_cursor:
   101         -  sqlite3SelectDelete(pSelect);
   102         -}
   103         -
   104         -/*
   105         -** The parser calls this routine in response to a CLOSE command.  Delete
   106         -** the cursor named in the argument.
   107         -*/
   108         -void sqlite3CursorClose(Parse *pParse, Token *pName){
   109         -  SqlCursor *p;
   110         -  sqlite3 *db = pParse->db;
   111         -
   112         -  p = findCursor(db, pName);
   113         -  if( p==0 ){
   114         -    sqlite3ErrorMsg(pParse, "no such cursor: %T", pName);
   115         -    return;
   116         -  }
   117         -  assert( p->idx>=0 && p->idx<db->nSqlCursor );
   118         -  assert( db->apSqlCursor[p->idx]==p );
   119         -  db->apSqlCursor[p->idx] = 0;
   120         -  sqlite3CursorDelete(p);
   121         -}
   122         -
   123         -/*
   124         -** Reverse the direction the ORDER BY clause on the SELECT statement.
   125         -*/
   126         -static void reverseSortOrder(Select *p){
   127         -  if( p->pOrderBy==0 ){
   128         -    /* If there no ORDER BY clause, add a new one that is "rowid DESC" */
   129         -    static const Token rowid = { "ROWID", 0, 5 };
   130         -    Expr *pExpr = sqlite3Expr(TK_ID, 0, 0, &rowid);
   131         -    ExprList *pList = sqlite3ExprListAppend(0, pExpr, 0);
   132         -    if( pList )  pList->a[0].sortOrder = SQLITE_SO_DESC;
   133         -    p->pOrderBy = pList;
   134         -  }else{
   135         -    int i;
   136         -    ExprList *pList = p->pOrderBy;
   137         -    for(i=0; i<pList->nExpr; i++){
   138         -      pList->a[i].sortOrder = !pList->a[i].sortOrder;
   139         -    }
   140         -  }
   141         -}
   142         -
   143         -/*
   144         -** The parser calls this routine when it sees a complete FETCH statement.
   145         -** This routine generates code to implement the FETCH.
   146         -**
   147         -** Information about the direction of the FETCH has already been inserted
   148         -** into the pParse structure by parser rules.  The arguments specify the
   149         -** name of the cursor from which we are fetching and the optional INTO
   150         -** clause.
   151         -*/
   152         -void sqlite3Fetch(Parse *pParse, Token *pName, IdList *pInto){
   153         -  SqlCursor *p;
   154         -  sqlite3 *db = pParse->db;
   155         -  Select *pCopy;
   156         -  Fetch sFetch;
   157         -
   158         -  p = findCursor(db, pName);
   159         -  if( p==0 ){
   160         -    sqlite3ErrorMsg(pParse, "no such cursor: %T", pName);
   161         -    return;
   162         -  }
   163         -  sFetch.pCursor = p;
   164         -  pCopy = sqlite3SelectDup(p->pSelect);
   165         -  pCopy->pFetch = &sFetch;
   166         -  switch( pParse->fetchDir ){
   167         -    case TK_FIRST: {
   168         -      sFetch.isBackwards = 0;
   169         -      sFetch.doRewind = 1;
   170         -      pCopy->nLimit = pParse->dirArg1;
   171         -      pCopy->nOffset = 0;
   172         -      break;
   173         -    }
   174         -    case TK_LAST: {
   175         -      reverseSortOrder(pCopy);
   176         -      sFetch.isBackwards = 1;
   177         -      sFetch.doRewind = 1;
   178         -      pCopy->nLimit = pParse->dirArg1;
   179         -      pCopy->nOffset = 0;
   180         -      break;
   181         -    }
   182         -    case TK_NEXT: {
   183         -      sFetch.isBackwards = 0;
   184         -      sFetch.doRewind = 0;
   185         -      pCopy->nLimit = pParse->dirArg1;
   186         -      pCopy->nOffset = 0;
   187         -      break;
   188         -    }
   189         -    case TK_PRIOR: {
   190         -      reverseSortOrder(pCopy);
   191         -      sFetch.isBackwards = 1;
   192         -      sFetch.doRewind = 0;
   193         -      pCopy->nLimit = pParse->dirArg1;
   194         -      pCopy->nOffset = 0;
   195         -      break;
   196         -    }
   197         -    case TK_ABSOLUTE: {
   198         -      sFetch.isBackwards = 0;
   199         -      sFetch.doRewind = 1;
   200         -      pCopy->nLimit = pParse->dirArg1;
   201         -      pCopy->nOffset = pParse->dirArg2;
   202         -      break;
   203         -    }
   204         -    default: {
   205         -      assert( pParse->fetchDir==TK_RELATIVE );
   206         -      if( pParse->dirArg2>=0 ){
   207         -        /* The index parameter is positive.  Move forward from the current
   208         -        ** location */
   209         -        sFetch.isBackwards = 0;
   210         -        sFetch.doRewind = 0;
   211         -        pCopy->nLimit = pParse->dirArg1;
   212         -        pCopy->nOffset = pParse->dirArg2;
   213         -      }else{
   214         -        /* The index is negative.  We have to code two separate SELECTs.
   215         -        ** The first one seeks to the no position and the second one does
   216         -        ** the query.
   217         -        */
   218         -        Select *pSeek = sqlite3SelectDup(pCopy);
   219         -        reverseSortOrder(pSeek);
   220         -        sFetch.isBackwards = 1;
   221         -        sFetch.doRewind = 0;
   222         -        pSeek->nLimit = pParse->dirArg2;
   223         -        pSeek->pFetch = &sFetch;
   224         -        sqlite3Select(pParse, pSeek, SRT_Discard, 0, 0, 0, 0, 0);
   225         -        sFetch.isBackwards = 0;
   226         -        sFetch.doRewind = 0;
   227         -        pCopy->nLimit = pParse->dirArg1;
   228         -        pCopy->nOffset = 0;
   229         -      }
   230         -      break;
   231         -    }
   232         -  }
   233         -  sqlite3Select(pParse, pCopy, SRT_Callback, 0, 0, 0, 0, 0);
   234         -
   235         -end_fetch:
   236         -  sqlite3IdListDelete(pInto);
   237         -}
   238         -
   239         -#endif /* SQLITE_OMIT_CURSOR */

Changes to src/expr.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains routines used for analyzing expressions and
    13     13   ** for generating VDBE code that evaluates expressions in SQLite.
    14     14   **
    15         -** $Id: expr.c,v 1.190 2005/01/30 09:17:59 danielk1977 Exp $
           15  +** $Id: expr.c,v 1.191 2005/02/04 04:07:17 danielk1977 Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   #include <ctype.h>
    19     19   
    20     20   /*
    21     21   ** Return the 'affinity' of the expression pExpr if any.
    22     22   **
................................................................................
   449    449   
   450    450   /*
   451    451   ** If cursors, triggers, views and subqueries are all omitted from
   452    452   ** the build, then none of the following routines, except for 
   453    453   ** sqlite3SelectDup(), can be called. sqlite3SelectDup() is sometimes
   454    454   ** called with a NULL argument.
   455    455   */
   456         -#if !defined(SQLITE_OMIT_CURSOR) || !defined(SQLITE_OMIT_VIEW) \
   457         - || !defined(SQLITE_OMIT_TRIGGER) || !defined(SQLITE_OMIT_SUBQUERY)
          456  +#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER) \
          457  + || !defined(SQLITE_OMIT_SUBQUERY)
   458    458   SrcList *sqlite3SrcListDup(SrcList *p){
   459    459     SrcList *pNew;
   460    460     int i;
   461    461     int nByte;
   462    462     if( p==0 ) return 0;
   463    463     nByte = sizeof(*p) + (p->nSrc>0 ? sizeof(p->a[0]) * (p->nSrc-1) : 0);
   464    464     pNew = sqliteMallocRaw( nByte );

Changes to src/main.c.

    10     10   **
    11     11   *************************************************************************
    12     12   ** Main file for the SQLite library.  The routines in this file
    13     13   ** implement the programmer interface to the library.  Routines in
    14     14   ** other files are for internal use by SQLite and should not be
    15     15   ** accessed by users of the library.
    16     16   **
    17         -** $Id: main.c,v 1.277 2005/01/31 12:42:29 danielk1977 Exp $
           17  +** $Id: main.c,v 1.278 2005/02/04 04:07:17 danielk1977 Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   #include "os.h"
    21     21   #include <ctype.h>
    22     22   
    23     23   /*
    24     24   ** The following constant value is used by the SQLITE_BIGENDIAN and
................................................................................
   496    496     if( db->pValue ){
   497    497       sqlite3ValueFree(db->pValue);
   498    498     }
   499    499     if( db->pErr ){
   500    500       sqlite3ValueFree(db->pErr);
   501    501     }
   502    502   
   503         -#ifndef SQLITE_OMIT_CURSOR
   504         -  for(j=0; j<db->nSqlCursor; j++){
   505         -    sqlite3CursorDelete(db->apSqlCursor[j]);
   506         -  }
   507         -  sqliteFree(db->apSqlCursor);
   508         -#endif
   509         -
   510    503     db->magic = SQLITE_MAGIC_ERROR;
   511    504     sqliteFree(db);
   512    505     return SQLITE_OK;
   513    506   }
   514    507   
   515    508   /*
   516    509   ** Rollback all database files.

Changes to src/parse.y.

    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains SQLite's grammar for SQL.  Process this file
    13     13   ** using the lemon parser generator to generate C code that runs
    14     14   ** the parser.  Lemon will also generate a header file containing
    15     15   ** numeric codes for all of the tokens.
    16     16   **
    17         -** @(#) $Id: parse.y,v 1.163 2005/01/29 08:32:45 danielk1977 Exp $
           17  +** @(#) $Id: parse.y,v 1.164 2005/02/04 04:07:17 danielk1977 Exp $
    18     18   */
    19     19   %token_prefix TK_
    20     20   %token_type {Token}
    21     21   %default_type {Token}
    22     22   %extra_argument {Parse *pParse}
    23     23   %syntax_error {
    24     24     if( pParse->zErrMsg==0 ){
................................................................................
   596    596     Expr *temp4 = sqlite3Expr(TK_DOT, temp2, temp3, 0);
   597    597     A = sqlite3Expr(TK_DOT, temp1, temp4, 0);
   598    598   }
   599    599   term(A) ::= INTEGER(X).      {A = sqlite3Expr(@X, 0, 0, &X);}
   600    600   term(A) ::= FLOAT(X).        {A = sqlite3Expr(@X, 0, 0, &X);}
   601    601   term(A) ::= STRING(X).       {A = sqlite3Expr(@X, 0, 0, &X);}
   602    602   expr(A) ::= BLOB(X).         {A = sqlite3Expr(@X, 0, 0, &X);}
   603         -%ifdef SQLITE_ENABLE_CURSOR
   604         -expr(A) ::= CURRENT OF id.
   605         -%endif 
   606    603   expr(A) ::= REGISTER(X).     {A = sqlite3RegisterExpr(pParse, &X);}
   607    604   expr(A) ::= VARIABLE(X).     {
   608    605     Token *pToken = &X;
   609    606     Expr *pExpr = A = sqlite3Expr(TK_VARIABLE, 0, 0, pToken);
   610    607     sqlite3ExprAssignVarNumber(pParse, pExpr);
   611    608   }
   612    609   expr(A) ::= ID(X) LP exprlist(Y) RP(E). {
................................................................................
   964    961   
   965    962   //////////////////////// ALTER TABLE table ... ////////////////////////////////
   966    963   %ifndef SQLITE_OMIT_ALTERTABLE
   967    964   cmd ::= ALTER TABLE fullname(X) RENAME TO nm(Z). {
   968    965     sqlite3AlterRenameTable(pParse,X,&Z);
   969    966   }
   970    967   %endif
   971         -
   972         -////////////////////////////// CURSORS //////////////////////////////////////
   973         -%ifdef SQLITE_ENABLE_CURSOR
   974         -cmd ::= DECLARE nm(X) CURSOR FOR select(Y).  {sqlite3CursorCreate(pParse,&X,Y);}
   975         -cmd ::= CLOSE nm(X).                         {sqlite3CursorClose(pParse,&X);}
   976         -
   977         -cmd ::= FETCH direction FROM nm(N) into_opt(D).
   978         -                                      {sqlite3Fetch(pParse,&N,D);}
   979         -
   980         -%type into_opt {IdList*}
   981         -%destructor into_opt {sqlite3IdListDelete($$);}
   982         -into_opt(A) ::= .                     {A = 0;}
   983         -into_opt(A) ::= INTO inscollist(X).   {A = X;}
   984         -direction ::= NEXT(X) count_opt(Y).   {pParse->fetchDir=@X; pParse->dirArg1=Y;}
   985         -direction ::= PRIOR(X) count_opt(Y).  {pParse->fetchDir=@X; pParse->dirArg1=Y;}
   986         -direction ::= FIRST(X) count_opt(Y).  {pParse->fetchDir=@X; pParse->dirArg1=Y;}
   987         -direction ::= LAST(X) count_opt(Y).   {pParse->fetchDir=@X; pParse->dirArg1=Y;}
   988         -direction ::= ABSOLUTE(X) signed(Z) comma_count_opt(Y).
   989         -                   {pParse->fetchDir=@X; pParse->dirArg1=Y; pParse->dirArg2=Z;}
   990         -direction ::= RELATIVE(X) signed(Z) comma_count_opt(Y).
   991         -                   {pParse->fetchDir=@X; pParse->dirArg1=Y; pParse->dirArg2=Z;}
   992         -
   993         -%type count_opt {int}
   994         -count_opt(A) ::= .          {A = 1;}
   995         -count_opt(A) ::= signed(X). {A = X;}
   996         -%type comma_count_opt {int}
   997         -comma_count_opt(A) ::= .                 {A = 1;}
   998         -comma_count_opt(A) ::= COMMA signed(X).  {A = X;}
   999         -%endif // SQLITE_ENABLE_CURSOR

Changes to src/pragma.c.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code used to implement the PRAGMA command.
    13     13   **
    14         -** $Id: pragma.c,v 1.86 2005/01/24 10:25:59 danielk1977 Exp $
           14  +** $Id: pragma.c,v 1.87 2005/02/04 04:07:17 danielk1977 Exp $
    15     15   */
    16     16   #include "sqliteInt.h"
    17     17   #include "os.h"
    18     18   #include <ctype.h>
    19     19   
    20     20   /* Ignore this whole file if pragmas are disabled
    21     21   */
................................................................................
   534    534         sqlite3VdbeAddOp(v, OP_Integer, i, 0);
   535    535         sqlite3VdbeOp3(v, OP_String8, 0, 0, db->aDb[i].zName, 0);
   536    536         sqlite3VdbeOp3(v, OP_String8, 0, 0,
   537    537              sqlite3BtreeGetFilename(db->aDb[i].pBt), 0);
   538    538         sqlite3VdbeAddOp(v, OP_Callback, 3, 0);
   539    539       }
   540    540     }else
   541         -
   542         -#ifndef SQLITE_OMIT_CURSOR
   543         -  if( sqlite3StrICmp(zLeft, "cursor_list")==0 ){
   544         -    int i;
   545         -    if( sqlite3ReadSchema(pParse) ) goto pragma_out;
   546         -    sqlite3VdbeSetNumCols(v, 2);
   547         -    sqlite3VdbeSetColName(v, 0, "seq", P3_STATIC);
   548         -    sqlite3VdbeSetColName(v, 1, "name", P3_STATIC);
   549         -    for(i=0; i<db->nSqlCursor; i++){
   550         -      SqlCursor *p = db->apSqlCursor[i];
   551         -      if( p==0 ) continue;
   552         -      assert( p->zName!=0 );
   553         -      sqlite3VdbeAddOp(v, OP_Integer, i, 0);
   554         -      sqlite3VdbeOp3(v, OP_String8, 0, 0, p->zName, 0);
   555         -      sqlite3VdbeAddOp(v, OP_Callback, 2, 0);
   556         -    }
   557         -  }else
   558         -#endif /* SQLITE_OMIT_CURSOR */
   559    541   #endif /* SQLITE_OMIT_SCHEMA_PRAGMAS */
   560    542   
   561    543   #ifndef SQLITE_OMIT_FOREIGN_KEY
   562    544     if( sqlite3StrICmp(zLeft, "foreign_key_list")==0 && zRight ){
   563    545       FKey *pFK;
   564    546       Table *pTab;
   565    547       if( sqlite3ReadSchema(pParse) ) goto pragma_out;

Changes to src/select.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains C code routines that are called by the parser
    13     13   ** to handle SELECT statements in SQLite.
    14     14   **
    15         -** $Id: select.c,v 1.237 2005/01/31 12:42:29 danielk1977 Exp $
           15  +** $Id: select.c,v 1.238 2005/02/04 04:07:17 danielk1977 Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   
    20     20   /*
    21     21   ** Allocate a new Select structure and return a pointer to that
    22     22   ** structure.
................................................................................
   543    543           pushOntoSorter(pParse, v, pOrderBy);
   544    544         }else{
   545    545           sqlite3VdbeAddOp(v, OP_Gosub, 0, iParm);
   546    546         }
   547    547         break;
   548    548       }
   549    549   
   550         -#if !defined(SQLITE_OMIT_TRIGGER) || !defined(SQLITE_OMIT_CURSOR)
          550  +#if !defined(SQLITE_OMIT_TRIGGER)
   551    551       /* Discard the results.  This is used for SELECT statements inside
   552    552       ** the body of a TRIGGER.  The purpose of such selects is to call
   553    553       ** user-defined functions that have side effects.  We do not care
   554    554       ** about the actual results of the select.
   555    555       */
   556    556       default: {
   557    557         assert( eDest==SRT_Discard );
................................................................................
  2518   2518     if( sqlite3_malloc_failed || pParse->nErr || p==0 ) return 1;
  2519   2519     if( sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0) ) return 1;
  2520   2520   
  2521   2521   #ifndef SQLITE_OMIT_COMPOUND_SELECT
  2522   2522     /* If there is are a sequence of queries, do the earlier ones first.
  2523   2523     */
  2524   2524     if( p->pPrior ){
  2525         -#ifndef SQLITE_OMIT_CURSOR
  2526         -    if( p->pFetch ){
  2527         -      sqlite3ErrorMsg(pParse, "cursors cannot be used on compound queries");
  2528         -      goto select_end;
  2529         -    }
  2530         -#endif
  2531   2525       return multiSelect(pParse, p, eDest, iParm, aff);
  2532   2526     }
  2533   2527   #endif
  2534   2528   
  2535   2529     saveAggregateInfo(pParse, &sAggInfo);
  2536   2530     pOrderBy = p->pOrderBy;
  2537   2531     if( eDest==SRT_Union || eDest==SRT_Except || eDest==SRT_Discard ){
................................................................................
  2579   2573       case SRT_Discard:
  2580   2574         pOrderBy = 0;
  2581   2575         break;
  2582   2576       default:
  2583   2577         break;
  2584   2578     }
  2585   2579   
  2586         -  /* We cannot use a SQL cursor on a join or on a DISTINCT query
  2587         -  */
  2588         -#ifndef SQLITE_OMIT_CURSOR
  2589         -  if( p->pFetch ){
  2590         -    if( p->isDistinct ){
  2591         -      sqlite3ErrorMsg(pParse, "cursors cannot be used on DISTINCT queries");
  2592         -      goto select_end;
  2593         -    }
  2594         -    if( pTabList->nSrc>0 ){
  2595         -      sqlite3ErrorMsg(pParse, "cursors cannot be used on joins");
  2596         -      goto select_end;
  2597         -    }
  2598         -    if( pTabList->a[0].pSelect ){
  2599         -      sqlite3ErrorMsg(pParse, "cursor cannot be used with nested queries "
  2600         -          "or views");
  2601         -      goto select_end;
  2602         -    }
  2603         -  }
  2604         -#endif
  2605         -
  2606   2580     /* Begin generating code.
  2607   2581     */
  2608   2582     v = sqlite3GetVdbe(pParse);
  2609   2583     if( v==0 ) goto select_end;
  2610   2584   
  2611   2585     /* Identify column names if we will be using them in a callback.  This
  2612   2586     ** step is skipped if the output is going to some other destination.

Changes to src/sqliteInt.h.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Internal interface definitions for SQLite.
    13     13   **
    14         -** @(#) $Id: sqliteInt.h,v 1.365 2005/01/31 12:56:44 danielk1977 Exp $
           14  +** @(#) $Id: sqliteInt.h,v 1.366 2005/02/04 04:07:17 danielk1977 Exp $
    15     15   */
    16     16   #ifndef _SQLITEINT_H_
    17     17   #define _SQLITEINT_H_
    18     18   
    19         -/*
    20         -** Cursor support is turned off unless the SQLITE_ENABLE_CURSOR option
    21         -** is defined.
    22         -*/
    23         -#ifndef SQLITE_ENABLE_CURSOR
    24         -# define SQLITE_OMIT_CURSOR 1
    25         -#endif
    26         -
    27     19   /*
    28     20   ** These #defines should enable >2GB file support on Posix if the
    29     21   ** underlying operating system supports it.  If the OS lacks
    30     22   ** large file support, or if the OS is windows, these should be no-ops.
    31     23   **
    32     24   ** Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch
    33     25   ** on the compiler command line.  This is necessary if you are compiling
................................................................................
   324    316   typedef struct TriggerStack TriggerStack;
   325    317   typedef struct FKey FKey;
   326    318   typedef struct Db Db;
   327    319   typedef struct AuthContext AuthContext;
   328    320   typedef struct KeyClass KeyClass;
   329    321   typedef struct CollSeq CollSeq;
   330    322   typedef struct KeyInfo KeyInfo;
   331         -typedef struct SqlCursor SqlCursor;
   332    323   typedef struct NameContext NameContext;
   333    324   typedef struct Fetch Fetch;
   334         -typedef struct CursorSubst CursorSubst;
   335    325   
   336    326   /*
   337    327   ** Each database file to be accessed by the system is an instance
   338    328   ** of the following structure.  There are normally two of these structures
   339    329   ** in the sqlite.aDb[] array.  aDb[0] is the main database file and
   340    330   ** aDb[1] is the database file used to hold temporary tables.  Additional
   341    331   ** databases may be attached.
................................................................................
   441    431     void *pAuthArg;               /* 1st argument to the access auth function */
   442    432   #endif
   443    433   #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
   444    434     int (*xProgress)(void *);     /* The progress callback */
   445    435     void *pProgressArg;           /* Argument to the progress callback */
   446    436     int nProgressOps;             /* Number of opcodes for progress callback */
   447    437   #endif
   448         -#ifndef SQLITE_OMIT_CURSOR
   449         -  int nSqlCursor;               /* Number of slots in apSqlCursor[] */
   450         -  SqlCursor **apSqlCursor;      /* Pointers to all active SQL cursors */
   451         -#endif
   452    438     int errCode;                  /* Most recent error code (SQLITE_*) */
   453    439     u8 enc;                       /* Text encoding for this database. */
   454    440     u8 autoCommit;                /* The auto-commit flag. */
   455    441     void(*xCollNeeded)(void*,sqlite3*,int eTextRep,const char*);
   456    442     void(*xCollNeeded16)(void*,sqlite3*,int eTextRep,const void*);
   457    443     void *pCollNeededArg;
   458    444     sqlite3_value *pValue;        /* Value used for transient conversions */
................................................................................
   970    956     int iTop;            /* The very beginning of the WHERE loop */
   971    957     int iContinue;       /* Jump here to continue with next record */
   972    958     int iBreak;          /* Jump here to break out of the loop */
   973    959     int nLevel;          /* Number of nested loop */
   974    960     WhereLevel a[1];     /* Information about each nest loop in the WHERE */
   975    961   };
   976    962   
   977         -/*
   978         -** An instance of the following structure is used to store information
   979         -** about a single FETCH sql command.
   980         -*/
   981         -struct Fetch {
   982         -  SqlCursor *pCursor;  /* Cursor used by the fetch */
   983         -  int isBackwards;     /* Cursor moves backwards if true, forward if false */
   984         -  int doRewind;        /* True to rewind cursor before starting */
   985         -};
   986         -
   987    963   /*
   988    964   ** A NameContext defines a context in which to resolve table and column
   989    965   ** names.  The context consists of a list of tables (the pSrcList) field and
   990    966   ** a list of named expression (pEList).  The named expression list may
   991    967   ** be NULL.  The pSrc corresponds to the FROM clause of a SELECT or
   992    968   ** to the table being operated on by INSERT, UPDATE, or DELETE.  The
   993    969   ** pEList corresponds to the result set of a SELECT and is NULL for
................................................................................
  1119   1095     ** each recursion */
  1120   1096   
  1121   1097     int nVar;            /* Number of '?' variables seen in the SQL so far */
  1122   1098     int nVarExpr;        /* Number of used slots in apVarExpr[] */
  1123   1099     int nVarExprAlloc;   /* Number of allocated slots in apVarExpr[] */
  1124   1100     Expr **apVarExpr;    /* Pointers to :aaa and $aaaa wildcard expressions */
  1125   1101     u8 explain;          /* True if the EXPLAIN flag is found on the query */
  1126         -#ifndef SQLITE_OMIT_CURSOR
  1127         -  u8 fetchDir;         /* The direction argument to the FETCH command */
  1128         -  int dirArg1;         /* First argument to the direction */
  1129         -  int dirArg2;         /* Second argument to the direction */
  1130         -#endif
  1131   1102     Token sErrToken;     /* The token at which the error occurred */
  1132   1103     Token sNameToken;    /* Token with unqualified schema object name */
  1133   1104     Token sLastToken;    /* The last token parsed */
  1134   1105     const char *zSql;    /* All SQL text */
  1135   1106     const char *zTail;   /* All SQL text past the last semicolon parsed */
  1136   1107     Table *pNewTable;    /* A table being constructed by CREATE TABLE */
  1137   1108     Trigger *pNewTrigger;     /* Trigger under construct by a CREATE TRIGGER */
................................................................................
  1307   1278   ** A pointer to this structure is used to communicate information
  1308   1279   ** from sqlite3Init and OP_ParseSchema into the sqlite3InitCallback.
  1309   1280   */
  1310   1281   typedef struct {
  1311   1282     sqlite3 *db;        /* The database being initialized */
  1312   1283     char **pzErrMsg;    /* Error message stored here */
  1313   1284   } InitData;
  1314         -
  1315         -/*
  1316         -** Each SQL cursor (a cursor created by the DECLARE ... CURSOR syntax)
  1317         -** is represented by an instance of the following structure.
  1318         -*/
  1319         -struct SqlCursor {
  1320         -  char *zName;           /* Name of this cursor */
  1321         -  int idx;               /* Index of this cursor in db->apSqlCursor[] */
  1322         -  Select *pSelect;       /* The SELECT statement that defines this cursor */
  1323         -  int nPtr;              /* Number of slots in aPtr[] */
  1324         -  sqlite3_value *aPtr;   /* Values that define the current cursor position */
  1325         -};
  1326         -
  1327   1285   
  1328   1286   /*
  1329   1287    * This global flag is set for performance testing of triggers. When it is set
  1330   1288    * SQLite will perform the overhead of building new and old trigger references 
  1331   1289    * even when no triggers exist
  1332   1290    */
  1333   1291   extern int sqlite3_always_code_trigger_setup;
................................................................................
  1574   1532   void sqlite3AlterRenameTable(Parse*, SrcList*, Token*);
  1575   1533   int sqlite3GetToken(const unsigned char *, int *);
  1576   1534   void sqlite3NestedParse(Parse*, const char*, ...);
  1577   1535   void sqlite3ExpirePreparedStatements(sqlite3*);
  1578   1536   void sqlite3CodeSubselect(Parse *, Expr *);
  1579   1537   int sqlite3SelectResolve(Parse *, Select *, NameContext *);
  1580   1538   
  1581         -#ifndef SQLITE_OMIT_CURSOR
  1582         -void sqlite3CursorDelete(SqlCursor*);
  1583         -void sqlite3CursorCreate(Parse*, Token*, Select*);
  1584         -void sqlite3CursorClose(Parse*, Token*);
  1585         -void sqlite3Fetch(Parse*, Token*, IdList*);
  1586         -#endif /* SQLITE_OMIT_CURSOR */
  1587         -
  1588   1539   #endif

Changes to src/test1.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Code for testing the printf() interface to SQLite.  This code
    13     13   ** is not included in the SQLite library.  It is used for automated
    14     14   ** testing of the SQLite library.
    15     15   **
    16         -** $Id: test1.c,v 1.128 2005/01/25 04:27:55 danielk1977 Exp $
           16  +** $Id: test1.c,v 1.129 2005/02/04 04:07:18 danielk1977 Exp $
    17     17   */
    18     18   #include "sqliteInt.h"
    19     19   #include "tcl.h"
    20     20   #include "os.h"
    21     21   #include <stdlib.h>
    22     22   #include <string.h>
    23     23   
................................................................................
  2725   2725   
  2726   2726   #ifdef SQLITE_OMIT_CONFLICT_CLAUSE
  2727   2727     Tcl_SetVar2(interp, "sqlite_options", "conflict", "0", TCL_GLOBAL_ONLY);
  2728   2728   #else
  2729   2729     Tcl_SetVar2(interp, "sqlite_options", "conflict", "1", TCL_GLOBAL_ONLY);
  2730   2730   #endif
  2731   2731   
  2732         -#ifdef SQLITE_OMIT_CURSOR
  2733         -  Tcl_SetVar2(interp, "sqlite_options", "cursor", "0", TCL_GLOBAL_ONLY);
  2734         -#else
  2735         -  Tcl_SetVar2(interp, "sqlite_options", "cursor", "1", TCL_GLOBAL_ONLY);
  2736         -#endif
  2737         -
  2738   2732   #ifdef SQLITE_OMIT_DATETIME_FUNCS
  2739   2733     Tcl_SetVar2(interp, "sqlite_options", "datetime", "0", TCL_GLOBAL_ONLY);
  2740   2734   #else
  2741   2735     Tcl_SetVar2(interp, "sqlite_options", "datetime", "1", TCL_GLOBAL_ONLY);
  2742   2736   #endif
  2743   2737   
  2744   2738   #ifdef SQLITE_OMIT_EXPLAIN

Changes to src/vdbe.c.

    39     39   **
    40     40   ** Various scripts scan this source file in order to generate HTML
    41     41   ** documentation, headers files, or other derived files.  The formatting
    42     42   ** of the code in this file is, therefore, important.  See other comments
    43     43   ** in this file for details.  If in doubt, do not deviate from existing
    44     44   ** commenting and indentation practices when changing or adding code.
    45     45   **
    46         -** $Id: vdbe.c,v 1.449 2005/01/29 08:32:45 danielk1977 Exp $
           46  +** $Id: vdbe.c,v 1.450 2005/02/04 04:07:18 danielk1977 Exp $
    47     47   */
    48     48   #include "sqliteInt.h"
    49     49   #include "os.h"
    50     50   #include <ctype.h>
    51     51   #include "vdbeInt.h"
    52     52   
    53     53   /*
................................................................................
  4473   4473   case OP_Vacuum: {
  4474   4474     if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse; 
  4475   4475     rc = sqlite3RunVacuum(&p->zErrMsg, db);
  4476   4476     if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse;
  4477   4477     break;
  4478   4478   }
  4479   4479   
  4480         -#ifndef SQLITE_OMIT_CURSOR
  4481         -/* Opcode: CursorStore P1 P2 *
  4482         -**
  4483         -** The implementation of SQL cursors (not to be confused with VDBE cursors
  4484         -** or B-tree cursors) stores information in the SQLite database connection
  4485         -** structure (the sqlite3* pointer) that identifies the row
  4486         -** in a table that an SQL cursor is pointing to.  This opcode is
  4487         -** used to store that information.  P1 is an index of an SQL cursor.
  4488         -** P2 is the index of a memory slot within that SQL cursor.  This opcode
  4489         -** pops the top of the stack and stores it in the SQL cursor.
  4490         -*/
  4491         -case OP_CursorStore: {
  4492         -  SqlCursor *pCursor;
  4493         -  assert( pTos>=p->aStack );
  4494         -  assert( pOp->p1>=0 && pOp->p1<db->nSqlCursor );
  4495         -  pCursor = db->apSqlCursor[pOp->p1];
  4496         -  assert( pCursor!=0 );
  4497         -  assert( pOp->p2>=0 && pOp->p2<2 );  
  4498         -  rc = sqlite3VdbeMemMove(&pCursor->aPtr[pOp->p1], pTos);
  4499         -  pTos--;
  4500         -  break;
  4501         -}
  4502         -
  4503         -/* Opcode: CursorLoad P1 P2 *
  4504         -**
  4505         -** The implementation of SQL cursors (not to be confused with VDBE cursors
  4506         -** or B-tree cursors) stores information in the SQLite database connection
  4507         -** structure (the sqlite3* pointer) that effectively records the current
  4508         -** location in a table that an SQL cursor is pointing to.  This opcode is
  4509         -** used to recover that information.  P1 is an index of an SQL cursor.
  4510         -** P2 is the index of a memory slot within that SQL cursor.  This opcode
  4511         -** pushes a new value onto the stack which is a copy of the information
  4512         -** obtained from entry P2 of cursor P1.
  4513         -*/
  4514         -case OP_CursorLoad: {
  4515         -  SqlCursor *pCursor;
  4516         -  int i = pOp->p1;
  4517         -  assert( pTos>=p->aStack );
  4518         -  assert( pOp->p1>=0 && pOp->p1<db->nSqlCursor );
  4519         -  pCursor = db->apSqlCursor[pOp->p1];
  4520         -  assert( pCursor!=0 );
  4521         -  assert( pOp->p2>=0 && pOp->p2<2 );  
  4522         -  pTos++;
  4523         -  sqlite3VdbeMemShallowCopy(pTos, &pCursor->aPtr[i], MEM_Ephem);
  4524         -  break;
  4525         -}
  4526         -#endif /* SQLITE_OMIT_CURSOR */
  4527         -
  4528   4480   /* Opcode: Expire P1 * *
  4529   4481   **
  4530   4482   ** Cause precompiled statements to become expired. An expired statement
  4531   4483   ** fails with an error code of SQLITE_SCHEMA if it is ever executed 
  4532   4484   ** (via sqlite3_step()).
  4533   4485   ** 
  4534   4486   ** If P1 is 0, then all SQL statements become expired. If P1 is non-zero,

Changes to test/capi2.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this script testing the callback-free C/C++ API.
    13     13   #
    14         -# $Id: capi2.test,v 1.24 2005/01/20 22:48:48 drh Exp $
           14  +# $Id: capi2.test,v 1.25 2005/02/04 04:07:18 danielk1977 Exp $
    15     15   #
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   # Return the text values from the current row pointed at by STMT as a list.
    21     21   proc get_row_values {STMT} {
................................................................................
   248    248          [get_row_values $VM] \
   249    249          [get_column_names $VM]
   250    250   } {SQLITE_ERROR 0 {} {}}
   251    251   do_test capi2-3.19 {
   252    252     list [sqlite3_finalize $VM] [sqlite3_errmsg $DB]
   253    253   } {SQLITE_CONSTRAINT {t2.a may not be NULL}}
   254    254   
          255  +do_test capi2-3.20 {
          256  +  execsql {
          257  +    CREATE TABLE a1(message_id, name , UNIQUE(message_id, name) );
          258  +    INSERT INTO a1 VALUES(1, 1);
          259  +  }
          260  +} {}
          261  +do_test capi2-3.21 {
          262  +  set VM [sqlite3_prepare $DB {INSERT INTO a1 VALUES(1, 1)} -1 TAIL]
          263  +  sqlite3_step $VM
          264  +} {SQLITE_ERROR}
          265  +do_test capi2-3.22 {
          266  +  sqlite3_errcode $DB
          267  +} {SQLITE_ERROR}
          268  +do_test capi2-3.23 {
          269  +  sqlite3_finalize $VM
          270  +} {SQLITE_CONSTRAINT}
          271  +do_test capi2-3.24 {
          272  +  sqlite3_errcode $DB
          273  +} {SQLITE_CONSTRAINT}
          274  +
   255    275   # Two or more virtual machines exists at the same time.
   256    276   #
   257    277   do_test capi2-4.1 {
   258    278     set VM1 [sqlite3_prepare $DB {INSERT INTO t2 VALUES(1,2)} -1 TAIL]
   259    279     set TAIL
   260    280   } {}
   261    281   do_test capi2-4.2 {

Changes to test/corrupt.test.

     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.
    12     12   #
    13     13   # This file implements tests to make sure SQLite does not crash or
    14     14   # segfault if it sees a corrupt database file.
    15     15   #
    16         -# $Id: corrupt.test,v 1.4 2005/01/20 02:17:02 danielk1977 Exp $
           16  +# $Id: corrupt.test,v 1.5 2005/02/04 04:07:18 danielk1977 Exp $
    17     17   
    18     18   catch {file delete -force test.db}
    19     19   catch {file delete -force test.db-journal}
    20     20   
    21     21   set testdir [file dirname $argv0]
    22     22   source $testdir/tester.tcl
    23     23   
................................................................................
    77     77     db close
    78     78     copy_file test.bu test.db
    79     79     set fd [open test.db r+]
    80     80     fconfigure $fd -translation binary
    81     81     seek $fd $i
    82     82     puts -nonewline $fd $junk
    83     83     close $fd
    84         -  sqlite3 db test.db
    85     84     do_test corrupt-2.$tn.1 {
    86     85       sqlite3 db test.db
    87     86       catchsql {SELECT count(*) FROM sqlite_master}
    88     87       set x {}
    89     88     } {}
    90     89     do_test corrupt-2.$tn.2 {
    91     90       catchsql {SELECT count(*) FROM t1}

Deleted test/cursor.test.

     1         -# 2004 November 22
     2         -#
     3         -# The author disclaims copyright to this source code.  In place of
     4         -# a legal notice, here is a blessing:
     5         -#
     6         -#    May you do good and not evil.
     7         -#    May you find forgiveness for yourself and forgive others.
     8         -#    May you share freely, never taking more than you give.
     9         -#
    10         -#*************************************************************************
    11         -# This file implements regression tests for SQLite library.  The
    12         -# focus of this script is DECLARE...CURSOR functionality
    13         -#
    14         -# $Id: cursor.test,v 1.2 2004/11/23 01:47:31 drh Exp $
    15         -#
    16         -
    17         -set testdir [file dirname $argv0]
    18         -source $testdir/tester.tcl
    19         -
    20         -# If SQLITE_OMIT_CURSOR is defined, omit this file.
    21         -ifcapable {!cursor} {
    22         -  finish_test
    23         -  return
    24         -}
    25         -
    26         -########
    27         -# Test the logic that creates and destroys cursors
    28         -########
    29         -do_test cursor-1.1 {
    30         -  execsql {
    31         -    CREATE TABLE t1(a,b,c);
    32         -    CREATE INDEX t1i1 ON t1(a);
    33         -    CREATE INDEX t1i2 ON t1(b,c);
    34         -  }
    35         -  execsql {
    36         -    DECLARE c1 CURSOR FOR SELECT c FROM t1 ORDER BY a;
    37         -  }
    38         -} {}
    39         -ifcapable schema_pragmas {
    40         -  do_test cursor-1.2 {
    41         -    execsql {PRAGMA cursor_list}
    42         -  } {0 c1}
    43         -}
    44         -do_test cursor-1.3 {
    45         -  execsql {
    46         -    DECLARE c2 CURSOR FOR SELECT a FROM t1 ORDER BY b, c;
    47         -  }
    48         -} {}
    49         -ifcapable schema_pragmas {
    50         -  do_test cursor-1.4 {
    51         -    execsql {PRAGMA cursor_list}
    52         -  } {0 c1 1 c2}
    53         -}
    54         -do_test cursor-1.5 {
    55         -  catchsql {
    56         -    CLOSE c3;
    57         -  }
    58         -} {1 {no such cursor: c3}}
    59         -ifcapable schema_pragmas {
    60         -  do_test cursor-1.6 {
    61         -    execsql {PRAGMA cursor_list}
    62         -  } {0 c1 1 c2}
    63         -}
    64         -do_test cursor-1.7 {
    65         -  catchsql {
    66         -    CLOSE c1;
    67         -  }
    68         -} {0 {}}
    69         -ifcapable schema_pragmas {
    70         -  do_test cursor-1.8 {
    71         -    execsql {PRAGMA cursor_list}
    72         -  } {1 c2}
    73         -}
    74         -do_test cursor-1.9 {
    75         -  catchsql {
    76         -    CLOSE c1;
    77         -  }
    78         -} {1 {no such cursor: c1}}
    79         -ifcapable schema_pragmas {
    80         -  do_test cursor-1.10 {
    81         -    execsql {PRAGMA cursor_list}
    82         -  } {1 c2}
    83         -}
    84         -do_test cursor-1.11 {
    85         -  catchsql {
    86         -    DECLARE c2 CURSOR FOR SELECT * FROM t1;
    87         -  }
    88         -} {1 {another cursor named c2 already exists}}
    89         -do_test cursor-1.12 {
    90         -  catchsql {
    91         -    DECLARE c3 CURSOR FOR SELECT * FROM t1;
    92         -  }
    93         -} {0 {}}
    94         -ifcapable schema_pragmas {
    95         -  do_test cursor-1.13 {
    96         -    execsql {PRAGMA cursor_list}
    97         -  } {0 c3 1 c2}
    98         -}
    99         -do_test cursor-1.14 {
   100         -  execsql {
   101         -    CLOSE c2;
   102         -    CLOSE c3;
   103         -  }
   104         -} {}
   105         -ifcapable schema_pragmas {
   106         -  do_test cursor-1.15 {
   107         -    execsql {PRAGMA cursor_list}
   108         -  } {}
   109         -}
   110         -
   111         -set all {}
   112         -for {set i 1} {$i<=50} {incr i} {
   113         -  lappend all [expr {$i-1}] x$i
   114         -  do_test cursor-2.1.$i.1 {
   115         -    execsql "DECLARE x$i CURSOR FOR SELECT * FROM t1"
   116         -  } {}
   117         -  ifcapable schema_pragmas {
   118         -    do_test cursor-2.1.$i.2 {
   119         -      execsql {PRAGMA cursor_list}
   120         -    } $all
   121         -  }
   122         -}
   123         -for {set i 1} {$i<=50} {incr i} {
   124         -  set all [lrange $all 2 end]
   125         -  do_test cursor-2.2.$i.1 {
   126         -    execsql "CLOSE x$i"
   127         -  } {}
   128         -  ifcapable schema_pragmas {
   129         -    do_test cursor-2.2.$i.2 {
   130         -      execsql {PRAGMA cursor_list}
   131         -    } $all
   132         -  }
   133         -}  
   134         -
   135         -
   136         -finish_test

Changes to tool/mkkeywordhash.c.

     3      3   ** implements a function that will translate alphabetic identifiers into
     4      4   ** parser token codes.
     5      5   */
     6      6   #include <stdio.h>
     7      7   #include <string.h>
     8      8   #include <stdlib.h>
     9      9   
    10         -/*
    11         -** Cursor support is off by default.
    12         -*/
    13         -#if !defined(SQLITE_ENABLE_CURSOR) && !defined(SQLITE_OMIT_CURSOR)
    14         -# define SQLITE_OMIT_CURSOR 1
    15         -#endif
    16         -
    17     10   /*
    18     11   ** All the keywords of the SQL language are stored as in a hash
    19     12   ** table composed of instances of the following structure.
    20     13   */
    21     14   typedef struct Keyword Keyword;
    22     15   struct Keyword {
    23     16     char *zName;         /* The keyword name */
................................................................................
    58     51   #  define COMPOUND   16
    59     52   #endif
    60     53   #ifdef SQLITE_OMIT_CONFLICT_CLAUSE
    61     54   #  define CONFLICT   0
    62     55   #else
    63     56   #  define CONFLICT   32
    64     57   #endif
    65         -#ifdef SQLITE_OMIT_CURSOR
    66         -#  define CURSOR     0
    67         -#else
    68         -#  define CURSOR     64
    69         -#endif
    70     58   #ifdef SQLITE_OMIT_EXPLAIN
    71     59   #  define EXPLAIN    0
    72     60   #else
    73     61   #  define EXPLAIN    128
    74     62   #endif
    75     63   #ifdef SQLITE_OMIT_FOREIGN_KEY
    76     64   #  define FKEY       0
................................................................................
   110     98   
   111     99   
   112    100   /*
   113    101   ** These are the keywords
   114    102   */
   115    103   static Keyword aKeywordTable[] = {
   116    104     { "ABORT",            "TK_ABORT",        CONFLICT|TRIGGER       },
   117         -  { "ABSOLUTE",         "TK_ABSOLUTE",     CURSOR                 },
   118    105     { "AFTER",            "TK_AFTER",        TRIGGER                },
   119    106     { "ALL",              "TK_ALL",          ALWAYS                 },
   120    107     { "ALTER",            "TK_ALTER",        ALTER                  },
   121    108     { "AND",              "TK_AND",          ALWAYS                 },
   122    109     { "AS",               "TK_AS",           ALWAYS                 },
   123    110     { "ASC",              "TK_ASC",          ALWAYS                 },
   124    111     { "ATTACH",           "TK_ATTACH",       ATTACH                 },
................................................................................
   126    113     { "BEFORE",           "TK_BEFORE",       TRIGGER                },
   127    114     { "BEGIN",            "TK_BEGIN",        ALWAYS                 },
   128    115     { "BETWEEN",          "TK_BETWEEN",      ALWAYS                 },
   129    116     { "BY",               "TK_BY",           ALWAYS                 },
   130    117     { "CASCADE",          "TK_CASCADE",      FKEY                   },
   131    118     { "CASE",             "TK_CASE",         ALWAYS                 },
   132    119     { "CHECK",            "TK_CHECK",        ALWAYS                 },
   133         -  { "CLOSE",            "TK_CLOSE",        CURSOR                 },
   134    120     { "COLLATE",          "TK_COLLATE",      ALWAYS                 },
   135    121     { "COMMIT",           "TK_COMMIT",       ALWAYS                 },
   136    122     { "CONFLICT",         "TK_CONFLICT",     CONFLICT               },
   137    123     { "CONSTRAINT",       "TK_CONSTRAINT",   ALWAYS                 },
   138    124     { "CREATE",           "TK_CREATE",       ALWAYS                 },
   139    125     { "CROSS",            "TK_JOIN_KW",      ALWAYS                 },
   140         -  { "CURSOR",           "TK_CURSOR",       CURSOR                 },
   141         -  { "CURRENT",          "TK_CURRENT",      CURSOR                 },
   142    126     { "CURRENT_DATE",     "TK_CDATE",        ALWAYS                 },
   143    127     { "CURRENT_TIME",     "TK_CTIME",        ALWAYS                 },
   144    128     { "CURRENT_TIMESTAMP","TK_CTIMESTAMP",   ALWAYS                 },
   145    129     { "DATABASE",         "TK_DATABASE",     ATTACH                 },
   146         -  { "DECLARE",          "TK_DECLARE",      CURSOR                 },
   147    130     { "DEFAULT",          "TK_DEFAULT",      ALWAYS                 },
   148    131     { "DEFERRED",         "TK_DEFERRED",     ALWAYS                 },
   149    132     { "DEFERRABLE",       "TK_DEFERRABLE",   FKEY                   },
   150    133     { "DELETE",           "TK_DELETE",       ALWAYS                 },
   151    134     { "DESC",             "TK_DESC",         ALWAYS                 },
   152    135     { "DETACH",           "TK_DETACH",       ATTACH                 },
   153    136     { "DISTINCT",         "TK_DISTINCT",     ALWAYS                 },
................................................................................
   157    140     { "ELSE",             "TK_ELSE",         ALWAYS                 },
   158    141     { "ESCAPE",           "TK_ESCAPE",       ALWAYS                 },
   159    142     { "EXCEPT",           "TK_EXCEPT",       COMPOUND               },
   160    143     { "EXCLUSIVE",        "TK_EXCLUSIVE",    ALWAYS                 },
   161    144     { "EXISTS",           "TK_EXISTS",       SUBQUERY               },
   162    145     { "EXPLAIN",          "TK_EXPLAIN",      EXPLAIN                },
   163    146     { "FAIL",             "TK_FAIL",         CONFLICT|TRIGGER       },
   164         -  { "FETCH",            "TK_FETCH",        CURSOR                 },
   165         -  { "FIRST",            "TK_FIRST",        CURSOR                 },
   166         -  { "FOR",              "TK_FOR",          TRIGGER|CURSOR         },
          147  +  { "FOR",              "TK_FOR",          TRIGGER                },
   167    148     { "FOREIGN",          "TK_FOREIGN",      FKEY                   },
   168    149     { "FROM",             "TK_FROM",         ALWAYS                 },
   169    150     { "FULL",             "TK_JOIN_KW",      ALWAYS                 },
   170    151     { "GLOB",             "TK_GLOB",         ALWAYS                 },
   171    152     { "GROUP",            "TK_GROUP",        ALWAYS                 },
   172    153     { "HAVING",           "TK_HAVING",       ALWAYS                 },
   173    154     { "IGNORE",           "TK_IGNORE",       CONFLICT|TRIGGER       },
................................................................................
   185    166     { "JOIN",             "TK_JOIN",         ALWAYS                 },
   186    167     { "KEY",              "TK_KEY",          ALWAYS                 },
   187    168     { "LEFT",             "TK_JOIN_KW",      ALWAYS                 },
   188    169     { "LIKE",             "TK_LIKE",         ALWAYS                 },
   189    170     { "LIMIT",            "TK_LIMIT",        ALWAYS                 },
   190    171     { "MATCH",            "TK_MATCH",        ALWAYS                 },
   191    172     { "NATURAL",          "TK_JOIN_KW",      ALWAYS                 },
   192         -  { "NEXT",             "TK_NEXT",         CURSOR                 },
   193    173     { "NOT",              "TK_NOT",          ALWAYS                 },
   194    174     { "NOTNULL",          "TK_NOTNULL",      ALWAYS                 },
   195    175     { "NULL",             "TK_NULL",         ALWAYS                 },
   196    176     { "OF",               "TK_OF",           ALWAYS                 },
   197    177     { "OFFSET",           "TK_OFFSET",       ALWAYS                 },
   198    178     { "ON",               "TK_ON",           ALWAYS                 },
   199    179     { "OR",               "TK_OR",           ALWAYS                 },
   200    180     { "ORDER",            "TK_ORDER",        ALWAYS                 },
   201    181     { "OUTER",            "TK_JOIN_KW",      ALWAYS                 },
   202    182     { "PRAGMA",           "TK_PRAGMA",       PRAGMA                 },
   203         -  { "PRIOR",            "TK_PRIOR",        CURSOR                 },
   204    183     { "PRIMARY",          "TK_PRIMARY",      ALWAYS                 },
   205    184     { "RAISE",            "TK_RAISE",        TRIGGER                },
   206    185     { "REFERENCES",       "TK_REFERENCES",   FKEY                   },
   207    186     { "REINDEX",          "TK_REINDEX",      REINDEX                },
   208         -  { "RELATIVE",         "TK_RELATIVE",     CURSOR                 },
   209    187     { "RENAME",           "TK_RENAME",       ALTER                  },
   210    188     { "REPLACE",          "TK_REPLACE",      CONFLICT               },
   211    189     { "RESTRICT",         "TK_RESTRICT",     FKEY                   },
   212    190     { "RIGHT",            "TK_JOIN_KW",      ALWAYS                 },
   213    191     { "ROLLBACK",         "TK_ROLLBACK",     ALWAYS                 },
   214    192     { "ROW",              "TK_ROW",          TRIGGER                },
   215    193     { "SELECT",           "TK_SELECT",       ALWAYS                 },