| Index: third_party/sqlite/src/test/table.test | 
| diff --git a/third_party/sqlite/src/test/table.test b/third_party/sqlite/src/test/table.test | 
| index 5fa9116656a9b7812e9fed7ff6f493b04193b1d7..69f105aa6ce1fa4fcec3a70cd715d9bcf7baac55 100644 | 
| --- a/third_party/sqlite/src/test/table.test | 
| +++ b/third_party/sqlite/src/test/table.test | 
| @@ -11,7 +11,6 @@ | 
| # This file implements regression tests for SQLite library.  The | 
| # focus of this file is testing the CREATE TABLE statement. | 
| # | 
| -# $Id: table.test,v 1.53 2009/06/05 17:09:12 drh Exp $ | 
|  | 
| set testdir [file dirname $argv0] | 
| source $testdir/tester.tcl | 
| @@ -260,6 +259,19 @@ do_test table-5.2 { | 
| catchsql {DROP TABLE IF EXISTS sqlite_master} | 
| } {1 {table sqlite_master may not be dropped}} | 
|  | 
| +# Dropping sqlite_statN tables is OK. | 
| +# | 
| +do_test table-5.2.1 { | 
| +  db eval { | 
| +    ANALYZE; | 
| +    DROP TABLE IF EXISTS sqlite_stat1; | 
| +    DROP TABLE IF EXISTS sqlite_stat2; | 
| +    DROP TABLE IF EXISTS sqlite_stat3; | 
| +    DROP TABLE IF EXISTS sqlite_stat4; | 
| +    SELECT name FROM sqlite_master WHERE name GLOB 'sqlite_stat*'; | 
| +  } | 
| +} {} | 
| + | 
| # Make sure an EXPLAIN does not really create a new table | 
| # | 
| do_test table-5.3 { | 
| @@ -451,7 +463,7 @@ do_test table-10.1 { | 
| CREATE TABLE t6(a REFERENCES t4(a) NOT NULL); | 
| INSERT INTO t6 VALUES(NULL); | 
| } | 
| -} {1 {t6.a may not be NULL}} | 
| +} {1 {NOT NULL constraint failed: t6.a}} | 
| do_test table-10.2 { | 
| catchsql { | 
| DROP TABLE t6; | 
| @@ -667,8 +679,8 @@ ifcapable attach { | 
| # Now attach a database and ensure that a table can be created in the | 
| # attached database whilst in a callback from a query on the main database. | 
| do_test table-14.3 { | 
| -    file delete -force test2.db | 
| -    file delete -force test2.db-journal | 
| +    forcedelete test2.db | 
| +    forcedelete test2.db-journal | 
| execsql { | 
| ATTACH 'test2.db' as aux; | 
| } | 
| @@ -713,4 +725,68 @@ do_test table-15.2 { | 
| execsql {COMMIT} | 
| } {} | 
|  | 
| +# Ticket 3a88d85f36704eebe134f7f48aebf00cd6438c1a (2014-08-05) | 
| +# The following SQL script segfaults while running the INSERT statement: | 
| +# | 
| +#    CREATE TABLE t1(x DEFAULT(max(1))); | 
| +#    INSERT INTO t1(rowid) VALUES(1); | 
| +# | 
| +# The problem appears to be the use of an aggregate function as part of | 
| +# the default value for a column. This problem has been in the code since | 
| +# at least 2006-01-01 and probably before that. This problem was detected | 
| +# and reported on the sqlite-users@sqlite.org mailing list by Zsbán Ambrus. | 
| +# | 
| +do_execsql_test table-16.1 { | 
| +  CREATE TABLE t16(x DEFAULT(max(1))); | 
| +  INSERT INTO t16(x) VALUES(123); | 
| +  SELECT rowid, x FROM t16; | 
| +} {1 123} | 
| +do_catchsql_test table-16.2 { | 
| +  INSERT INTO t16(rowid) VALUES(4); | 
| +} {1 {unknown function: max()}} | 
| +do_execsql_test table-16.3 { | 
| +  DROP TABLE t16; | 
| +  CREATE TABLE t16(x DEFAULT(abs(1))); | 
| +  INSERT INTO t16(rowid) VALUES(4); | 
| +  SELECT rowid, x FROM t16; | 
| +} {4 1} | 
| +do_catchsql_test table-16.4 { | 
| +  DROP TABLE t16; | 
| +  CREATE TABLE t16(x DEFAULT(avg(1))); | 
| +  INSERT INTO t16(rowid) VALUES(123); | 
| +  SELECT rowid, x FROM t16; | 
| +} {1 {unknown function: avg()}} | 
| +do_catchsql_test table-16.5 { | 
| +  DROP TABLE t16; | 
| +  CREATE TABLE t16(x DEFAULT(count())); | 
| +  INSERT INTO t16(rowid) VALUES(123); | 
| +  SELECT rowid, x FROM t16; | 
| +} {1 {unknown function: count()}} | 
| +do_catchsql_test table-16.6 { | 
| +  DROP TABLE t16; | 
| +  CREATE TABLE t16(x DEFAULT(group_concat('x',','))); | 
| +  INSERT INTO t16(rowid) VALUES(123); | 
| +  SELECT rowid, x FROM t16; | 
| +} {1 {unknown function: group_concat()}} | 
| +do_catchsql_test table-16.7 { | 
| +  INSERT INTO t16 DEFAULT VALUES; | 
| +} {1 {unknown function: group_concat()}} | 
| + | 
| +# Ticket [https://www.sqlite.org/src/info/094d39a4c95ee4abbc417f04214617675ba15c63] | 
| +# describes a assertion fault that occurs on a CREATE TABLE .. AS SELECT statement. | 
| +# the following test verifies that the problem has been fixed. | 
| +# | 
| +do_execsql_test table-17.1 { | 
| +  DROP TABLE IF EXISTS t1; | 
| +  CREATE TABLE t1(a TEXT); | 
| +  INSERT INTO t1(a) VALUES(1),(2); | 
| +  DROP TABLE IF EXISTS t2; | 
| +  CREATE TABLE t2(x TEXT, y TEXT); | 
| +  INSERT INTO t2(x,y) VALUES(3,4); | 
| +  DROP TABLE IF EXISTS t3; | 
| +  CREATE TABLE t3 AS | 
| +    SELECT a AS p, coalesce(y,a) AS q FROM t1 LEFT JOIN t2 ON a=x; | 
| +  SELECT p, q, '|' FROM t3 ORDER BY p; | 
| +} {1 1 | 2 2 |} | 
| + | 
| finish_test | 
|  |