/ Check-in [61c381e7]
Login

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

Overview
Comment::-) (CVS 81)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 61c381e7e6c85619b7b494417956fc209c5b7b84
User & Date: drh 2000-06-08 15:10:47
Context
2000-06-08
16:26
:-) (CVS 82) check-in: 33355b2d user: drh tags: trunk
15:10
:-) (CVS 81) check-in: 61c381e7 user: drh tags: trunk
13:36
remove all memory leaks (CVS 80) check-in: bf98cf82 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/dbbe.c.

    26     26   ** sqlite and the code that does the actually reading and writing
    27     27   ** of information to the disk.
    28     28   **
    29     29   ** This file uses GDBM as the database backend.  It should be
    30     30   ** relatively simple to convert to a different database such
    31     31   ** as NDBM, SDBM, or BerkeleyDB.
    32     32   **
    33         -** $Id: dbbe.c,v 1.12 2000/06/07 14:42:26 drh Exp $
           33  +** $Id: dbbe.c,v 1.13 2000/06/08 15:10:47 drh Exp $
    34     34   */
    35     35   #include "sqliteInt.h"
    36     36   #include <gdbm.h>
    37     37   #include <sys/stat.h>
    38     38   #include <unistd.h>
    39     39   #include <ctype.h>
    40     40   #include <time.h>
