SQLite

Check-in [a17e331717]
Login

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

Overview
Comment:Enable the SQLITE_LIMIT_FUNCTION_ARG limiter. (CVS 6753)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a17e3317176772446abdc8ebe6fb6f0d3b7ac018
User & Date: drh 2009-06-12 12:04:16.000
Context
2009-06-12
12:50
In lemon: omit unused entries from the end of the yyFallback array. (CVS 6754) (check-in: 9cfbe2ba68 user: drh tags: trunk)
12:04
Enable the SQLITE_LIMIT_FUNCTION_ARG limiter. (CVS 6753) (check-in: a17e331717 user: drh tags: trunk)
11:42
Remove a C++-ism from the code. Ticket #3912. (CVS 6752) (check-in: bc729bc3e6 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/parse.y.
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
**
*************************************************************************
** This file contains SQLite's grammar for SQL.  Process this file
** using the lemon parser generator to generate C code that runs
** the parser.  Lemon will also generate a header file containing
** numeric codes for all of the tokens.
**
** @(#) $Id: parse.y,v 1.280 2009/06/12 03:47:37 drh Exp $
*/

// All token codes are small integers with #defines that begin with "TK_"
%token_prefix TK_

// The type of the data attached to each token is Token.  This is also the
// default type for non-terminals.







|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
**
*************************************************************************
** This file contains SQLite's grammar for SQL.  Process this file
** using the lemon parser generator to generate C code that runs
** the parser.  Lemon will also generate a header file containing
** numeric codes for all of the tokens.
**
** @(#) $Id: parse.y,v 1.281 2009/06/12 12:04:16 drh Exp $
*/

// All token codes are small integers with #defines that begin with "TK_"
%token_prefix TK_

// The type of the data attached to each token is Token.  This is also the
// default type for non-terminals.
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
%ifndef SQLITE_OMIT_CAST
expr(A) ::= CAST(X) LP expr(E) AS typetoken(T) RP(Y). {
  A.pExpr = sqlite3PExpr(pParse, TK_CAST, E.pExpr, 0, &T);
  spanSet(&A,&X,&Y);
}
%endif  SQLITE_OMIT_CAST
expr(A) ::= ID(X) LP distinct(D) exprlist(Y) RP(E). {
  if( Y && Y->nExpr>SQLITE_MAX_FUNCTION_ARG ){
    sqlite3ErrorMsg(pParse, "too many arguments on function %T", &X);
  }
  A.pExpr = sqlite3ExprFunction(pParse, Y, &X);
  spanSet(&A,&X,&E);
  if( D && A.pExpr ){
    A.pExpr->flags |= EP_Distinct;
  }







|







785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
%ifndef SQLITE_OMIT_CAST
expr(A) ::= CAST(X) LP expr(E) AS typetoken(T) RP(Y). {
  A.pExpr = sqlite3PExpr(pParse, TK_CAST, E.pExpr, 0, &T);
  spanSet(&A,&X,&Y);
}
%endif  SQLITE_OMIT_CAST
expr(A) ::= ID(X) LP distinct(D) exprlist(Y) RP(E). {
  if( Y && Y->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
    sqlite3ErrorMsg(pParse, "too many arguments on function %T", &X);
  }
  A.pExpr = sqlite3ExprFunction(pParse, Y, &X);
  spanSet(&A,&X,&E);
  if( D && A.pExpr ){
    A.pExpr->flags |= EP_Distinct;
  }
Changes to test/sqllimits1.test.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# This file contains tests to verify that the limits defined in
# sqlite source file limits.h are enforced.
#
# $Id: sqllimits1.test,v 1.31 2008/07/15 00:27:35 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Verify that the default per-connection limits are the same as
# the compile-time hard limits.
#







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# This file contains tests to verify that the limits defined in
# sqlite source file limits.h are enforced.
#
# $Id: sqllimits1.test,v 1.32 2009/06/12 12:04:16 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Verify that the default per-connection limits are the same as
# the compile-time hard limits.
#
714
715
716
717
718
719
720

721
722
723

724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
#
# TODO

#--------------------------------------------------------------------
# Test the SQLITE_LIMIT_FUNCTION_ARG limit works. Test case names
# match the pattern "sqllimits1-11.*".
#

do_test sqllimits1-11.1 {
  set max $::SQLITE_MAX_FUNCTION_ARG
  set vals [list]

  for {set i 0} {$i < $SQLITE_MAX_FUNCTION_ARG} {incr i} {
    lappend vals $i
  }
  catchsql "SELECT max([join $vals ,])"
} "0 [expr {$::SQLITE_MAX_FUNCTION_ARG - 1}]"
do_test sqllimits1-11.2 {
  set max $::SQLITE_MAX_FUNCTION_ARG
  set vals [list]
  for {set i 0} {$i <= $SQLITE_MAX_FUNCTION_ARG} {incr i} {
    lappend vals $i
  }
  catchsql "SELECT max([join $vals ,])"
} {1 {too many arguments on function max}}

# Test that it is SQLite, and not the implementation of the
# user function that is throwing the error.
proc myfunc {args} {error "I don't like to be called!"}
do_test sqllimits1-11.2 {
  db function myfunc myfunc
  set max $::SQLITE_MAX_FUNCTION_ARG
  set vals [list]
  for {set i 0} {$i <= $SQLITE_MAX_FUNCTION_ARG} {incr i} {
    lappend vals $i
  }
  catchsql "SELECT myfunc([join $vals ,])"
} {1 {too many arguments on function myfunc}}


#--------------------------------------------------------------------
# Test cases sqllimits1-12.*: Test the SQLITE_MAX_ATTACHED limit.
#
ifcapable attach {
  do_test sqllimits1-12.1 {
    set max $::SQLITE_MAX_ATTACHED







>
|
<
|
>
|
|
|
|
|
|
<
|
|
|
|
|
|

|
|
|
|
|
<
|
|
|
|
|
|
|







714
715
716
717
718
719
720
721
722

723
724
725
726
727
728
729
730

731
732
733
734
735
736
737
738
739
740
741
742

743
744
745
746
747
748
749
750
751
752
753
754
755
756
#
# TODO

#--------------------------------------------------------------------
# Test the SQLITE_LIMIT_FUNCTION_ARG limit works. Test case names
# match the pattern "sqllimits1-11.*".
#
for {set max 5} {$max<=$SQLITE_MAX_FUNCTION_ARG} {incr max} {
  do_test sqllimits1-11.$max.1 {

    set vals [list]
    sqlite3_limit db SQLITE_LIMIT_FUNCTION_ARG $::max
    for {set i 0} {$i < $::max} {incr i} {
      lappend vals $i
    }
    catchsql "SELECT max([join $vals ,])"
  } "0 [expr {$::max - 1}]"
  do_test sqllimits1-11.$max.2 {

    set vals [list]
    for {set i 0} {$i <= $::max} {incr i} {
      lappend vals $i
    }
    catchsql "SELECT max([join $vals ,])"
  } {1 {too many arguments on function max}}

  # Test that it is SQLite, and not the implementation of the
  # user function that is throwing the error.
  proc myfunc {args} {error "I don't like to be called!"}
  do_test sqllimits1-11.$max.2 {
    db function myfunc myfunc

    set vals [list]
    for {set i 0} {$i <= $::max} {incr i} {
      lappend vals $i
    }
    catchsql "SELECT myfunc([join $vals ,])"
  } {1 {too many arguments on function myfunc}}
}

#--------------------------------------------------------------------
# Test cases sqllimits1-12.*: Test the SQLITE_MAX_ATTACHED limit.
#
ifcapable attach {
  do_test sqllimits1-12.1 {
    set max $::SQLITE_MAX_ATTACHED