/ Check-in [d3baa046]
Login

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

Overview
Comment::-) (CVS 70)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d3baa046c946a2c4d5567ee57d96a6c8aa5740b9
User & Date: drh 2000-06-07 15:11:27
Context
2000-06-07
15:23
:-) (CVS 71) check-in: a92eb771 user: drh tags: trunk
15:11
:-) (CVS 70) check-in: d3baa046 user: drh tags: trunk
14:42
:-) (CVS 69) check-in: e4f6b17f user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

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.7 2000/06/07 14:42:27 drh Exp $
           27  +** $Id: insert.c,v 1.8 2000/06/07 15:11:27 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 form:
    33     33   **
    34     34   **    insert into TABLE (IDLIST) values(EXPRLIST)
................................................................................
   180    180           char *zDflt = pTab->aCol[idx].zDflt;
   181    181           if( zDflt==0 ){
   182    182             sqliteVdbeAddOp(v, OP_Null, 0, 0, 0, 0);
   183    183           }else{
   184    184             sqliteVdbeAddOp(v, OP_String, 0, 0, zDflt, 0);
   185    185           }
   186    186         }else if( srcTab>=0 ){
   187         -        sqliteVdbeAddOp(v, OP_Field, srcTab, i, 0, 0); 
          187  +        sqliteVdbeAddOp(v, OP_Field, srcTab, idx, 0, 0); 
   188    188         }else{
   189    189           sqliteExprCode(pParse, pList->a[j].pExpr);
   190    190         }
   191    191       }
   192    192       sqliteVdbeAddOp(v, OP_MakeKey, pIdx->nField, 0, 0, 0);
   193    193       sqliteVdbeAddOp(v, OP_PutIdx, idx+base, 0, 0, 0);
   194    194       /* sqliteVdbeAddOp(v, OP_Close, idx, 0, 0, 0); */

