/ Check-in [e7b65e37]
Login

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

Overview
Comment:All tests now pass. But there are still issues. For example, inserts are way too slow. And additional tests are needed for new features. (CVS 243)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e7b65e37fd88c4d69c89cfe73ab345b8b645ada6
User & Date: drh 2001-09-14 03:24:24
Context
2001-09-14
16:42
Bug fixes and speed improvements. Delete is still slow. (CVS 244) check-in: 7da856cd user: drh tags: trunk
03:24
All tests now pass. But there are still issues. For example, inserts are way too slow. And additional tests are needed for new features. (CVS 243) check-in: e7b65e37 user: drh tags: trunk
2001-09-13
21:53
Many problems fixed. Many problems yet to go. (CVS 1722) check-in: 3dfe1711 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

    17     17   ** Boston, MA  02111-1307, USA.
    18     18   **
    19     19   ** Author contact information:
    20     20   **   drh@hwaci.com
    21     21   **   http://www.hwaci.com/drh/
    22     22   **
    23     23   *************************************************************************
    24         -** $Id: btree.c,v 1.24 2001/09/13 21:53:09 drh Exp $
           24  +** $Id: btree.c,v 1.25 2001/09/14 03:24:24 drh Exp $
    25     25   **
    26     26   ** This file implements a external (disk-based) database using BTrees.
    27     27   ** For a detailed discussion of BTrees, refer to
    28     28   **
    29     29   **     Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3:
    30     30   **     "Sorting And Searching", pages 473-480. Addison-Wesley
    31     31   **     Publishing Company, Reading, Massachusetts.
