/ Check-in [a37d1174]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Fix an assert that could fail after a parse error in expr.c. (CVS 6555)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a37d1174eb80e9a09522b236afdb47283f312d06
User & Date: danielk1977 2009-04-28 11:10:39
Context
2009-04-28
12:08
Another fix to the same assert as in (6555). It can also fail after a malloc error. (CVS 6556) check-in: e096f90a user: danielk1977 tags: trunk
11:10
Fix an assert that could fail after a parse error in expr.c. (CVS 6555) check-in: a37d1174 user: danielk1977 tags: trunk
05:27
Avoid changing the pager journal-mode once a write-transaction is open, even if no database pages have been modified. (CVS 6554) check-in: ad8aba3e user: danielk1977 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.428 2009/04/23 13:22:43 drh Exp $
           15  +** $Id: expr.c,v 1.429 2009/04/28 11:10:39 danielk1977 Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   /*
    20     20   ** Return the 'affinity' of the expression pExpr if any.
    21     21   **
    22     22   ** If pExpr is a column, a reference to a column via an 'AS' alias,
................................................................................
  2571   2571         if( pExpr->pRight ){
  2572   2572           sqlite3ExprCachePush(pParse);
  2573   2573           sqlite3ExprCode(pParse, pExpr->pRight, target);
  2574   2574           sqlite3ExprCachePop(pParse, 1);
  2575   2575         }else{
  2576   2576           sqlite3VdbeAddOp2(v, OP_Null, 0, target);
  2577   2577         }
  2578         -      assert( pParse->iCacheLevel==iCacheLevel );
         2578  +      assert( pParse->nErr>0 || pParse->iCacheLevel==iCacheLevel );
  2579   2579         sqlite3VdbeResolveLabel(v, endLabel);
  2580   2580         break;
  2581   2581       }
  2582   2582   #ifndef SQLITE_OMIT_TRIGGER
  2583   2583       case TK_RAISE: {
  2584   2584         if( !pParse->trigStack ){
  2585   2585           sqlite3ErrorMsg(pParse,

Changes to test/fuzz.test.

    15     15   #
    16     16   # The tests in this file are really about testing fuzzily generated
    17     17   # SQL parse-trees. The majority of the fuzzily generated SQL is 
    18     18   # valid as far as the parser is concerned. 
    19     19   #
    20     20   # The most complicated trees are for SELECT statements.
    21     21   #
    22         -# $Id: fuzz.test,v 1.18 2009/01/06 00:11:26 drh Exp $
           22  +# $Id: fuzz.test,v 1.19 2009/04/28 11:10:39 danielk1977 Exp $
    23     23   
    24     24   set testdir [file dirname $argv0]
    25     25   source $testdir/tester.tcl
    26     26   
    27     27   set ::REPEATS 5000
    28     28   
    29     29   # If running quick.test, don't do so many iterations.
................................................................................
   282    282                     ) IN (SELECT 2147483649) 
   283    283                 FROM sqlite_master
   284    284              ) NOT IN (SELECT ALL 'The')
   285    285           )
   286    286        ))
   287    287     }
   288    288   } {0 -4294967298}
          289  +
          290  +# At one point the following INSERT statement caused an assert() to fail.
          291  +# 
          292  +do_test fuzz-1.19 {
          293  +  execsql { CREATE TABLE t1(a) }
          294  +  catchsql {
          295  +    INSERT INTO t1 VALUES( 
          296  +      CASE WHEN NULL THEN NULL ELSE ( SELECT 0 ORDER BY 456 ) END 
          297  +    )
          298  +  }
          299  +} {1 {1st ORDER BY term out of range - should be between 1 and 1}}
          300  +do_test fuzz-1.20 {
          301  +  execsql { DROP TABLE t1 }
          302  +} {}
   289    303   
   290    304   #----------------------------------------------------------------
   291    305   # Test some fuzzily generated expressions.
   292    306   #
   293    307   do_fuzzy_test fuzz-2 -template  { SELECT [Expr] }
   294    308   
   295    309   do_test fuzz-3.1 {