/ Check-in [66a0f6a8]
Login

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

Overview
Comment:Fixes and test improvements resulting from code coverage testing. (CVS 716)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:66a0f6a8e25e3eeed78eba4b63b097f921c79d99
User & Date: drh 2002-08-15 01:26:09
Context
2002-08-15
11:48
Additional test cases and documentation updates. (CVS 717) check-in: 048b16c1 user: drh tags: trunk
01:26
Fixes and test improvements resulting from code coverage testing. (CVS 716) check-in: 66a0f6a8 user: drh tags: trunk
2002-08-14
23:18
Fix for ticket #134: Change the lemon.c sources to work around a problem with the AIX C compiler. (CVS 715) check-in: 07f6020b user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/build.c.

    21     21   **     COPY
    22     22   **     VACUUM
    23     23   **     BEGIN TRANSACTION
    24     24   **     COMMIT
    25     25   **     ROLLBACK
    26     26   **     PRAGMA
    27     27   **
    28         -** $Id: build.c,v 1.107 2002/08/02 10:36:09 drh Exp $
           28  +** $Id: build.c,v 1.108 2002/08/15 01:26:09 drh Exp $
    29     29   */
    30     30   #include "sqliteInt.h"
    31     31   #include <ctype.h>
    32     32   
    33     33   /*
    34     34   ** This routine is called when a new SQL statement is beginning to
    35     35   ** be parsed.  Check to see if the schema for the database needs
................................................................................
   457    457     for(i=j=0; z[i]; i++){
   458    458       int c = z[i];
   459    459       if( isspace(c) ) continue;
   460    460       z[j++] = c;
   461    461     }
   462    462     z[j] = 0;
   463    463     pCol->sortOrder = SQLITE_SO_NUM;
   464         -  for(i=0; z[i]; i++){
   465         -    switch( z[i] ){
   466         -      case 'b':
   467         -      case 'B': {
   468         -        if( sqliteStrNICmp(&z[i],"blob",4)==0 ){
   469         -          pCol->sortOrder = SQLITE_SO_TEXT;
   470         -          return;
          464  +  if( pParse->db->file_format>=4 ){
          465  +    for(i=0; z[i]; i++){
          466  +      switch( z[i] ){
          467  +        case 'b':
          468  +        case 'B': {
          469  +          if( sqliteStrNICmp(&z[i],"blob",4)==0 ){
          470  +            pCol->sortOrder = SQLITE_SO_TEXT;
          471  +            return;
          472  +          }
          473  +          break;
          474  +        }
          475  +        case 'c':
          476  +        case 'C': {
          477  +          if( sqliteStrNICmp(&z[i],"char",4)==0 ||
          478  +                  sqliteStrNICmp(&z[i],"clob",4)==0 ){
          479  +            pCol->sortOrder = SQLITE_SO_TEXT;
          480  +            return;
          481  +          }
          482  +          break;
   471    483           }
   472         -        break;
   473         -      }
   474         -      case 'c':
   475         -      case 'C': {
   476         -        if( sqliteStrNICmp(&z[i],"char",4)==0 ||
   477         -                sqliteStrNICmp(&z[i],"clob",4)==0 ){
   478         -          pCol->sortOrder = SQLITE_SO_TEXT;
   479         -          return;
          484  +        case 'x':
          485  +        case 'X': {
          486  +          if( i>=2 && sqliteStrNICmp(&z[i-2],"text",4)==0 ){
          487  +            pCol->sortOrder = SQLITE_SO_TEXT;
          488  +            return;
          489  +          }
          490  +          break;
   480    491           }
   481         -        break;
   482         -      }
   483         -      case 'x':
   484         -      case 'X': {
   485         -        if( i>=2 && sqliteStrNICmp(&z[i-2],"text",4)==0 ){
   486         -          pCol->sortOrder = SQLITE_SO_TEXT;
   487         -          return;
          492  +        default: {
          493  +          break;
   488    494           }
   489         -        break;
   490         -      }
   491         -      default: {
   492         -        break;
   493    495         }
   494    496       }
   495    497     }
   496    498   }
   497    499   
   498    500   /*
   499    501   ** The given token is the default value for the last column added to

Changes to src/vdbe.c.

    26     26   ** type to the other occurs as necessary.
    27     27   ** 
    28     28   ** Most of the code in this file is taken up by the sqliteVdbeExec()
    29     29   ** function which does the work of interpreting a VDBE program.
    30     30   ** But other routines are also provided to help in building up
    31     31   ** a program instruction by instruction.
    32     32   **
    33         -** $Id: vdbe.c,v 1.168 2002/08/13 23:02:57 drh Exp $
           33  +** $Id: vdbe.c,v 1.169 2002/08/15 01:26:10 drh Exp $
    34     34   */
    35     35   #include "sqliteInt.h"
    36     36   #include <ctype.h>
    37     37   
    38     38   /*
    39     39   ** The following global variable is incremented every time a cursor
    40     40   ** moves, either by the OP_MoveTo or the OP_Next opcode.  The test
................................................................................
  2802   2802   */
  2803   2803   case OP_IncrKey: {
  2804   2804     int tos = p->tos;
  2805   2805   
  2806   2806     VERIFY( if( tos<0 ) goto bad_instruction );
  2807   2807     if( Stringify(p, tos) ) goto no_mem;
  2808   2808     if( aStack[tos].flags & STK_Static ){
  2809         -    char *zNew = sqliteMalloc( aStack[tos].n );
  2810         -    memcpy(zNew, zStack[tos], aStack[tos].n);
  2811         -    zStack[tos] = zNew;
  2812         -    aStack[tos].flags = STK_Str | STK_Dyn;
         2809  +    /* CANT HAPPEN.  The IncrKey opcode is only applied to keys
         2810  +    ** generated by MakeKey or MakeIdxKey and the results of those
         2811  +    ** operands are always dynamic strings.
         2812  +    */
         2813  +    goto abort_due_to_error;
  2813   2814     }
  2814   2815     zStack[tos][aStack[tos].n-1]++;
  2815   2816     break;
  2816   2817   }
  2817   2818   
  2818   2819   /* Opcode: Checkpoint * * *
  2819   2820   **

Changes to test/expr.test.

     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.  The
    12     12   # focus of this file is testing expressions.
    13     13   #
    14         -# $Id: expr.test,v 1.26 2002/08/13 23:02:58 drh Exp $
           14  +# $Id: expr.test,v 1.27 2002/08/15 01:26:11 drh Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
    19     19   # Create a table to work with.
    20     20   #
    21     21   execsql {CREATE TABLE test1(i1 int, i2 int, r1 real, r2 real, t1 text, t2 text)}
................................................................................
   118    118   test_expr expr-1.91 {i1=3, i2=NULL} {5 not between i1 and i2} {{}}
   119    119   test_expr expr-1.92 {i1=3, i2=NULL} {2 between i1 and i2} 0
   120    120   test_expr expr-1.93 {i1=3, i2=NULL} {2 not between i1 and i2} 1
   121    121   test_expr expr-1.94 {i1=NULL, i2=8} {2 between i1 and i2} {{}}
   122    122   test_expr expr-1.95 {i1=NULL, i2=8} {2 not between i1 and i2} {{}}
   123    123   test_expr expr-1.94 {i1=NULL, i2=8} {55 between i1 and i2} 0
   124    124   test_expr expr-1.95 {i1=NULL, i2=8} {55 not between i1 and i2} 1
   125         -
          125  +test_expr expr-1.96 {i1=NULL, i2=3} {coalesce(i1<<i2,99)} 99
          126  +test_expr expr-1.97 {i1=32, i2=NULL} {coalesce(i1>>i2,99)} 99
          127  +test_expr expr-1.98 {i1=NULL, i2=NULL} {coalesce(i1|i2,99)} 99
          128  +test_expr expr-1.99 {i1=32, i2=NULL} {coalesce(i1&i2,99)} 99
   126    129   
   127    130   test_expr expr-2.1 {r1=1.23, r2=2.34} {r1+r2} 3.57
   128    131   test_expr expr-2.2 {r1=1.23, r2=2.34} {r1-r2} -1.11
   129    132   test_expr expr-2.3 {r1=1.23, r2=2.34} {r1*r2} 2.8782
   130    133   test_expr expr-2.4 {r1=1.23, r2=2.34} {r1/r2} 0.525641025641026
   131    134   test_expr expr-2.5 {r1=1.23, r2=2.34} {r2/r1} 1.90243902439024
   132    135   test_expr expr-2.6 {r1=1.23, r2=2.34} {r2<r1} 0
................................................................................
   180    183   test_expr expr-3.27 {t1=NULL, t2='hi'} {t1 notnull} 0
   181    184   test_expr expr-3.28 {t1=NULL, t2='hi'} {t2 notnull} 1
   182    185   test_expr expr-3.28b {t1=NULL, t2='hi'} {t2 is not null} 1
   183    186   test_expr expr-3.29 {t1='xyz', t2='abc'} {t1||t2} {xyzabc}
   184    187   test_expr expr-3.30 {t1=NULL, t2='abc'} {t1||t2} {{}}
   185    188   test_expr expr-3.31 {t1='xyz', t2=NULL} {t1||t2} {{}}
   186    189   test_expr expr-3.32 {t1='xyz', t2='abc'} {t1||' hi '||t2} {{xyz hi abc}}
          190  +test_expr epxr-3.33 {t1='abc', t2=NULL} {coalesce(t1<t2,99)} 99
          191  +test_expr epxr-3.34 {t1='abc', t2=NULL} {coalesce(t2<t1,99)} 99
          192  +test_expr epxr-3.35 {t1='abc', t2=NULL} {coalesce(t1>t2,99)} 99
          193  +test_expr epxr-3.36 {t1='abc', t2=NULL} {coalesce(t2>t1,99)} 99
          194  +test_expr epxr-3.37 {t1='abc', t2=NULL} {coalesce(t1<=t2,99)} 99
          195  +test_expr epxr-3.38 {t1='abc', t2=NULL} {coalesce(t2<=t1,99)} 99
          196  +test_expr epxr-3.39 {t1='abc', t2=NULL} {coalesce(t1>=t2,99)} 99
          197  +test_expr epxr-3.40 {t1='abc', t2=NULL} {coalesce(t2>=t1,99)} 99
          198  +test_expr epxr-3.41 {t1='abc', t2=NULL} {coalesce(t1==t2,99)} 99
          199  +test_expr epxr-3.42 {t1='abc', t2=NULL} {coalesce(t2==t1,99)} 99
          200  +test_expr epxr-3.43 {t1='abc', t2=NULL} {coalesce(t1!=t2,99)} 99
          201  +test_expr epxr-3.44 {t1='abc', t2=NULL} {coalesce(t2!=t1,99)} 99
          202  +
   187    203   
   188    204   test_expr expr-4.1 {t1='abc', t2='Abc'} {t1<t2} 0
   189    205   test_expr expr-4.2 {t1='abc', t2='Abc'} {t1>t2} 1
   190    206   test_expr expr-4.3 {t1='abc', t2='Bbc'} {t1<t2} 0
   191    207   test_expr expr-4.4 {t1='abc', t2='Bbc'} {t1>t2} 1
   192    208   test_expr expr-4.5 {t1='0', t2='0.0'} {t1==t2} 0
   193    209   test_expr expr-4.6 {t1='0.000', t2='0.0'} {t1==t2} 0
................................................................................
   435    451   test_expr2 expr-7.36 {a<2 OR (a<0 OR b=0)} {{} 1}
   436    452   test_expr2 expr-7.37 {a<2 OR (b=0 OR a<0)} {{} 1}
   437    453   test_expr2 expr-7.38 {a<2 OR (a<0 AND b=0)} {1}
   438    454   test_expr2 expr-7.39 {a<2 OR (b=0 AND a<0)} {1}
   439    455   test_expr2 expr-7.40 {((a<2 OR a IS NULL) AND b<3) OR b>1e10} {{} 1}
   440    456   test_expr2 expr-7.41 {a BETWEEN -1 AND 1} {1}
   441    457   test_expr2 expr-7.42 {a NOT BETWEEN 2 AND 100} {1}
          458  +test_expr2 expr-7.43 {(b+1234)||'this is a string that is at least 32 characters long' BETWEEN 1 AND 2} {}
          459  +test_expr2 expr-7.44 {123||'xabcdefghijklmnopqrstuvwyxz01234567890'||a BETWEEN '123a' AND '123b'} {}
          460  +test_expr2 expr-7.45 {((123||'xabcdefghijklmnopqrstuvwyxz01234567890'||a) BETWEEN '123a' AND '123b')<0} {}
          461  +test_expr2 expr-7.46 {((123||'xabcdefghijklmnopqrstuvwyxz01234567890'||a) BETWEEN '123a' AND '123z')>0} {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20}
   442    462   
   443    463   test_expr2 expr-7.50 {((a between 1 and 2 OR 0) AND 1) OR 0} {1 2}
   444    464   test_expr2 expr-7.51 {((a not between 3 and 100 OR 0) AND 1) OR 0} {1 2}
   445    465   test_expr2 expr-7.52 {((a in (1,2) OR 0) AND 1) OR 0} {1 2}
   446    466   test_expr2 expr-7.53 {((a not in (3,4,5,6,7,8,9,10) OR 0) AND a<11) OR 0} {1 2}
   447    467   test_expr2 expr-7.54 {((a>0 OR 0) AND a<3) OR 0} {1 2}
   448    468   test_expr2 expr-7.55 {((a in (1,2) OR 0) IS NULL AND 1) OR 0} {{}}
   449    469   test_expr2 expr-7.56 {((a not in (3,4,5,6,7,8,9,10) IS NULL OR 0) AND 1) OR 0} \
   450    470      {{}}
   451    471   test_expr2 expr-7.57 {((a>0 IS NULL OR 0) AND 1) OR 0} {{}}
   452    472   
   453         -
          473  +test_expr2 expr-7.58  {(a||'')<='1'}                  {1}
   454    474   
   455    475   finish_test

Changes to test/intpkey.test.

     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.
    12     12   #
    13     13   # This file implements tests for the special processing associated
    14     14   # with INTEGER PRIMARY KEY columns.
    15     15   #
    16         -# $Id: intpkey.test,v 1.10 2002/06/19 20:32:45 drh Exp $
           16  +# $Id: intpkey.test,v 1.11 2002/08/15 01:26:11 drh Exp $
    17     17   
    18     18   set testdir [file dirname $argv0]
    19     19   source $testdir/tester.tcl
    20     20   
    21     21   # Create a table with a primary key and a datatype other than
    22     22   # integer
    23     23   #
................................................................................
   457    457   } {2 2 3}
   458    458   do_test intpkey-10.3 {
   459    459     execsql {
   460    460       INSERT INTO t2 SELECT NULL, z, y FROM t2;
   461    461       SELECT * FROM t2;
   462    462     }
   463    463   } {1 1 2 2 2 3 3 2 1 4 3 2}
          464  +
          465  +# This tests checks to see if a floating point number can be used
          466  +# to reference an integer primary key.
          467  +#
          468  +do_test intpkey-11.1 {
          469  +  execsql {
          470  +    SELECT b FROM t1 WHERE a=2.0+3.0;
          471  +  }
          472  +} {hello}
          473  +do_test intpkey-11.1 {
          474  +  execsql {
          475  +    SELECT b FROM t1 WHERE a=2.0+3.5;
          476  +  }
          477  +} {}
   464    478   
   465    479   finish_test