/ Check-in [9bf2c594]
Login

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

Overview
Comment:Add further test cases for compile time limits. (CVS 3963)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9bf2c594a48a4661700f0833562ee2b3ff7b761c
User & Date: danielk1977 2007-05-09 11:37:23
Context
2007-05-09
15:56
Fix an obscure cache corruption that could occur after an SQLITE_FULL error. (CVS 3964) check-in: e8e879ac user: danielk1977 tags: trunk
11:37
Add further test cases for compile time limits. (CVS 3963) check-in: 9bf2c594 user: danielk1977 tags: trunk
08:24
Fix enforcement of the LIKE_PATTERN limit. (CVS 3962) check-in: 8819617b 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.287 2007/05/08 18:04:46 danielk1977 Exp $
           15  +** $Id: expr.c,v 1.288 2007/05/09 11:37:23 danielk1977 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   **
................................................................................
   409    409         }
   410    410         if( !sqlite3MallocFailed() ){
   411    411           assert( pParse->apVarExpr!=0 );
   412    412           pParse->apVarExpr[pParse->nVarExpr++] = pExpr;
   413    413         }
   414    414       }
   415    415     } 
          416  +  if( !pParse->nErr && pParse->nVar>SQLITE_MAX_VARIABLE_NUMBER ){
          417  +    sqlite3ErrorMsg(pParse, "too many SQL variables");
          418  +  }
   416    419   }
   417    420   
   418    421   /*
   419    422   ** Recursively delete an expression tree.
   420    423   */
   421    424   void sqlite3ExprDelete(Expr *p){
   422    425     if( p==0 ) return;

Changes to src/test_config.c.

    12     12   ** 
    13     13   ** This file contains code used for testing the SQLite system.
    14     14   ** None of the code in this file goes into a deliverable build.
    15     15   ** 
    16     16   ** The focus of this file is providing the TCL testing layer
    17     17   ** access to compile-time constants.
    18     18   **
    19         -** $Id: test_config.c,v 1.2 2007/05/09 08:24:44 danielk1977 Exp $
           19  +** $Id: test_config.c,v 1.3 2007/05/09 11:37:23 danielk1977 Exp $
    20     20   */
    21     21   #include "sqliteInt.h"
    22     22   #include "tcl.h"
    23     23   #include "os.h"
    24     24   #include <stdlib.h>
    25     25   #include <string.h>
    26     26   
................................................................................
   438    438              (char*)&sqlite_default_file_format, TCL_LINK_INT|TCL_LINK_READ_ONLY);
   439    439     }
   440    440     {
   441    441       static int sqlite_max_like_pattern = SQLITE_MAX_LIKE_PATTERN_LENGTH;
   442    442       Tcl_LinkVar(interp, "SQLITE_MAX_LIKE_PATTERN_LENGTH",
   443    443              (char*)&sqlite_max_like_pattern, TCL_LINK_INT|TCL_LINK_READ_ONLY);
   444    444     }
          445  +  {
          446  +    static int sqlite_max_attached = SQLITE_MAX_ATTACHED;
          447  +    Tcl_LinkVar(interp, "SQLITE_MAX_ATTACHED",
          448  +           (char*)&sqlite_max_attached, TCL_LINK_INT|TCL_LINK_READ_ONLY);
          449  +  }
   445    450   }
   446    451   
   447    452   
   448    453   /*
   449    454   ** Register commands with the TCL interpreter.
   450    455   */
   451    456   int Sqliteconfig_Init(Tcl_Interp *interp){
   452    457     set_options(interp);
   453    458     return TCL_OK;
   454    459   }

