| Index: third_party/sqlite/src/test/func.test | 
| diff --git a/third_party/sqlite/src/test/func.test b/third_party/sqlite/src/test/func.test | 
| index eef05439861b81e924aaaedf5e048284d7bcac17..98ae8ddeb59b0010119a5512f976aa1e16223f49 100644 | 
| --- a/third_party/sqlite/src/test/func.test | 
| +++ b/third_party/sqlite/src/test/func.test | 
| @@ -14,6 +14,7 @@ | 
|  | 
| set testdir [file dirname $argv0] | 
| source $testdir/tester.tcl | 
| +set testprefix func | 
|  | 
| # Create a table to work with. | 
| # | 
| @@ -312,7 +313,7 @@ ifcapable floatingpoint { | 
| execsql {SELECT round(9999999999999.55,1);} | 
| } {9999999999999.6} | 
| do_test func-4.38 { | 
| -    execsql {SELECT round(9999999999999.555,2);} | 
| +    execsql {SELECT round(9999999999999.556,2);} | 
| } {9999999999999.56} | 
| } | 
|  | 
| @@ -682,6 +683,32 @@ do_test func-13.7 { | 
| lappend res [sqlite3_finalize $STMT] | 
| } {{0 0} {1 0} SQLITE_OK} | 
|  | 
| +# Test that auxiliary data is discarded when a statement is reset. | 
| +do_execsql_test 13.8.1 { | 
| +  SELECT test_auxdata('constant') FROM t4; | 
| +} {0 1} | 
| +do_execsql_test 13.8.2 { | 
| +  SELECT test_auxdata('constant') FROM t4; | 
| +} {0 1} | 
| +db cache flush | 
| +do_execsql_test 13.8.3 { | 
| +  SELECT test_auxdata('constant') FROM t4; | 
| +} {0 1} | 
| +set V "one" | 
| +do_execsql_test 13.8.4 { | 
| +  SELECT test_auxdata($V), $V FROM t4; | 
| +} {0 one 1 one} | 
| +set V "two" | 
| +do_execsql_test 13.8.5 { | 
| +  SELECT test_auxdata($V), $V FROM t4; | 
| +} {0 two 1 two} | 
| +db cache flush | 
| +set V "three" | 
| +do_execsql_test 13.8.6 { | 
| +  SELECT test_auxdata($V), $V FROM t4; | 
| +} {0 three 1 three} | 
| + | 
| + | 
| # Make sure that a function with a very long name is rejected | 
| do_test func-14.1 { | 
| catch { | 
| @@ -1167,6 +1194,18 @@ do_test func-24.12 { | 
| WHEN 'program' THEN null ELSE t1 END) FROM tbl1 | 
| } | 
| } {,is,free,software} | 
| +# Tests to verify ticket http://www.sqlite.org/src/tktview/55746f9e65f8587c0 | 
| +do_test func-24.13 { | 
| +  execsql { | 
| +    SELECT typeof(group_concat(x)) FROM (SELECT '' AS x); | 
| +  } | 
| +} {text} | 
| +do_test func-24.14 { | 
| +  execsql { | 
| +    SELECT typeof(group_concat(x,'')) | 
| +      FROM (SELECT '' AS x UNION ALL SELECT ''); | 
| +  } | 
| +} {text} | 
|  | 
|  | 
| # Use the test_isolation function to make sure that type conversions | 
| @@ -1247,4 +1286,98 @@ do_test func-28.1 { | 
| } | 
| } {1 {unknown function: nosuchfunc()}} | 
|  | 
| +# Verify that the length() and typeof() functions do not actually load | 
| +# the content of their argument. | 
| +# | 
| +do_test func-29.1 { | 
| +  db eval { | 
| +    CREATE TABLE t29(id INTEGER PRIMARY KEY, x, y); | 
| +    INSERT INTO t29 VALUES(1, 2, 3), (2, NULL, 4), (3, 4.5, 5); | 
| +    INSERT INTO t29 VALUES(4, randomblob(1000000), 6); | 
| +    INSERT INTO t29 VALUES(5, "hello", 7); | 
| +  } | 
| +  db close | 
| +  sqlite3 db test.db | 
| +  sqlite3_db_status db CACHE_MISS 1 | 
| +  db eval {SELECT typeof(x), length(x), typeof(y) FROM t29 ORDER BY id} | 
| +} {integer 1 integer null {} integer real 3 integer blob 1000000 integer text 5 integer} | 
| +do_test func-29.2 { | 
| +  set x [lindex [sqlite3_db_status db CACHE_MISS 1] 1] | 
| +  if {$x<5} {set x 1} | 
| +  set x | 
| +} {1} | 
| +do_test func-29.3 { | 
| +  db close | 
| +  sqlite3 db test.db | 
| +  sqlite3_db_status db CACHE_MISS 1 | 
| +  db eval {SELECT typeof(+x) FROM t29 ORDER BY id} | 
| +} {integer null real blob text} | 
| +if {[permutation] != "mmap"} { | 
| +  ifcapable !direct_read { | 
| +    do_test func-29.4 { | 
| +      set x [lindex [sqlite3_db_status db CACHE_MISS 1] 1] | 
| +      if {$x>100} {set x many} | 
| +      set x | 
| +    } {many} | 
| +  } | 
| +} | 
| +do_test func-29.5 { | 
| +  db close | 
| +  sqlite3 db test.db | 
| +  sqlite3_db_status db CACHE_MISS 1 | 
| +  db eval {SELECT sum(length(x)) FROM t29} | 
| +} {1000009} | 
| +do_test func-29.6 { | 
| +  set x [lindex [sqlite3_db_status db CACHE_MISS 1] 1] | 
| +  if {$x<5} {set x 1} | 
| +  set x | 
| +} {1} | 
| + | 
| +# The OP_Column opcode has an optimization that avoids loading content | 
| +# for fields with content-length=0 when the content offset is on an overflow | 
| +# page.  Make sure the optimization works. | 
| +# | 
| +do_execsql_test func-29.10 { | 
| +  CREATE TABLE t29b(a,b,c,d,e,f,g,h,i); | 
| +  INSERT INTO t29b | 
| +   VALUES(1, hex(randomblob(2000)), null, 0, 1, '', zeroblob(0),'x',x'01'); | 
| +  SELECT typeof(c), typeof(d), typeof(e), typeof(f), | 
| +         typeof(g), typeof(h), typeof(i) FROM t29b; | 
| +} {null integer integer text blob text blob} | 
| +do_execsql_test func-29.11 { | 
| +  SELECT length(f), length(g), length(h), length(i) FROM t29b; | 
| +} {0 0 1 1} | 
| +do_execsql_test func-29.12 { | 
| +  SELECT quote(f), quote(g), quote(h), quote(i) FROM t29b; | 
| +} {'' X'' 'x' X'01'} | 
| + | 
| +# EVIDENCE-OF: R-29701-50711 The unicode(X) function returns the numeric | 
| +# unicode code point corresponding to the first character of the string | 
| +# X. | 
| +# | 
| +# EVIDENCE-OF: R-55469-62130 The char(X1,X2,...,XN) function returns a | 
| +# string composed of characters having the unicode code point values of | 
| +# integers X1 through XN, respectively. | 
| +# | 
| +do_execsql_test func-30.1 {SELECT unicode('$');} 36 | 
| +do_execsql_test func-30.2 [subst {SELECT unicode('\u00A2');}] 162 | 
| +do_execsql_test func-30.3 [subst {SELECT unicode('\u20AC');}] 8364 | 
| +do_execsql_test func-30.4 {SELECT char(36,162,8364);} [subst {$\u00A2\u20AC}] | 
| + | 
| +for {set i 1} {$i<0xd800} {incr i 13} { | 
| +  do_execsql_test func-30.5.$i {SELECT unicode(char($i))} $i | 
| +} | 
| +for {set i 57344} {$i<=0xfffd} {incr i 17} { | 
| +  if {$i==0xfeff} continue | 
| +  do_execsql_test func-30.5.$i {SELECT unicode(char($i))} $i | 
| +} | 
| +for {set i 65536} {$i<=0x10ffff} {incr i 139} { | 
| +  do_execsql_test func-30.5.$i {SELECT unicode(char($i))} $i | 
| +} | 
| + | 
| +# Test char(). | 
| +# | 
| +do_execsql_test func-31.1 { | 
| +  SELECT char(), length(char()), typeof(char()) | 
| +} {{} 0 text} | 
| finish_test | 
|  |