/ Check-in [d8bbab78]
Login

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

Overview
Comment:Add test cases to e_expr.test.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d8bbab78fa56b076dfafb36daa7d6ef0b07f9a44
User & Date: dan 2010-08-14 12:25:18
Context
2010-08-14
12:42
Tweaks to comments in pager.c. Fix two compiler warnings. check-in: 68a49f7f user: drh tags: trunk
12:25
Add test cases to e_expr.test. check-in: d8bbab78 user: dan tags: trunk
05:04
Test that it is possible to drop a trigger while there are active statements belonging to the same connection. check-in: d4ec61e2 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to test/e_expr.test.

   442    442   do_execsql_test e_expr-10.4.2 { SELECT typeof(x'0123456789ABCDEF') } blob
   443    443   do_execsql_test e_expr-10.4.3 { SELECT typeof(X'0123456789abcdef') } blob
   444    444   do_execsql_test e_expr-10.4.4 { SELECT typeof(x'0123456789abcdef') } blob
   445    445   do_execsql_test e_expr-10.4.5 { SELECT typeof(X'53514C697465')     } blob
   446    446   
   447    447   # EVIDENCE-OF: R-23914-51476 A literal value can also be the token
   448    448   # "NULL".
          449  +#
   449    450   do_execsql_test e_expr-10.5.1 { SELECT NULL         } {{}}
   450    451   do_execsql_test e_expr-10.5.2 { SELECT typeof(NULL) } {null}
          452  +
          453  +#-------------------------------------------------------------------------
          454  +# Test statements related to bound parameters
          455  +#
          456  +
          457  +proc parameter_test {tn sql params result} {
          458  +  set stmt [sqlite3_prepare_v2 db $sql -1]
          459  +
          460  +  foreach {number name} $params {
          461  +    set nm [sqlite3_bind_parameter_name $stmt $number]
          462  +    do_test $tn.name.$number [list set {} $nm] $name
          463  +    sqlite3_bind_int $stmt $number [expr -1 * $number]
          464  +  }
          465  +
          466  +  sqlite3_step $stmt
          467  +
          468  +  set res [list]
          469  +  for {set i 0} {$i < [sqlite3_column_count $stmt]} {incr i} {
          470  +    lappend res [sqlite3_column_text $stmt $i]
          471  +  }
          472  +
          473  +  set rc [sqlite3_finalize $stmt]
          474  +  do_test $tn.rc [list set {} $rc] SQLITE_OK
          475  +  do_test $tn.res [list set {} $res] $result
          476  +}
          477  +
          478  +# EVIDENCE-OF: R-33509-39458 A question mark followed by a number NNN
          479  +# holds a spot for the NNN-th parameter. NNN must be between 1 and
          480  +# SQLITE_MAX_VARIABLE_NUMBER.
          481  +#
          482  +set mvn $SQLITE_MAX_VARIABLE_NUMBER
          483  +parameter_test e_expr-11.1 "
          484  +  SELECT ?1, ?123, ?$SQLITE_MAX_VARIABLE_NUMBER, ?123, ?4
          485  +"   "1 ?1  123 ?123 $mvn ?$mvn 4 ?4"   "-1 -123 -$mvn -123 -4"
          486  +
          487  +set errmsg "variable number must be between ?1 and ?$SQLITE_MAX_VARIABLE_NUMBER"
          488  +foreach {tn param_number} [list \
          489  +  2  0                                    \
          490  +  3  [expr $SQLITE_MAX_VARIABLE_NUMBER+1] \
          491  +  4  [expr $SQLITE_MAX_VARIABLE_NUMBER+2] \
          492  +  5  12345678903456789034567890234567890  \
          493  +  6  2147483648                           \
          494  +  7  2147483649                           \
          495  +  8  4294967296                           \
          496  +  9  4294967297                           \
          497  +  10 9223372036854775808                  \
          498  +  11 9223372036854775809                  \
          499  +  12 18446744073709551616                 \
          500  +  13 18446744073709551617                 \
          501  +] {
          502  +  do_catchsql_test e_expr-11.1.$tn "SELECT ?$param_number" [list 1 $errmsg]
          503  +}
          504  +
          505  +# EVIDENCE-OF: R-33670-36097 A question mark that is not followed by a
          506  +# number creates a parameter with a number one greater than the largest
          507  +# parameter number already assigned.
          508  +#
          509  +# EVIDENCE-OF: R-42938-07030 If this means the parameter number is
          510  +# greater than SQLITE_MAX_VARIABLE_NUMBER, it is an error.
          511  +#
          512  +parameter_test e_expr-11.2.1 "SELECT ?"          {1 {}}       -1
          513  +parameter_test e_expr-11.2.2 "SELECT ?, ?"       {1 {} 2 {}}  {-1 -2}
          514  +parameter_test e_expr-11.2.3 "SELECT ?5, ?"      {5 ?5 6 {}}  {-5 -6}
          515  +parameter_test e_expr-11.2.4 "SELECT ?, ?5"      {1 {} 5 ?5}  {-1 -5}
          516  +parameter_test e_expr-11.2.5 "SELECT ?, ?456, ?" {
          517  +  1 {} 456 ?456 457 {}
          518  +}  {-1 -456 -457}
          519  +parameter_test e_expr-11.2.5 "SELECT ?, ?456, ?4, ?" {
          520  +  1 {} 456 ?456 4 ?4 457 {}
          521  +}  {-1 -456 -4 -457}
          522  +foreach {tn sql} [list                           \
          523  +  1  "SELECT ?$mvn, ?"                           \
          524  +  2  "SELECT ?[expr $mvn-5], ?, ?, ?, ?, ?, ?"   \
          525  +  3  "SELECT ?[expr $mvn], ?5, ?6, ?"            \
          526  +] {
          527  +  do_catchsql_test e_expr-11.3.$tn $sql [list 1 {too many SQL variables}]
          528  +}
          529  +
          530  +# EVIDENCE-OF: R-11620-22743 A colon followed by an identifier name
          531  +# holds a spot for a named parameter with the name :AAAA.
          532  +#
          533  +# Identifiers in SQLite consist of alphanumeric, '_' and '$' characters,
          534  +# and any UTF characters with codepoints larger than 127 (non-ASCII 
          535  +# characters).
          536  +#
          537  +parameter_test e_expr-11.2.1 {SELECT :AAAA}         {1 :AAAA}       -1
          538  +parameter_test e_expr-11.2.2 {SELECT :123}          {1 :123}        -1
          539  +parameter_test e_expr-11.2.3 {SELECT :__}           {1 :__}         -1
          540  +parameter_test e_expr-11.2.4 {SELECT :_$_}          {1 :_$_}        -1
          541  +parameter_test e_expr-11.2.5 "
          542  +  SELECT :\u0e40\u0e2d\u0e28\u0e02\u0e39\u0e40\u0e2d\u0e25
          543  +" "1 :\u0e40\u0e2d\u0e28\u0e02\u0e39\u0e40\u0e2d\u0e25" -1
          544  +parameter_test e_expr-11.2.6 "SELECT :\u0080" "1 :\u0080" -1
          545  +
          546  +# EVIDENCE-OF: R-49783-61279 An "at" sign works exactly like a colon,
          547  +# except that the name of the parameter created is @AAAA.
          548  +#
          549  +parameter_test e_expr-11.3.1 {SELECT @AAAA}         {1 @AAAA}       -1
          550  +parameter_test e_expr-11.3.2 {SELECT @123}          {1 @123}        -1
          551  +parameter_test e_expr-11.3.3 {SELECT @__}           {1 @__}         -1
          552  +parameter_test e_expr-11.3.4 {SELECT @_$_}          {1 @_$_}        -1
          553  +parameter_test e_expr-11.3.5 "
          554  +  SELECT @\u0e40\u0e2d\u0e28\u0e02\u0e39\u0e40\u0e2d\u0e25
          555  +" "1 @\u0e40\u0e2d\u0e28\u0e02\u0e39\u0e40\u0e2d\u0e25" -1
          556  +parameter_test e_expr-11.3.6 "SELECT @\u0080" "1 @\u0080" -1
          557  +
          558  +# EVIDENCE-OF: R-62610-51329 A dollar-sign followed by an identifier
          559  +# name also holds a spot for a named parameter with the name $AAAA.
          560  +#
          561  +# EVIDENCE-OF: R-55025-21042 The identifier name in this case can
          562  +# include one or more occurrences of "::" and a suffix enclosed in
          563  +# "(...)" containing any text at all.
          564  +#
          565  +# Note: Looks like an identifier cannot consist entirely of "::" 
          566  +# characters or just a suffix. Also, the other named variable characters
          567  +# (: and @) work the same way internally. Why not just document it that way?
          568  +#
          569  +parameter_test e_expr-11.4.1 {SELECT $AAAA}         {1 $AAAA}       -1
          570  +parameter_test e_expr-11.4.2 {SELECT $123}          {1 $123}        -1
          571  +parameter_test e_expr-11.4.3 {SELECT $__}           {1 $__}         -1
          572  +parameter_test e_expr-11.4.4 {SELECT $_$_}          {1 $_$_}        -1
          573  +parameter_test e_expr-11.4.5 "
          574  +  SELECT \$\u0e40\u0e2d\u0e28\u0e02\u0e39\u0e40\u0e2d\u0e25
          575  +" "1 \$\u0e40\u0e2d\u0e28\u0e02\u0e39\u0e40\u0e2d\u0e25" -1
          576  +parameter_test e_expr-11.4.6 "SELECT \$\u0080" "1 \$\u0080" -1
          577  +
          578  +parameter_test e_expr-11.5.1 {SELECT $::::a(++--++)} {1 $::::a(++--++)} -1
          579  +parameter_test e_expr-11.5.2 {SELECT $::a()} {1 $::a()} -1
          580  +parameter_test e_expr-11.5.3 {SELECT $::1(::#$)} {1 $::1(::#$)} -1
          581  + 
          582  +# EVIDENCE-OF: R-11370-04520 Named parameters are also numbered. The
          583  +# number assigned is one greater than the largest parameter number
          584  +# already assigned.
          585  +#
          586  +# EVIDENCE-OF: R-42620-22184 If this means the parameter would be
          587  +# assigned a number greater than SQLITE_MAX_VARIABLE_NUMBER, it is an
          588  +# error.
          589  +#
          590  +parameter_test e_expr-11.6.1 "SELECT ?, @abc"    {1 {} 2 @abc} {-1 -2}
          591  +parameter_test e_expr-11.6.2 "SELECT ?123, :a1"  {123 ?123 124 :a1} {-123 -124}
          592  +parameter_test e_expr-11.6.3 {SELECT $a, ?8, ?, $b, ?2, $c} {
          593  +  1 $a 8 ?8 9 {} 10 $b 2 ?2 11 $c
          594  +} {-1 -8 -9 -10 -2 -11}
          595  +foreach {tn sql} [list                           \
          596  +  1  "SELECT ?$mvn, \$::a"                       \
          597  +  2  "SELECT ?$mvn, ?4, @a1"                     \
          598  +  3  "SELECT ?[expr $mvn-2], :bag, @123, \$x"    \
          599  +] {
          600  +  do_catchsql_test e_expr-11.7.$tn $sql [list 1 {too many SQL variables}]
          601  +}
   451    602   
   452    603   finish_test