................................................................................
  1698   1698     MemPage aOld[3];             /* Temporary copies of pPage and its siblings */
  1699   1699   
  1700   1700     /* 
  1701   1701     ** Return without doing any work if pPage is neither overfull nor
  1702   1702     ** underfull.
  1703   1703     */
  1704   1704     assert( sqlitepager_iswriteable(pPage) );
  1705         -  if( !pPage->isOverfull && pPage->nFree<SQLITE_PAGE_SIZE/3 ){
         1705  +  if( !pPage->isOverfull && pPage->nFree<SQLITE_PAGE_SIZE/2 && pPage->nCell>=2){
  1706   1706       relinkCellList(pPage);
  1707   1707       return SQLITE_OK;
  1708   1708     }
  1709   1709   
  1710   1710     /*
  1711   1711     ** Find the parent of the page to be balanceed.
  1712   1712     ** If there is no parent, it means this page is the root page and
................................................................................
  1977   1977     apNew[nNew-1]->u.hdr.rightChild = apOld[nOld-1]->u.hdr.rightChild;
  1978   1978     if( nxDiv==pParent->nCell ){
  1979   1979       pParent->u.hdr.rightChild = pgnoNew[nNew-1];
  1980   1980     }else{
  1981   1981       pParent->apCell[nxDiv]->h.leftChild = pgnoNew[nNew-1];
  1982   1982     }
  1983   1983     if( pCur ){
  1984         -    assert( pOldCurPage!=0 );
  1985         -    sqlitepager_ref(pCur->pPage);
  1986         -    sqlitepager_unref(pOldCurPage);
         1984  +    if( j<=iCur && pCur->pPage==pParent && pCur->idx>idxDiv[nOld-1] ){
         1985  +      assert( pCur->pPage==pOldCurPage );
         1986  +      pCur->idx += nNew - nOld;
         1987  +    }else{
         1988  +      assert( pOldCurPage!=0 );
         1989  +      sqlitepager_ref(pCur->pPage);
         1990  +      sqlitepager_unref(pOldCurPage);
         1991  +    }
  1987   1992     }
  1988   1993   
  1989   1994     /*
  1990   1995     ** Reparent children of all cells.
  1991   1996     */
  1992   1997     for(i=0; i<nNew; i++){
  1993   1998       reparentChildPages(pBt->pPager, apNew[i]);
................................................................................
  2059   2064       assert( pPage->u.hdr.rightChild==0 );  /* Must be a leaf page */
  2060   2065       pCur->idx++;
  2061   2066     }else{
  2062   2067       assert( pPage->u.hdr.rightChild==0 );  /* Must be a leaf page */
  2063   2068     }
  2064   2069     insertCell(pPage, pCur->idx, &newCell, szNew);
  2065   2070     rc = balance(pCur->pBt, pPage, pCur);
         2071  +  /* sqliteBtreePageDump(pCur->pBt, pCur->pgnoRoot, 1); */
         2072  +  /* fflush(stdout); */
  2066   2073     return rc;
  2067   2074   }
  2068   2075   
  2069   2076   /*
  2070   2077   ** Delete the entry that the cursor is pointing to.
  2071   2078   **
  2072   2079   ** The cursor is left pointing at either the next or the previous

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.32 2001/09/13 21:53:10 drh Exp $
           36  +** $Id: build.c,v 1.33 2001/09/14 03:24:24 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
................................................................................
    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     51     int rc = SQLITE_OK;
    52     52     sqlite *db = pParse->db;
    53     53     if( sqlite_malloc_failed ) return;
    54         -  if( pParse->pVdbe ){
           54  +  if( pParse->pVdbe && pParse->nErr==0 ){
    55     55       if( pParse->explain ){
    56     56         rc = sqliteVdbeList(pParse->pVdbe, pParse->xCallback, pParse->pArg, 
    57     57                             &pParse->zErrMsg);
    58     58       }else{
    59         -      FILE *trace = (db->flags & SQLITE_VdbeTrace)!=0 ? stderr : 0;
           59  +      FILE *trace = (db->flags & SQLITE_VdbeTrace)!=0 ? stdout : 0;
    60     60         sqliteVdbeTrace(pParse->pVdbe, trace);
    61     61         rc = sqliteVdbeExec(pParse->pVdbe, pParse->xCallback, pParse->pArg, 
    62     62                             &pParse->zErrMsg, db->pBusyArg,
    63     63                             db->xBusyCallback);
    64     64       }
    65     65       sqliteVdbeDelete(pParse->pVdbe);
    66     66       pParse->pVdbe = 0;
................................................................................
   864    864       };
   865    865       int base;
   866    866   
   867    867       if( (db->flags & SQLITE_InTrans)==0 ){
   868    868         sqliteVdbeAddOp(v, OP_Transaction, 0, 0, 0, 0);
   869    869       }
   870    870       base = sqliteVdbeAddOpList(v, ArraySize(dropIndex), dropIndex);
          871  +    sqliteVdbeChangeP3(v, base+2, pIndex->zName, 0);
   871    872       sqliteVdbeChangeP1(v, base+8, pIndex->tnum);
   872    873       if( (db->flags & SQLITE_InTrans)==0 ){
   873    874         sqliteVdbeAddOp(v, OP_Commit, 0, 0, 0, 0);
   874    875       }
   875    876     }
   876    877   
   877    878     /* Mark the internal Index structure for deletion by the

Changes to src/expr.c.

    20     20   **   drh@hwaci.com
    21     21   **   http://www.hwaci.com/drh/
    22     22   **
    23     23   *************************************************************************
    24     24   ** This file contains routines used for analyzing expressions and
    25     25   ** for generating VDBE code that evaluates expressions.
    26     26   **
    27         -** $Id: expr.c,v 1.26 2001/09/13 14:46:10 drh Exp $
           27  +** $Id: expr.c,v 1.27 2001/09/14 03:24:25 drh Exp $
    28     28   */
    29     29   #include "sqliteInt.h"
    30     30   
    31     31   /*
    32     32   ** Walk an expression tree.  Return 1 if the expression is constant
    33     33   ** and 0 if it involves variables.
    34     34   */