Changes to src/main.c.

    22     22   **
    23     23   *************************************************************************
    24     24   ** Main file for the SQLite library.  The routines in this file
    25     25   ** implement the programmer interface to the library.  Routines in
    26     26   ** other files are for internal use by SQLite and should not be
    27     27   ** accessed by users of the library.
    28     28   **
    29         -** $Id: main.c,v 1.10 2000/06/07 14:42:27 drh Exp $
           29  +** $Id: main.c,v 1.11 2000/06/07 15:11:27 drh Exp $
    30     30   */
    31     31   #include "sqliteInt.h"
    32     32   
    33     33   /*
    34     34   ** This is the callback routine for the code that initializes the
    35     35   ** database.  Each callback contains text of a CREATE TABLE or
    36     36   ** CREATE INDEX statement that must be parsed to yield the internal
................................................................................
   181    181   
   182    182     /* Attempt to read the schema */
   183    183     rc = sqliteInit(db, pzErrMsg);
   184    184     if( rc!=SQLITE_OK && rc!=SQLITE_BUSY ){
   185    185       sqlite_close(db);
   186    186       return 0;
   187    187     }else{
   188         -    sqliteFree(*pzErrMsg);
          188  +    free(*pzErrMsg);
   189    189       *pzErrMsg = 0;
   190    190     }
   191    191     return db;
   192    192   }
   193    193   
   194    194   /*
   195    195   ** Close an existing SQLite database

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.1 2000/06/07 14:42:27 drh Exp $
           27  +# $Id: insert2.test,v 1.2 2000/06/07 15:11:27 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 {
................................................................................
    65     65       CREATE TABLE t1(log int, cnt int);
    66     66       INSERT INTO t1 
    67     67          SELECT log, count(*) FROM d1 GROUP BY log
    68     68          INTERSECT SELECT n-1,log FROM d1;
    69     69       SELECT * FROM t1 ORDER BY log;
    70     70     }
    71     71   } {1 1 2 2}
           72  +do_test insert2-1.4 {
           73  +  catch {execsql {DROP TABLE t1}}
           74  +  set r [execsql {
           75  +    CREATE TABLE t1(log int, cnt int);
           76  +    CREATE INDEX i1 ON t1(log);
           77  +    CREATE INDEX i2 ON t1(cnt);
           78  +    INSERT INTO t1 SELECT log, count() FROM d1 GROUP BY log;
           79  +    SELECT * FROM t1 ORDER BY log;
           80  +  }]
           81  +  lappend r [execsql {SELECT cnt FROM t1 WHERE log=3}]
           82  +  lappend r [execsql {SELECT log FROM t1 WHERE cnt=4 ORDER BY log}]
           83  +} {0 1 1 1 2 2 3 4 4 8 5 4 4 {3 5}}
    72     84   
    73     85   finish_test

Added test/main.test.

            1  +# Copyright (c) 1999, 2000 D. Richard Hipp
            2  +#
            3  +# This program is free software; you can redistribute it and/or
            4  +# modify it under the terms of the GNU General Public
            5  +# License as published by the Free Software Foundation; either
            6  +# version 2 of the License, or (at your option) any later version.
            7  +#
            8  +# This program is distributed in the hope that it will be useful,
            9  +# but WITHOUT ANY WARRANTY; without even the implied warranty of
           10  +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
           11  +# General Public License for more details.
           12  +# 
           13  +# You should have received a copy of the GNU General Public
           14  +# License along with this library; if not, write to the
           15  +# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
           16  +# Boston, MA  02111-1307, USA.
           17  +#
           18  +# Author contact information:
           19  +#   drh@hwaci.com
           20  +#   http://www.hwaci.com/drh/
           21  +#
           22  +#***********************************************************************
           23  +# This file implements regression tests for SQLite library.  The
           24  +# focus of this file is exercising the code in main.c.
           25  +#
           26  +# $Id: main.test,v 1.1 2000/06/07 15:11:27 drh Exp $
           27  +
           28  +set testdir [file dirname $argv0]
           29  +source $testdir/tester.tcl
           30  +
           31  +# Tests of the sqlite_complete() function.
           32  +#
           33  +do_test main-1.1 {
           34  +  db complete {This is a test}
           35  +} {0}
           36  +do_test main-1.2 {
           37  +  db complete {
           38  +  }
           39  +} {0}
           40  +do_test main-1.3 {
           41  +  db complete {
           42  +     -- a comment ;
           43  +  }
           44  +} {0}
           45  +do_test main-1.4 {
           46  +  db complete {
           47  +     -- a comment ;
           48  +     ;
           49  +  }
           50  +} {1}
           51  +
           52  +# Try to open a database with a corrupt master file.
           53  +#
           54  +do_test main-2.0 {
           55  +  catch {db close}
           56  +  file delete -force testdb
           57  +  file mkdir testdb
           58  +  set fd [open testdb/sqlite_master.tbl w]
           59  +  puts $fd hi!
           60  +  close $fd
           61  +  set v [catch {sqlite db testdb} msg]
           62  +  lappend v $msg
           63  +} {0 {}}
           64  +
           65  +finish_test

Changes to test/select1.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: select1.test,v 1.4 2000/06/07 14:42:27 drh Exp $
           26  +# $Id: select1.test,v 1.5 2000/06/07 15:11:27 drh Exp $
    27     27   
    28     28   set testdir [file dirname $argv0]
    29     29   source $testdir/tester.tcl
    30     30   
    31     31   # Try to select on a non-existant table.
    32     32   #
    33     33   do_test select1-1.1 {
................................................................................
   277    277     lappend v $msg
   278    278   } {0 {A.f1 11 test2.t1 abc A.f1 33 test2.t1 abc}}
   279    279   do_test select1-6.8 {
   280    280     set v [catch {execsql2 {SELECT A.f1, f1 FROM test1 as A, test1 as B 
   281    281            ORDER BY f2}} msg]
   282    282     lappend v $msg
   283    283   } {1 {ambiguous field name: f1}}
   284         -do_test select1-6.8 {
          284  +do_test select1-6.8b {
   285    285     set v [catch {execsql2 {SELECT A.f1, B.f1 FROM test1 as A, test1 as B 
   286    286            ORDER BY f2}} msg]
   287    287     lappend v $msg
   288    288   } {1 {ambiguous field name: f2}}
          289  +do_test select1-6.8c {
          290  +  set v [catch {execsql2 {SELECT A.f1, f1 FROM test1 as A, test1 as A 
          291  +         ORDER BY f2}} msg]
          292  +  lappend v $msg
          293  +} {1 {ambiguous field name: A.f1}}
   289    294   do_test select1-6.9 {
   290    295     set v [catch {execsql2 {SELECT A.f1, B.f1 FROM test1 as A, test1 as B 
   291    296            ORDER BY A.f1, B.f1}} msg]
   292    297     lappend v $msg
   293    298   } {0 {A.f1 11 B.f1 11 A.f1 11 B.f1 33 A.f1 33 B.f1 11 A.f1 33 B.f1 33}}
   294    299   
   295    300   finish_test