/ Check-in [0d61960a]
Login

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

Overview
Comment:Additional coverage testing in the new name resolver module. (CVS 5608)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0d61960afd35721d6d07acd75288c20d2cd6fda1
User & Date: drh 2008-08-25 12:14:09
Context
2008-08-25
14:49
Pick up a small performance increase by eliminating the pcacheRef() function. (CVS 5609) check-in: e3840fbf user: danielk1977 tags: trunk
12:14
Additional coverage testing in the new name resolver module. (CVS 5608) check-in: 0d61960a user: drh tags: trunk
12:08
Two if statements should be asserts. GCC was silently ignoring them, hence the problem did not show up in coverage testing. Ticket #3333. (CVS 5607) check-in: 635933b1 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/resolve.c.

    10     10   **
    11     11   *************************************************************************
    12     12   **
    13     13   ** This file contains routines used for walking the parser tree and
    14     14   ** resolve all identifiers by associating them with a particular
    15     15   ** table and column.
    16     16   **
    17         -** $Id: resolve.c,v 1.2 2008/08/22 17:34:45 drh Exp $
           17  +** $Id: resolve.c,v 1.3 2008/08/25 12:14:09 drh Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   #include <stdlib.h>
    21     21   #include <string.h>
    22     22   
    23     23   /*
    24     24   ** Given the name of a column of the form X.Y.Z or Y.Z or just Z, look up
................................................................................
    89     89       if( pSrcList ){
    90     90         for(i=0, pItem=pSrcList->a; i<pSrcList->nSrc; i++, pItem++){
    91     91           Table *pTab;
    92     92           int iDb;
    93     93           Column *pCol;
    94     94     
    95     95           pTab = pItem->pTab;
    96         -        assert( pTab!=0 );
           96  +        assert( pTab!=0 && pTab->zName!=0 );
    97     97           iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
    98     98           assert( pTab->nCol>0 );
    99     99           if( zTab ){
   100    100             if( pItem->zAlias ){
   101    101               char *zTabName = pItem->zAlias;
   102    102               if( sqlite3StrICmp(zTabName, zTab)!=0 ) continue;
   103    103             }else{
................................................................................
   342    342   ** function names.  The operator for aggregate functions is changed
   343    343   ** to TK_AGG_FUNCTION.
   344    344   */
   345    345   static int resolveExprStep(Walker *pWalker, Expr *pExpr){
   346    346     NameContext *pNC;
   347    347     Parse *pParse;
   348    348   
   349         -  if( pExpr==0 ) return WRC_Continue;
   350    349     pNC = pWalker->u.pNC;
   351    350     assert( pNC!=0 );
   352    351     pParse = pNC->pParse;
   353    352     assert( pParse==pWalker->pParse );
   354    353   
   355    354     if( ExprHasAnyProperty(pExpr, EP_Resolved) ) return WRC_Prune;
   356    355     ExprSetProperty(pExpr, EP_Resolved);

Changes to test/collate8.test.

     9      9   #    May you share freely, never taking more than you give.
    10     10   #
    11     11   #***********************************************************************
    12     12   # This file implements regression tests for SQLite library.  The
    13     13   # focus of this script is making sure collations pass through the
    14     14   # unary + operator.
    15     15   #
    16         -# $Id: collate8.test,v 1.1 2007/06/20 16:13:23 drh Exp $
           16  +# $Id: collate8.test,v 1.2 2008/08/25 12:14:09 drh Exp $
    17     17   
    18     18   set testdir [file dirname $argv0]
    19     19   source $testdir/tester.tcl
    20     20   
    21     21   do_test collate8-1.1 {
    22     22     execsql {
    23     23       CREATE TABLE t1(a TEXT COLLATE nocase);
................................................................................
    44     44     }
    45     45   } {1 2}
    46     46   do_test collate8-1.5 {
    47     47     execsql {
    48     48       SELECT a FROM t1 ORDER BY +a
    49     49     }
    50     50   } {aaa BBB ccc DDD}
           51  +do_test collate8-1.11 {
           52  +  execsql {
           53  +    SELECT a AS x FROM t1 ORDER BY "x";
           54  +  }
           55  +} {aaa BBB ccc DDD}
           56  +do_test collate8-1.12 {
           57  +  execsql {
           58  +    SELECT a AS x FROM t1 WHERE x<'ccc' ORDER BY 1
           59  +  }
           60  +} {aaa BBB}
           61  +do_test collate8-1.13 {
           62  +  execsql {
           63  +    SELECT a AS x FROM t1 WHERE x<'ccc' COLLATE binary ORDER BY [x]
           64  +  }
           65  +} {aaa BBB DDD}
           66  +do_test collate8-1.14 {
           67  +  execsql {
           68  +    SELECT a AS x FROM t1 WHERE +x<'ccc' ORDER BY 1
           69  +  }
           70  +} {aaa BBB}
           71  +do_test collate8-1.15 {
           72  +  execsql {
           73  +    SELECT a AS x FROM t1 ORDER BY +x
           74  +  }
           75  +} {aaa BBB ccc DDD}
           76  +
           77  +
           78  +# When a result-set column is aliased into a WHERE clause, make sure the
           79  +# collating sequence logic works correctly.
           80  +#
           81  +do_test collate8-2.1 {
           82  +  execsql {
           83  +    CREATE TABLE t2(a);
           84  +    INSERT INTO t2 VALUES('abc');
           85  +    INSERT INTO t2 VALUES('ABC');
           86  +    SELECT a AS x FROM t2 WHERE x='abc';
           87  +  }
           88  +} {abc}
           89  +do_test collate8-2.2 {
           90  +  execsql {
           91  +    SELECT a AS x FROM t2 WHERE x='abc' COLLATE nocase;
           92  +  }
           93  +} {abc ABC}
           94  +do_test collate8-2.3 {
           95  +  execsql {
           96  +    SELECT a AS x FROM t2 WHERE (x COLLATE nocase)='abc';
           97  +  }
           98  +} {abc ABC}
           99  +do_test collate8-2.4 {
          100  +  execsql {
          101  +    SELECT a COLLATE nocase AS x FROM t2 WHERE x='abc';
          102  +  }
          103  +} {abc ABC}
          104  +do_test collate8-2.5 {
          105  +  execsql {
          106  +    SELECT a COLLATE nocase AS x FROM t2 WHERE (x COLLATE binary)='abc';
          107  +  }
          108  +} {abc}
          109  +do_test collate8-2.6 {
          110  +  execsql {
          111  +    SELECT a COLLATE nocase AS x FROM t2 WHERE x='abc' COLLATE binary;
          112  +  }
          113  +} {abc ABC}
          114  +do_test collate8-2.7 {
          115  +  execsql {
          116  +    SELECT * FROM t2 WHERE (a COLLATE nocase)='abc' COLLATE binary;
          117  +  }
          118  +} {abc ABC}
          119  +do_test collate8-2.8 {
          120  +  execsql {
          121  +    SELECT a COLLATE nocase AS x FROM t2 WHERE 'abc'=x COLLATE binary;
          122  +  }
          123  +} {abc}
    51    124   
    52    125   finish_test

Changes to test/corrupt.test.

     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.
    12     12   #
    13     13   # This file implements tests to make sure SQLite does not crash or
    14     14   # segfault if it sees a corrupt database file.
    15     15   #
    16         -# $Id: corrupt.test,v 1.9 2008/05/05 12:09:33 danielk1977 Exp $
           16  +# $Id: corrupt.test,v 1.10 2008/08/25 12:14:09 drh Exp $
    17     17   
    18         -catch {file delete -force test.db}
    19         -catch {file delete -force test.db-journal}
           18  +catch {file delete -force test.db test.db-journal test.bu}
    20     19   
    21     20   set testdir [file dirname $argv0]
    22     21   source $testdir/tester.tcl
    23     22   
    24     23   # Construct a large database for testing.
    25     24   #
    26     25   do_test corrupt-1.1 {

Changes to test/triggerB.test.

     1      1   # 2008 April 15
     2      2   #
     3      3   # The author disclaims copyright to this source code.  In place of
     4         -# a legal notice, here is a blessing:
            4  +# a legal notice', here is a blessing:
     5      5   #
     6      6   #    May you do good and not evil.
     7      7   #    May you find forgiveness for yourself and forgive others.
     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. Specifically,
................................................................................
    36     36   } {1 1 0 2 1 0}
    37     37   do_test triggerB-1.2 {
    38     38     execsql {
    39     39       UPDATE vx SET y = yy;
    40     40       SELECT * FROM vx;
    41     41     }
    42     42   } {1 0 0 2 0 0}
           43  +
           44  +# Added 2008-08-22:
           45  +#
           46  +# Name resolution within triggers.
           47  +#
           48  +do_test triggerB-2.1 {
           49  +  catchsql {
           50  +    CREATE TRIGGER ty AFTER INSERT ON x BEGIN
           51  +       SELECT wen.x; -- Unrecognized name
           52  +    END;
           53  +    INSERT INTO x VALUES(1,2);
           54  +  }
           55  +} {1 {no such column: wen.x}}
           56  +do_test triggerB-2.2 {
           57  +  catchsql {
           58  +    CREATE TRIGGER tz AFTER UPDATE ON x BEGIN
           59  +       SELECT dlo.x; -- Unrecognized name
           60  +    END;
           61  +    UPDATE x SET y=y+1;
           62  +  }
           63  +} {1 {no such column: dlo.x}}
           64  +
           65  +do_test triggerB-2.3 {
           66  +  execsql {
           67  +    CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
           68  +    INSERT INTO t2 VALUES(1,2);
           69  +    CREATE TABLE changes(x,y);
           70  +    CREATE TRIGGER r1t2 AFTER UPDATE ON t2 BEGIN
           71  +      INSERT INTO changes VALUES(new.a, new.b);
           72  +    END;
           73  +  }
           74  +  execsql {
           75  +    UPDATE t2 SET a=a+10;
           76  +    SELECT * FROM changes;
           77  +  }
           78  +} {11 2}
           79  +do_test triggerB-2.4 {
           80  +  execsql {
           81  +    CREATE TRIGGER r2t2 AFTER DELETE ON t2 BEGIN
           82  +      INSERT INTO changes VALUES(old.a, old.c);
           83  +    END;
           84  +  }
           85  +  catchsql {
           86  +    DELETE FROM t2;
           87  +  }
           88  +} {1 {no such column: old.c}}
           89  +
           90  +# Triggers maintain a mask of columns from the invoking table that are
           91  +# used in the trigger body as NEW.column or OLD.column.  That mask is then
           92  +# used to reduce the amount of information that needs to be loaded into
           93  +# the NEW and OLD pseudo-tables at run-time.
           94  +#
           95  +# These tests cases check the logic for when there are many columns - more
           96  +# than will fit in a bitmask.
           97  +#
           98  +do_test triggerB-3.1 {
           99  +  execsql {
          100  +    CREATE TABLE t3(
          101  +       c0,  c1,  c2,  c3,  c4,  c5,  c6,  c7,  c8,  c9,
          102  +       c10, c11, c12, c13, c14, c15, c16, c17, c18, c19,
          103  +       c20, c21, c22, c23, c24, c25, c26, c27, c28, c29,
          104  +       c30, c31, c32, c33, c34, c35, c36, c37, c38, c39,
          105  +       c40, c41, c42, c43, c44, c45, c46, c47, c48, c49,
          106  +       c50, c51, c52, c53, c54, c55, c56, c57, c58, c59,
          107  +       c60, c61, c62, c63, c64, c65
          108  +    );
          109  +    CREATE TABLE t3_changes(colnum, oldval, newval);
          110  +    INSERT INTO t3 VALUES(
          111  +       'a0', 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9',
          112  +       'a10','a11','a12','a13','a14','a15','a16','a17','a18','a19',
          113  +       'a20','a21','a22','a23','a24','a25','a26','a27','a28','a29',
          114  +       'a30','a31','a32','a33','a34','a35','a36','a37','a38','a39',
          115  +       'a40','a41','a42','a43','a44','a45','a46','a47','a48','a49',
          116  +       'a50','a51','a52','a53','a54','a55','a56','a57','a58','a59',
          117  +       'a60','a61','a62','a63','a64','a65'
          118  +    );
          119  +  }
          120  +  for {set i 0} {$i<=65} {incr i} {
          121  +    set sql [subst {
          122  +      CREATE TRIGGER t3c$i AFTER UPDATE ON t3
          123  +         WHEN old.c$i!=new.c$i BEGIN
          124  +          INSERT INTO t3_changes VALUES($i, old.c$i, new.c$i);
          125  +      END
          126  +    }]
          127  +    db eval $sql
          128  +  }
          129  +  execsql {
          130  +    SELECT * FROM t3_changes
          131  +  }
          132  +} {}
          133  +for {set i 0} {$i<=64} {incr i} {
          134  +  do_test triggerB-3.2.$i.1 [subst {
          135  +    execsql {
          136  +      UPDATE t3 SET c$i='b$i';
          137  +      SELECT * FROM t3_changes ORDER BY rowid DESC LIMIT 1;
          138  +    }
          139  +  }] [subst {$i a$i b$i}]
          140  +  do_test triggerB-3.2.$i.2 [subst {
          141  +    execsql {
          142  +      SELECT count(*) FROM t3_changes
          143  +    }
          144  +  }] [expr {$i+1}]
          145  +  do_test triggerB-3.2.$i.2 [subst {
          146  +    execsql {
          147  +      SELECT * FROM t3_changes WHERE colnum=$i
          148  +    }
          149  +  }] [subst {$i a$i b$i}]
          150  +}
          151  +  
    43    152   
    44    153   finish_test