................................................................................
   513    513     switch( pExpr->op ){
   514    514       case TK_COLUMN: {
   515    515         if( pParse->useAgg ){
   516    516           sqliteVdbeAddOp(v, OP_AggGet, 0, pExpr->iAgg, 0, 0);
   517    517         }else if( pExpr->iColumn>=0 ){
   518    518           sqliteVdbeAddOp(v, OP_Column, pExpr->iTable, pExpr->iColumn, 0, 0);
   519    519         }else{
   520         -        sqliteVdbeAddOp(v, OP_FullKey, pExpr->iTable, 0, 0, 0);
          520  +        sqliteVdbeAddOp(v, OP_Recno, pExpr->iTable, 0, 0, 0);
   521    521         }
   522    522         break;
   523    523       }
   524    524       case TK_INTEGER: {
   525    525         int i = atoi(pExpr->token.z);
   526    526         sqliteVdbeAddOp(v, OP_Integer, i, 0, 0, 0);
   527    527         break;

Changes to src/insert.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 INSERT statements.
    26     26   **
    27         -** $Id: insert.c,v 1.15 2001/09/13 14:46:10 drh Exp $
           27  +** $Id: insert.c,v 1.16 2001/09/14 03:24:25 drh Exp $
    28     28   */
    29     29   #include "sqliteInt.h"
    30     30   
    31     31   /*
    32     32   ** This routine is call to handle SQL of the following forms:
    33     33   **
    34     34   **    insert into TABLE (IDLIST) values(EXPRLIST)
................................................................................
   177    177       sqliteVdbeAddOp(v, OP_Rewind, srcTab, 0, 0, 0);
   178    178       iBreak = sqliteVdbeMakeLabel(v);
   179    179       iCont = sqliteVdbeAddOp(v, OP_Next, srcTab, iBreak, 0, 0);
   180    180     }
   181    181   
   182    182     /* Create a new entry in the table and fill it with data.
   183    183     */
   184         -  sqliteVdbeAddOp(v, OP_NewRecno, 0, 0, 0, 0);
          184  +  sqliteVdbeAddOp(v, OP_NewRecno, base, 0, 0, 0);
   185    185     if( pTab->pIndex ){
   186    186       sqliteVdbeAddOp(v, OP_Dup, 0, 0, 0, 0);
   187    187     }
   188    188     for(i=0; i<pTab->nCol; i++){
   189    189       if( pColumn==0 ){
   190    190         j = i;
   191    191       }else{

Changes to src/pager.c.

    23     23   *************************************************************************
    24     24   ** This is the implementation of the page cache subsystem.
    25     25   ** 
    26     26   ** The page cache is used to access a database file.  The pager journals
    27     27   ** all writes in order to support rollback.  Locking is used to limit
    28     28   ** access to one or more reader or to one writer.
    29     29   **
    30         -** @(#) $Id: pager.c,v 1.15 2001/09/13 14:46:10 drh Exp $
           30  +** @(#) $Id: pager.c,v 1.16 2001/09/14 03:24:25 drh Exp $
    31     31   */
    32     32   #include "sqliteInt.h"
    33     33   #include "pager.h"
    34     34   #include <fcntl.h>
    35     35   #include <sys/stat.h>
    36     36   #include <unistd.h>
    37     37   #include <assert.h>
................................................................................
   471    471        "/tmp",
   472    472        "/temp",
   473    473        "./temp",
   474    474     };
   475    475     int i;
   476    476     struct stat buf;
   477    477     for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){
   478         -    if( stat(azDirs[i], &buf)==0 && S_ISDIR(buf.st_mode)
   479         -         && access(azDirs[i], W_OK) ){
   480         -       return azDirs[i];
   481         -    }
          478  +    if( stat(azDirs[i], &buf) ) continue;
          479  +    if( !S_ISDIR(buf.st_mode) ) continue;
          480  +    if( access(azDirs[i], 07) ) continue;
          481  +    return azDirs[i];
   482    482     }
   483    483     return 0;
   484    484   }
   485    485   
   486    486   /*
   487    487   ** Create a new page cache and put a pointer to the page cache in *ppPager.
   488    488   ** The file to be cached need not exist.  The file is not locked until

Changes to src/random.c.

    23     23   *************************************************************************
    24     24   ** This file contains code to implement a pseudo-random number
    25     25   ** generator (PRNG) for SQLite.
    26     26   **
    27     27   ** Random numbers are used by some of the database backends in order
    28     28   ** to generate random integer keys for tables or random filenames.
    29     29   **
    30         -** $Id: random.c,v 1.3 2001/09/13 21:53:10 drh Exp $
           30  +** $Id: random.c,v 1.4 2001/09/14 03:24:25 drh Exp $
    31     31   */
    32     32   #include "sqliteInt.h"
    33     33   #include <time.h>
    34     34   
    35     35   /*
    36     36   ** Get a single 8-bit random value from the RC4 PRNG.
    37     37   */
................................................................................
   100    100     r = sqliteRandomByte();
   101    101     for(i=1; i<4; i++){
   102    102       r = (r<<8) + sqliteRandomByte();
   103    103     }
   104    104     return r;
   105    105   }
   106    106   
          107  +/*
          108  +** Return a random 16-bit unsigned integer.  The integer is generated by
          109  +** making 2 calls to sqliteRandomByte().
          110  +*/
          111  +int sqliteRandomShort(void){
          112  +  int r;
          113  +  r = sqliteRandomByte();
          114  +  r = (r<<8) + sqliteRandomByte();
          115  +  return r;
          116  +}
   107    117   
   108    118   /*
   109    119   ** Generate a random filename with the given prefix.  The new filename
   110    120   ** is written into zBuf[].  The calling function must insure that
   111    121   ** zBuf[] is big enough to hold the prefix plus 20 or so extra
   112    122   ** characters.
   113    123   **

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.35 2001/09/13 21:53:10 drh Exp $
           27  +** $Id: select.c,v 1.36 2001/09/14 03:24:25 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   */
................................................................................
   177    177     }else 
   178    178   
   179    179     /* Construct a record from the query result, but instead of
   180    180     ** saving that record, use it as a key to delete elements from
   181    181     ** the temporary table iParm.
   182    182     */
   183    183     if( eDest==SRT_Except ){
   184         -    sqliteVdbeAddOp(v, OP_MakeRecord, nColumn, 0, 0, 0);
   185         -    sqliteVdbeAddOp(v, OP_MoveTo, iParm, 0, 0, 0);
          184  +    int addr = sqliteVdbeAddOp(v, OP_MakeRecord, nColumn, 0, 0, 0);
          185  +    sqliteVdbeAddOp(v, OP_NotFound, iParm, addr+3, 0, 0);
   186    186       sqliteVdbeAddOp(v, OP_Delete, iParm, 0, 0, 0);
   187    187     }else 
   188    188   
   189    189     /* If we are creating a set for an "expr IN (SELECT ...)" construct,
   190    190     ** then there should be a single item on the stack.  Write this
   191    191     ** item into the set table with bogus data.
   192    192     */

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.19 2001/04/11 14:28:43 drh Exp $
           30  +** $Id: tokenize.c,v 1.20 2001/09/14 03:24:25 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
................................................................................
   350    350           /* Various debugging modes can be turned on and off using
   351    351           ** special SQL comments.  Check for the special comments
   352    352           ** here and take approriate action if found.
   353    353           */
   354    354   #ifndef NDEBUG
   355    355           char *z = pParse->sLastToken.z;
   356    356           if( sqliteStrNICmp(z,"--parser-trace-on--",19)==0 ){
   357         -          trace = stderr;
          357  +          trace = stdout;
   358    358             sqliteParserTrace(trace, "parser: ");
   359    359           }else if( sqliteStrNICmp(z,"--parser-trace-off--", 20)==0 ){
   360    360             trace = 0;
   361    361             sqliteParserTrace(trace, "parser: ");
   362    362           }else if( sqliteStrNICmp(z,"--vdbe-trace-on--",17)==0 ){
   363    363             pParse->db->flags |= SQLITE_VdbeTrace;
   364    364           }else if( sqliteStrNICmp(z,"--vdbe-trace-off--", 18)==0 ){

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.64 2001/09/13 21:53:10 drh Exp $
           44  +** $Id: vdbe.c,v 1.65 2001/09/14 03:24:25 drh Exp $
    45     45   */
    46     46   #include "sqliteInt.h"
    47     47   #include <ctype.h>
    48     48   #include <unistd.h>
    49     49   
    50     50   /*
    51     51   ** SQL is translated into a sequence of instructions to be
................................................................................
  1057   1057     zStack = p->zStack;
  1058   1058     aStack = p->aStack;
  1059   1059     p->tos = -1;
  1060   1060   
  1061   1061     rc = SQLITE_OK;
  1062   1062   #ifdef MEMORY_DEBUG
  1063   1063     if( access("vdbe_trace",0)==0 ){
  1064         -    p->trace = stderr;
         1064  +    p->trace = stdout;
  1065   1065     }
  1066   1066   #endif
  1067   1067     /* if( pzErrMsg ){ *pzErrMsg = 0; } */
  1068   1068     if( sqlite_malloc_failed ) rc = SQLITE_NOMEM;
  1069   1069     for(pc=0; rc==SQLITE_OK && pc<p->nOp VERIFY(&& pc>=0); pc++){
  1070   1070       pOp = &p->aOp[pc];
  1071   1071   
................................................................................
  1081   1081       /* Only allow tracing if NDEBUG is not defined.
  1082   1082       */
  1083   1083   #ifndef NDEBUG
  1084   1084       if( p->trace ){
  1085   1085         fprintf(p->trace,"%4d %-12s %4d %4d %s\n",
  1086   1086           pc, zOpName[pOp->opcode], pOp->p1, pOp->p2,
  1087   1087              pOp->p3 ? pOp->p3 : "");
         1088  +      fflush(p->trace);
  1088   1089       }
  1089   1090   #endif
  1090   1091   
  1091   1092       switch( pOp->opcode ){
  1092   1093   
  1093   1094   /*****************************************************************************
  1094   1095   ** What follows is a massive switch statement where each case implements a
................................................................................
  2137   2138     break;
  2138   2139   }
  2139   2140   
  2140   2141   /* Opcode: Distinct P1 P2 *
  2141   2142   **
  2142   2143   ** Use the top of the stack as a key.  If a record with that key
  2143   2144   ** does not exist in file P1, then jump to P2.  If the record
  2144         -** does already exist, then fall thru.  The record is not retrieved.
  2145         -** The key is not popped from the stack.
         2145  +** does already exist, then fall thru.  The cursor is left pointing
         2146  +** at the record if it exists. The key is not popped from the stack.
  2146   2147   **
  2147   2148   ** This operation is similar to NotFound except that this operation
  2148   2149   ** does not pop the key from the stack.
  2149   2150   */
  2150   2151   /* Opcode: Found P1 P2 *
  2151   2152   **
  2152   2153   ** Use the top of the stack as a key.  If a record with that key
  2153   2154   ** does exist in file P1, then jump to P2.  If the record
  2154         -** does not exist, then fall thru.  The record is not retrieved.
  2155         -** The key is popped from the stack.
         2155  +** does not exist, then fall thru.  The cursor is left pointing
         2156  +** to the record if it exists.  The key is popped from the stack.
  2156   2157   */
  2157   2158   /* Opcode: NotFound P1 P2 *
  2158   2159   **
  2159   2160   ** Use the top of the stack as a key.  If a record with that key
  2160   2161   ** does not exist in file P1, then jump to P2.  If the record
  2161         -** does exist, then fall thru.  The record is not retrieved.
  2162         -** The key is popped from the stack.
         2162  +** does exist, then fall thru.  The cursor is left pointing to the
         2163  +** record if it exists.  The key is popped from the stack.
  2163   2164   **
  2164   2165   ** The difference between this operation and Distinct is that
  2165   2166   ** Distinct does not pop the key from the stack.
  2166   2167   */
  2167   2168   case OP_Distinct:
  2168   2169   case OP_NotFound:
  2169   2170   case OP_Found: {
................................................................................
  2199   2200   ** Get a new integer record number used as the key to a table.
  2200   2201   ** The record number is not previous used by the database file
  2201   2202   ** associated with cursor P1.  The new record number pushed 
  2202   2203   ** onto the stack.
  2203   2204   */
  2204   2205   case OP_NewRecno: {
  2205   2206     int i = pOp->p1;
  2206         -  int v;
         2207  +  static int v = 0;
  2207   2208     if( VERIFY( i<0 || i>=p->nCursor || ) p->aCsr[i].pCursor==0 ){
  2208   2209       v = 0;
  2209   2210     }else{
  2210   2211       int res, rx, cnt;
  2211   2212       cnt = 0;
  2212   2213       do{
  2213         -      v = sqliteRandomInteger();
         2214  +      if( v==0 || cnt>5 ){
         2215  +        v = sqliteRandomInteger();
         2216  +      }else{
         2217  +        v += sqliteRandomByte() + 1;
         2218  +      }
  2214   2219         rx = sqliteBtreeMoveto(p->aCsr[i].pCursor, &v, sizeof(v), &res);
  2215   2220         cnt++;
  2216   2221       }while( cnt<10 && rx==SQLITE_OK && res==0 );
  2217   2222     }
  2218   2223     VERIFY( NeedStack(p, p->tos+1); )
  2219   2224     p->tos++;
  2220   2225     aStack[p->tos].i = v;

Changes to test/insert2.test.

    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 testing the INSERT statement that takes is
    25     25   # result from a SELECT.
    26     26   #
    27         -# $Id: insert2.test,v 1.2 2000/06/07 15:11:27 drh Exp $
           27  +# $Id: insert2.test,v 1.3 2001/09/14 03:24:25 drh Exp $
    28     28   
    29     29   set testdir [file dirname $argv0]
    30     30   source $testdir/tester.tcl
    31     31   
    32     32   # Create some tables with data that we can select against
    33     33   #
    34     34   do_test insert2-1.0 {
................................................................................
    41     41   } {1 0 2 1 3 2 4 2 5 3 6 3 7 3 8 3 9 4 10 4 11 4 12 4 13 4 14 4 15 4 16 4 17 5 18 5 19 5 20 5}
    42     42   
    43     43   # Insert into a new table from the old one.
    44     44   #
    45     45   do_test insert2-1.1 {
    46     46     execsql {
    47     47       CREATE TABLE t1(log int, cnt int);
           48  +---vdbe-trace-on--
    48     49       INSERT INTO t1 SELECT log, count(*) FROM d1 GROUP BY log;
    49     50     }
    50     51     execsql {SELECT * FROM t1 ORDER BY log}
    51     52   } {0 1 1 1 2 2 3 4 4 8 5 4}
           53  +
    52     54   do_test insert2-1.2 {
    53     55     catch {execsql {DROP TABLE t1}}
    54     56     execsql {
    55     57       CREATE TABLE t1(log int, cnt int);
    56     58       INSERT INTO t1 
    57     59          SELECT log, count(*) FROM d1 GROUP BY log
    58     60          EXCEPT SELECT n-1,log FROM d1;

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.8 2001/04/03 16:53:22 drh Exp $
           26  +# $Id: lock.test,v 1.9 2001/09/14 03:24:25 drh Exp $
    27     27   
    28         -if {$dbprefix=="gdbm:" && $::tcl_platform(platform)!="windows"} {
           28  +if {0} {
    29     29   
    30     30   set testdir [file dirname $argv0]
    31     31   source $testdir/tester.tcl
    32     32   
    33     33   # Create a largish table
    34     34   #
    35     35   do_test lock-1.0 {

Changes to test/main.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 main.c.
    25     25   #
    26         -# $Id: main.test,v 1.6 2001/04/04 11:48:58 drh Exp $
           26  +# $Id: main.test,v 1.7 2001/09/14 03:24:25 drh Exp $
    27     27   
    28     28   set testdir [file dirname $argv0]
    29     29   source $testdir/tester.tcl
    30     30   
    31     31   # Tests of the sqlite_complete() function.
    32     32   #
    33     33   do_test main-1.1 {
................................................................................
    79     79   do_test main-1.14 {
    80     80     db complete {SELECT a-b FROM t1; }
    81     81   } {1}
    82     82   do_test main-1.15 {
    83     83     db complete {SELECT a-b FROM t1 }
    84     84   } {0}
    85     85   
    86         -# Try to open a database with a corrupt master file.
           86  +# Try to open a database with a corrupt database file.
    87     87   #
    88     88   do_test main-2.0 {
    89     89     catch {db close}
    90         -  foreach f [glob -nocomplain testdb/*] {file delete -force $f}
    91         -  file delete -force testdb
    92         -  file mkdir testdb
    93         -  set fd [open testdb/sqlite_master.tbl w]
           90  +  file delete -force test.db
           91  +  set fd [open test.db w]
    94     92     puts $fd hi!
    95     93     close $fd
    96         -  set v [catch {sqlite db testdb} msg]
           94  +  set v [catch {sqlite db test.db} msg]
    97     95     lappend v $msg
    98     96   } {0 {}}
    99     97   
   100     98   # Here are some tests for tokenize.c.  
   101     99   #
   102    100   do_test main-3.1 {
   103    101     catch {db close}

Changes to test/pager.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 page cache subsystem.
    25     25   #
    26         -# $Id: pager.test,v 1.8 2001/08/20 00:33:58 drh Exp $
           26  +# $Id: pager.test,v 1.9 2001/09/14 03:24:25 drh Exp $
    27     27   
    28     28   
    29     29   set testdir [file dirname $argv0]
    30     30   source $testdir/tester.tcl
    31     31   
    32         -if {$dbprefix!="memory:" && [info commands pager_open]!=""} {
           32  +if {[info commands pager_open]!=""} {
    33     33   
    34     34   # Basic sanity check.  Open and close a pager.
    35     35   #
    36     36   do_test pager-1.0 {
    37     37     catch {file delete -force ptf1.db}
    38     38     catch {file delete -force ptf1.db-journal}
    39     39     set v [catch {

Changes to test/select2.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 testing the SELECT statement.
    25     25   #
    26         -# $Id: select2.test,v 1.12 2001/09/13 21:53:10 drh Exp $
           26  +# $Id: select2.test,v 1.13 2001/09/14 03:24:25 drh Exp $
    27     27   
    28     28   set testdir [file dirname $argv0]
    29     29   source $testdir/tester.tcl
    30     30   
    31     31   # Create a table with some data
    32     32   #
    33     33   execsql {CREATE TABLE tbl1(f1 int, f2 int)}
................................................................................
    74     74   do_test select2-2.0 {
    75     75     execsql {CREATE TABLE tbl2(f1 int, f2 int, f3 int)}
    76     76     set f [open ./testdata1.txt w]
    77     77     for {set i 1} {$i<=30000} {incr i} {
    78     78       puts $f "$i\t[expr {$i*2}]\t[expr {$i*3}]"
    79     79     }
    80     80     close $f
           81  +  # execsql {--vdbe-trace-on--}
    81     82     execsql {COPY tbl2 FROM './testdata1.txt'}
    82     83     file delete -force ./testdata1.txt
    83     84   } {}
    84     85   
    85     86   do_test select2-2.1 {
    86     87     execsql {SELECT count(*) FROM tbl2}
    87     88   } {30000}

Changes to test/table.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 testing the CREATE TABLE statement.
    25     25   #
    26         -# $Id: table.test,v 1.10 2001/09/13 21:53:10 drh Exp $
           26  +# $Id: table.test,v 1.11 2001/09/14 03:24:25 drh Exp $
    27     27   
    28     28   set testdir [file dirname $argv0]
    29     29   source $testdir/tester.tcl
    30     30   
    31     31   # Create a basic table and verify it is added to sqlite_master
    32     32   #
    33     33   do_test table-1.1 {
................................................................................
    53     53   } {test1 test1 table}
    54     54   
    55     55   # Close and reopen the database.  Verify that everything is
    56     56   # still the same.
    57     57   #
    58     58   do_test table-1.4 {
    59     59     db close
    60         -  sqlite db testdb
           60  +  sqlite db test.db
    61     61     execsql {SELECT name, tbl_name, type from sqlite_master WHERE type!='meta'}
    62     62   } {test1 test1 table}
    63     63   
    64     64   # Drop the database and make sure it disappears.
    65     65   #
    66     66   do_test table-1.5 {
    67     67     execsql {DROP TABLE test1}
    68     68     execsql {SELECT * FROM sqlite_master WHERE type!='meta'}
    69     69   } {}
    70     70   
    71         -# Verify that the file associated with the database is gone.
    72         -#
    73         -do_test table-1.5 {
    74         -  lsort [glob -nocomplain testdb/*.tbl]
    75         -} {testdb/sqlite_master.tbl}
    76         -
    77     71   # Close and reopen the database.  Verify that the table is
    78     72   # still gone.
    79     73   #
    80     74   do_test table-1.6 {
    81     75     db close
    82         -  sqlite db testdb
           76  +  sqlite db test.db
    83     77     execsql {SELECT name FROM sqlite_master WHERE type!='meta'}
    84     78   } {}
    85     79   
    86     80   # Repeat the above steps, but this time quote the table name.
    87     81   #
    88     82   do_test table-1.10 {
    89     83     execsql {CREATE TABLE "create" (f1 int)}
................................................................................
   113    107   } {1 {table test2 already exists}}
   114    108   do_test table-2.1b {
   115    109     set v [catch {execsql {CREATE TABLE sqlite_master(two text)}} msg]
   116    110     lappend v $msg
   117    111   } {1 {table sqlite_master already exists}}
   118    112   do_test table-2.1c {
   119    113     db close
   120         -  sqlite db testdb
          114  +  sqlite db test.db
   121    115     set v [catch {execsql {CREATE TABLE sqlite_master(two text)}} msg]
   122    116     lappend v $msg
   123    117   } {1 {table sqlite_master already exists}}
   124    118   do_test table-2.1d {
   125    119     execsql {DROP TABLE test2; SELECT name FROM sqlite_master WHERE type!='meta'}
   126    120   } {}
   127    121   
................................................................................
   130    124   do_test table-2.2a {
   131    125     execsql {CREATE TABLE test2(one text); CREATE INDEX test3 ON test2(one)}
   132    126     set v [catch {execsql {CREATE TABLE test3(two text)}} msg]
   133    127     lappend v $msg
   134    128   } {1 {there is already an index named test3}}
   135    129   do_test table-2.2b {
   136    130     db close
   137         -  sqlite db testdb
          131  +  sqlite db test.db
   138    132     set v [catch {execsql {CREATE TABLE test3(two text)}} msg]
   139    133     lappend v $msg
   140    134   } {1 {there is already an index named test3}}
   141    135   do_test table-2.2c {
          136  +  execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
          137  +} {test2 test3}
          138  +do_test table-2.2d {
   142    139     execsql {DROP INDEX test3}
   143    140     set v [catch {execsql {CREATE TABLE test3(two text)}} msg]
   144    141     lappend v $msg
   145    142   } {0 {}}
   146         -do_test table-2.2d {
          143  +do_test table-2.2e {
   147    144     execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
   148    145   } {test2 test3}
   149         -do_test table-2.2e {
          146  +do_test table-2.2f {
   150    147     execsql {DROP TABLE test2; DROP TABLE test3}
   151    148     execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
   152    149   } {}
   153    150   
   154    151   # Create a table with many field names
   155    152   #
   156    153   set big_table \
................................................................................
   190    187   } {1 {table biG already exists}}
   191    188   do_test table-3.4 {
   192    189     set v [catch {execsql {CREATE TABLE bIg(xyz foo)}} msg]
   193    190     lappend v $msg
   194    191   } {1 {table bIg already exists}}
   195    192   do_test table-3.5 {
   196    193     db close
   197         -  sqlite db testdb
          194  +  sqlite db test.db
   198    195     set v [catch {execsql {CREATE TABLE Big(xyz foo)}} msg]
   199    196     lappend v $msg
   200    197   } {1 {table Big already exists}}
   201    198   do_test table-3.6 {
   202    199     execsql {DROP TABLE big}
   203    200     execsql {SELECT name FROM sqlite_master WHERE type!='meta'}
   204    201   } {}
................................................................................
   218    215       append sql "last_field text)"
   219    216       execsql $sql
   220    217     }
   221    218     execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
   222    219   } $r
   223    220   do_test table-4.1b {
   224    221     db close
   225         -  sqlite db testdb
          222  +  sqlite db test.db
   226    223     execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
   227    224   } $r
   228    225   
   229    226   # Drop the even numbered tables
   230    227   #
   231    228   set r {}
   232    229   for {set i 1} {$i<=100} {incr i 2} {
   233    230     lappend r test$i
   234    231   }
          232  +#execsql {--vdbe-trace-on--}
   235    233   do_test table-4.2 {
   236    234     for {set i 2} {$i<=100} {incr i 2} {
   237    235       set sql "DROP TABLE TEST$i"
   238    236       execsql $sql
   239    237     }
   240    238     execsql {SELECT name FROM sqlite_master WHERE type!='meta' ORDER BY name}
   241    239   } $r
          240  +#exit
   242    241   
   243    242   # Drop the odd number tables
   244    243   #
   245    244   do_test table-4.3 {
   246    245     for {set i 1} {$i<=100} {incr i 2} {
   247    246       set sql "DROP TABLE test$i"
   248    247       execsql $sql
................................................................................
   277    276     execsql {CREATE TABLE test1(f1 int)}
   278    277     execsql {EXPLAIN DROP TABLE test1}
   279    278     execsql {SELECT name FROM sqlite_master WHERE type!='meta'}
   280    279   } {test1}
   281    280   
   282    281   # Create a table with a goofy name
   283    282   #
   284         -do_test table-6.1 {
   285         -  execsql {CREATE TABLE 'Spaces In This Name!'(x int)}
   286         -  execsql {INSERT INTO 'spaces in this name!' VALUES(1)}
   287         -  set list [glob -nocomplain testdb/spaces*.tbl]
   288         -} {testdb/spaces+in+this+name+.tbl}
          283  +#do_test table-6.1 {
          284  +#  execsql {CREATE TABLE 'Spaces In This Name!'(x int)}
          285  +#  execsql {INSERT INTO 'spaces in this name!' VALUES(1)}
          286  +#  set list [glob -nocomplain testdb/spaces*.tbl]
          287  +#} {testdb/spaces+in+this+name+.tbl}
   289    288   
   290    289   # Try using keywords as table names or column names.
   291    290   # 
   292    291   do_test table-7.1 {
   293    292     set v [catch {execsql {
   294    293       CREATE TABLE weird(
   295    294         desc text,

Changes to test/trans.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: trans.test,v 1.2 2001/04/12 23:21:59 drh Exp $
           26  +# $Id: trans.test,v 1.3 2001/09/14 03:24:25 drh Exp $
    27     27   
    28     28   
    29     29   set testdir [file dirname $argv0]
    30     30   source $testdir/tester.tcl
    31     31   
    32         -if {$dbprefix=="gdbm:" && $::tcl_platform(platform)!="windows"} {
           32  +if {0} {
    33     33   
    34     34   # Create several tables to work with.
    35     35   #
    36     36   do_test trans-1.0 {
    37     37     execsql {
    38     38       CREATE TABLE one(a int PRIMARY KEY, b text);
    39     39       INSERT INTO one VALUES(1,'one');

Changes to test/vacuum.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 testing the VACUUM statement.
    25     25   #
    26         -# $Id: vacuum.test,v 1.4 2001/09/13 21:53:10 drh Exp $
           26  +# $Id: vacuum.test,v 1.5 2001/09/14 03:24:25 drh Exp $
    27     27   
    28     28   set testdir [file dirname $argv0]
    29     29   source $testdir/tester.tcl
           30  +
           31  +if {0} {
    30     32   
    31     33   # Try to vacuum a non-existant table.
    32     34   #
    33     35   do_test vacuum-1.1 {
    34     36     set v [catch {execsql {VACUUM dummy1}} msg]
    35     37     lappend v $msg
    36     38   } {1 {no such table or index: dummy1}}
................................................................................
    75     77     set a2 [file mtime testdb/test2.tbl]
    76     78     set a3 [file mtime testdb/index1.tbl]
    77     79     expr {$a1>$b1 && $a2>$b2 && $a3>$b3}
    78     80   } {1}
    79     81   } ;# End if( platform!=windows )
    80     82   
    81     83   finish_test
           84  +
           85  +}