/ Check-in [c0e3f1c5]
Login

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

Overview
Comment:Fix bug in anonymous subquery in a join. Parser requires a semicolon or end-of-input before executing. (CVS 429)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c0e3f1c592f583a0659901743a368aff1927f1cb
User & Date: drh 2002-03-13 18:54:07
Context
2002-03-13
18:54
Version 2.4.1 (CVS 430) check-in: 9333ecca user: drh tags: trunk
18:54
Fix bug in anonymous subquery in a join. Parser requires a semicolon or end-of-input before executing. (CVS 429) check-in: c0e3f1c5 user: drh tags: trunk
2002-03-12
23:10
Fix the return type of the xStep function in the FuncDef structure definition. (CVS 428) check-in: 753adb78 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

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.55 2002/03/06 03:08:26 drh Exp $
           15  +** $Id: expr.c,v 1.56 2002/03/13 18:54:07 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   
    20     20   /*
    21     21   ** Construct a new expression node and return a pointer to it.  Memory
    22     22   ** for this node is obtained from sqliteMalloc().  The calling function
................................................................................
   462    462           if( pTab==0 ) continue;
   463    463           assert( pTab->nCol>0 );
   464    464           if( pTabList->a[i].zAlias ){
   465    465             zTab = pTabList->a[i].zAlias;
   466    466           }else{
   467    467             zTab = pTab->zName;
   468    468           }
   469         -        if( sqliteStrICmp(zTab, zLeft)!=0 ) continue;
          469  +        if( zTab==0 || sqliteStrICmp(zTab, zLeft)!=0 ) continue;
   470    470           if( 0==(cntTab++) ) pExpr->iTable = i + base;
   471    471           for(j=0; j<pTab->nCol; j++){
   472    472             if( sqliteStrICmp(pTab->aCol[j].zName, zRight)==0 ){
   473    473               cnt++;
   474    474               pExpr->iTable = i + base;
   475    475               if( j==pTab->iPKey ){
   476    476                 /* Substitute the record number for the INTEGER PRIMARY KEY */

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.56 2002/03/05 01:11:14 drh Exp $
           17  +** @(#) $Id: parse.y,v 1.57 2002/03/13 18:54:08 drh 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     sqliteSetString(&pParse->zErrMsg,"syntax error",0);
................................................................................
    44     44   
    45     45   // Input is zero or more commands.
    46     46   input ::= cmdlist.
    47     47   
    48     48   // A list of commands is zero or more commands
    49     49   //
    50     50   cmdlist ::= ecmd.
    51         -cmdlist ::= cmdlist SEMI ecmd.
    52         -ecmd ::= explain cmd.  {sqliteExec(pParse);}
    53         -ecmd ::= cmd.          {sqliteExec(pParse);}
    54         -ecmd ::= .
           51  +cmdlist ::= cmdlist ecmd.
           52  +ecmd ::= explain cmd SEMI.  {sqliteExec(pParse);}
           53  +ecmd ::= cmd SEMI.          {sqliteExec(pParse);}
           54  +ecmd ::= SEMI.
    55     55   explain ::= EXPLAIN.    {pParse->explain = 1;}
    56     56   
    57     57   ///////////////////// Begin and end transactions. ////////////////////////////
    58     58   //
    59     59   
    60     60   cmd ::= BEGIN trans_opt onconf(R).  {sqliteBeginTransaction(pParse,R);}
    61     61   trans_opt ::= .

Changes to src/tokenize.c.

    11     11   *************************************************************************
    12     12   ** An tokenizer for SQL
    13     13   **
    14     14   ** This file contains C code that splits an SQL input string up into
    15     15   ** individual tokens and sends those tokens one-by-one over to the
    16     16   ** parser for analysis.
    17     17   **
    18         -** $Id: tokenize.c,v 1.38 2002/02/23 02:32:10 drh Exp $
           18  +** $Id: tokenize.c,v 1.39 2002/03/13 18:54:08 drh Exp $
    19     19   */
    20     20   #include "sqliteInt.h"
    21     21   #include "os.h"
    22     22   #include <ctype.h>
    23     23   #include <stdlib.h>
    24     24   
    25     25   /*
................................................................................
   417    417             sqliteSetString(pzErrMsg, sqlite_error_string(pParse->rc), 0);
   418    418             nErr++;
   419    419           }
   420    420           break;
   421    421       }
   422    422     }
   423    423     if( zSql[i]==0 ){
          424  +    sqliteParser(pEngine, TK_SEMI, pParse->sLastToken, pParse);
   424    425       sqliteParser(pEngine, 0, pParse->sLastToken, pParse);
   425    426       if( pParse->zErrMsg && pParse->sErrToken.z ){
   426    427          sqliteSetNString(pzErrMsg, "near \"", -1, 
   427    428             pParse->sErrToken.z, pParse->sErrToken.n,
   428    429             "\": ", -1,
   429    430             pParse->zErrMsg, -1,
   430    431             0);

Changes to test/misc1.test.

     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.
    12     12   #
    13     13   # This file implements tests for miscellanous features that were
    14     14   # left out of other test files.
    15     15   #
    16         -# $Id: misc1.test,v 1.3 2002/02/14 12:50:35 drh Exp $
           16  +# $Id: misc1.test,v 1.4 2002/03/13 18:54:08 drh Exp $
    17     17   
    18     18   set testdir [file dirname $argv0]
    19     19   source $testdir/tester.tcl
    20     20   
    21     21   # Test the creation and use of tables that have a large number
    22     22   # of columns.
    23     23   #
................................................................................
   129    129       INSERT INTO t2 SELECT '4 - ' || a FROM t2;
   130    130       INSERT INTO t2 SELECT '5 - ' || a FROM t2;
   131    131       INSERT INTO t2 SELECT '6 - ' || a FROM t2;
   132    132       COMMIT;
   133    133       SELECT count(*) FROM t2;
   134    134     }
   135    135   } {64}
          136  +
          137  +# Make sure we actually see a semicolon or end-of-file in the SQL input
          138  +# before executing a command.  Thus if "WHERE" is misspelled on an UPDATE,
          139  +# the user won't accidently update every record.
          140  +#
          141  +do_test misc1-5.1 {
          142  +  catchsql {
          143  +    CREATE TABLE t3(a,b);
          144  +    INSERT INTO t3 VALUES(1,2);
          145  +    INSERT INTO t3 VALUES(3,4);
          146  +    UPDATE t3 SET a=0 WHEREwww b=2;
          147  +  }
          148  +} {1 {near "WHEREwww": syntax error}}
          149  +do_test misc1-5.2 {
          150  +  execsql {
          151  +    SELECT * FROM t3 ORDER BY a;
          152  +  }
          153  +} {1 2 3 4}
   136    154   
   137    155   finish_test

Changes to test/select6.test.

     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 file is testing SELECT statements that contain
    13     13   # subqueries in their FROM clause.
    14     14   #
    15         -# $Id: select6.test,v 1.6 2002/03/03 03:42:31 drh Exp $
           15  +# $Id: select6.test,v 1.7 2002/03/13 18:54:09 drh Exp $
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   do_test select6-1.0 {
    21     21     execsql {
    22     22       BEGIN;
................................................................................
   276    276   do_test select6-5.1 {
   277    277     execsql {
   278    278       SELECT a,x,b FROM
   279    279         (SELECT x+3 AS 'a', x FROM t1 WHERE y=3) AS 'p',
   280    280         (SELECT x AS 'b' FROM t1 WHERE y=4) AS 'q'
   281    281       WHERE a=b
   282    282       ORDER BY a
          283  +  }
          284  +} {8 5 8 9 6 9 10 7 10}
          285  +do_test select6-5.2 {
          286  +  execsql {
          287  +    SELECT a,x,b FROM
          288  +      (SELECT x+3 AS 'a', x FROM t1 WHERE y=3),
          289  +      (SELECT x AS 'b' FROM t1 WHERE y=4)
          290  +    WHERE a=b
          291  +    ORDER BY a
   283    292     }
   284    293   } {8 5 8 9 6 9 10 7 10}
   285    294   
   286    295   finish_test

Changes to www/changes.tcl.

    12     12   }
    13     13   
    14     14   
    15     15   proc chng {date desc} {
    16     16     puts "<DT><B>$date</B></DT>"
    17     17     puts "<DD><P><UL>$desc</UL></P></DD>"
    18     18   }
           19  +
           20  +chng {2002 Mar 13 (2.4.1)} {
           21  +<li>Using an unnamed subquery in a FROM clause would cause a segfault.</p>
           22  +<li>The parser insist on seeing a semicolon or the end of input before
           23  +    executing a statement.  This avoids an accidental disaster if the
           24  +    WHERE keyword is misspelled in an UPDATE or DELETE statement.</li>
           25  +}
           26  +
    19     27   
    20     28   chng {2002 Mar 10 (2.4.0)} {
    21     29   <li>Change the name of the sanity_check PRAGMA to <b>integrity_check</b>
    22     30       and make it available in all compiles.</li>
    23     31   <li>SELECT min() or max() of an indexed column with no WHERE or GROUP BY
    24     32       clause is handled as a special case which avoids a complete table scan.</li>
    25     33   <li>Automatically generated ROWIDs are now sequential.</li>