Changes to test/bind.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 script testing the sqlite_bind API.
    13     13   #
    14         -# $Id: bind.test,v 1.38 2006/06/27 20:06:45 drh Exp $
           14  +# $Id: bind.test,v 1.39 2007/05/09 11:37:23 danielk1977 Exp $
    15     15   #
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   proc sqlite_step {stmt N VALS COLS} {
    21     21     upvar VALS vals
................................................................................
   354    354     ]
   355    355     sqlite3_bind_parameter_count $VM
   356    356   } {999}
   357    357   catch {sqlite3_finalize $VM}
   358    358   do_test bind-9.4 {
   359    359     set VM [
   360    360       sqlite3_prepare $DB {
   361         -      INSERT INTO t2(a,b,c,d) VALUES(?1,?999,?,?)
          361  +      INSERT INTO t2(a,b,c,d) VALUES(?1,?997,?,?)
   362    362       } -1 TAIL
   363    363     ]
   364    364     sqlite3_bind_parameter_count $VM
   365         -} {1001}
          365  +} {999}
   366    366   do_test bind-9.5 {
   367    367     sqlite3_bind_int $VM 1 1
   368         -  sqlite3_bind_int $VM 999 999
   369         -  sqlite3_bind_int $VM 1000 1000
   370         -  sqlite3_bind_int $VM 1001 1001
          368  +  sqlite3_bind_int $VM 997 999
          369  +  sqlite3_bind_int $VM 998 1000
          370  +  sqlite3_bind_int $VM 999 1001
   371    371     sqlite3_step $VM
   372    372   } SQLITE_DONE
   373    373   do_test bind-9.6 {
   374    374     sqlite3_finalize $VM
   375    375   } SQLITE_OK
   376    376   do_test bind-9.7 {
   377    377     execsql {SELECT * FROM t2}

Changes to test/sqllimits1.test.

     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   #
    12     12   # This file contains tests to verify that the limits defined in
    13     13   # sqlite source file limits.h are enforced.
    14     14   #
    15         -# $Id: sqllimits1.test,v 1.4 2007/05/09 08:24:44 danielk1977 Exp $
           15  +# $Id: sqllimits1.test,v 1.5 2007/05/09 11:37:23 danielk1977 Exp $
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   # Test organization:
    21     21   #
    22     22   #     sqllimits-1.*:  SQLITE_MAX_LENGTH
    23     23   #     sqllimits-2.*:  SQLITE_MAX_SQL_LENGTH
    24     24   #     sqllimits-3.*:  SQLITE_MAX_PAGE_COUNT
    25     25   #     sqllimits-4.*:  SQLITE_MAX_COLUMN
    26     26   #
    27         -# Todo:
    28     27   #
    29         -#     sqllimits-5.*:   SQLITE_MAX_EXPR_LENGTH           (sqlite todo)
    30         -#     sqllimits-6.*:   SQLITE_MAX_VDBE_OP               (sqlite todo)
    31     28   #     sqllimits-7.*:   SQLITE_MAX_FUNCTION_ARG  
    32     29   #     sqllimits-8.*:   SQLITE_MAX_ATTACHED
    33     30   #     sqllimits-9.*:   SQLITE_MAX_VARIABLE_NUMBER
    34     31   #     sqllimits-10.*:  SQLITE_MAX_PAGE_SIZE
    35         -#     sqllimits-11.*:  SQLITE_MAX_PAGE_COUNT
    36         -#     sqllimits-12.*:  SQLITE_MAX_LIKE_PATTERN_LENGTH
           32  +#     sqllimits-11.*:  SQLITE_MAX_LIKE_PATTERN_LENGTH
           33  +#
           34  +# Todo:
           35  +#
           36  +#     sqllimits-5.*:   SQLITE_MAX_EXPR_LENGTH           (sqlite todo)
           37  +#     sqllimits-6.*:   SQLITE_MAX_VDBE_OP               (sqlite todo)
    37     38   #
    38     39   
    39     40   #--------------------------------------------------------------------
    40     41   # Test cases sqllimits-1.* test that the SQLITE_MAX_LENGTH limit
    41     42   # is enforced.
    42     43   #
    43     44   do_test sqllimits-1.1 {
................................................................................
   237    238   } {1 {too many columns in result set}}
   238    239   
   239    240   #--------------------------------------------------------------------
   240    241   # These tests - sqllimits-5.* - test that the SQLITE_MAX_EXPR_LENGTH
   241    242   # limit is enforced. The limit refers to the number of terms in 
   242    243   # the expression.
   243    244   #
          245  +# TODO
          246  +
          247  +#--------------------------------------------------------------------
          248  +# Test cases sqllimits-6.* test that the SQLITE_MAX_VDBE_OP
          249  +# limit works as expected. The limit refers to the number of opcodes
          250  +# in a single VDBE program.
          251  +#
          252  +# TODO
          253  +
          254  +#--------------------------------------------------------------------
          255  +# Test the SQLITE_MAX_FUNCTION_ARG limit works. Test case names
          256  +# match the pattern "sqllimits-7.*".
          257  +#
          258  +do_test sqllimits-1.7.1 {
          259  +  set max $::SQLITE_MAX_FUNCTION_ARG
          260  +  set vals [list]
          261  +  for {set i 0} {$i < $SQLITE_MAX_FUNCTION_ARG} {incr i} {
          262  +    lappend vals $i
          263  +  }
          264  +  catchsql "SELECT max([join $vals ,])"
          265  +} "0 [expr {$::SQLITE_MAX_FUNCTION_ARG - 1}]"
          266  +do_test sqllimits-1.7.2 {
          267  +  set max $::SQLITE_MAX_FUNCTION_ARG
          268  +  set vals [list]
          269  +  for {set i 0} {$i <= $SQLITE_MAX_FUNCTION_ARG} {incr i} {
          270  +    lappend vals $i
          271  +  }
          272  +  catchsql "SELECT max([join $vals ,])"
          273  +} {1 {too many arguments on function max}}
          274  +
          275  +# Test that it is SQLite, and not the implementation of the
          276  +# user function that is throwing the error.
          277  +proc myfunc {args} {error "I don't like to be called!"}
          278  +do_test sqllimits-1.7.2 {
          279  +  db function myfunc myfunc
          280  +  set max $::SQLITE_MAX_FUNCTION_ARG
          281  +  set vals [list]
          282  +  for {set i 0} {$i <= $SQLITE_MAX_FUNCTION_ARG} {incr i} {
          283  +    lappend vals $i
          284  +  }
          285  +  catchsql "SELECT myfunc([join $vals ,])"
          286  +} {1 {too many arguments on function myfunc}}
          287  +
          288  +#--------------------------------------------------------------------
          289  +# Test cases sqllimits-8.*: Test the SQLITE_MAX_ATTACHED limit.
          290  +#
          291  +# TODO
          292  +do_test sqllimits-1.8.1 {
          293  +  set max $::SQLITE_MAX_ATTACHED
          294  +  for {set i 0} {$i < ($max)} {incr i} {
          295  +    execsql "ATTACH 'test${i}.db' AS aux${i}"
          296  +  }
          297  +  catchsql "ATTACH 'test${i}.db' AS aux${i}"
          298  +} "1 {too many attached databases - max $::SQLITE_MAX_ATTACHED}"
          299  +do_test sqllimits-1.8.2 {
          300  +  set max $::SQLITE_MAX_ATTACHED
          301  +  for {set i 0} {$i < ($max)} {incr i} {
          302  +    execsql "DETACH aux${i}"
          303  +  }
          304  +} {}
          305  +
          306  +#--------------------------------------------------------------------
          307  +# Test cases sqllimits-9.*: Check that the SQLITE_MAX_VARIABLE_NUMBER 
          308  +# limit works.
          309  +#
          310  +do_test sqllimits-1.9.1 {
          311  +  set max $::SQLITE_MAX_VARIABLE_NUMBER
          312  +  catchsql "SELECT ?[expr {$max+1}] FROM t1"
          313  +} "1 {variable number must be between ?1 and ?$::SQLITE_MAX_VARIABLE_NUMBER}"
          314  +do_test sqllimits-1.9.2 {
          315  +  set max $::SQLITE_MAX_VARIABLE_NUMBER
          316  +  set vals [list]
          317  +  for {set i 0} {$i < ($max+3)} {incr i} {
          318  +    lappend vals ?
          319  +  }
          320  +  catchsql "SELECT [join $vals ,] FROM t1"
          321  +} "1 {too many SQL variables}"
          322  +
          323  +
          324  +#--------------------------------------------------------------------
          325  +# sqllimits-10.*:  Test the SQLITE_MAX_PAGE_SIZE define is enforced. 
          326  +# This is probably tested elsewhere too (pagerX.test). Attempts
          327  +# to raise the page size above this limit are silently ignored.
          328  +#
          329  +do_test sqllimits-1.10.1 {
          330  +  db close
          331  +  file delete -force test.db test.db-journal
          332  +  sqlite3 db test.db
          333  +  set max $::SQLITE_MAX_PAGE_SIZE
          334  +  catchsql "PRAGMA page_size = [expr {$max*2}]"
          335  +} {0 {}}
          336  +do_test sqllimits-1.10.2 {
          337  +  catchsql "PRAGMA page_size"
          338  +} {0 1024}
          339  +do_test sqllimits-1.10.3 {
          340  +  set max $::SQLITE_MAX_PAGE_SIZE
          341  +  catchsql "PRAGMA page_size = $max"
          342  +} {0 {}}
          343  +do_test sqllimits-1.10.4 {
          344  +  execsql "pragma page_size"
          345  +} $::SQLITE_MAX_PAGE_SIZE
          346  +do_test sqllimits-1.10.5 {
          347  +  set max $::SQLITE_MAX_PAGE_SIZE
          348  +  execsql "pragma page_size = [expr {$max - 5}]"
          349  +  execsql "pragma page_size"
          350  +} $::SQLITE_MAX_PAGE_SIZE
   244    351   
   245    352   #--------------------------------------------------------------------
   246         -# Test cases sqllimits-12.* verify that the 
          353  +# Test cases sqllimits-11.* verify that the 
   247    354   # SQLITE_MAX_LIKE_PATTERN_LENGTH limit is enforced. This limit only
   248    355   # applies to the built-in LIKE operator, supplying an external 
   249    356   # implementation by overriding the like() scalar function bypasses
   250    357   # this limitation.
   251    358   #
   252    359   # These tests check that the limit is not incorrectly applied to
   253    360   # the left-hand-side of the LIKE operator (the string being tested
   254    361   # against the pattern).
   255    362   #
   256         -do_test sqllimits-1.12.1 {
          363  +do_test sqllimits-1.11.1 {
   257    364     set max $::SQLITE_MAX_LIKE_PATTERN_LENGTH
   258    365     set ::pattern [string repeat "A%" [expr $max/2]]
   259    366     set ::string  [string repeat "A" [expr {$max*2}]]
   260    367     execsql {
   261    368       SELECT $::string LIKE $::pattern;
   262    369     }
   263    370   } {1}
   264         -do_test sqllimits-1.12.2 {
          371  +do_test sqllimits-1.11.2 {
   265    372     set max $::SQLITE_MAX_LIKE_PATTERN_LENGTH
   266    373     set ::pattern [string repeat "A%" [expr {($max/2) + 1}]]
   267    374     set ::string  [string repeat "A" [expr {$max*2}]]
   268    375     catchsql {
   269    376       SELECT $::string LIKE $::pattern;
   270    377     }
   271    378   } {1 {LIKE or GLOB pattern too complex}}
   272    379   
   273    380   finish_test
   274    381   
   275    382