/ Check-in [92f9d2b2]
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:Test coverage improvements. (CVS 2215)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 92f9d2b2f480fccfa6e8b70a1d19058b92a4ea8f
User & Date: drh 2005-01-15 01:52:32
Context
2005-01-15
12:45
Enhance the performance of auto-vacuum databases by reducing the number of pointer-map entries written during tree balancing. Also fix bugs in balance_quick(). (CVS 2216) check-in: 0ae29538 user: danielk1977 tags: trunk
01:52
Test coverage improvements. (CVS 2215) check-in: 92f9d2b2 user: drh tags: trunk
00:40
Improved test coverage for update.c. (CVS 2214) check-in: 3ef95d5f user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/date.c.

    12     12   ** This file contains the C functions that implement date and time
    13     13   ** functions for SQLite.  
    14     14   **
    15     15   ** There is only one exported symbol in this file - the function
    16     16   ** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
    17     17   ** All other code has file scope.
    18     18   **
    19         -** $Id: date.c,v 1.42 2004/11/14 21:56:30 drh Exp $
           19  +** $Id: date.c,v 1.43 2005/01/15 01:52:32 drh Exp $
    20     20   **
    21     21   ** NOTES:
    22     22   **
    23     23   ** SQLite processes all times and dates as Julian Day numbers.  The
    24     24   ** dates and times are stored as the number of days since noon
    25     25   ** in Greenwich on November 24, 4714 B.C. according to the Gregorian
    26     26   ** calendar system.