................................................................................
   308    308       }
   309    309       pFile = sqliteMalloc( sizeof(*pFile) );
   310    310       if( pFile==0 ){
   311    311         sqliteFree(zFile);
   312    312         return SQLITE_NOMEM;
   313    313       }
   314    314       if( zFile ){
   315         -      pFile->dbf = gdbm_open(zFile, 0, rw_mask, mode, 0);
          315  +      if( !writeable || pBe->write ){
          316  +        pFile->dbf = gdbm_open(zFile, 0, rw_mask, mode, 0);
          317  +      }else{
          318  +        pFile->dbf = 0;
          319  +      }
   316    320       }else{
   317    321         int limit;
   318    322         struct rc4 *pRc4;
   319    323         char zRandom[50];
   320    324         pRc4 = &pBe->rc4;
   321    325         zFile = 0;
   322    326         limit = 5;
................................................................................
   335    339       if( pBe->pOpen ){
   336    340         pBe->pOpen->pPrev = pFile;
   337    341       }
   338    342       pFile->pNext = pBe->pOpen;
   339    343       pBe->pOpen = pFile;
   340    344       if( pFile->dbf==0 ){
   341    345         if( !writeable && access(zFile,0) ){
   342         -        rc = SQLITE_OK;
          346  +        /* Trying to read a non-existant file.  This is OK.  All the
          347  +        ** reads will return empty, which is what we want. */
          348  +        rc = SQLITE_OK;   
   343    349         }else if( access(zFile,W_OK|R_OK) ){
   344    350           rc = SQLITE_PERM;
   345    351         }else{
   346    352           rc = SQLITE_BUSY;
   347    353         }
   348    354       }
   349    355     }else{

Changes to src/expr.c.

    19     19   ** Author contact information:
    20     20   **   drh@hwaci.com
    21     21   **   http://www.hwaci.com/drh/
    22     22   **
    23     23   *************************************************************************
    24     24   ** This file contains C code routines used for processing expressions
    25     25   **
    26         -** $Id: expr.c,v 1.13 2000/06/08 13:36:40 drh Exp $
           26  +** $Id: expr.c,v 1.14 2000/06/08 15:10:47 drh Exp $
    27     27   */
    28     28   #include "sqliteInt.h"
    29     29   
    30     30   /*
    31     31   ** Walk an expression tree.  Return 1 if the expression is constant
    32     32   ** and 0 if it involves variables.
    33     33   */
................................................................................
   396    396              pExpr->token.z, pExpr->token.n, "()", 2, 0);
   397    397           pParse->nErr++;
   398    398           nErr++;
   399    399         }
   400    400         if( is_agg ) pExpr->op = TK_AGG_FUNCTION;
   401    401         if( is_agg && pIsAgg ) *pIsAgg = 1;
   402    402         for(i=0; nErr==0 && i<n; i++){
   403         -        nErr = sqliteExprCheck(pParse, pExpr->pList->a[i].pExpr, 0, 0);
          403  +        nErr = sqliteExprCheck(pParse, pExpr->pList->a[i].pExpr,
          404  +                               allowAgg && !is_agg, pIsAgg);
   404    405         }
   405    406       }
   406    407       default: {
   407    408         if( pExpr->pLeft ){
   408    409           nErr = sqliteExprCheck(pParse, pExpr->pLeft, allowAgg, pIsAgg);
   409    410         }
   410    411         if( nErr==0 && pExpr->pRight ){

Changes to src/parse.y.

    22     22   **
    23     23   *************************************************************************
    24     24   ** This file contains SQLite's grammar for SQL.  Process this file
    25     25   ** using the lemon parser generator to generate C code that runs
    26     26   ** the parser.  Lemon will also generate a header file containing
    27     27   ** numeric codes for all of the tokens.
    28     28   **
    29         -** @(#) $Id: parse.y,v 1.17 2000/06/08 13:36:40 drh Exp $
           29  +** @(#) $Id: parse.y,v 1.18 2000/06/08 15:10:47 drh Exp $
    30     30   */
    31     31   %token_prefix TK_
    32     32   %token_type {Token}
    33     33   %extra_argument {Parse *pParse}
    34     34   %syntax_error {
    35     35     sqliteSetNString(&pParse->zErrMsg,"syntax error near \"",0,TOKEN.z,TOKEN.n,
    36     36                      "\"", 1, 0);
................................................................................
    79     79   columnid ::= id(X).                {sqliteAddColumn(pParse,&X);}
    80     80   %type id {Token}
    81     81   id(A) ::= ID(X).     {A = X;}
    82     82   id(A) ::= STRING(X). {A = X;}
    83     83   type ::= typename.
    84     84   type ::= typename LP signed RP.
    85     85   type ::= typename LP signed COMMA signed RP.
    86         -typename ::= ID.
    87         -typename ::= typename ID.
           86  +typename ::= id.
           87  +typename ::= typename id.
    88     88   signed ::= INTEGER.
    89     89   signed ::= PLUS INTEGER.
    90     90   signed ::= MINUS INTEGER.
    91     91   carglist ::= carglist carg.
    92     92   carglist ::= .
    93         -carg ::= CONSTRAINT ID ccons.
           93  +carg ::= CONSTRAINT id ccons.
    94     94   carg ::= ccons.
    95     95   carg ::= DEFAULT STRING(X).          {sqliteAddDefaultValue(pParse,&X,0);}
    96     96   carg ::= DEFAULT ID(X).              {sqliteAddDefaultValue(pParse,&X,0);}
    97     97   carg ::= DEFAULT INTEGER(X).         {sqliteAddDefaultValue(pParse,&X,0);}
    98     98   carg ::= DEFAULT PLUS INTEGER(X).    {sqliteAddDefaultValue(pParse,&X,0);}
    99     99   carg ::= DEFAULT MINUS INTEGER(X).   {sqliteAddDefaultValue(pParse,&X,1);}
   100    100   carg ::= DEFAULT FLOAT(X).           {sqliteAddDefaultValue(pParse,&X,0);}
................................................................................
   113    113   // For the time being, the only constraint we care about is the primary
   114    114   // key.
   115    115   //
   116    116   conslist_opt ::= .
   117    117   conslist_opt ::= COMMA conslist.
   118    118   conslist ::= conslist COMMA tcons.
   119    119   conslist ::= tcons.
   120         -tcons ::= CONSTRAINT ID tcons2.
          120  +tcons ::= CONSTRAINT id tcons2.
   121    121   tcons ::= tcons2.
   122    122   tcons2 ::= PRIMARY KEY LP idxlist(X) RP.  
   123    123         {sqliteCreateIndex(pParse,0,0,X,0,0);}
   124    124   tcons2 ::= UNIQUE LP idlist RP.
   125    125   tcons2 ::= CHECK expr.
   126    126   idlist ::= idlist COMMA id.
   127    127   idlist ::= id.
................................................................................
   174    174   %destructor selcollist {sqliteExprListDelete($$);}
   175    175   %type sclp {ExprList*}
   176    176   %destructor sclp {sqliteExprListDelete($$);}
   177    177   sclp(A) ::= selcollist(X) COMMA.             {A = X;}
   178    178   sclp(A) ::= .                                {A = 0;}
   179    179   selcollist(A) ::= STAR.                      {A = 0;}
   180    180   selcollist(A) ::= sclp(P) expr(X).           {A = sqliteExprListAppend(P,X,0);}
   181         -selcollist(A) ::= sclp(P) expr(X) as ID(Y).  {A = sqliteExprListAppend(P,X,&Y);}
   182         -selcollist(A) ::= sclp(P) expr(X) as STRING(Y).
   183         -  {A = sqliteExprListAppend(P,X,&Y);}
          181  +selcollist(A) ::= sclp(P) expr(X) as id(Y).  {A = sqliteExprListAppend(P,X,&Y);}
   184    182   as ::= .
   185    183   as ::= AS.
   186    184   
   187    185   
   188    186   %type seltablist {IdList*}
   189    187   %destructor seltablist {sqliteIdListDelete($$);}
   190    188   %type stl_prefix {IdList*}
................................................................................
   232    230   
   233    231   %type having_opt {Expr*}
   234    232   %destructor having_opt {sqliteExprDelete($$);}
   235    233   having_opt(A) ::= .      {A = 0;}
   236    234   having_opt(A) ::= HAVING expr(X).  {A = X;}
   237    235   
   238    236   
   239         -cmd ::= DELETE FROM ID(X) where_opt(Y).
          237  +cmd ::= DELETE FROM id(X) where_opt(Y).
   240    238       {sqliteDeleteFrom(pParse, &X, Y);}
   241    239   
   242    240   %type where_opt {Expr*}
   243    241   %destructor where_opt {sqliteExprDelete($$);}
   244    242   
   245    243   where_opt(A) ::= .                    {A = 0;}
   246    244   where_opt(A) ::= WHERE expr(X).       {A = X;}
   247    245   
   248    246   %type setlist {ExprList*}
   249    247   %destructor setlist {sqliteExprListDelete($$);}
   250    248   
   251         -cmd ::= UPDATE ID(X) SET setlist(Y) where_opt(Z).
          249  +cmd ::= UPDATE id(X) SET setlist(Y) where_opt(Z).
   252    250       {sqliteUpdate(pParse,&X,Y,Z);}
   253    251   
   254         -setlist(A) ::= ID(X) EQ expr(Y) COMMA setlist(Z).
          252  +setlist(A) ::= id(X) EQ expr(Y) COMMA setlist(Z).
   255    253       {A = sqliteExprListAppend(Z,Y,&X);}
   256         -setlist(A) ::= ID(X) EQ expr(Y).   {A = sqliteExprListAppend(0,Y,&X);}
          254  +setlist(A) ::= id(X) EQ expr(Y).   {A = sqliteExprListAppend(0,Y,&X);}
   257    255   
   258         -cmd ::= INSERT INTO ID(X) fieldlist_opt(F) VALUES LP itemlist(Y) RP.
          256  +cmd ::= INSERT INTO id(X) fieldlist_opt(F) VALUES LP itemlist(Y) RP.
   259    257                  {sqliteInsert(pParse, &X, Y, 0, F);}
   260         -cmd ::= INSERT INTO ID(X) fieldlist_opt(F) select(S).
          258  +cmd ::= INSERT INTO id(X) fieldlist_opt(F) select(S).
   261    259                  {sqliteInsert(pParse, &X, 0, S, F);}
   262    260   
   263    261   
   264    262   %type itemlist {ExprList*}
   265    263   %destructor itemlist {sqliteExprListDelete($$);}
   266    264   %type item {Expr*}
   267    265   %destructor item {sqliteExprDelete($$);}
................................................................................
   286    284   %type fieldlist_opt {IdList*}
   287    285   %destructor fieldlist_opt {sqliteIdListDelete($$);}
   288    286   %type fieldlist {IdList*}
   289    287   %destructor fieldlist {sqliteIdListDelete($$);}
   290    288   
   291    289   fieldlist_opt(A) ::= .                    {A = 0;}
   292    290   fieldlist_opt(A) ::= LP fieldlist(X) RP.  {A = X;}
   293         -fieldlist(A) ::= fieldlist(X) COMMA ID(Y). {A = sqliteIdListAppend(X,&Y);}
   294         -fieldlist(A) ::= ID(Y).                    {A = sqliteIdListAppend(0,&Y);}
          291  +fieldlist(A) ::= fieldlist(X) COMMA id(Y). {A = sqliteIdListAppend(X,&Y);}
          292  +fieldlist(A) ::= id(Y).                    {A = sqliteIdListAppend(0,&Y);}
   295    293   
   296    294   %left OR.
   297    295   %left AND.
   298    296   %right NOT.
   299    297   %left EQ NE ISNULL NOTNULL IS LIKE GLOB BETWEEN IN.
   300    298   %left GT GE LT LE.
   301    299   %left PLUS MINUS.
................................................................................
   304    302   
   305    303   %type expr {Expr*}
   306    304   %destructor expr {sqliteExprDelete($$);}
   307    305   
   308    306   expr(A) ::= LP expr(X) RP.   {A = X;}
   309    307   expr(A) ::= ID(X).           {A = sqliteExpr(TK_ID, 0, 0, &X);}
   310    308   expr(A) ::= NULL.            {A = sqliteExpr(TK_NULL, 0, 0, 0);}
   311         -expr(A) ::= ID(X) DOT ID(Y). {Expr *temp1 = sqliteExpr(TK_ID, 0, 0, &X);
          309  +expr(A) ::= id(X) DOT id(Y). {Expr *temp1 = sqliteExpr(TK_ID, 0, 0, &X);
   312    310                                 Expr *temp2 = sqliteExpr(TK_ID, 0, 0, &Y);
   313    311                                 A = sqliteExpr(TK_DOT, temp1, temp2, 0);}
   314    312   expr(A) ::= INTEGER(X).      {A = sqliteExpr(TK_INTEGER, 0, 0, &X);}
   315    313   expr(A) ::= FLOAT(X).        {A = sqliteExpr(TK_FLOAT, 0, 0, &X);}
   316    314   expr(A) ::= STRING(X).       {A = sqliteExpr(TK_STRING, 0, 0, &X);}
   317    315   expr(A) ::= ID(X) LP exprlist(Y) RP.  {A = sqliteExprFunction(Y, &X);}
   318    316   expr(A) ::= ID(X) LP STAR RP.         {A = sqliteExprFunction(0, &X);}
................................................................................
   389    387   exprlist(A) ::= exprlist(X) COMMA expritem(Y). 
   390    388      {A = sqliteExprListAppend(X,Y,0);}
   391    389   exprlist(A) ::= expritem(X).            {A = sqliteExprListAppend(0,X,0);}
   392    390   expritem(A) ::= expr(X).                {A = X;}
   393    391   expritem(A) ::= .                       {A = 0;}
   394    392   
   395    393   
   396         -cmd ::= CREATE(S) uniqueflag INDEX ID(X) ON ID(Y) LP idxlist(Z) RP(E).
          394  +cmd ::= CREATE(S) uniqueflag INDEX id(X) ON id(Y) LP idxlist(Z) RP(E).
   397    395       {sqliteCreateIndex(pParse, &X, &Y, Z, &S, &E);}
   398    396   uniqueflag ::= UNIQUE.
   399    397   uniqueflag ::= .
   400    398   
   401    399   %type idxlist {IdList*}
   402    400   %destructor idxlist {sqliteIdListDelete($$);}
   403    401   %type idxitem {Token}
   404    402   
   405    403   idxlist(A) ::= idxlist(X) COMMA idxitem(Y).  
   406    404        {A = sqliteIdListAppend(X,&Y);}
   407    405   idxlist(A) ::= idxitem(Y).
   408    406        {A = sqliteIdListAppend(0,&Y);}
   409         -idxitem(A) ::= ID(X).           {A = X;}
          407  +idxitem(A) ::= id(X).           {A = X;}
   410    408   
   411    409   cmd ::= DROP INDEX id(X).       {sqliteDropIndex(pParse, &X);}
   412    410   
   413    411   cmd ::= COPY id(X) FROM id(Y) USING DELIMITERS STRING(Z).
   414    412       {sqliteCopy(pParse,&X,&Y,&Z);}
   415    413   cmd ::= COPY id(X) FROM id(Y).
   416    414       {sqliteCopy(pParse,&X,&Y,0);}
   417    415   
   418    416   cmd ::= VACUUM.                {sqliteVacuum(pParse,0);}
   419    417   cmd ::= VACUUM id(X).          {sqliteVacuum(pParse,&X);}

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.22 2000/06/08 13:36:40 drh Exp $
           27  +** $Id: select.c,v 1.23 2000/06/08 15:10:48 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   */
................................................................................
   373    373     }
   374    374     pEList = pSelect->pEList;
   375    375     for(i=0; i<pOrderBy->nExpr; i++){
   376    376       Expr *pE = pOrderBy->a[i].pExpr;
   377    377       int match = 0;
   378    378       if( pOrderBy->a[i].done ) continue;
   379    379       for(j=0; j<pEList->nExpr; j++){
   380         -      if( pEList->a[i].zName && (pE->op==TK_ID || pE->op==TK_STRING) ){
   381         -        char *zName = pEList->a[i].zName;
          380  +      if( pEList->a[j].zName && (pE->op==TK_ID || pE->op==TK_STRING) ){
          381  +        char *zName = pEList->a[j].zName;
   382    382           char *zLabel = sqliteStrNDup(pE->token.z, pE->token.n);
   383    383           sqliteDequote(zLabel);
   384    384           if( sqliteStrICmp(zName, zLabel)==0 ){ 
   385    385             match = 1; 
   386    386           }
   387    387           sqliteFree(zLabel);
   388    388         }
   389         -      if( match==0 && sqliteExprCompare(pE, pEList->a[i].pExpr) ){
          389  +      if( match==0 && sqliteExprCompare(pE, pEList->a[j].pExpr) ){
   390    390           match = 1;
   391    391         }
   392    392         if( match ){
   393    393           pE->op = TK_FIELD;
   394    394           pE->iField = j;
   395    395           pE->iTable = iTable;
   396    396           pOrderBy->a[i].done = 1;

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.28 2000/06/08 13:36:41 drh Exp $
           44  +** $Id: vdbe.c,v 1.29 2000/06/08 15:10:48 drh Exp $
    45     45   */
    46     46   #include "sqliteInt.h"
    47     47   #include <unistd.h>
    48     48   
    49     49   /*
    50     50   ** SQL is translated into a sequence of instructions to be
    51     51   ** executed by a virtual machine.  Each instruction is an instance
................................................................................
  1707   1707             case SQLITE_PERM: {
  1708   1708               sqliteSetString(pzErrMsg, pOp->p2 ? "write" : "read",
  1709   1709                 " permission denied for table ", pOp->p3, 0);
  1710   1710               break;
  1711   1711             }
  1712   1712             case SQLITE_READONLY: {
  1713   1713               sqliteSetString(pzErrMsg,"table ", pOp->p3, 
  1714         -               " is already opened for reading", 0);
         1714  +               " is readonly", 0);
  1715   1715               break;
  1716   1716             }
  1717   1717             case SQLITE_NOMEM: {
  1718   1718               goto no_mem;
  1719   1719             }
  1720   1720           }
  1721   1721           p->aTab[i].index = 0;

Changes to test/dbbe.test.

    19     19   #   drh@hwaci.com
    20     20   #   http://www.hwaci.com/drh/
    21     21   #
    22     22   #***********************************************************************
    23     23   # This file implements regression tests for SQLite library.  The
    24     24   # focus of this file is exercising the code in dbbe.c.
    25     25   #
    26         -# $Id: dbbe.test,v 1.1 2000/06/07 14:42:27 drh Exp $
           26  +# $Id: dbbe.test,v 1.2 2000/06/08 15:10:48 drh Exp $
    27     27   
    28     28   set testdir [file dirname $argv0]
    29     29   source $testdir/tester.tcl
    30     30   
    31     31   # Try to open a database that does not exist.
    32     32   #
    33     33   do_test dbbe-1.1 {
................................................................................
   114    114     db close
   115    115     sqlite db testdb 0444
   116    116     set r [execsql {SELECT * FROM T1}]
   117    117     db close
   118    118     sqlite db testdb 0666
   119    119     lappend r [execsql {SELECT * FROM t1}]
   120    120   } {1 1}
          121  +
          122  +# Try to change a table after opening the database readonly
          123  +#
          124  +do_test dbbe-3.1 {
          125  +  catch {db close}
          126  +  file delete -force testdb
          127  +  sqlite db testdb 0666
          128  +  execsql {CREATE TABLE t1(x int)}
          129  +  db close
          130  +  sqlite db testdb 0444
          131  +  set v [catch {execsql {INSERT INTO t1 VALUES(1)}} msg]
          132  +  lappend v $msg
          133  +} {1 {write permission denied for table t1}}
          134  +
   121    135   
   122    136   finish_test

Changes to test/delete.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 DELETE FROM statement.
    25     25   #
    26         -# $Id: delete.test,v 1.4 2000/06/03 19:19:42 drh Exp $
           26  +# $Id: delete.test,v 1.5 2000/06/08 15:10:48 drh Exp $
    27     27   
    28     28   set testdir [file dirname $argv0]
    29     29   source $testdir/tester.tcl
    30     30   
    31     31   # Try to delete from a non-existant table.
    32     32   #
    33     33   do_test delete-1.1 {
................................................................................
    54     54   } {1 2 2 4 3 8 4 16}
    55     55   do_test delete-3.1b {
    56     56     execsql {DELETE FROM table1 WHERE f1=3}
    57     57     execsql {SELECT * FROM table1 ORDER BY f1}
    58     58   } {1 2 2 4 4 16}
    59     59   do_test delete-3.1c {
    60     60     execsql {CREATE INDEX index1 ON table1(f1)}
    61         -  execsql {DELETE FROM table1 WHERE f1=3}
           61  +  execsql {DELETE FROM 'table1' WHERE f1=3}
    62     62     execsql {SELECT * FROM table1 ORDER BY f1}
    63     63   } {1 2 2 4 4 16}
    64     64   do_test delete-3.1d {
    65     65     execsql {DELETE FROM table1 WHERE f1=2}
    66     66     execsql {SELECT * FROM table1 ORDER BY f1}
    67     67   } {1 2 4 16}
    68     68   

Changes to test/select3.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 aggregate functions and the
    25     25   # GROUP BY and HAVING clauses of SELECT statements.
    26     26   #
    27         -# $Id: select3.test,v 1.1 2000/06/06 18:00:16 drh Exp $
           27  +# $Id: select3.test,v 1.2 2000/06/08 15:10:48 drh Exp $
    28     28   
    29     29   set testdir [file dirname $argv0]
    30     30   source $testdir/tester.tcl
    31     31   
    32     32   # Build some test data
    33     33   #
    34     34   do_test select3-1.0 {
................................................................................
   107    107       SELECT log, count(*) FROM t1 
   108    108       GROUP BY log 
   109    109       HAVING count(*)>=4 
   110    110       ORDER BY max(n)
   111    111     }
   112    112   } {3 4 4 8 5 15}
   113    113   
          114  +do_test select3-5.1 {
          115  +  execsql {
          116  +    SELECT log, count(*), avg(n), max(n+log*2) FROM t1 
          117  +    GROUP BY log 
          118  +    ORDER BY max(n+log*2), avg(n)
          119  +  }
          120  +} {0 1 1 1 1 1 2 4 2 2 3.5 8 3 4 6.5 14 4 8 12.5 24 5 15 24 41}
          121  +do_test select3-5.2 {
          122  +  execsql {
          123  +    SELECT log, count(*), avg(n), max(n+log*2) FROM t1 
          124  +    GROUP BY log 
          125  +    ORDER BY max(n+log*2), min(log,avg(n))
          126  +  }
          127  +} {0 1 1 1 1 1 2 4 2 2 3.5 8 3 4 6.5 14 4 8 12.5 24 5 15 24 41}
          128  +
   114    129   finish_test

Changes to test/select4.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 UNION, INTERSECT and EXCEPT operators
    25     25   # in SELECT statements.
    26     26   #
    27         -# $Id: select4.test,v 1.2 2000/06/08 01:55:31 drh Exp $
           27  +# $Id: select4.test,v 1.3 2000/06/08 15:10:48 drh Exp $
    28     28   
    29     29   set testdir [file dirname $argv0]
    30     30   source $testdir/tester.tcl
    31     31   
    32     32   # Build some test data
    33     33   #
    34     34   set fd [open data1.txt w]
................................................................................
   240    240       UNION ALL
   241    241       SELECT log FROM t1 WHERE n=5
   242    242       ORDER BY log;
   243    243     }} msg]
   244    244     lappend v $msg
   245    245   } {0 {1 2 2 3}}
   246    246   
          247  +do_test select4-6.1 {
          248  +  execsql {
          249  +    SELECT log, count(*) as cnt FROM t1 GROUP BY log
          250  +    UNION
          251  +    SELECT log, n FROM t1 WHERE n=7
          252  +    ORDER BY cnt, log;
          253  +  }
          254  +} {0 1 1 1 2 2 3 4 3 7 4 8 5 15}
          255  +do_test select4-6.2 {
          256  +  execsql {
          257  +    SELECT log, count(*) FROM t1 GROUP BY log
          258  +    UNION
          259  +    SELECT log, n FROM t1 WHERE n=7
          260  +    ORDER BY count(*), log;
          261  +  }
          262  +} {0 1 1 1 2 2 3 4 3 7 4 8 5 15}
          263  +
   247    264   finish_test

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.4 2000/05/30 16:27:05 drh Exp $
           26  +# $Id: table.test,v 1.5 2000/06/08 15:10:48 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 {
................................................................................
   109    109   } {}
   110    110   
   111    111   
   112    112   
   113    113   # Verify that we cannot make two tables with the same name
   114    114   #
   115    115   do_test table-2.1 {
   116         -  execsql {CREATE TABLE test2(one text)}
          116  +  execsql {CREATE TABLE TEST2(one text)}
   117    117     set v [catch {execsql {CREATE TABLE test2(two text)}} msg]
   118    118     lappend v $msg
   119    119   } {1 {table test2 already exists}}
   120    120   do_test table-2.1b {
   121    121     set v [catch {execsql {CREATE TABLE sqlite_master(two text)}} msg]
   122    122     lappend v $msg
   123    123   } {1 {table sqlite_master already exists}}
................................................................................
   281    281   #
   282    282   do_test table-5.4 {
   283    283     execsql {CREATE TABLE test1(f1 int)}
   284    284     execsql {EXPLAIN DROP TABLE test1}
   285    285     execsql {SELECT name FROM sqlite_master}
   286    286   } {test1}
   287    287   
          288  +# Create a table with a goofy name
          289  +#
          290  +do_test table-6.1 {
          291  +  execsql {CREATE TABLE 'Spaces In This Name!'(x int)}
          292  +  execsql {INSERT INTO 'spaces in this name!' VALUES(1)}
          293  +  set list [glob -nocomplain testdb/spaces*.tbl]
          294  +} {testdb/spaces+in+this+name+.tbl}
          295  +
   288    296   finish_test