................................................................................
   311    311     memset(p, 0, sizeof(*p));
   312    312     if( parseYyyyMmDd(zDate,p)==0 ){
   313    313       return 0;
   314    314     }else if( parseHhMmSs(zDate, p)==0 ){
   315    315       return 0;
   316    316     }else if( sqlite3StrICmp(zDate,"now")==0){
   317    317       double r;
   318         -    if( sqlite3OsCurrentTime(&r)==0 ){
   319         -      p->rJD = r;
   320         -      p->validJD = 1;
   321         -      return 0;
   322         -    }
   323         -    return 1;
          318  +    sqlite3OsCurrentTime(&r);
          319  +    p->rJD = r;
          320  +    p->validJD = 1;
          321  +    return 0;
   324    322     }else if( sqlite3IsNumber(zDate, 0, SQLITE_UTF8) ){
   325    323       p->rJD = sqlite3AtoF(zDate, 0);
   326    324       p->validJD = 1;
   327    325       return 0;
   328    326     }
   329    327     return 1;
   330    328   }

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.177 2005/01/13 02:14:25 danielk1977 Exp $
           15  +** $Id: expr.c,v 1.178 2005/01/15 01:52:32 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   #include <ctype.h>
    19     19   
    20     20   /*
    21     21   ** Return the 'affinity' of the expression pExpr if any.
    22     22   **
................................................................................
   608    608   */
   609    609   int sqlite3ExprIsInteger(Expr *p, int *pValue){
   610    610     switch( p->op ){
   611    611       case TK_INTEGER: {
   612    612         if( sqlite3GetInt32(p->token.z, pValue) ){
   613    613           return 1;
   614    614         }
   615         -      break;
   616         -    }
   617         -    case TK_STRING: {
   618         -      const u8 *z = (u8*)p->token.z;
   619         -      int n = p->token.n;
   620         -      if( n>0 && z[0]=='-' ){ z++; n--; }
   621         -      while( n>0 && *z && isdigit(*z) ){ z++; n--; }
   622         -      if( n==0 && sqlite3GetInt32(p->token.z, pValue) ){
   623         -        return 1;
   624         -      }
   625    615         break;
   626    616       }
   627    617       case TK_UPLUS: {
   628    618         return sqlite3ExprIsInteger(p->pLeft, pValue);
   629    619       }
   630    620       case TK_UMINUS: {
   631    621         int v;

Changes to src/select.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 C code routines that are called by the parser
    13     13   ** to handle SELECT statements in SQLite.
    14     14   **
    15         -** $Id: select.c,v 1.220 2005/01/03 02:26:55 drh Exp $
           15  +** $Id: select.c,v 1.221 2005/01/15 01:52:32 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   
    20     20   /*
    21     21   ** Allocate a new Select structure and return a pointer to that
    22     22   ** structure.
................................................................................
   666    666         if( iCol<0 ){
   667    667           zType = "INTEGER";
   668    668         }else{
   669    669           zType = pTab->aCol[iCol].zType;
   670    670         }
   671    671         break;
   672    672       }
   673         -    case TK_AS:
   674         -      zType = columnType(pParse, pTabList, pExpr->pLeft); 
   675         -      break;
   676    673       case TK_SELECT: {
   677    674         Select *pS = pExpr->pSelect;
   678    675         zType = columnType(pParse, pS->pSrc, pS->pEList->a[0].pExpr); 
   679    676         break;
   680    677       }
          678  +    case TK_AS:
          679  +      /* The TK_AS operator can only occur in ORDER BY, GROUP BY, HAVING,
          680  +      ** and LIMIT clauses.  But pExpr originates in the result set of a
          681  +      ** SELECT.  So pExpr can never contain an AS operator.
          682  +      */
          683  +      assert( 0 );
          684  +      /* Fall thru */
   681    685       default:
   682    686         zType = 0;
   683    687     }
   684    688     
   685    689     return zType;
   686    690   }
   687    691   

Changes to test/date.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 date and time functions.
    13     13   #
    14         -# $Id: date.test,v 1.11 2004/10/31 02:22:50 drh Exp $
           14  +# $Id: date.test,v 1.12 2005/01/15 01:52:33 drh Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
    19     19   # Skip this whole file if date and time functions are omitted
    20     20   # at compile-time
    21     21   #
................................................................................
    51     51   datetest 1.19 {julianday('2000-01-01 12:00:00.1')}   2451545.00000116
    52     52   datetest 1.20 {julianday('2000-01-01 12:00:00.01')}  2451545.00000012
    53     53   datetest 1.21 {julianday('2000-01-01 12:00:00.001')} 2451545.00000001
    54     54   datetest 1.22 {julianday('2000-01-01 12:00:00.')} NULL
    55     55   datetest 1.23 julianday(12345.6) 12345.6
    56     56   datetest 1.24 {julianday('2001-01-01 12:00:00 bogus')} NULL
    57     57   datetest 1.25 {julianday('2001-01-01 bogus')} NULL
           58  +datetest 1.26 {julianday('2001-01-01 12:60:00')} NULL
           59  +datetest 1.27 {julianday('2001-01-01 12:59:60')} NULL
    58     60   
    59     61   datetest 2.1 datetime(0,'unixepoch') {1970-01-01 00:00:00}
    60     62   datetest 2.2 datetime(946684800,'unixepoch') {2000-01-01 00:00:00}
    61     63   datetest 2.3 {date('2003-10-22','weekday 0')} 2003-10-26
    62     64   datetest 2.4 {date('2003-10-22','weekday 1')} 2003-10-27
    63     65   datetest 2.5 {date('2003-10-22','weekday 2')} 2003-10-28
    64     66   datetest 2.6 {date('2003-10-22','weekday 3')} 2003-10-22
................................................................................
   136    138   set now [clock format [clock seconds] -format "%Y-%m-%d" -gmt 1]
   137    139   datetest 4.1 {date('now')} $now
   138    140   
   139    141   datetest 5.1 {datetime('1994-04-16 14:00:00 -05:00')} {1994-04-16 09:00:00}
   140    142   datetest 5.2 {datetime('1994-04-16 14:00:00 +05:15')} {1994-04-16 19:15:00}
   141    143   datetest 5.3 {datetime('1994-04-16 05:00:00 -08:30')} {1994-04-15 20:30:00}
   142    144   datetest 5.4 {datetime('1994-04-16 14:00:00 +11:55')} {1994-04-17 01:55:00}
          145  +datetest 5.5 {datetime('1994-04-16 14:00:00 +11:60')} NULL
   143    146   
   144    147   # localtime->utc and utc->localtime conversions.  These tests only work
   145    148   # if the localtime is in the US Eastern Time (the time in Charlotte, NC
   146    149   # and in New York.)
   147    150   #
   148    151   if {[clock scan [clock format 0 -format {%b %d, %Y %H:%M:%S}] -gmt 1]==-18000} {
   149    152     datetest 6.1 {datetime('2000-10-29 05:59:00','localtime')}\
................................................................................
   254    257      {2004-02-28 07:59:00}
   255    258   datetest 11.7 {datetime('2004-02-28 20:00:00', '-11:59')} \
   256    259      {2004-02-28 08:01:00}
   257    260   datetest 11.8 {datetime('2004-02-28 20:00:00', '11:59')} \
   258    261      {2004-02-29 07:59:00}
   259    262   datetest 11.9 {datetime('2004-02-28 20:00:00', '12:01')} \
   260    263      {2004-02-29 08:01:00}
          264  +datetest 11.10 {datetime('2004-02-28 20:00:00', '12:60')} NULL
   261    265   
   262    266   
   263    267   
   264    268   
   265    269   finish_test

Changes to test/limit.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 the LIMIT ... OFFSET ... clause
    13     13   #  of SELECT statements.
    14     14   #
    15         -# $Id: limit.test,v 1.19 2004/12/16 21:09:18 drh Exp $
           15  +# $Id: limit.test,v 1.20 2005/01/15 01:52:33 drh Exp $
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   # Build some test data
    21     21   #
    22     22   execsql {
................................................................................
   344    344       SELECT * FROM (SELECT * FROM t6 LIMIT 3)
   345    345       UNION
   346    346       SELECT * FROM (SELECT * FROM t7 LIMIT 3)
   347    347       ORDER BY 1
   348    348       LIMIT 2
   349    349     }
   350    350   } {1 2}
          351  +do_test limit-9.5 {
          352  +  catchsql {
          353  +    SELECT * FROM t6 LIMIT 3
          354  +    UNION
          355  +    SELECT * FROM t7 LIMIT 3
          356  +  }
          357  +} {1 {LIMIT clause should come after UNION not before}}
   351    358   
   352    359   finish_test

Changes to test/select1.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 the SELECT statement.
    13     13   #
    14         -# $Id: select1.test,v 1.37 2004/11/22 13:35:42 danielk1977 Exp $
           14  +# $Id: select1.test,v 1.38 2005/01/15 01:52:33 drh Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
    19     19   # Try to select on a non-existant table.
    20     20   #
    21     21   do_test select1-1.1 {
................................................................................
   287    287     }
   288    288   } {1 {ORDER BY terms must not be non-integer constants}}
   289    289   do_test select1-4.6 {
   290    290     catchsql {
   291    291       SELECT f1 FROM test1 ORDER BY '8.4';
   292    292     }
   293    293   } {1 {ORDER BY terms must not be non-integer constants}}
   294         -do_test select1-4.7 {
          294  +do_test select1-4.7.1 {
   295    295     catchsql {
   296    296       SELECT f1 FROM test1 ORDER BY 'xyz';
   297    297     }
          298  +} {1 {ORDER BY terms must not be non-integer constants}}
          299  +do_test select1-4.7.2 {
          300  +  catchsql {
          301  +    SELECT f1 FROM test1 ORDER BY -8.4;
          302  +  }
          303  +} {1 {ORDER BY terms must not be non-integer constants}}
          304  +do_test select1-4.7.3 {
          305  +  catchsql {
          306  +    SELECT f1 FROM test1 ORDER BY +8.4;
          307  +  }
          308  +} {1 {ORDER BY terms must not be non-integer constants}}
          309  +do_test select1-4.7.4 {
          310  +  catchsql {
          311  +    SELECT f1 FROM test1 ORDER BY 4294967296; -- constant larger than 32 bits
          312  +  }
   298    313   } {1 {ORDER BY terms must not be non-integer constants}}
   299    314   do_test select1-4.8 {
   300    315     execsql {
   301    316       CREATE TABLE t5(a,b);
   302    317       INSERT INTO t5 VALUES(1,10);
   303    318       INSERT INTO t5 VALUES(2,9);
   304    319       SELECT * FROM t5 ORDER BY 1;
   305    320     }
   306    321   } {1 10 2 9}
   307         -do_test select1-4.9 {
          322  +do_test select1-4.9.1 {
   308    323     execsql {
   309    324       SELECT * FROM t5 ORDER BY 2;
   310    325     }
   311    326   } {2 9 1 10}
   312         -do_test select1-4.10 {
          327  +do_test select1-4.9.2 {
          328  +  execsql {
          329  +    SELECT * FROM t5 ORDER BY +2;
          330  +  }
          331  +} {2 9 1 10}
          332  +do_test select1-4.10.1 {
   313    333     catchsql {
   314    334       SELECT * FROM t5 ORDER BY 3;
   315    335     }
   316    336   } {1 {ORDER BY column number 3 out of range - should be between 1 and 2}}
          337  +do_test select1-4.10.2 {
          338  +  catchsql {
          339  +    SELECT * FROM t5 ORDER BY -1;
          340  +  }
          341  +} {1 {ORDER BY column number -1 out of range - should be between 1 and 2}}
   317    342   do_test select1-4.11 {
   318    343     execsql {
   319    344       INSERT INTO t5 VALUES(3,10);
   320    345       SELECT * FROM t5 ORDER BY 2, 1 DESC;
   321    346     }
   322    347   } {2 9 3 10 1 10}
   323    348   do_test select1-4.12 {